import 'package:test_sa/controllers/localization/localization.dart'; import 'package:test_sa/models/device/device.dart'; import 'package:test_sa/models/subtitle.dart'; import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/widgets/equipment/single_device_picker.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class DeviceButton extends StatelessWidget { final Function(Device) onDevicePick; final Device device; const DeviceButton({ Key key, this.device, this.onDevicePick }) : super(key: key); @override Widget build(BuildContext context) { Subtitle _subtitle = AppLocalization.of(context).subtitle; return ElevatedButton( style: ElevatedButton.styleFrom( padding: EdgeInsets.symmetric(horizontal: 16,vertical: device == null ? 12 : 8), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( AppStyle.borderRadius * AppStyle.getScaleFactor(context) ), side: BorderSide( color: AColors.black ) ), onPrimary: AColors.primaryColor, primary: AColors.white, ), child: Row( children: [ FaIcon( FontAwesomeIcons.hardDrive, size: 28, color: AColors.black, ), device == null ? Expanded( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 6), child: Text( _subtitle.pickDevice, style: Theme.of(context).textTheme.subtitle1, textScaleFactor: AppStyle.getScaleFactor(context), textDirection: TextDirection.rtl, textAlign: TextAlign.center, ), ), ): Expanded( child: ListTile( title: Text("${_subtitle.sn} : " + device.serialNumber, style: Theme.of(context).textTheme.subtitle1, ), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Divider(color: Theme.of(context).textTheme.subtitle1.color,), Text("${_subtitle.brand} : " + device.brand, style: Theme.of(context).textTheme.subtitle2, ), Divider(color: Theme.of(context).textTheme.subtitle1.color,), Text("${_subtitle.model} : " + device.model, style: Theme.of(context).textTheme.subtitle2, ), ], ), ) ) ], ), onPressed: () async { Device _device = await Navigator.of(context).pushNamed(SingleDevicePicker.id) as Device; onDevicePick(_device); } ); } }