| @@ -39,94 +39,87 @@ class _DropdownSupplyWidgetState extends State<DropdownSupplyWidget> { | |||
| @override | |||
| Widget build(BuildContext context) { | |||
| // return Container(); | |||
| return GetBuilder<ChangeDropdownController>( | |||
| tag: 's', | |||
| init: controller, | |||
| tag: widget.tag, | |||
| builder: (data) { | |||
| return Container(); | |||
| return SizedBox( | |||
| width: double.infinity, | |||
| height: Validators.stringNotNullOrEmpty(widget.invalidMessage ?? '') ? 85 : 65, | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Validators.stringNotNullOrEmpty(data?.currentData?.name ?? '') | |||
| ? Text( | |||
| widget.hint ?? '', | |||
| style: TextStyle( | |||
| color: Validators.stringNotNullOrEmpty(widget.invalidMessage ?? '') ? Colors.red : Colors.black54, fontSize: 13.0), | |||
| ) | |||
| : Text( | |||
| '', | |||
| style: TextStyle( | |||
| color: Validators.stringNotNullOrEmpty(widget.invalidMessage ?? '') ? Colors.red : Colors.black54, fontSize: 13.0), | |||
| ), | |||
| SizedBox( | |||
| width: double.infinity, | |||
| height: 44, | |||
| child: TextButton( | |||
| onPressed: () { | |||
| Navigator.of(context) | |||
| .push(MaterialPageRoute( | |||
| builder: (_) => CommonDataHelperScreen( | |||
| titleName: widget.titleName ?? '', | |||
| tbSupply: widget.tbSupply ?? '', | |||
| condition: widget.condition ?? '', | |||
| selectedId: data?.selectedId ?? -1, | |||
| currentItems: [], | |||
| currentEditId: -1), | |||
| fullscreenDialog: false)) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as CommonData; | |||
| controller?.change(result); | |||
| widget.onPressed(result); | |||
| } | |||
| }); | |||
| }, | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: Border( | |||
| bottom: BorderSide( | |||
| width: 0.5, | |||
| color: Validators.stringNotNullOrEmpty(widget.invalidMessage ?? '') ? Colors.red : Colors.black54)), | |||
| ), | |||
| child: Row( | |||
| children: [ | |||
| Expanded( | |||
| child: Validators.stringNotNullOrEmpty(data?.currentData?.name ?? '') | |||
| ? Text(data?.currentData?.name ?? '', style: TextStyle(fontSize: 16.0, color: Colors.black)) | |||
| : Text(widget.hint, style: TextStyle(fontSize: 16.0, color: Colors.black54)), | |||
| ), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| )) | |||
| ], | |||
| )), | |||
| ), | |||
| Validators.stringNotNullOrEmpty(widget.invalidMessage ?? '') | |||
| ? Text( | |||
| widget.invalidMessage ?? '', | |||
| style: TextStyle(fontSize: 12.0, color: Colors.red, fontWeight: FontWeight.normal), | |||
| textAlign: TextAlign.left, | |||
| ) | |||
| : SizedBox(), | |||
| ], | |||
| ), | |||
| ); | |||
| }); | |||
| // return GetBuilder<ChangeDropdownController>( | |||
| // tag: widget.tag, | |||
| // builder: (data) { | |||
| // return Container(); | |||
| // return SizedBox( | |||
| // width: double.infinity, | |||
| // height: Validators.stringNotNullOrEmpty(widget.invalidMessage ?? '') ? 85 : 65, | |||
| // child: Column( | |||
| // crossAxisAlignment: CrossAxisAlignment.start, | |||
| // children: [ | |||
| // Validators.stringNotNullOrEmpty(data?.currentData?.name ?? '') | |||
| // ? Text( | |||
| // widget.hint ?? '', | |||
| // style: TextStyle( | |||
| // color: Validators.stringNotNullOrEmpty(widget.invalidMessage ?? '') ? Colors.red : Colors.black54, fontSize: 13.0), | |||
| // ) | |||
| // : Text( | |||
| // '', | |||
| // style: TextStyle( | |||
| // color: Validators.stringNotNullOrEmpty(widget.invalidMessage ?? '') ? Colors.red : Colors.black54, fontSize: 13.0), | |||
| // ), | |||
| // SizedBox( | |||
| // width: double.infinity, | |||
| // height: 44, | |||
| // child: TextButton( | |||
| // onPressed: () { | |||
| // Navigator.of(context) | |||
| // .push(MaterialPageRoute( | |||
| // builder: (_) => CommonDataHelperScreen( | |||
| // titleName: widget.titleName ?? '', | |||
| // tbSupply: widget.tbSupply ?? '', | |||
| // condition: widget.condition ?? '', | |||
| // selectedId: data?.selectedId ?? -1, | |||
| // currentItems: [], | |||
| // currentEditId: -1), | |||
| // fullscreenDialog: false)) | |||
| // .then((value) { | |||
| // if (value != null) { | |||
| // var result = value as CommonData; | |||
| // controller?.change(result); | |||
| // widget.onPressed(result); | |||
| // } | |||
| // }); | |||
| // }, | |||
| // child: Column( | |||
| // crossAxisAlignment: CrossAxisAlignment.start, | |||
| // children: [ | |||
| // Container( | |||
| // padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| // decoration: BoxDecoration( | |||
| // border: Border( | |||
| // bottom: BorderSide( | |||
| // width: 0.5, | |||
| // color: Validators.stringNotNullOrEmpty(widget.invalidMessage ?? '') ? Colors.red : Colors.black54)), | |||
| // ), | |||
| // child: Row( | |||
| // children: [ | |||
| // Expanded( | |||
| // child: Validators.stringNotNullOrEmpty(data?.currentData?.name ?? '') | |||
| // ? Text(data?.currentData?.name ?? '', style: TextStyle(fontSize: 16.0, color: Colors.black)) | |||
| // : Text(widget.hint, style: TextStyle(fontSize: 16.0, color: Colors.black54)), | |||
| // ), | |||
| // Icon( | |||
| // Icons.arrow_drop_down, | |||
| // color: Colors.grey, | |||
| // ), | |||
| // ], | |||
| // )) | |||
| // ], | |||
| // )), | |||
| // ), | |||
| // Validators.stringNotNullOrEmpty(widget.invalidMessage ?? '') | |||
| // ? Text( | |||
| // widget.invalidMessage ?? '', | |||
| // style: TextStyle(fontSize: 12.0, color: Colors.red, fontWeight: FontWeight.normal), | |||
| // textAlign: TextAlign.left, | |||
| // ) | |||
| // : SizedBox(), | |||
| // ], | |||
| // ), | |||
| // ); | |||
| // }); | |||
| } | |||
| } | |||
| @@ -43,6 +43,7 @@ class _FieldDateWidgetState extends State<FieldDateWidget> { | |||
| @override | |||
| Widget build(BuildContext context) { | |||
| return GetBuilder<ChangeDateTimePicker>( | |||
| init: controller, | |||
| tag: widget.tag, | |||
| builder: (data) { | |||
| return SizedBox( | |||
| @@ -27,33 +27,35 @@ class _WidgetFieldDateTimePickerState extends State<WidgetFieldDateTimePicker> { | |||
| @override | |||
| Widget build(BuildContext context) { | |||
| return GetBuilder<ChangeDateTimePicker>(builder: (value) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {}, onConfirm: (date) { | |||
| changeDate.change(date); | |||
| widget.onUpdateDateTime(date); | |||
| }, currentTime: value.selectedDateTime, locale: LocaleType.vi); | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| child: Row( | |||
| children: [ | |||
| Expanded( | |||
| child: Text( | |||
| value.selectedDateTime?.displayDateTime_DDMMYYYY_HHmm() ?? '', | |||
| style: TextStyle(fontSize: 14.0, color: Colors.black87), | |||
| )), | |||
| Icon( | |||
| Icons.date_range, | |||
| color: Colors.grey, | |||
| return GetBuilder<ChangeDateTimePicker>( | |||
| init: changeDate, | |||
| builder: (value) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {}, onConfirm: (date) { | |||
| changeDate.change(date); | |||
| widget.onUpdateDateTime(date); | |||
| }, currentTime: value.selectedDateTime, locale: LocaleType.vi); | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| ], | |||
| ))); | |||
| }); | |||
| child: Row( | |||
| children: [ | |||
| Expanded( | |||
| child: Text( | |||
| value.selectedDateTime?.displayDateTime_DDMMYYYY_HHmm() ?? '', | |||
| style: TextStyle(fontSize: 14.0, color: Colors.black87), | |||
| )), | |||
| Icon( | |||
| Icons.date_range, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ))); | |||
| }); | |||
| } | |||
| } | |||
| @@ -37,6 +37,7 @@ class _RadioButtonWidgetState extends State<RadioButtonWidget> { | |||
| @override | |||
| Widget build(BuildContext context) { | |||
| return GetBuilder<ChangeDropdownController>( | |||
| init: controller, | |||
| tag: widget.tag, | |||
| builder: (data) { | |||
| return BlocProvider( | |||
| @@ -54,249 +54,268 @@ class _WidgetDungSupplyState extends State<WidgetDungSupply> { | |||
| } | |||
| Widget _buildListSupply() { | |||
| return GetBuilder<ChangeSupplyUsing>(builder: (value) { | |||
| widget.onChangeSupplies(value.currentItems ?? []); | |||
| if (value.currentItems!.isEmpty) { | |||
| return Container(); | |||
| } else { | |||
| return Container( | |||
| height: 120, | |||
| child: ListView.builder( | |||
| physics: ClampingScrollPhysics(), | |||
| scrollDirection: Axis.horizontal, | |||
| shrinkWrap: true, | |||
| itemCount: value.currentItems?.length, | |||
| itemBuilder: (context, index) { | |||
| return GestureDetector( | |||
| onTap: () { | |||
| print("edit"); | |||
| changeSupplyUsing.changeIndexEdit(index); | |||
| changeButton.updateToEdit(true); | |||
| var editedSupplyUsing = value.currentItems?[index] ?? SuppliesUsing(); | |||
| var editedSupply = Supply() | |||
| ..id = editedSupplyUsing.tbSuppliesInWarehouseId | |||
| ..tbSuppliesName = editedSupplyUsing.supplyName | |||
| ..unit = editedSupplyUsing.supplyUnit; | |||
| changeSelectedSupply.change(editedSupply); | |||
| return GetBuilder<ChangeSupplyUsing>( | |||
| init: changeSupplyUsing, | |||
| builder: (value) { | |||
| widget.onChangeSupplies(value.currentItems ?? []); | |||
| if (value.currentItems!.isEmpty) { | |||
| return Container(); | |||
| } else { | |||
| return Container( | |||
| height: 120, | |||
| child: ListView.builder( | |||
| physics: ClampingScrollPhysics(), | |||
| scrollDirection: Axis.horizontal, | |||
| shrinkWrap: true, | |||
| itemCount: value.currentItems?.length, | |||
| itemBuilder: (context, index) { | |||
| return GestureDetector( | |||
| onTap: () { | |||
| print("edit"); | |||
| changeSupplyUsing.changeIndexEdit(index); | |||
| changeButton.updateToEdit(true); | |||
| var editedSupplyUsing = value.currentItems?[index] ?? SuppliesUsing(); | |||
| var editedSupply = Supply() | |||
| ..id = editedSupplyUsing.tbSuppliesInWarehouseId | |||
| ..tbSuppliesName = editedSupplyUsing.supplyName | |||
| ..unit = editedSupplyUsing.supplyUnit; | |||
| changeSelectedSupply.change(editedSupply); | |||
| var editedDevice = Device() | |||
| ..id = editedSupplyUsing.tbEquipmentOfCustomerId | |||
| ..name = editedSupplyUsing.equipmentName; | |||
| changeSelectedDevice.change(editedDevice); | |||
| var editedDevice = Device() | |||
| ..id = editedSupplyUsing.tbEquipmentOfCustomerId | |||
| ..name = editedSupplyUsing.equipmentName; | |||
| changeSelectedDevice.change(editedDevice); | |||
| changeUnit.updateListByUnitName(editedSupplyUsing.supplyUnit ?? ''); | |||
| changeUnit.updateSelected(editedSupplyUsing.supplyUnit ?? ''); | |||
| _dosageController.text = editedSupplyUsing.dosage ?? ''; | |||
| _howToUseController.text = editedSupplyUsing.howToUse ?? ''; | |||
| _quantityController.text = editedSupplyUsing.quantity?.formatNumtoStringDecimal() ?? '0'; | |||
| }, | |||
| child: Card( | |||
| child: Stack( | |||
| alignment: Alignment.bottomCenter, | |||
| children: <Widget>[ | |||
| Positioned( | |||
| child: ClipRRect( | |||
| borderRadius: BorderRadius.circular(8), | |||
| child: Container( | |||
| padding: EdgeInsets.all(4), | |||
| width: 150, | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.center, | |||
| mainAxisAlignment: MainAxisAlignment.center, | |||
| children: [ | |||
| SizedBox( | |||
| height: 12.0, | |||
| ), | |||
| Flexible( | |||
| child: Text(value.currentItems?[index].supplyName ?? "", overflow: TextOverflow.ellipsis, maxLines: 1), | |||
| changeUnit.updateListByUnitName(editedSupplyUsing.supplyUnit ?? ''); | |||
| changeUnit.updateSelected(editedSupplyUsing.supplyUnit ?? ''); | |||
| _dosageController.text = editedSupplyUsing.dosage ?? ''; | |||
| _howToUseController.text = editedSupplyUsing.howToUse ?? ''; | |||
| _quantityController.text = editedSupplyUsing.quantity?.formatNumtoStringDecimal() ?? '0'; | |||
| }, | |||
| child: Card( | |||
| child: Stack( | |||
| alignment: Alignment.bottomCenter, | |||
| children: <Widget>[ | |||
| Positioned( | |||
| child: ClipRRect( | |||
| borderRadius: BorderRadius.circular(8), | |||
| child: Container( | |||
| padding: EdgeInsets.all(4), | |||
| width: 150, | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.center, | |||
| mainAxisAlignment: MainAxisAlignment.center, | |||
| children: [ | |||
| SizedBox( | |||
| height: 12.0, | |||
| ), | |||
| Flexible( | |||
| child: Text(value.currentItems?[index].supplyName ?? "", overflow: TextOverflow.ellipsis, maxLines: 1), | |||
| ), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].dosage ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].dosage ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? '0') | |||
| ? Flexible( | |||
| child: Text( | |||
| "${value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? ""} ${value.currentItems?[index].supplyUnit ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].equipmentName ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].equipmentName ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].howToUse ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].howToUse ?? ""}")) | |||
| : SizedBox(), | |||
| ], | |||
| ), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].dosage ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].dosage ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? '0') | |||
| ? Flexible( | |||
| child: Text( | |||
| "${value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? ""} ${value.currentItems?[index].supplyUnit ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].equipmentName ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].equipmentName ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].howToUse ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].howToUse ?? ""}")) | |||
| : SizedBox(), | |||
| ], | |||
| ), | |||
| ), | |||
| )), | |||
| Positioned( | |||
| top: -10, | |||
| right: -10, | |||
| child: IconButton( | |||
| icon: Icon( | |||
| Icons.cancel, | |||
| color: Colors.redAccent, | |||
| ), | |||
| onPressed: () { | |||
| changeSupplyUsing.deleteSupply(index); | |||
| }), | |||
| ) | |||
| ], | |||
| ))); | |||
| })); | |||
| } | |||
| }); | |||
| )), | |||
| Positioned( | |||
| top: -10, | |||
| right: -10, | |||
| child: IconButton( | |||
| icon: Icon( | |||
| Icons.cancel, | |||
| color: Colors.redAccent, | |||
| ), | |||
| onPressed: () { | |||
| changeSupplyUsing.deleteSupply(index); | |||
| }), | |||
| ) | |||
| ], | |||
| ))); | |||
| })); | |||
| } | |||
| }); | |||
| } | |||
| Widget _btnSelectSubstrates() { | |||
| return GetBuilder<ChangeSupply>(builder: (data) { | |||
| return TextButton(onPressed: () { | |||
| var currentIndexEdit = changeSupplyUsing.currentIndex; | |||
| Navigator.of(context) | |||
| .push(MaterialPageRoute( | |||
| builder: (_) => ResourceHelperScreen( | |||
| titleName: "Phân bón", | |||
| type: ConstCommon.supplyTypeDung, | |||
| selectedId: changeSelectedSupply.selectedSupplyId ?? -1, | |||
| currentItems: changeSupplyUsing.currentItems ?? [], | |||
| currentEditId: | |||
| ((currentIndexEdit ?? 0) >= 0) ? changeSupplyUsing.currentItems![currentIndexEdit!].tbSuppliesInWarehouseId ?? -1 : -1, | |||
| ), | |||
| fullscreenDialog: false)) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as Supply; | |||
| changeSelectedSupply.change(result); | |||
| changeUnit.updateListByUnitName(result.unit ?? ''); | |||
| changeFormField.change(true); | |||
| } | |||
| }); | |||
| }, child: GetBuilder<ChangeSupply>(builder: (_) { | |||
| var isValid = changeSelectedSupply.isValid; | |||
| return Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: Border(bottom: BorderSide(width: 1, color: (isValid ?? false) ? Colors.grey : Colors.red)), | |||
| ), | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Validators.stringNotNullOrEmpty(changeSelectedSupply.selectedSupplyName ?? '') | |||
| ? Text( | |||
| 'Tên thương mại *', | |||
| style: | |||
| TextStyle(fontSize: 13, fontWeight: FontWeight.normal, color: (isValid ?? false) ? Colors.black54 : Colors.red[600]), | |||
| ) | |||
| : Text( | |||
| '', | |||
| style: | |||
| TextStyle(fontSize: 13, fontWeight: FontWeight.normal, color: (isValid ?? false) ? Colors.black54 : Colors.red[600]), | |||
| ), | |||
| Row( | |||
| return GetBuilder<ChangeSupply>( | |||
| init: changeSelectedSupply, | |||
| builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| var currentIndexEdit = changeSupplyUsing.currentIndex; | |||
| Navigator.of(context) | |||
| .push(MaterialPageRoute( | |||
| builder: (_) => ResourceHelperScreen( | |||
| titleName: "Phân bón", | |||
| type: ConstCommon.supplyTypeDung, | |||
| selectedId: changeSelectedSupply.selectedSupplyId ?? -1, | |||
| currentItems: changeSupplyUsing.currentItems ?? [], | |||
| currentEditId: ((currentIndexEdit ?? 0) >= 0) | |||
| ? changeSupplyUsing.currentItems![currentIndexEdit!].tbSuppliesInWarehouseId ?? -1 | |||
| : -1, | |||
| ), | |||
| fullscreenDialog: false)) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as Supply; | |||
| changeSelectedSupply.change(result); | |||
| changeUnit.updateListByUnitName(result.unit ?? ''); | |||
| changeFormField.change(true); | |||
| } | |||
| }); | |||
| }, | |||
| child: GetBuilder<ChangeSupply>( | |||
| init: changeSelectedSupply, | |||
| builder: (_) { | |||
| var isValid = changeSelectedSupply.isValid; | |||
| return Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Expanded( | |||
| child: Validators.stringNotNullOrEmpty(changeSelectedSupply.selectedSupplyName ?? '') | |||
| ? Text(changeSelectedSupply.selectedSupplyName ?? '', style: TextStyle(fontSize: 14.0, color: Colors.black87)) | |||
| : Text("Tên thương mại*", style: TextStyle(fontSize: 14.0, color: Colors.black54)), | |||
| ), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: Border(bottom: BorderSide(width: 1, color: (isValid ?? false) ? Colors.grey : Colors.red)), | |||
| ), | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Validators.stringNotNullOrEmpty(changeSelectedSupply.selectedSupplyName ?? '') | |||
| ? Text( | |||
| 'Tên thương mại *', | |||
| style: TextStyle( | |||
| fontSize: 13, | |||
| fontWeight: FontWeight.normal, | |||
| color: (isValid ?? false) ? Colors.black54 : Colors.red[600]), | |||
| ) | |||
| : Text( | |||
| '', | |||
| style: TextStyle( | |||
| fontSize: 13, | |||
| fontWeight: FontWeight.normal, | |||
| color: (isValid ?? false) ? Colors.black54 : Colors.red[600]), | |||
| ), | |||
| Row( | |||
| children: [ | |||
| Expanded( | |||
| child: Validators.stringNotNullOrEmpty(changeSelectedSupply.selectedSupplyName ?? '') | |||
| ? Text(changeSelectedSupply.selectedSupplyName ?? '', | |||
| style: TextStyle(fontSize: 14.0, color: Colors.black87)) | |||
| : Text("Tên thương mại*", style: TextStyle(fontSize: 14.0, color: Colors.black54)), | |||
| ), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ) | |||
| ], | |||
| )), | |||
| (isValid ?? false) ? SizedBox() : WidgetErrorTextField() | |||
| ], | |||
| ) | |||
| ], | |||
| )), | |||
| (isValid ?? false) ? SizedBox() : WidgetErrorTextField() | |||
| ], | |||
| ); | |||
| })); | |||
| }); | |||
| ); | |||
| })); | |||
| }); | |||
| } | |||
| Widget _btnSelectDevice() { | |||
| return GetBuilder<ChangeDevice>(builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| Navigator.of(context) | |||
| .push(MaterialPageRoute( | |||
| builder: (_) => ListDeviceActivity(selectedId: changeSelectedDevice.selectedDeviceId ?? -1), fullscreenDialog: false)) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as Device; | |||
| changeSelectedDevice.change(result); | |||
| changeFormField.change(true); | |||
| } | |||
| }); | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Validators.stringNotNullOrEmpty(changeSelectedDevice.selectedDeviceName ?? '') | |||
| ? Text( | |||
| 'Thiết bị', | |||
| style: TextStyle(fontSize: 13, fontWeight: FontWeight.normal, color: Colors.black54), | |||
| ) | |||
| : Text( | |||
| '', | |||
| style: TextStyle(fontSize: 13, fontWeight: FontWeight.normal, color: Colors.black54), | |||
| ), | |||
| Row( | |||
| return GetBuilder<ChangeDevice>( | |||
| init: changeSelectedDevice, | |||
| builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| Navigator.of(context) | |||
| .push(MaterialPageRoute( | |||
| builder: (_) => ListDeviceActivity(selectedId: changeSelectedDevice.selectedDeviceId ?? -1), fullscreenDialog: false)) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as Device; | |||
| changeSelectedDevice.change(result); | |||
| changeFormField.change(true); | |||
| } | |||
| }); | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| GetBuilder<ChangeSupply>( | |||
| builder: (_) => Expanded( | |||
| child: Validators.stringNotNullOrEmpty(changeSelectedDevice.selectedDeviceName ?? '') | |||
| ? Text(changeSelectedDevice.selectedDeviceName ?? '', style: TextStyle(fontSize: 14.0, color: Colors.black87)) | |||
| : Text("Thiết bị", style: TextStyle(fontSize: 14.0, color: Colors.black54)), | |||
| )), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| Validators.stringNotNullOrEmpty(changeSelectedDevice.selectedDeviceName ?? '') | |||
| ? Text( | |||
| 'Thiết bị', | |||
| style: TextStyle(fontSize: 13, fontWeight: FontWeight.normal, color: Colors.black54), | |||
| ) | |||
| : Text( | |||
| '', | |||
| style: TextStyle(fontSize: 13, fontWeight: FontWeight.normal, color: Colors.black54), | |||
| ), | |||
| Row( | |||
| children: [ | |||
| GetBuilder<ChangeSupply>( | |||
| init: changeSelectedSupply, | |||
| builder: (_) => Expanded( | |||
| child: Validators.stringNotNullOrEmpty(changeSelectedDevice.selectedDeviceName ?? '') | |||
| ? Text(changeSelectedDevice.selectedDeviceName ?? '', style: TextStyle(fontSize: 14.0, color: Colors.black87)) | |||
| : Text("Thiết bị", style: TextStyle(fontSize: 14.0, color: Colors.black54)), | |||
| )), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ), | |||
| ], | |||
| ), | |||
| ], | |||
| ))); | |||
| }); | |||
| ))); | |||
| }); | |||
| } | |||
| Widget _dropdownUnitTypes() { | |||
| return GetBuilder<ChangeUnit>(builder: (data) { | |||
| return DropdownButtonFormField<String>( | |||
| itemHeight: 100, | |||
| value: !Validators.stringNotNullOrEmpty(data.selectedUnit ?? '') ? null : data.selectedUnit, | |||
| items: data.currentUnits! | |||
| .map((label) => DropdownMenuItem( | |||
| child: Text(label), | |||
| value: label, | |||
| )) | |||
| .toList(), | |||
| onChanged: (value) { | |||
| var currentQuantity = _quantityController.text; | |||
| num assignValue = currentQuantity.parseDoubleThousand(); | |||
| if (assignValue != null) { | |||
| var oldSelected = data.selectedUnit; | |||
| if (oldSelected == value) { | |||
| } else { | |||
| assignValue = UtilAction.convertUnit( | |||
| inputValue: assignValue, | |||
| oldUnit: oldSelected ?? '', | |||
| newUnit: value ?? '', | |||
| ); | |||
| } | |||
| _quantityController.text = assignValue.formatNumtoStringDecimal(); | |||
| } | |||
| changeUnit.updateSelected(value ?? ''); | |||
| }, | |||
| ); | |||
| }); | |||
| return GetBuilder<ChangeUnit>( | |||
| init: changeUnit, | |||
| builder: (data) { | |||
| return DropdownButtonFormField<String>( | |||
| itemHeight: 100, | |||
| value: !Validators.stringNotNullOrEmpty(data.selectedUnit ?? '') ? null : data.selectedUnit, | |||
| items: data.currentUnits! | |||
| .map((label) => DropdownMenuItem( | |||
| child: Text(label), | |||
| value: label, | |||
| )) | |||
| .toList(), | |||
| onChanged: (value) { | |||
| var currentQuantity = _quantityController.text; | |||
| num assignValue = currentQuantity.parseDoubleThousand(); | |||
| if (assignValue != null) { | |||
| var oldSelected = data.selectedUnit; | |||
| if (oldSelected == value) { | |||
| } else { | |||
| assignValue = UtilAction.convertUnit( | |||
| inputValue: assignValue, | |||
| oldUnit: oldSelected ?? '', | |||
| newUnit: value ?? '', | |||
| ); | |||
| } | |||
| _quantityController.text = assignValue.formatNumtoStringDecimal(); | |||
| } | |||
| changeUnit.updateSelected(value ?? ''); | |||
| }, | |||
| ); | |||
| }); | |||
| } | |||
| _quantityField() { | |||
| @@ -322,126 +341,128 @@ class _WidgetDungSupplyState extends State<WidgetDungSupply> { | |||
| } | |||
| _buttonInForm() { | |||
| return GetBuilder<ChangeButtonInForm>(builder: (_) { | |||
| return Row( | |||
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | |||
| children: [ | |||
| _.isEdit ?? false | |||
| ? TextButton( | |||
| child: Text("Huỷ"), | |||
| onPressed: () { | |||
| changeButton.resetValue(); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| }) | |||
| : SizedBox(), | |||
| _.isEdit ?? false | |||
| ? Expanded( | |||
| child: TextButton( | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| var currentDevice = changeSelectedDevice.currentDevice; | |||
| var currentQuantity = _quantityController.text.parseDoubleThousand(); | |||
| if (currentSupply?.id != null && (currentQuantity ?? 0) > 0) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: currentQuantity, | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..howToUse = _howToUseController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..tbEquipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentName = currentDevice?.name ?? '' | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.editSupply(changeSupplyUsing.currentIndex ?? -1, newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } else if (currentSupply?.id == null || ((currentQuantity ?? 0) <= 0)) { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| } | |||
| }, | |||
| child: Text( | |||
| "Sửa phân bón", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| : Expanded( | |||
| child: TextButton( | |||
| return GetBuilder<ChangeButtonInForm>( | |||
| init: changeButton, | |||
| builder: (_) { | |||
| return Row( | |||
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | |||
| children: [ | |||
| _.isEdit ?? false | |||
| ? TextButton( | |||
| child: Text("Huỷ"), | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| var currentDevice = changeSelectedDevice.currentDevice; | |||
| var currentQuantity = _quantityController.text.parseDoubleThousand(); | |||
| if (currentSupply?.id != null && (currentQuantity ?? 0) > 0) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: currentQuantity, | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..howToUse = _howToUseController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..tbEquipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentName = currentDevice?.name | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.addSupply(newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } else if (currentSupply?.id == null || ((currentQuantity ?? 0) <= 0)) { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| // | |||
| } | |||
| }, | |||
| child: Text( | |||
| "+ Thêm phân bón", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| ], | |||
| ); | |||
| }); | |||
| changeButton.resetValue(); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| }) | |||
| : SizedBox(), | |||
| _.isEdit ?? false | |||
| ? Expanded( | |||
| child: TextButton( | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| var currentDevice = changeSelectedDevice.currentDevice; | |||
| var currentQuantity = _quantityController.text.parseDoubleThousand(); | |||
| if (currentSupply?.id != null && (currentQuantity ?? 0) > 0) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: currentQuantity, | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..howToUse = _howToUseController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..tbEquipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentName = currentDevice?.name ?? '' | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.editSupply(changeSupplyUsing.currentIndex ?? -1, newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } else if (currentSupply?.id == null || ((currentQuantity ?? 0) <= 0)) { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| } | |||
| }, | |||
| child: Text( | |||
| "Sửa phân bón", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| : Expanded( | |||
| child: TextButton( | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| var currentDevice = changeSelectedDevice.currentDevice; | |||
| var currentQuantity = _quantityController.text.parseDoubleThousand(); | |||
| if (currentSupply?.id != null && (currentQuantity ?? 0) > 0) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: currentQuantity, | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..howToUse = _howToUseController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..tbEquipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentName = currentDevice?.name | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.addSupply(newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } else if (currentSupply?.id == null || ((currentQuantity ?? 0) <= 0)) { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| // | |||
| } | |||
| }, | |||
| child: Text( | |||
| "+ Thêm phân bón", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| ], | |||
| ); | |||
| }); | |||
| } | |||
| Widget _formEdit() { | |||
| @@ -57,222 +57,237 @@ class _WidgetHarvestProcessSupplyState extends State<WidgetHarvestProcessSupply> | |||
| } | |||
| Widget _buildListSupply() { | |||
| return GetBuilder<ChangeSupplyUsing>(builder: (value) { | |||
| widget.onChangeSupplies(value.currentItems ?? []); | |||
| if (value.currentItems!.isEmpty) { | |||
| return Container(); | |||
| } else { | |||
| return Container( | |||
| height: 120, | |||
| child: ListView.builder( | |||
| physics: ClampingScrollPhysics(), | |||
| scrollDirection: Axis.horizontal, | |||
| shrinkWrap: true, | |||
| itemCount: value.currentItems?.length ?? 0, | |||
| itemBuilder: (context, index) { | |||
| return GestureDetector( | |||
| onTap: () { | |||
| print("edit"); | |||
| changeSupplyUsing.changeIndexEdit(index); | |||
| changeButton.updateToEdit(true); | |||
| var editedSupplyUsing = value.currentItems![index]; | |||
| var editedSupply = Supply() | |||
| ..id = editedSupplyUsing.tbSuppliesInWarehouseId | |||
| ..tbSuppliesName = editedSupplyUsing.supplyName | |||
| ..unit = editedSupplyUsing.supplyUnit; | |||
| changeSelectedSupply.change(editedSupply); | |||
| return GetBuilder<ChangeSupplyUsing>( | |||
| init: changeSupplyUsing, | |||
| builder: (value) { | |||
| widget.onChangeSupplies(value.currentItems ?? []); | |||
| if (value.currentItems!.isEmpty) { | |||
| return Container(); | |||
| } else { | |||
| return Container( | |||
| height: 120, | |||
| child: ListView.builder( | |||
| physics: ClampingScrollPhysics(), | |||
| scrollDirection: Axis.horizontal, | |||
| shrinkWrap: true, | |||
| itemCount: value.currentItems?.length ?? 0, | |||
| itemBuilder: (context, index) { | |||
| return GestureDetector( | |||
| onTap: () { | |||
| print("edit"); | |||
| changeSupplyUsing.changeIndexEdit(index); | |||
| changeButton.updateToEdit(true); | |||
| var editedSupplyUsing = value.currentItems![index]; | |||
| var editedSupply = Supply() | |||
| ..id = editedSupplyUsing.tbSuppliesInWarehouseId | |||
| ..tbSuppliesName = editedSupplyUsing.supplyName | |||
| ..unit = editedSupplyUsing.supplyUnit; | |||
| changeSelectedSupply.change(editedSupply); | |||
| var editedDevice = Device() | |||
| ..id = editedSupplyUsing.tbEquipmentOfCustomerId | |||
| ..name = editedSupplyUsing.equipmentName; | |||
| changeSelectedDevice.change(editedDevice); | |||
| var editedDevice = Device() | |||
| ..id = editedSupplyUsing.tbEquipmentOfCustomerId | |||
| ..name = editedSupplyUsing.equipmentName; | |||
| changeSelectedDevice.change(editedDevice); | |||
| changeUnit.updateListByUnitName(editedSupplyUsing.supplyUnit ?? ''); | |||
| changeUnit.updateSelected(editedSupplyUsing.supplyUnit ?? ''); | |||
| _dosageController.text = editedSupplyUsing.dosage ?? ''; | |||
| _howToUseController.text = editedSupplyUsing.howToUse ?? ''; | |||
| _quantityController.text = editedSupplyUsing.quantity?.formatNumtoStringDecimal() ?? '0'; | |||
| }, | |||
| child: Card( | |||
| child: Stack( | |||
| alignment: Alignment.bottomCenter, | |||
| children: <Widget>[ | |||
| Positioned( | |||
| child: ClipRRect( | |||
| borderRadius: BorderRadius.circular(8), | |||
| child: Container( | |||
| padding: EdgeInsets.all(4), | |||
| width: 150, | |||
| child: Column( | |||
| mainAxisAlignment: MainAxisAlignment.center, | |||
| children: [ | |||
| SizedBox( | |||
| height: 12.0, | |||
| ), | |||
| Flexible( | |||
| child: Text(value.currentItems?[index].supplyName ?? "", overflow: TextOverflow.ellipsis, maxLines: 1), | |||
| changeUnit.updateListByUnitName(editedSupplyUsing.supplyUnit ?? ''); | |||
| changeUnit.updateSelected(editedSupplyUsing.supplyUnit ?? ''); | |||
| _dosageController.text = editedSupplyUsing.dosage ?? ''; | |||
| _howToUseController.text = editedSupplyUsing.howToUse ?? ''; | |||
| _quantityController.text = editedSupplyUsing.quantity?.formatNumtoStringDecimal() ?? '0'; | |||
| }, | |||
| child: Card( | |||
| child: Stack( | |||
| alignment: Alignment.bottomCenter, | |||
| children: <Widget>[ | |||
| Positioned( | |||
| child: ClipRRect( | |||
| borderRadius: BorderRadius.circular(8), | |||
| child: Container( | |||
| padding: EdgeInsets.all(4), | |||
| width: 150, | |||
| child: Column( | |||
| mainAxisAlignment: MainAxisAlignment.center, | |||
| children: [ | |||
| SizedBox( | |||
| height: 12.0, | |||
| ), | |||
| Flexible( | |||
| child: Text(value.currentItems?[index].supplyName ?? "", overflow: TextOverflow.ellipsis, maxLines: 1), | |||
| ), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].dosage ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].dosage ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? '') | |||
| ? Flexible( | |||
| child: Text( | |||
| "${value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? ""} ${value.currentItems?[index].supplyUnit ?? ""}", | |||
| )) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].equipmentName ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].equipmentName ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].howToUse ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].howToUse ?? ""}")) | |||
| : SizedBox(), | |||
| ], | |||
| ), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].dosage ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].dosage ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? '') | |||
| ? Flexible( | |||
| child: Text( | |||
| "${value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? ""} ${value.currentItems?[index].supplyUnit ?? ""}", | |||
| )) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].equipmentName ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].equipmentName ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].howToUse ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].howToUse ?? ""}")) | |||
| : SizedBox(), | |||
| ], | |||
| ), | |||
| ), | |||
| )), | |||
| Positioned( | |||
| top: -10, | |||
| right: -10, | |||
| child: IconButton( | |||
| icon: Icon( | |||
| Icons.cancel, | |||
| color: Colors.redAccent, | |||
| ), | |||
| onPressed: () { | |||
| changeSupplyUsing.deleteSupply(index); | |||
| }), | |||
| ) | |||
| ], | |||
| ))); | |||
| })); | |||
| } | |||
| }); | |||
| )), | |||
| Positioned( | |||
| top: -10, | |||
| right: -10, | |||
| child: IconButton( | |||
| icon: Icon( | |||
| Icons.cancel, | |||
| color: Colors.redAccent, | |||
| ), | |||
| onPressed: () { | |||
| changeSupplyUsing.deleteSupply(index); | |||
| }), | |||
| ) | |||
| ], | |||
| ))); | |||
| })); | |||
| } | |||
| }); | |||
| } | |||
| Widget _btnSelectSubstrates() { | |||
| return GetBuilder<ChangeSupply>(builder: (data) { | |||
| return TextButton(onPressed: () { | |||
| var currentIndexEdit = changeSupplyUsing.currentIndex; | |||
| Navigator.of(context) | |||
| .push(MaterialPageRoute( | |||
| builder: (_) => ResourceHelperScreen( | |||
| titleName: "Hoá chất xử lý", | |||
| type: ConstCommon.supplyTypeAll, | |||
| selectedId: changeSelectedSupply.selectedSupplyId ?? -1, | |||
| currentItems: changeSupplyUsing.currentItems ?? [], | |||
| currentEditId: ((currentIndexEdit ?? -1) >= 0) | |||
| ? (changeSupplyUsing.currentItems?[(currentIndexEdit ?? 0)].tbSuppliesInWarehouseId ?? -1) | |||
| : -1, | |||
| ), | |||
| fullscreenDialog: false)) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as Supply; | |||
| changeSelectedSupply.change(result); | |||
| changeUnit.updateListByUnitName(result.unit ?? ''); | |||
| changeFormField.change(true); | |||
| } | |||
| }); | |||
| }, child: GetBuilder<ChangeSupply>(builder: (_) { | |||
| var isValid = changeSelectedSupply.isValid; | |||
| return Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: Border(bottom: BorderSide(width: 1, color: (isValid ?? false) ? Colors.grey : Colors.red)), | |||
| ), | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Text( | |||
| 'Hoá chất xử lý *', | |||
| style: TextStyle(fontSize: 13, fontWeight: FontWeight.normal, color: (isValid ?? false) ? Colors.black54 : Colors.red[600]), | |||
| ), | |||
| Row( | |||
| return GetBuilder<ChangeSupply>( | |||
| init: changeSelectedSupply, | |||
| builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| var currentIndexEdit = changeSupplyUsing.currentIndex; | |||
| Navigator.of(context) | |||
| .push(MaterialPageRoute( | |||
| builder: (_) => ResourceHelperScreen( | |||
| titleName: "Hoá chất xử lý", | |||
| type: ConstCommon.supplyTypeAll, | |||
| selectedId: changeSelectedSupply.selectedSupplyId ?? -1, | |||
| currentItems: changeSupplyUsing.currentItems ?? [], | |||
| currentEditId: ((currentIndexEdit ?? -1) >= 0) | |||
| ? (changeSupplyUsing.currentItems?[(currentIndexEdit ?? 0)].tbSuppliesInWarehouseId ?? -1) | |||
| : -1, | |||
| ), | |||
| fullscreenDialog: false)) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as Supply; | |||
| changeSelectedSupply.change(result); | |||
| changeUnit.updateListByUnitName(result.unit ?? ''); | |||
| changeFormField.change(true); | |||
| } | |||
| }); | |||
| }, | |||
| child: GetBuilder<ChangeSupply>( | |||
| init: changeSelectedSupply, | |||
| builder: (_) { | |||
| var isValid = changeSelectedSupply.isValid; | |||
| return Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Expanded( | |||
| child: Text(changeSelectedSupply.selectedSupplyName ?? "Hoá chất xử lý", | |||
| style: TextStyle(fontSize: 14.0, color: Colors.black87))), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: Border(bottom: BorderSide(width: 1, color: (isValid ?? false) ? Colors.grey : Colors.red)), | |||
| ), | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Text( | |||
| 'Hoá chất xử lý *', | |||
| style: TextStyle( | |||
| fontSize: 13, fontWeight: FontWeight.normal, color: (isValid ?? false) ? Colors.black54 : Colors.red[600]), | |||
| ), | |||
| Row( | |||
| children: [ | |||
| Expanded( | |||
| child: Text(changeSelectedSupply.selectedSupplyName ?? "Hoá chất xử lý", | |||
| style: TextStyle(fontSize: 14.0, color: Colors.black87))), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ), | |||
| ], | |||
| )), | |||
| (isValid ?? false) ? SizedBox() : WidgetErrorTextField() | |||
| ], | |||
| ), | |||
| ], | |||
| )), | |||
| (isValid ?? false) ? SizedBox() : WidgetErrorTextField() | |||
| ], | |||
| ); | |||
| })); | |||
| }); | |||
| ); | |||
| })); | |||
| }); | |||
| } | |||
| Widget _btnSelectDevice() { | |||
| return GetBuilder<ChangeDevice>(builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| Navigator.of(context) | |||
| .push( | |||
| MaterialPageRoute(builder: (_) => ListDeviceActivity(selectedId: changeSelectedDevice.selectedDeviceId ?? -1), fullscreenDialog: false), | |||
| ) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as Device; | |||
| changeSelectedDevice.change(result); | |||
| changeFormField.change(true); | |||
| } | |||
| }); | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| child: Row( | |||
| children: [ | |||
| GetBuilder<ChangeSupply>( | |||
| builder: (_) => Expanded( | |||
| child: | |||
| Text(changeSelectedDevice.selectedDeviceName ?? "Thiết bị", style: TextStyle(fontSize: 14.0, color: Colors.black87)))), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| return GetBuilder<ChangeDevice>( | |||
| init: changeSelectedDevice, | |||
| builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| Navigator.of(context) | |||
| .push( | |||
| MaterialPageRoute( | |||
| builder: (_) => ListDeviceActivity(selectedId: changeSelectedDevice.selectedDeviceId ?? -1), fullscreenDialog: false), | |||
| ) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as Device; | |||
| changeSelectedDevice.change(result); | |||
| changeFormField.change(true); | |||
| } | |||
| }); | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| ], | |||
| ))); | |||
| }); | |||
| child: Row( | |||
| children: [ | |||
| GetBuilder<ChangeSupply>( | |||
| init: changeSelectedSupply, | |||
| builder: (_) => Expanded( | |||
| child: Text(changeSelectedDevice.selectedDeviceName ?? "Thiết bị", | |||
| style: TextStyle(fontSize: 14.0, color: Colors.black87)))), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ))); | |||
| }); | |||
| } | |||
| Widget _dropdownUnitTypes() { | |||
| return GetBuilder<ChangeUnit>(builder: (data) { | |||
| return DropdownButtonFormField<String>( | |||
| itemHeight: 100, | |||
| value: (data.selectedUnit ?? '').isEmpty ? null : data.selectedUnit, | |||
| items: (data.currentUnits ?? []) | |||
| .map((label) => DropdownMenuItem( | |||
| child: Text(label), | |||
| value: label, | |||
| )) | |||
| .toList(), | |||
| onChanged: (value) { | |||
| var currentQuantity = _quantityController.text; | |||
| num assignValue = currentQuantity.parseDoubleThousand(); | |||
| if (assignValue != null) { | |||
| var oldSelected = data.selectedUnit; | |||
| if (oldSelected == value) { | |||
| } else { | |||
| assignValue = UtilAction.convertUnit(inputValue: assignValue, oldUnit: oldSelected ?? '', newUnit: value ?? ''); | |||
| } | |||
| _quantityController.text = assignValue.formatNumtoStringDecimal(); | |||
| } | |||
| changeUnit.updateSelected(value ?? ''); | |||
| }, | |||
| ); | |||
| }); | |||
| return GetBuilder<ChangeUnit>( | |||
| init: changeUnit, | |||
| builder: (data) { | |||
| return DropdownButtonFormField<String>( | |||
| itemHeight: 100, | |||
| value: (data.selectedUnit ?? '').isEmpty ? null : data.selectedUnit, | |||
| items: (data.currentUnits ?? []) | |||
| .map((label) => DropdownMenuItem( | |||
| child: Text(label), | |||
| value: label, | |||
| )) | |||
| .toList(), | |||
| onChanged: (value) { | |||
| var currentQuantity = _quantityController.text; | |||
| num assignValue = currentQuantity.parseDoubleThousand(); | |||
| if (assignValue != null) { | |||
| var oldSelected = data.selectedUnit; | |||
| if (oldSelected == value) { | |||
| } else { | |||
| assignValue = UtilAction.convertUnit(inputValue: assignValue, oldUnit: oldSelected ?? '', newUnit: value ?? ''); | |||
| } | |||
| _quantityController.text = assignValue.formatNumtoStringDecimal(); | |||
| } | |||
| changeUnit.updateSelected(value ?? ''); | |||
| }, | |||
| ); | |||
| }); | |||
| } | |||
| _quantityField() { | |||
| @@ -298,125 +313,127 @@ class _WidgetHarvestProcessSupplyState extends State<WidgetHarvestProcessSupply> | |||
| } | |||
| _buttonInForm() { | |||
| return GetBuilder<ChangeButtonInForm>(builder: (_) { | |||
| return Row( | |||
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | |||
| children: [ | |||
| _.isEdit ?? false | |||
| ? TextButton( | |||
| child: Text("Huỷ"), | |||
| onPressed: () { | |||
| changeButton.resetValue(); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| }) | |||
| : SizedBox(), | |||
| _.isEdit ?? false | |||
| ? Expanded( | |||
| child: TextButton( | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| var currentDevice = changeSelectedDevice.currentDevice; | |||
| var currentQuantity = _quantityController.text.parseDoubleThousand(); | |||
| if (currentSupply?.id != null && (currentQuantity ?? 0) > 0) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: currentQuantity, | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..howToUse = _howToUseController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..tbEquipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentName = currentDevice?.name ?? '' | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.editSupply(changeSupplyUsing.currentIndex ?? -1, newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } else if (currentSupply?.id == null || ((currentQuantity ?? 0) <= 0)) { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| } | |||
| }, | |||
| child: Text( | |||
| "Sửa hoá chất xử lý", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| : Expanded( | |||
| child: TextButton( | |||
| return GetBuilder<ChangeButtonInForm>( | |||
| init: changeButton, | |||
| builder: (_) { | |||
| return Row( | |||
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | |||
| children: [ | |||
| _.isEdit ?? false | |||
| ? TextButton( | |||
| child: Text("Huỷ"), | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| var currentDevice = changeSelectedDevice.currentDevice; | |||
| var currentQuantity = _quantityController.text.parseDoubleThousand(); | |||
| if (currentSupply?.id != null && (currentQuantity ?? 0) > 0) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: currentQuantity, | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..howToUse = _howToUseController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..tbEquipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentName = currentDevice?.name ?? '' | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.addSupply(newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } else if (currentSupply?.id == null || ((currentQuantity ?? 0) <= 0)) { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| } | |||
| }, | |||
| child: Text( | |||
| "+ Thêm hoá chất xử lý", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| ], | |||
| ); | |||
| }); | |||
| changeButton.resetValue(); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| }) | |||
| : SizedBox(), | |||
| _.isEdit ?? false | |||
| ? Expanded( | |||
| child: TextButton( | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| var currentDevice = changeSelectedDevice.currentDevice; | |||
| var currentQuantity = _quantityController.text.parseDoubleThousand(); | |||
| if (currentSupply?.id != null && (currentQuantity ?? 0) > 0) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: currentQuantity, | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..howToUse = _howToUseController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..tbEquipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentName = currentDevice?.name ?? '' | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.editSupply(changeSupplyUsing.currentIndex ?? -1, newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } else if (currentSupply?.id == null || ((currentQuantity ?? 0) <= 0)) { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| } | |||
| }, | |||
| child: Text( | |||
| "Sửa hoá chất xử lý", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| : Expanded( | |||
| child: TextButton( | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| var currentDevice = changeSelectedDevice.currentDevice; | |||
| var currentQuantity = _quantityController.text.parseDoubleThousand(); | |||
| if (currentSupply?.id != null && (currentQuantity ?? 0) > 0) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: currentQuantity, | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..howToUse = _howToUseController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..tbEquipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentName = currentDevice?.name ?? '' | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.addSupply(newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } else if (currentSupply?.id == null || ((currentQuantity ?? 0) <= 0)) { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| } | |||
| }, | |||
| child: Text( | |||
| "+ Thêm hoá chất xử lý", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| ], | |||
| ); | |||
| }); | |||
| } | |||
| Widget _formEdit() { | |||
| @@ -31,167 +31,174 @@ class _WidgetWorkerState extends State<WidgetWorker> { | |||
| } | |||
| Widget _buildListWorker() { | |||
| return GetBuilder<ChangeWorker>(builder: (data) { | |||
| widget.onChangeWorkers(data.currentItems ?? []); | |||
| if (data.currentItems?.length == 0 || data.currentItems == null) { | |||
| return Container(); | |||
| } else { | |||
| return Container( | |||
| height: 70, | |||
| child: ListView.builder( | |||
| physics: ClampingScrollPhysics(), | |||
| scrollDirection: Axis.horizontal, | |||
| shrinkWrap: true, | |||
| itemCount: data?.currentItems?.length ?? 0, | |||
| itemBuilder: (context, index) { | |||
| return GestureDetector( | |||
| onTap: () { | |||
| print("edit worker"); | |||
| }, | |||
| child: Card( | |||
| child: Stack( | |||
| alignment: Alignment.bottomCenter, | |||
| children: <Widget>[ | |||
| Positioned( | |||
| child: ClipRRect( | |||
| borderRadius: BorderRadius.circular(8), | |||
| child: Container( | |||
| padding: EdgeInsets.all(4), | |||
| width: 120, | |||
| child: Column( | |||
| mainAxisAlignment: MainAxisAlignment.center, | |||
| children: [ | |||
| SizedBox( | |||
| height: 12.0, | |||
| ), | |||
| Flexible( | |||
| child: Text(data.currentItems?[index].workerName ?? '', overflow: TextOverflow.ellipsis, maxLines: 1), | |||
| return GetBuilder<ChangeWorker>( | |||
| init: controller, | |||
| builder: (data) { | |||
| widget.onChangeWorkers(data.currentItems ?? []); | |||
| if (data.currentItems?.length == 0 || data.currentItems == null) { | |||
| return Container(); | |||
| } else { | |||
| return Container( | |||
| height: 70, | |||
| child: ListView.builder( | |||
| physics: ClampingScrollPhysics(), | |||
| scrollDirection: Axis.horizontal, | |||
| shrinkWrap: true, | |||
| itemCount: data?.currentItems?.length ?? 0, | |||
| itemBuilder: (context, index) { | |||
| return GestureDetector( | |||
| onTap: () { | |||
| print("edit worker"); | |||
| }, | |||
| child: Card( | |||
| child: Stack( | |||
| alignment: Alignment.bottomCenter, | |||
| children: <Widget>[ | |||
| Positioned( | |||
| child: ClipRRect( | |||
| borderRadius: BorderRadius.circular(8), | |||
| child: Container( | |||
| padding: EdgeInsets.all(4), | |||
| width: 120, | |||
| child: Column( | |||
| mainAxisAlignment: MainAxisAlignment.center, | |||
| children: [ | |||
| SizedBox( | |||
| height: 12.0, | |||
| ), | |||
| Flexible( | |||
| child: Text(data.currentItems?[index].workerName ?? '', overflow: TextOverflow.ellipsis, maxLines: 1), | |||
| ), | |||
| Validators.stringNotNullOrEmpty(data.currentItems?[index].trayNumber ?? '') | |||
| ? Flexible(child: Text(data.currentItems?[index].trayNumber ?? '')) | |||
| : SizedBox() | |||
| ], | |||
| ), | |||
| Validators.stringNotNullOrEmpty(data.currentItems?[index].trayNumber ?? '') | |||
| ? Flexible(child: Text(data.currentItems?[index].trayNumber ?? '')) | |||
| : SizedBox() | |||
| ], | |||
| ), | |||
| ), | |||
| )), | |||
| Positioned( | |||
| top: -10, | |||
| right: -10, | |||
| child: IconButton( | |||
| icon: Icon( | |||
| Icons.cancel, | |||
| color: Colors.redAccent, | |||
| ), | |||
| onPressed: () { | |||
| controller?.deleteNurseryDetail(index); | |||
| print("Delete worker"); | |||
| }), | |||
| ) | |||
| ], | |||
| ))); | |||
| })); | |||
| } | |||
| }); | |||
| )), | |||
| Positioned( | |||
| top: -10, | |||
| right: -10, | |||
| child: IconButton( | |||
| icon: Icon( | |||
| Icons.cancel, | |||
| color: Colors.redAccent, | |||
| ), | |||
| onPressed: () { | |||
| controller?.deleteNurseryDetail(index); | |||
| print("Delete worker"); | |||
| }), | |||
| ) | |||
| ], | |||
| ))); | |||
| })); | |||
| } | |||
| }); | |||
| } | |||
| @override | |||
| Widget build(BuildContext context) { | |||
| return GetBuilder<ChangeWorker>(builder: (data) { | |||
| return Container( | |||
| child: Form( | |||
| key: _formWorkerKey, | |||
| child: Column( | |||
| children: [ | |||
| Container( | |||
| width: double.infinity, | |||
| height: 16, | |||
| color: Colors.grey[200], | |||
| ), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| Padding( | |||
| padding: const EdgeInsets.all(8.0), | |||
| child: Align( | |||
| alignment: Alignment.centerLeft, | |||
| child: Text( | |||
| 'Người thực hiện', | |||
| style: TextStyle(color: Colors.black54, fontSize: 14), | |||
| return GetBuilder<ChangeWorker>( | |||
| init: controller, | |||
| builder: (data) { | |||
| return Container( | |||
| child: Form( | |||
| key: _formWorkerKey, | |||
| child: Column( | |||
| children: [ | |||
| Container( | |||
| width: double.infinity, | |||
| height: 16, | |||
| color: Colors.grey[200], | |||
| ), | |||
| ), | |||
| ), | |||
| _buildListWorker(), | |||
| Container( | |||
| padding: EdgeInsets.all(8.0), | |||
| margin: EdgeInsets.all(8), | |||
| decoration: BoxDecoration( | |||
| shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(10), color: Colors.white, border: Border.all(color: Colors.grey)), | |||
| child: Column( | |||
| children: [ | |||
| TextFormField( | |||
| keyboardType: TextInputType.text, | |||
| controller: _workerNameController, | |||
| decoration: InputDecoration(labelText: "Tên công nhân *"), | |||
| validator: (value) { | |||
| return Validators.validateNotNullOrEmpty(value ?? '', label_validate_input_empty); | |||
| }, | |||
| onSaved: (newValue) {}, | |||
| onChanged: (value) { | |||
| if (!Validators.stringNotNullOrEmpty(value)) { | |||
| changeFormField.change(false); | |||
| } else { | |||
| changeFormField.change(true); | |||
| } | |||
| }, | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| Padding( | |||
| padding: const EdgeInsets.all(8.0), | |||
| child: Align( | |||
| alignment: Alignment.centerLeft, | |||
| child: Text( | |||
| 'Người thực hiện', | |||
| style: TextStyle(color: Colors.black54, fontSize: 14), | |||
| ), | |||
| ), | |||
| TextFormField( | |||
| keyboardType: TextInputType.text, | |||
| controller: _trayNumberController, | |||
| decoration: InputDecoration(labelText: "Ươm khây số"), | |||
| onSaved: (newValue) {}, | |||
| onChanged: (value) { | |||
| if (!Validators.stringNotNullOrEmpty(value)) { | |||
| changeFormField.change(false); | |||
| } else { | |||
| changeFormField.change(true); | |||
| } | |||
| }, | |||
| ), | |||
| _buildListWorker(), | |||
| Container( | |||
| padding: EdgeInsets.all(8.0), | |||
| margin: EdgeInsets.all(8), | |||
| decoration: BoxDecoration( | |||
| shape: BoxShape.rectangle, | |||
| borderRadius: BorderRadius.circular(10), | |||
| color: Colors.white, | |||
| border: Border.all(color: Colors.grey)), | |||
| child: Column( | |||
| children: [ | |||
| TextFormField( | |||
| keyboardType: TextInputType.text, | |||
| controller: _workerNameController, | |||
| decoration: InputDecoration(labelText: "Tên công nhân *"), | |||
| validator: (value) { | |||
| return Validators.validateNotNullOrEmpty(value ?? '', label_validate_input_empty); | |||
| }, | |||
| onSaved: (newValue) {}, | |||
| onChanged: (value) { | |||
| if (!Validators.stringNotNullOrEmpty(value)) { | |||
| changeFormField.change(false); | |||
| } else { | |||
| changeFormField.change(true); | |||
| } | |||
| }, | |||
| ), | |||
| TextFormField( | |||
| keyboardType: TextInputType.text, | |||
| controller: _trayNumberController, | |||
| decoration: InputDecoration(labelText: "Ươm khây số"), | |||
| onSaved: (newValue) {}, | |||
| onChanged: (value) { | |||
| if (!Validators.stringNotNullOrEmpty(value)) { | |||
| changeFormField.change(false); | |||
| } else { | |||
| changeFormField.change(true); | |||
| } | |||
| }, | |||
| ), | |||
| ], | |||
| ), | |||
| ], | |||
| ), | |||
| ), | |||
| Container( | |||
| margin: EdgeInsets.all(8), | |||
| child: TextButton( | |||
| onPressed: () { | |||
| if (_formWorkerKey.currentState!.validate()) { | |||
| _formWorkerKey.currentState!.save(); | |||
| if (Validators.stringNotNullOrEmpty(_workerNameController.text)) { | |||
| TbNurseryDetailsDTO _nurseryDetail = TbNurseryDetailsDTO() | |||
| ..workerName = _workerNameController.text | |||
| ..trayNumber = _trayNumberController.text; | |||
| controller?.addNurseryDetail(_nurseryDetail); | |||
| _workerNameController.clear(); | |||
| _trayNumberController.clear(); | |||
| changeFormField.change(false); | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập tên công nhân"); | |||
| } | |||
| } else { | |||
| // | |||
| if (!Validators.stringNotNullOrEmpty(_workerNameController.text)) { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập tên công nhân"); | |||
| } | |||
| } | |||
| }, | |||
| child: Text( | |||
| "+ Thêm người thực hiện", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ), | |||
| Container( | |||
| margin: EdgeInsets.all(8), | |||
| child: TextButton( | |||
| onPressed: () { | |||
| if (_formWorkerKey.currentState!.validate()) { | |||
| _formWorkerKey.currentState!.save(); | |||
| if (Validators.stringNotNullOrEmpty(_workerNameController.text)) { | |||
| TbNurseryDetailsDTO _nurseryDetail = TbNurseryDetailsDTO() | |||
| ..workerName = _workerNameController.text | |||
| ..trayNumber = _trayNumberController.text; | |||
| controller?.addNurseryDetail(_nurseryDetail); | |||
| _workerNameController.clear(); | |||
| _trayNumberController.clear(); | |||
| changeFormField.change(false); | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập tên công nhân"); | |||
| } | |||
| } else { | |||
| // | |||
| if (!Validators.stringNotNullOrEmpty(_workerNameController.text)) { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập tên công nhân"); | |||
| } | |||
| } | |||
| }, | |||
| child: Text( | |||
| "+ Thêm người thực hiện", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ), | |||
| ], | |||
| ), | |||
| ], | |||
| ), | |||
| )); | |||
| }); | |||
| )); | |||
| }); | |||
| } | |||
| } | |||
| @@ -48,203 +48,214 @@ class _WidgetPlantSupplyState extends State<WidgetPlantSupply> { | |||
| } | |||
| Widget _buildListSupply() { | |||
| return GetBuilder<ChangeSupplyUsing>(builder: (value) { | |||
| widget.onChangeSupplies(value.currentItems ?? []); | |||
| if ((value.currentItems ?? []).isEmpty) { | |||
| return Container(); | |||
| } else { | |||
| return Container( | |||
| height: 90, | |||
| child: ListView.builder( | |||
| physics: ClampingScrollPhysics(), | |||
| scrollDirection: Axis.horizontal, | |||
| shrinkWrap: true, | |||
| itemCount: value.currentItems?.length, | |||
| itemBuilder: (context, index) { | |||
| return GestureDetector( | |||
| onTap: () { | |||
| print("edit"); | |||
| changeSupplyUsing.changeIndexEdit(index); | |||
| changeButton.updateToEdit(true); | |||
| var editedSupplyUsing = value.currentItems?[index]; | |||
| var editedSupply = Supply() | |||
| ..id = editedSupplyUsing?.tbSuppliesInWarehouseId ?? -1 | |||
| ..tbSuppliesName = editedSupplyUsing?.supplyName ?? '' | |||
| ..unit = editedSupplyUsing?.supplyUnit; | |||
| changeSelectedSupply.change(editedSupply); | |||
| changeUnit.updateListByUnitName(editedSupplyUsing?.supplyUnit ?? ''); | |||
| changeUnit.updateSelected(editedSupplyUsing?.supplyUnit ?? ''); | |||
| _dosageController.text = editedSupplyUsing?.dosage ?? ''; | |||
| _quantityController.text = editedSupplyUsing?.quantity?.formatNumtoStringDecimal() ?? ''; | |||
| }, | |||
| child: Card( | |||
| child: Stack( | |||
| alignment: Alignment.bottomCenter, | |||
| children: <Widget>[ | |||
| Positioned( | |||
| child: ClipRRect( | |||
| borderRadius: BorderRadius.circular(8), | |||
| child: Container( | |||
| padding: EdgeInsets.all(4), | |||
| width: 150, | |||
| child: Column( | |||
| mainAxisAlignment: MainAxisAlignment.center, | |||
| children: [ | |||
| SizedBox( | |||
| height: 12.0, | |||
| return GetBuilder<ChangeSupplyUsing>( | |||
| init: changeSupplyUsing, | |||
| builder: (value) { | |||
| widget.onChangeSupplies(value.currentItems ?? []); | |||
| if ((value.currentItems ?? []).isEmpty) { | |||
| return Container(); | |||
| } else { | |||
| return Container( | |||
| height: 90, | |||
| child: ListView.builder( | |||
| physics: ClampingScrollPhysics(), | |||
| scrollDirection: Axis.horizontal, | |||
| shrinkWrap: true, | |||
| itemCount: value.currentItems?.length, | |||
| itemBuilder: (context, index) { | |||
| return GestureDetector( | |||
| onTap: () { | |||
| print("edit"); | |||
| changeSupplyUsing.changeIndexEdit(index); | |||
| changeButton.updateToEdit(true); | |||
| var editedSupplyUsing = value.currentItems?[index]; | |||
| var editedSupply = Supply() | |||
| ..id = editedSupplyUsing?.tbSuppliesInWarehouseId ?? -1 | |||
| ..tbSuppliesName = editedSupplyUsing?.supplyName ?? '' | |||
| ..unit = editedSupplyUsing?.supplyUnit; | |||
| changeSelectedSupply.change(editedSupply); | |||
| changeUnit.updateListByUnitName(editedSupplyUsing?.supplyUnit ?? ''); | |||
| changeUnit.updateSelected(editedSupplyUsing?.supplyUnit ?? ''); | |||
| _dosageController.text = editedSupplyUsing?.dosage ?? ''; | |||
| _quantityController.text = editedSupplyUsing?.quantity?.formatNumtoStringDecimal() ?? ''; | |||
| }, | |||
| child: Card( | |||
| child: Stack( | |||
| alignment: Alignment.bottomCenter, | |||
| children: <Widget>[ | |||
| Positioned( | |||
| child: ClipRRect( | |||
| borderRadius: BorderRadius.circular(8), | |||
| child: Container( | |||
| padding: EdgeInsets.all(4), | |||
| width: 150, | |||
| child: Column( | |||
| mainAxisAlignment: MainAxisAlignment.center, | |||
| children: [ | |||
| SizedBox( | |||
| height: 12.0, | |||
| ), | |||
| Flexible( | |||
| child: Text( | |||
| value.currentItems?[index].supplyName ?? "", | |||
| overflow: TextOverflow.ellipsis, | |||
| maxLines: 1, | |||
| ), | |||
| ), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].dosage ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].dosage ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? '') | |||
| ? Flexible( | |||
| child: Text( | |||
| "${value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? ""} ${value.currentItems?[index].supplyUnit ?? ""}", | |||
| ), | |||
| ) | |||
| : SizedBox(), | |||
| ], | |||
| ), | |||
| Flexible( | |||
| child: Text( | |||
| value.currentItems?[index].supplyName ?? "", | |||
| overflow: TextOverflow.ellipsis, | |||
| maxLines: 1, | |||
| ), | |||
| ), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].dosage ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].dosage ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? '') | |||
| ? Flexible( | |||
| child: Text( | |||
| "${value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? ""} ${value.currentItems?[index].supplyUnit ?? ""}", | |||
| ), | |||
| ) | |||
| : SizedBox(), | |||
| ], | |||
| ), | |||
| ), | |||
| )), | |||
| Positioned( | |||
| top: -10, | |||
| right: -10, | |||
| child: IconButton( | |||
| icon: Icon( | |||
| Icons.cancel, | |||
| color: Colors.redAccent, | |||
| ), | |||
| onPressed: () { | |||
| changeSupplyUsing.deleteSupply(index); | |||
| }), | |||
| ) | |||
| ], | |||
| ))); | |||
| })); | |||
| } | |||
| }); | |||
| )), | |||
| Positioned( | |||
| top: -10, | |||
| right: -10, | |||
| child: IconButton( | |||
| icon: Icon( | |||
| Icons.cancel, | |||
| color: Colors.redAccent, | |||
| ), | |||
| onPressed: () { | |||
| changeSupplyUsing.deleteSupply(index); | |||
| }), | |||
| ) | |||
| ], | |||
| ))); | |||
| })); | |||
| } | |||
| }); | |||
| } | |||
| Widget _btnSelectSubstrates() { | |||
| return GetBuilder<ChangeSupply>(builder: (data) { | |||
| var isValid = changeSelectedSupply.isValid; | |||
| return TextButton(onPressed: () { | |||
| var currentIndexEdit = changeSupplyUsing.currentIndex; | |||
| Navigator.of(context) | |||
| .push(MaterialPageRoute( | |||
| builder: (_) => ResourceHelperScreen( | |||
| titleName: "Hoá chất xử lý", | |||
| type: ConstCommon.supplyTypeAll, | |||
| selectedId: changeSelectedSupply.selectedSupplyId ?? -1, | |||
| currentItems: changeSupplyUsing.currentItems ?? [], | |||
| currentEditId: ((currentIndexEdit ?? -1) >= 0) | |||
| ? (changeSupplyUsing.currentItems ?? [])[(currentIndexEdit ?? 0)].tbSuppliesInWarehouseId ?? -1 | |||
| : -1, | |||
| ), | |||
| fullscreenDialog: false)) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as Supply; | |||
| changeSelectedSupply.change(result); | |||
| changeUnit.updateListByUnitName(result.unit ?? ''); | |||
| changeFormField.change(true); | |||
| } | |||
| }); | |||
| }, child: GetBuilder<ChangeSupply>(builder: (_) { | |||
| var isValid = changeSelectedSupply.isValid; | |||
| return Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: Border( | |||
| bottom: BorderSide( | |||
| width: 1, | |||
| color: (isValid ?? false) ? Colors.grey : Colors.red, | |||
| ), | |||
| ), | |||
| ), | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Validators.stringNotNullOrEmpty(changeSelectedSupply.selectedSupplyName ?? '') | |||
| ? Text( | |||
| 'Hoá chất xử lý *', | |||
| style: TextStyle( | |||
| fontSize: 13, | |||
| fontWeight: FontWeight.normal, | |||
| color: (isValid ?? false) ? Colors.black54 : Colors.red, | |||
| return GetBuilder<ChangeSupply>( | |||
| init: changeSelectedSupply, | |||
| builder: (data) { | |||
| var isValid = changeSelectedSupply.isValid; | |||
| return TextButton( | |||
| onPressed: () { | |||
| var currentIndexEdit = changeSupplyUsing.currentIndex; | |||
| Navigator.of(context) | |||
| .push(MaterialPageRoute( | |||
| builder: (_) => ResourceHelperScreen( | |||
| titleName: "Hoá chất xử lý", | |||
| type: ConstCommon.supplyTypeAll, | |||
| selectedId: changeSelectedSupply.selectedSupplyId ?? -1, | |||
| currentItems: changeSupplyUsing.currentItems ?? [], | |||
| currentEditId: ((currentIndexEdit ?? -1) >= 0) | |||
| ? (changeSupplyUsing.currentItems ?? [])[(currentIndexEdit ?? 0)].tbSuppliesInWarehouseId ?? -1 | |||
| : -1, | |||
| ), | |||
| ) | |||
| : Text( | |||
| '', | |||
| style: TextStyle( | |||
| fontSize: 13, | |||
| fontWeight: FontWeight.normal, | |||
| color: (isValid ?? false) ? Colors.black54 : Colors.red, | |||
| ), | |||
| ), | |||
| Row( | |||
| fullscreenDialog: false)) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as Supply; | |||
| changeSelectedSupply.change(result); | |||
| changeUnit.updateListByUnitName(result.unit ?? ''); | |||
| changeFormField.change(true); | |||
| } | |||
| }); | |||
| }, | |||
| child: GetBuilder<ChangeSupply>( | |||
| init: changeSelectedSupply, | |||
| builder: (_) { | |||
| var isValid = changeSelectedSupply.isValid; | |||
| return Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Expanded( | |||
| child: Validators.stringNotNullOrEmpty(changeSelectedSupply.selectedSupplyName ?? '') | |||
| ? Text(changeSelectedSupply.selectedSupplyName ?? '', style: TextStyle(fontSize: 14.0, color: Colors.black87)) | |||
| : Text("Hoá chất xử lý *", style: TextStyle(fontSize: 14.0, color: Colors.black54)), | |||
| ), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: Border( | |||
| bottom: BorderSide( | |||
| width: 1, | |||
| color: (isValid ?? false) ? Colors.grey : Colors.red, | |||
| ), | |||
| ), | |||
| ), | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Validators.stringNotNullOrEmpty(changeSelectedSupply.selectedSupplyName ?? '') | |||
| ? Text( | |||
| 'Hoá chất xử lý *', | |||
| style: TextStyle( | |||
| fontSize: 13, | |||
| fontWeight: FontWeight.normal, | |||
| color: (isValid ?? false) ? Colors.black54 : Colors.red, | |||
| ), | |||
| ) | |||
| : Text( | |||
| '', | |||
| style: TextStyle( | |||
| fontSize: 13, | |||
| fontWeight: FontWeight.normal, | |||
| color: (isValid ?? false) ? Colors.black54 : Colors.red, | |||
| ), | |||
| ), | |||
| Row( | |||
| children: [ | |||
| Expanded( | |||
| child: Validators.stringNotNullOrEmpty(changeSelectedSupply.selectedSupplyName ?? '') | |||
| ? Text(changeSelectedSupply.selectedSupplyName ?? '', | |||
| style: TextStyle(fontSize: 14.0, color: Colors.black87)) | |||
| : Text("Hoá chất xử lý *", style: TextStyle(fontSize: 14.0, color: Colors.black54)), | |||
| ), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ) | |||
| ], | |||
| )), | |||
| (isValid ?? false) ? SizedBox() : WidgetErrorTextField() | |||
| ], | |||
| ) | |||
| ], | |||
| )), | |||
| (isValid ?? false) ? SizedBox() : WidgetErrorTextField() | |||
| ], | |||
| ); | |||
| })); | |||
| }); | |||
| ); | |||
| })); | |||
| }); | |||
| } | |||
| Widget _dropdownUnitTypes() { | |||
| return GetBuilder<ChangeUnit>(builder: (data) { | |||
| return DropdownButtonFormField<String>( | |||
| itemHeight: 100, | |||
| value: (data.selectedUnit ?? '').isEmpty ? null : data.selectedUnit, | |||
| items: (data.currentUnits ?? []) | |||
| .map((label) => DropdownMenuItem( | |||
| child: Text(label), | |||
| value: label, | |||
| )) | |||
| .toList(), | |||
| onChanged: (value) { | |||
| var currentQuantity = _quantityController.text; | |||
| num assignValue = currentQuantity.parseDoubleThousand(); | |||
| if (assignValue != null) { | |||
| var oldSelected = data.selectedUnit; | |||
| if (oldSelected == value) { | |||
| } else { | |||
| assignValue = UtilAction.convertUnit( | |||
| inputValue: assignValue, | |||
| oldUnit: oldSelected ?? '', | |||
| newUnit: value ?? '', | |||
| ); | |||
| } | |||
| _quantityController.text = assignValue.formatNumtoStringDecimal(); | |||
| } | |||
| changeUnit.updateSelected(value ?? ''); | |||
| }, | |||
| ); | |||
| }); | |||
| return GetBuilder<ChangeUnit>( | |||
| init: changeUnit, | |||
| builder: (data) { | |||
| return DropdownButtonFormField<String>( | |||
| itemHeight: 100, | |||
| value: (data.selectedUnit ?? '').isEmpty ? null : data.selectedUnit, | |||
| items: (data.currentUnits ?? []) | |||
| .map((label) => DropdownMenuItem( | |||
| child: Text(label), | |||
| value: label, | |||
| )) | |||
| .toList(), | |||
| onChanged: (value) { | |||
| var currentQuantity = _quantityController.text; | |||
| num assignValue = currentQuantity.parseDoubleThousand(); | |||
| if (assignValue != null) { | |||
| var oldSelected = data.selectedUnit; | |||
| if (oldSelected == value) { | |||
| } else { | |||
| assignValue = UtilAction.convertUnit( | |||
| inputValue: assignValue, | |||
| oldUnit: oldSelected ?? '', | |||
| newUnit: value ?? '', | |||
| ); | |||
| } | |||
| _quantityController.text = assignValue.formatNumtoStringDecimal(); | |||
| } | |||
| changeUnit.updateSelected(value ?? ''); | |||
| }, | |||
| ); | |||
| }); | |||
| } | |||
| _quantityField() { | |||
| @@ -268,110 +279,112 @@ class _WidgetPlantSupplyState extends State<WidgetPlantSupply> { | |||
| } | |||
| _buttonInForm() { | |||
| return GetBuilder<ChangeButtonInForm>(builder: (_) { | |||
| return Row( | |||
| mainAxisAlignment: MainAxisAlignment.start, | |||
| children: [ | |||
| _.isEdit ?? false | |||
| ? TextButton( | |||
| child: Text("Huỷ"), | |||
| onPressed: () { | |||
| changeButton.resetValue(); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| }) | |||
| : SizedBox(), | |||
| _.isEdit ?? false | |||
| ? Expanded( | |||
| child: TextButton( | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| if (currentSupply?.id != null) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: _quantityController.text.parseDoubleThousand(), | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.editSupply(changeSupplyUsing.currentIndex ?? -1, newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập hoá chất và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| } | |||
| }, | |||
| child: Text( | |||
| "Sửa hoá chất xử lý", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| : Expanded( | |||
| child: TextButton( | |||
| return GetBuilder<ChangeButtonInForm>( | |||
| init: changeButton, | |||
| builder: (_) { | |||
| return Row( | |||
| mainAxisAlignment: MainAxisAlignment.start, | |||
| children: [ | |||
| _.isEdit ?? false | |||
| ? TextButton( | |||
| child: Text("Huỷ"), | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| if (currentSupply?.id != null) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: _quantityController.text.parseDoubleThousand(), | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.addSupply(newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập hoá chất và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| // | |||
| } | |||
| }, | |||
| child: Text( | |||
| "+ Thêm hoá chất xử lý", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| ], | |||
| ); | |||
| }); | |||
| changeButton.resetValue(); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| }) | |||
| : SizedBox(), | |||
| _.isEdit ?? false | |||
| ? Expanded( | |||
| child: TextButton( | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| if (currentSupply?.id != null) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: _quantityController.text.parseDoubleThousand(), | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.editSupply(changeSupplyUsing.currentIndex ?? -1, newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập hoá chất và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| } | |||
| }, | |||
| child: Text( | |||
| "Sửa hoá chất xử lý", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| : Expanded( | |||
| child: TextButton( | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| if (currentSupply?.id != null) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: _quantityController.text.parseDoubleThousand(), | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.addSupply(newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập hoá chất và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| // | |||
| } | |||
| }, | |||
| child: Text( | |||
| "+ Thêm hoá chất xử lý", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| ], | |||
| ); | |||
| }); | |||
| } | |||
| Widget _formEdit() { | |||
| @@ -55,271 +55,286 @@ class _WidgetSprayingSupplyState extends State<WidgetSprayingSupply> { | |||
| } | |||
| Widget _buildListSupply() { | |||
| return GetBuilder<ChangeSupplyUsing>(builder: (value) { | |||
| widget.onChangeSupplies(value.currentItems ?? []); | |||
| if ((value.currentItems ?? []).isEmpty) { | |||
| return Container(); | |||
| } else { | |||
| return Container( | |||
| height: 120, | |||
| child: ListView.builder( | |||
| physics: ClampingScrollPhysics(), | |||
| scrollDirection: Axis.horizontal, | |||
| shrinkWrap: true, | |||
| itemCount: value.currentItems?.length, | |||
| itemBuilder: (context, index) { | |||
| return GestureDetector( | |||
| onTap: () { | |||
| print("edit"); | |||
| changeSupplyUsing.changeIndexEdit(index); | |||
| changeButton.updateToEdit(true); | |||
| var editedSupplyUsing = value.currentItems?[index]; | |||
| var editedSupply = Supply() | |||
| ..id = editedSupplyUsing?.tbSuppliesInWarehouseId ?? -1 | |||
| ..tbSuppliesName = editedSupplyUsing?.supplyName ?? '' | |||
| ..unit = editedSupplyUsing?.supplyUnit ?? ''; | |||
| changeSelectedSupply.change(editedSupply); | |||
| return GetBuilder<ChangeSupplyUsing>( | |||
| init: changeSupplyUsing, | |||
| builder: (value) { | |||
| widget.onChangeSupplies(value.currentItems ?? []); | |||
| if ((value.currentItems ?? []).isEmpty) { | |||
| return Container(); | |||
| } else { | |||
| return Container( | |||
| height: 120, | |||
| child: ListView.builder( | |||
| physics: ClampingScrollPhysics(), | |||
| scrollDirection: Axis.horizontal, | |||
| shrinkWrap: true, | |||
| itemCount: value.currentItems?.length, | |||
| itemBuilder: (context, index) { | |||
| return GestureDetector( | |||
| onTap: () { | |||
| print("edit"); | |||
| changeSupplyUsing.changeIndexEdit(index); | |||
| changeButton.updateToEdit(true); | |||
| var editedSupplyUsing = value.currentItems?[index]; | |||
| var editedSupply = Supply() | |||
| ..id = editedSupplyUsing?.tbSuppliesInWarehouseId ?? -1 | |||
| ..tbSuppliesName = editedSupplyUsing?.supplyName ?? '' | |||
| ..unit = editedSupplyUsing?.supplyUnit ?? ''; | |||
| changeSelectedSupply.change(editedSupply); | |||
| var editedDevice = Device() | |||
| ..id = editedSupplyUsing?.tbEquipmentOfCustomerId | |||
| ..name = editedSupplyUsing?.equipmentName; | |||
| changeSelectedDevice.change(editedDevice); | |||
| var editedDevice = Device() | |||
| ..id = editedSupplyUsing?.tbEquipmentOfCustomerId | |||
| ..name = editedSupplyUsing?.equipmentName; | |||
| changeSelectedDevice.change(editedDevice); | |||
| changeUnit.updateListByUnitName(editedSupplyUsing?.supplyUnit ?? ''); | |||
| changeUnit.updateSelected(editedSupplyUsing?.supplyUnit ?? ''); | |||
| _dosageController.text = editedSupplyUsing?.dosage ?? ''; | |||
| _howToUseController.text = editedSupplyUsing?.howToUse ?? ''; | |||
| _quantityController.text = editedSupplyUsing?.quantity?.formatNumtoStringDecimal() ?? ''; | |||
| }, | |||
| child: Card( | |||
| child: Stack( | |||
| alignment: Alignment.bottomCenter, | |||
| children: <Widget>[ | |||
| Positioned( | |||
| child: ClipRRect( | |||
| borderRadius: BorderRadius.circular(8), | |||
| child: Container( | |||
| padding: EdgeInsets.all(4), | |||
| width: 150, | |||
| child: Column( | |||
| mainAxisAlignment: MainAxisAlignment.center, | |||
| children: [ | |||
| SizedBox( | |||
| height: 12.0, | |||
| ), | |||
| Flexible( | |||
| child: Text(value.currentItems?[index].supplyName ?? "", overflow: TextOverflow.ellipsis, maxLines: 1), | |||
| changeUnit.updateListByUnitName(editedSupplyUsing?.supplyUnit ?? ''); | |||
| changeUnit.updateSelected(editedSupplyUsing?.supplyUnit ?? ''); | |||
| _dosageController.text = editedSupplyUsing?.dosage ?? ''; | |||
| _howToUseController.text = editedSupplyUsing?.howToUse ?? ''; | |||
| _quantityController.text = editedSupplyUsing?.quantity?.formatNumtoStringDecimal() ?? ''; | |||
| }, | |||
| child: Card( | |||
| child: Stack( | |||
| alignment: Alignment.bottomCenter, | |||
| children: <Widget>[ | |||
| Positioned( | |||
| child: ClipRRect( | |||
| borderRadius: BorderRadius.circular(8), | |||
| child: Container( | |||
| padding: EdgeInsets.all(4), | |||
| width: 150, | |||
| child: Column( | |||
| mainAxisAlignment: MainAxisAlignment.center, | |||
| children: [ | |||
| SizedBox( | |||
| height: 12.0, | |||
| ), | |||
| Flexible( | |||
| child: Text(value.currentItems?[index].supplyName ?? "", overflow: TextOverflow.ellipsis, maxLines: 1), | |||
| ), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].dosage ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].dosage ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty( | |||
| value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? '', | |||
| ) | |||
| ? Flexible( | |||
| child: Text( | |||
| "${value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? ""} ${value.currentItems?[index].supplyUnit ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].equipmentName ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].equipmentName ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].howToUse ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].howToUse ?? ""}")) | |||
| : SizedBox(), | |||
| ], | |||
| ), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].dosage ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].dosage ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty( | |||
| value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? '', | |||
| ) | |||
| ? Flexible( | |||
| child: Text( | |||
| "${value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? ""} ${value.currentItems?[index].supplyUnit ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].equipmentName ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].equipmentName ?? ""}")) | |||
| : SizedBox(), | |||
| Validators.stringNotNullOrEmpty(value.currentItems?[index].howToUse ?? '') | |||
| ? Flexible(child: Text("${value.currentItems?[index].howToUse ?? ""}")) | |||
| : SizedBox(), | |||
| ], | |||
| ), | |||
| ), | |||
| )), | |||
| Positioned( | |||
| top: -10, | |||
| right: -10, | |||
| child: IconButton( | |||
| icon: Icon( | |||
| Icons.cancel, | |||
| color: Colors.redAccent, | |||
| ), | |||
| onPressed: () { | |||
| changeSupplyUsing.deleteSupply(index); | |||
| }), | |||
| ) | |||
| ], | |||
| ))); | |||
| })); | |||
| } | |||
| }); | |||
| )), | |||
| Positioned( | |||
| top: -10, | |||
| right: -10, | |||
| child: IconButton( | |||
| icon: Icon( | |||
| Icons.cancel, | |||
| color: Colors.redAccent, | |||
| ), | |||
| onPressed: () { | |||
| changeSupplyUsing.deleteSupply(index); | |||
| }), | |||
| ) | |||
| ], | |||
| ))); | |||
| })); | |||
| } | |||
| }); | |||
| } | |||
| Widget _btnSelectSubstrates() { | |||
| return GetBuilder<ChangeSupply>(builder: (data) { | |||
| return TextButton(onPressed: () { | |||
| var currentIndexEdit = changeSupplyUsing.currentIndex; | |||
| Navigator.of(context) | |||
| .push(MaterialPageRoute( | |||
| builder: (_) => ResourceHelperScreen( | |||
| titleName: "Thuốc BVTV", | |||
| type: ConstCommon.supplyTypeProtectPlant, | |||
| selectedId: changeSelectedSupply.selectedSupplyId ?? -1, | |||
| currentItems: changeSupplyUsing.currentItems ?? [], | |||
| currentEditId: ((currentIndexEdit ?? -1) >= 0) | |||
| ? (changeSupplyUsing.currentItems ?? [])[(currentIndexEdit ?? 0)].tbSuppliesInWarehouseId ?? -1 | |||
| : -1, | |||
| ), | |||
| fullscreenDialog: false)) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as Supply; | |||
| changeSelectedSupply.change(result); | |||
| changeUnit.updateListByUnitName(result.unit ?? ''); | |||
| changeFormField.change(true); | |||
| } | |||
| }); | |||
| }, child: GetBuilder<ChangeSupply>(builder: (_) { | |||
| var isValid = changeSelectedSupply.isValid; | |||
| return Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: Border( | |||
| bottom: BorderSide( | |||
| width: 1, | |||
| color: (isValid ?? false) ? Colors.grey : Colors.red, | |||
| ), | |||
| ), | |||
| ), | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Validators.stringNotNullOrEmpty(changeSelectedSupply.selectedSupplyName ?? '') | |||
| ? Text( | |||
| 'Tên thương mại *', | |||
| style: | |||
| TextStyle(fontSize: 13, fontWeight: FontWeight.normal, color: (isValid ?? false) ? Colors.black54 : Colors.red[600]), | |||
| ) | |||
| : Text( | |||
| '', | |||
| style: TextStyle( | |||
| fontSize: 13, | |||
| fontWeight: FontWeight.normal, | |||
| color: (isValid ?? false) ? Colors.black54 : Colors.red, | |||
| return GetBuilder<ChangeSupply>( | |||
| init: changeSelectedSupply, | |||
| builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| var currentIndexEdit = changeSupplyUsing.currentIndex; | |||
| Navigator.of(context) | |||
| .push(MaterialPageRoute( | |||
| builder: (_) => ResourceHelperScreen( | |||
| titleName: "Thuốc BVTV", | |||
| type: ConstCommon.supplyTypeProtectPlant, | |||
| selectedId: changeSelectedSupply.selectedSupplyId ?? -1, | |||
| currentItems: changeSupplyUsing.currentItems ?? [], | |||
| currentEditId: ((currentIndexEdit ?? -1) >= 0) | |||
| ? (changeSupplyUsing.currentItems ?? [])[(currentIndexEdit ?? 0)].tbSuppliesInWarehouseId ?? -1 | |||
| : -1, | |||
| ), | |||
| ), | |||
| Row( | |||
| fullscreenDialog: false)) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as Supply; | |||
| changeSelectedSupply.change(result); | |||
| changeUnit.updateListByUnitName(result.unit ?? ''); | |||
| changeFormField.change(true); | |||
| } | |||
| }); | |||
| }, | |||
| child: GetBuilder<ChangeSupply>( | |||
| init: changeSelectedSupply, | |||
| builder: (_) { | |||
| var isValid = changeSelectedSupply.isValid; | |||
| return Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Expanded( | |||
| child: Validators.stringNotNullOrEmpty(changeSelectedSupply.selectedSupplyName ?? '') | |||
| ? Text( | |||
| changeSelectedSupply.selectedSupplyName ?? '', | |||
| style: TextStyle( | |||
| fontSize: 14.0, | |||
| color: Colors.black87, | |||
| ), | |||
| ) | |||
| : Text("Tên thương mại *", style: TextStyle(fontSize: 14.0, color: Colors.black54)), | |||
| ), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: Border( | |||
| bottom: BorderSide( | |||
| width: 1, | |||
| color: (isValid ?? false) ? Colors.grey : Colors.red, | |||
| ), | |||
| ), | |||
| ), | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Validators.stringNotNullOrEmpty(changeSelectedSupply.selectedSupplyName ?? '') | |||
| ? Text( | |||
| 'Tên thương mại *', | |||
| style: TextStyle( | |||
| fontSize: 13, | |||
| fontWeight: FontWeight.normal, | |||
| color: (isValid ?? false) ? Colors.black54 : Colors.red[600]), | |||
| ) | |||
| : Text( | |||
| '', | |||
| style: TextStyle( | |||
| fontSize: 13, | |||
| fontWeight: FontWeight.normal, | |||
| color: (isValid ?? false) ? Colors.black54 : Colors.red, | |||
| ), | |||
| ), | |||
| Row( | |||
| children: [ | |||
| Expanded( | |||
| child: Validators.stringNotNullOrEmpty(changeSelectedSupply.selectedSupplyName ?? '') | |||
| ? Text( | |||
| changeSelectedSupply.selectedSupplyName ?? '', | |||
| style: TextStyle( | |||
| fontSize: 14.0, | |||
| color: Colors.black87, | |||
| ), | |||
| ) | |||
| : Text("Tên thương mại *", style: TextStyle(fontSize: 14.0, color: Colors.black54)), | |||
| ), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ), | |||
| ], | |||
| )), | |||
| (isValid ?? false) ? SizedBox() : WidgetErrorTextField() | |||
| ], | |||
| ), | |||
| ], | |||
| )), | |||
| (isValid ?? false) ? SizedBox() : WidgetErrorTextField() | |||
| ], | |||
| ); | |||
| })); | |||
| }); | |||
| ); | |||
| })); | |||
| }); | |||
| } | |||
| Widget _btnSelectDevice() { | |||
| return GetBuilder<ChangeDevice>(builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| Navigator.of(context) | |||
| .push( | |||
| MaterialPageRoute( | |||
| builder: (_) => ListDeviceActivity( | |||
| selectedId: changeSelectedDevice.selectedDeviceId ?? -1, | |||
| ), | |||
| fullscreenDialog: false, | |||
| ), | |||
| ) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as Device; | |||
| changeSelectedDevice.change(result); | |||
| changeFormField.change(true); | |||
| } | |||
| }); | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| Validators.stringNotNullOrEmpty(changeSelectedDevice.selectedDeviceName ?? '') | |||
| ? Text( | |||
| 'Thiết bị', | |||
| style: TextStyle(fontSize: 13, fontWeight: FontWeight.normal, color: Colors.black45), | |||
| ) | |||
| : Text( | |||
| '', | |||
| style: TextStyle(fontSize: 13, fontWeight: FontWeight.normal, color: Colors.black54), | |||
| ), | |||
| Row( | |||
| return GetBuilder<ChangeDevice>( | |||
| init: changeSelectedDevice, | |||
| builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| Navigator.of(context) | |||
| .push( | |||
| MaterialPageRoute( | |||
| builder: (_) => ListDeviceActivity( | |||
| selectedId: changeSelectedDevice.selectedDeviceId ?? -1, | |||
| ), | |||
| fullscreenDialog: false, | |||
| ), | |||
| ) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as Device; | |||
| changeSelectedDevice.change(result); | |||
| changeFormField.change(true); | |||
| } | |||
| }); | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| children: [ | |||
| GetBuilder<ChangeSupply>( | |||
| builder: (_) => Expanded( | |||
| child: Validators.stringNotNullOrEmpty(changeSelectedDevice.selectedDeviceName ?? '') | |||
| ? Text(changeSelectedDevice.selectedDeviceName ?? '', style: TextStyle(fontSize: 14.0, color: Colors.black87)) | |||
| : Text("Thiết bị", style: TextStyle(fontSize: 14.0, color: Colors.black54)), | |||
| )), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| Validators.stringNotNullOrEmpty(changeSelectedDevice.selectedDeviceName ?? '') | |||
| ? Text( | |||
| 'Thiết bị', | |||
| style: TextStyle(fontSize: 13, fontWeight: FontWeight.normal, color: Colors.black45), | |||
| ) | |||
| : Text( | |||
| '', | |||
| style: TextStyle(fontSize: 13, fontWeight: FontWeight.normal, color: Colors.black54), | |||
| ), | |||
| Row( | |||
| children: [ | |||
| GetBuilder<ChangeSupply>( | |||
| init: changeSelectedSupply, | |||
| builder: (_) => Expanded( | |||
| child: Validators.stringNotNullOrEmpty(changeSelectedDevice.selectedDeviceName ?? '') | |||
| ? Text(changeSelectedDevice.selectedDeviceName ?? '', style: TextStyle(fontSize: 14.0, color: Colors.black87)) | |||
| : Text("Thiết bị", style: TextStyle(fontSize: 14.0, color: Colors.black54)), | |||
| )), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ), | |||
| ], | |||
| ), | |||
| ], | |||
| ))); | |||
| }); | |||
| ))); | |||
| }); | |||
| } | |||
| Widget _dropdownUnitTypes() { | |||
| return GetBuilder<ChangeUnit>(builder: (data) { | |||
| return DropdownButtonFormField<String>( | |||
| itemHeight: 100, | |||
| value: (data.selectedUnit ?? '').isEmpty ? null : data.selectedUnit, | |||
| items: (data.currentUnits ?? []) | |||
| .map((label) => DropdownMenuItem( | |||
| child: Text(label), | |||
| value: label, | |||
| )) | |||
| .toList(), | |||
| onChanged: (value) { | |||
| var currentQuantity = _quantityController.text; | |||
| num assignValue = currentQuantity.parseDoubleThousand(); | |||
| if (assignValue != null) { | |||
| var oldSelected = data.selectedUnit; | |||
| if (oldSelected == value) { | |||
| } else { | |||
| assignValue = UtilAction.convertUnit( | |||
| inputValue: assignValue, | |||
| oldUnit: oldSelected ?? '', | |||
| newUnit: value ?? '', | |||
| ); | |||
| } | |||
| _quantityController.text = assignValue.formatNumtoStringDecimal(); | |||
| } | |||
| changeUnit.updateSelected(value ?? ''); | |||
| }, | |||
| ); | |||
| }); | |||
| return GetBuilder<ChangeUnit>( | |||
| init: changeUnit, | |||
| builder: (data) { | |||
| return DropdownButtonFormField<String>( | |||
| itemHeight: 100, | |||
| value: (data.selectedUnit ?? '').isEmpty ? null : data.selectedUnit, | |||
| items: (data.currentUnits ?? []) | |||
| .map((label) => DropdownMenuItem( | |||
| child: Text(label), | |||
| value: label, | |||
| )) | |||
| .toList(), | |||
| onChanged: (value) { | |||
| var currentQuantity = _quantityController.text; | |||
| num assignValue = currentQuantity.parseDoubleThousand(); | |||
| if (assignValue != null) { | |||
| var oldSelected = data.selectedUnit; | |||
| if (oldSelected == value) { | |||
| } else { | |||
| assignValue = UtilAction.convertUnit( | |||
| inputValue: assignValue, | |||
| oldUnit: oldSelected ?? '', | |||
| newUnit: value ?? '', | |||
| ); | |||
| } | |||
| _quantityController.text = assignValue.formatNumtoStringDecimal(); | |||
| } | |||
| changeUnit.updateSelected(value ?? ''); | |||
| }, | |||
| ); | |||
| }); | |||
| } | |||
| _quantityField() { | |||
| @@ -345,125 +360,127 @@ class _WidgetSprayingSupplyState extends State<WidgetSprayingSupply> { | |||
| } | |||
| _buttonInForm() { | |||
| return GetBuilder<ChangeButtonInForm>(builder: (_) { | |||
| return Row( | |||
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | |||
| children: [ | |||
| _.isEdit ?? false | |||
| ? TextButton( | |||
| child: Text("Huỷ"), | |||
| onPressed: () { | |||
| changeButton.resetValue(); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| }) | |||
| : SizedBox(), | |||
| _.isEdit ?? false | |||
| ? Expanded( | |||
| child: TextButton( | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| var currentDevice = changeSelectedDevice.currentDevice; | |||
| var currentQuantity = _quantityController.text.parseDoubleThousand(); | |||
| if (currentSupply?.id != null && (currentQuantity ?? 0) > 0) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: currentQuantity, | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..howToUse = _howToUseController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..tbEquipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentName = currentDevice?.name ?? '' | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.editSupply(changeSupplyUsing.currentIndex ?? -1, newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } else if (currentSupply?.id == null || ((currentQuantity ?? 0) <= 0)) { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| } | |||
| }, | |||
| child: Text( | |||
| "Sửa thuốc BVTV", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| : Expanded( | |||
| child: TextButton( | |||
| return GetBuilder<ChangeButtonInForm>( | |||
| init: changeButton, | |||
| builder: (_) { | |||
| return Row( | |||
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | |||
| children: [ | |||
| _.isEdit ?? false | |||
| ? TextButton( | |||
| child: Text("Huỷ"), | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| var currentDevice = changeSelectedDevice.currentDevice; | |||
| var currentQuantity = _quantityController.text.parseDoubleThousand(); | |||
| if (currentSupply?.id != null && (currentQuantity ?? 0) > 0) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: currentQuantity, | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..howToUse = _howToUseController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..tbEquipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentName = currentDevice?.name ?? '' | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.addSupply(newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } else if (currentSupply?.id == null || ((currentQuantity ?? 0) <= 0)) { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| } | |||
| }, | |||
| child: Text( | |||
| "+ Thêm thuốc BVTV", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| ], | |||
| ); | |||
| }); | |||
| changeButton.resetValue(); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| }) | |||
| : SizedBox(), | |||
| _.isEdit ?? false | |||
| ? Expanded( | |||
| child: TextButton( | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| var currentDevice = changeSelectedDevice.currentDevice; | |||
| var currentQuantity = _quantityController.text.parseDoubleThousand(); | |||
| if (currentSupply?.id != null && (currentQuantity ?? 0) > 0) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: currentQuantity, | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..howToUse = _howToUseController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..tbEquipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentName = currentDevice?.name ?? '' | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.editSupply(changeSupplyUsing.currentIndex ?? -1, newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } else if (currentSupply?.id == null || ((currentQuantity ?? 0) <= 0)) { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| } | |||
| }, | |||
| child: Text( | |||
| "Sửa thuốc BVTV", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| : Expanded( | |||
| child: TextButton( | |||
| onPressed: () { | |||
| if (_formSupplyKey.currentState!.validate()) { | |||
| _formSupplyKey.currentState!.save(); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| var currentSupply = changeSelectedSupply.currentSupply; | |||
| var currentDevice = changeSelectedDevice.currentDevice; | |||
| var currentQuantity = _quantityController.text.parseDoubleThousand(); | |||
| if (currentSupply?.id != null && (currentQuantity ?? 0) > 0) { | |||
| var quantityWithCurrentSupplyUnit = UtilAction.convertUnit( | |||
| inputValue: currentQuantity, | |||
| oldUnit: changeUnit.selectedUnit ?? '', | |||
| newUnit: changeSelectedSupply.currentSupply?.unit ?? '', | |||
| ); | |||
| SuppliesUsing newSup = SuppliesUsing() | |||
| ..dosage = _dosageController.text | |||
| ..howToUse = _howToUseController.text | |||
| ..quantity = quantityWithCurrentSupplyUnit | |||
| ..tbSuppliesInWarehouseId = currentSupply?.id | |||
| ..suppliesInWarehouseId = currentSupply?.id | |||
| ..supplyName = currentSupply?.tbSuppliesName | |||
| ..supplyUnit = currentSupply?.unit | |||
| ..tbEquipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentOfCustomerId = currentDevice?.id ?? -1 | |||
| ..equipmentName = currentDevice?.name ?? '' | |||
| ..unit = currentSupply?.unit; | |||
| changeSupplyUsing.addSupply(newSup); | |||
| _resetForm(); | |||
| _hidenKeyboard(context); | |||
| } else if (currentSupply?.id == null || ((currentQuantity ?? 0) <= 0)) { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| } | |||
| } else { | |||
| Utils.showSnackBarWarning(message: "Vui lòng nhập vật tư và số lượng"); | |||
| if ((changeSelectedSupply.selectedSupplyId ?? -1) <= 0) { | |||
| changeSelectedSupply.changeValid(false); | |||
| } else { | |||
| changeSelectedSupply.changeValid(true); | |||
| } | |||
| } | |||
| }, | |||
| child: Text( | |||
| "+ Thêm thuốc BVTV", | |||
| style: TextStyle(color: Colors.blue), | |||
| )), | |||
| ) | |||
| ], | |||
| ); | |||
| }); | |||
| } | |||
| Widget _formEdit() { | |||
| @@ -177,6 +177,7 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> with Auto | |||
| height: 16, | |||
| ), | |||
| GetBuilder<DescriptionChangeControler>( | |||
| init: controller, | |||
| builder: (_) { | |||
| return ButtonWidget( | |||
| title: 'CẬP NHẬT', | |||
| @@ -55,37 +55,39 @@ class _HomeTabbarWidgetState extends State<HomeTabbarWidget> with TickerProvider | |||
| preferredSize: Size.fromHeight(40), | |||
| child: Align( | |||
| alignment: Alignment.centerLeft, | |||
| child: GetBuilder<HomeTabbarSelected>(builder: (selectedTab) { | |||
| return TabBar( | |||
| controller: tabbarController, | |||
| isScrollable: false, | |||
| indicatorColor: AppColors.DEFAULT, | |||
| onTap: (index) { | |||
| homeTabSelected.changeTab(index); | |||
| }, | |||
| tabs: [ | |||
| Container( | |||
| padding: EdgeInsets.only(top: 8, bottom: 8), | |||
| child: Text( | |||
| 'Chỉ số', | |||
| style: TextStyle(color: selectedTab.index == 0 ? AppColors.DEFAULT : Colors.black, fontSize: 12), | |||
| ), | |||
| ), | |||
| Container( | |||
| padding: EdgeInsets.only(top: 8, bottom: 8), | |||
| child: Text('Thông tin', style: TextStyle(color: selectedTab.index == 1 ? AppColors.DEFAULT : Colors.black, fontSize: 12)), | |||
| ), | |||
| Container( | |||
| padding: EdgeInsets.only(top: 8, bottom: 8), | |||
| child: Text('Canh tác', style: TextStyle(color: selectedTab.index == 2 ? AppColors.DEFAULT : Colors.black, fontSize: 12)), | |||
| ), | |||
| Container( | |||
| padding: EdgeInsets.only(top: 8, bottom: 8), | |||
| child: Text('Lịch sử', style: TextStyle(color: selectedTab.index == 3 ? AppColors.DEFAULT : Colors.black, fontSize: 12)), | |||
| ) | |||
| ], | |||
| ); | |||
| }), | |||
| child: GetBuilder<HomeTabbarSelected>( | |||
| init: homeTabSelected, | |||
| builder: (selectedTab) { | |||
| return TabBar( | |||
| controller: tabbarController, | |||
| isScrollable: false, | |||
| indicatorColor: AppColors.DEFAULT, | |||
| onTap: (index) { | |||
| homeTabSelected.changeTab(index); | |||
| }, | |||
| tabs: [ | |||
| Container( | |||
| padding: EdgeInsets.only(top: 8, bottom: 8), | |||
| child: Text( | |||
| 'Chỉ số', | |||
| style: TextStyle(color: selectedTab.index == 0 ? AppColors.DEFAULT : Colors.black, fontSize: 12), | |||
| ), | |||
| ), | |||
| Container( | |||
| padding: EdgeInsets.only(top: 8, bottom: 8), | |||
| child: Text('Thông tin', style: TextStyle(color: selectedTab.index == 1 ? AppColors.DEFAULT : Colors.black, fontSize: 12)), | |||
| ), | |||
| Container( | |||
| padding: EdgeInsets.only(top: 8, bottom: 8), | |||
| child: Text('Canh tác', style: TextStyle(color: selectedTab.index == 2 ? AppColors.DEFAULT : Colors.black, fontSize: 12)), | |||
| ), | |||
| Container( | |||
| padding: EdgeInsets.only(top: 8, bottom: 8), | |||
| child: Text('Lịch sử', style: TextStyle(color: selectedTab.index == 3 ? AppColors.DEFAULT : Colors.black, fontSize: 12)), | |||
| ) | |||
| ], | |||
| ); | |||
| }), | |||
| ), | |||
| ), | |||
| body: TabBarView( | |||
| @@ -123,220 +123,232 @@ class _UpdateProfileScreenState extends State<UpdateProfileScreen> { | |||
| } | |||
| Widget _btnSelectCountry() { | |||
| return GetBuilder<CheckChangeAnotherDropdown>(builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| if (Get.isSnackbarOpen) { | |||
| Get.back(); | |||
| } | |||
| Navigator.of(context) | |||
| .push(MaterialPageRoute( | |||
| builder: (_) => LocationScreen( | |||
| titleName: "Quốc gia", | |||
| type: LocationType.country, | |||
| filterId: -1, | |||
| selectedId: checkChangeLocation.currentCountry?.id ?? -1, | |||
| ), | |||
| fullscreenDialog: false)) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as LocationUnit; | |||
| checkChangeLocation.changeCountry(result); | |||
| } | |||
| }); | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| child: Row( | |||
| children: [ | |||
| GetBuilder<ChangeSupply>( | |||
| builder: (_) => Expanded( | |||
| child: Text( | |||
| checkChangeLocation.currentCountry?.name ?? "Quốc gia", | |||
| style: TextStyle( | |||
| fontSize: 14.0, | |||
| color: Colors.black87, | |||
| return GetBuilder<CheckChangeAnotherDropdown>( | |||
| init: checkChangeLocation, | |||
| builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| if (Get.isSnackbarOpen) { | |||
| Get.back(); | |||
| } | |||
| Navigator.of(context) | |||
| .push(MaterialPageRoute( | |||
| builder: (_) => LocationScreen( | |||
| titleName: "Quốc gia", | |||
| type: LocationType.country, | |||
| filterId: -1, | |||
| selectedId: checkChangeLocation.currentCountry?.id ?? -1, | |||
| ), | |||
| fullscreenDialog: false)) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as LocationUnit; | |||
| checkChangeLocation.changeCountry(result); | |||
| } | |||
| }); | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| child: Row( | |||
| children: [ | |||
| GetBuilder<ChangeSupply>( | |||
| init: ChangeSupply(), | |||
| builder: (_) => Expanded( | |||
| child: Text( | |||
| checkChangeLocation.currentCountry?.name ?? "Quốc gia", | |||
| style: TextStyle( | |||
| fontSize: 14.0, | |||
| color: Colors.black87, | |||
| ), | |||
| ), | |||
| ), | |||
| ), | |||
| ), | |||
| ), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ))); | |||
| }); | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ))); | |||
| }); | |||
| } | |||
| Widget _btnSelectProvince() { | |||
| return GetBuilder<CheckChangeAnotherDropdown>(builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| if (Get.isSnackbarOpen) { | |||
| Get.back(); | |||
| } | |||
| if (checkChangeLocation.currentCountry?.id != null) { | |||
| Navigator.of(context) | |||
| .push( | |||
| MaterialPageRoute( | |||
| builder: (_) => LocationScreen( | |||
| titleName: "Tỉnh/Thành phố", | |||
| type: LocationType.province, | |||
| filterId: checkChangeLocation.currentCountry?.id ?? -1, | |||
| selectedId: checkChangeLocation.currentProvince?.id ?? -1, | |||
| ), | |||
| fullscreenDialog: false, | |||
| ), | |||
| ) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as LocationUnit; | |||
| checkChangeLocation.changeProvince(result); | |||
| return GetBuilder<CheckChangeAnotherDropdown>( | |||
| init: CheckChangeAnotherDropdown(), | |||
| builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| if (Get.isSnackbarOpen) { | |||
| Get.back(); | |||
| } | |||
| }); | |||
| } else { | |||
| Utils.showSnackBarWarning(message: label_country_empty); | |||
| } | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| child: Row( | |||
| children: [ | |||
| GetBuilder<ChangeSupply>( | |||
| builder: (_) => Expanded( | |||
| child: Text( | |||
| checkChangeLocation.currentProvince?.name ?? "Tỉnh/Thành Phố", | |||
| style: TextStyle( | |||
| fontSize: 14.0, | |||
| color: Colors.black87, | |||
| ), | |||
| if (checkChangeLocation.currentCountry?.id != null) { | |||
| Navigator.of(context) | |||
| .push( | |||
| MaterialPageRoute( | |||
| builder: (_) => LocationScreen( | |||
| titleName: "Tỉnh/Thành phố", | |||
| type: LocationType.province, | |||
| filterId: checkChangeLocation.currentCountry?.id ?? -1, | |||
| selectedId: checkChangeLocation.currentProvince?.id ?? -1, | |||
| ), | |||
| fullscreenDialog: false, | |||
| ), | |||
| ) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as LocationUnit; | |||
| checkChangeLocation.changeProvince(result); | |||
| } | |||
| }); | |||
| } else { | |||
| Utils.showSnackBarWarning(message: label_country_empty); | |||
| } | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ))); | |||
| }); | |||
| child: Row( | |||
| children: [ | |||
| GetBuilder<ChangeSupply>( | |||
| init: ChangeSupply(), | |||
| builder: (_) => Expanded( | |||
| child: Text( | |||
| checkChangeLocation.currentProvince?.name ?? "Tỉnh/Thành Phố", | |||
| style: TextStyle( | |||
| fontSize: 14.0, | |||
| color: Colors.black87, | |||
| ), | |||
| ), | |||
| ), | |||
| ), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ))); | |||
| }); | |||
| } | |||
| Widget _btnSelectDistrict() { | |||
| return GetBuilder<CheckChangeAnotherDropdown>(builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| if (Get.isSnackbarOpen) Get.back(); | |||
| if (checkChangeLocation.currentProvince?.id != null) { | |||
| Navigator.of(context) | |||
| .push( | |||
| MaterialPageRoute( | |||
| builder: (_) => LocationScreen( | |||
| titleName: "Quận/Huyện", | |||
| type: LocationType.district, | |||
| filterId: checkChangeLocation.currentProvince?.id ?? -1, | |||
| selectedId: checkChangeLocation.currentDistrict?.id ?? -1, | |||
| ), | |||
| fullscreenDialog: false, | |||
| ), | |||
| ) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as LocationUnit; | |||
| checkChangeLocation.changeDistrict(result); | |||
| } | |||
| }); | |||
| } else { | |||
| Utils.showSnackBarWarning(message: label_province_empty); | |||
| } | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| child: Row( | |||
| children: [ | |||
| GetBuilder<ChangeSupply>( | |||
| builder: (_) => Expanded( | |||
| child: Text( | |||
| checkChangeLocation.currentDistrict?.name ?? "Quận/Huyện", | |||
| style: TextStyle( | |||
| fontSize: 14.0, | |||
| color: Colors.black87, | |||
| ), | |||
| return GetBuilder<CheckChangeAnotherDropdown>( | |||
| init: CheckChangeAnotherDropdown(), | |||
| builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| if (Get.isSnackbarOpen) Get.back(); | |||
| if (checkChangeLocation.currentProvince?.id != null) { | |||
| Navigator.of(context) | |||
| .push( | |||
| MaterialPageRoute( | |||
| builder: (_) => LocationScreen( | |||
| titleName: "Quận/Huyện", | |||
| type: LocationType.district, | |||
| filterId: checkChangeLocation.currentProvince?.id ?? -1, | |||
| selectedId: checkChangeLocation.currentDistrict?.id ?? -1, | |||
| ), | |||
| fullscreenDialog: false, | |||
| ), | |||
| ) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as LocationUnit; | |||
| checkChangeLocation.changeDistrict(result); | |||
| } | |||
| }); | |||
| } else { | |||
| Utils.showSnackBarWarning(message: label_province_empty); | |||
| } | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ))); | |||
| }); | |||
| child: Row( | |||
| children: [ | |||
| GetBuilder<ChangeSupply>( | |||
| init: ChangeSupply(), | |||
| builder: (_) => Expanded( | |||
| child: Text( | |||
| checkChangeLocation.currentDistrict?.name ?? "Quận/Huyện", | |||
| style: TextStyle( | |||
| fontSize: 14.0, | |||
| color: Colors.black87, | |||
| ), | |||
| ), | |||
| ), | |||
| ), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ))); | |||
| }); | |||
| } | |||
| Widget _btnSelectWard() { | |||
| return GetBuilder<CheckChangeAnotherDropdown>(builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| if (Get.isSnackbarOpen) Get.back(); | |||
| if (checkChangeLocation.currentDistrict?.id != null) { | |||
| Navigator.of(context) | |||
| .push( | |||
| MaterialPageRoute( | |||
| builder: (_) => LocationScreen( | |||
| titleName: "Phường/Xã", | |||
| type: LocationType.ward, | |||
| filterId: checkChangeLocation.currentDistrict?.id ?? -1, | |||
| selectedId: checkChangeLocation.currentWard?.id ?? -1, | |||
| ), | |||
| fullscreenDialog: false, | |||
| ), | |||
| ) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as LocationUnit; | |||
| checkChangeLocation.changeWard(result); | |||
| } | |||
| }); | |||
| } else { | |||
| Utils.showSnackBarWarning(message: label_district_empty); | |||
| } | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| child: Row( | |||
| children: [ | |||
| GetBuilder<ChangeSupply>( | |||
| builder: (_) => Expanded( | |||
| child: Text( | |||
| checkChangeLocation.currentWard?.name ?? "Phường/Xã", | |||
| style: TextStyle( | |||
| fontSize: 14.0, | |||
| color: Colors.black87, | |||
| ), | |||
| return GetBuilder<CheckChangeAnotherDropdown>( | |||
| init: CheckChangeAnotherDropdown(), | |||
| builder: (data) { | |||
| return TextButton( | |||
| onPressed: () { | |||
| if (Get.isSnackbarOpen) Get.back(); | |||
| if (checkChangeLocation.currentDistrict?.id != null) { | |||
| Navigator.of(context) | |||
| .push( | |||
| MaterialPageRoute( | |||
| builder: (_) => LocationScreen( | |||
| titleName: "Phường/Xã", | |||
| type: LocationType.ward, | |||
| filterId: checkChangeLocation.currentDistrict?.id ?? -1, | |||
| selectedId: checkChangeLocation.currentWard?.id ?? -1, | |||
| ), | |||
| fullscreenDialog: false, | |||
| ), | |||
| ) | |||
| .then((value) { | |||
| if (value != null) { | |||
| var result = value as LocationUnit; | |||
| checkChangeLocation.changeWard(result); | |||
| } | |||
| }); | |||
| } else { | |||
| Utils.showSnackBarWarning(message: label_district_empty); | |||
| } | |||
| }, | |||
| child: Container( | |||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0), | |||
| decoration: BoxDecoration( | |||
| border: kBorderTextField, | |||
| ), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ))); | |||
| }); | |||
| child: Row( | |||
| children: [ | |||
| GetBuilder<ChangeSupply>( | |||
| init: ChangeSupply(), | |||
| builder: (_) => Expanded( | |||
| child: Text( | |||
| checkChangeLocation.currentWard?.name ?? "Phường/Xã", | |||
| style: TextStyle( | |||
| fontSize: 14.0, | |||
| color: Colors.black87, | |||
| ), | |||
| ), | |||
| ), | |||
| ), | |||
| Icon( | |||
| Icons.arrow_drop_down, | |||
| color: Colors.grey, | |||
| ), | |||
| ], | |||
| ))); | |||
| }); | |||
| } | |||
| Widget _addressField() { | |||
| @@ -202,100 +202,104 @@ class _TabbarScreenState extends State<TabbarScreen> { | |||
| top: false, | |||
| bottom: true, | |||
| child: Scaffold( | |||
| body: GetBuilder<TabbarSelected>(builder: (tabbarSelected) { | |||
| switch (tabbarSelected.index) { | |||
| case TabBarIndex.plot: | |||
| return PlotListScreen(); | |||
| break; | |||
| case TabBarIndex.device: | |||
| return ControlDeviceScreen(); | |||
| break; | |||
| // case TabBarIndex.qrManage: | |||
| // return CodePage(); | |||
| // break; | |||
| case TabBarIndex.qr: | |||
| return Container(); | |||
| break; | |||
| case TabBarIndex.notification: | |||
| return NotificationScreen(); | |||
| break; | |||
| case TabBarIndex.account: | |||
| return AccountScreen(); | |||
| break; | |||
| default: | |||
| return PlotListScreen(); | |||
| } | |||
| }), | |||
| body: GetBuilder<TabbarSelected>( | |||
| init: changeTabbar, | |||
| builder: (tabbarSelected) { | |||
| switch (tabbarSelected.index) { | |||
| case TabBarIndex.plot: | |||
| return PlotListScreen(); | |||
| break; | |||
| case TabBarIndex.device: | |||
| return ControlDeviceScreen(); | |||
| break; | |||
| // case TabBarIndex.qrManage: | |||
| // return CodePage(); | |||
| // break; | |||
| case TabBarIndex.qr: | |||
| return Container(); | |||
| break; | |||
| case TabBarIndex.notification: | |||
| return NotificationScreen(); | |||
| break; | |||
| case TabBarIndex.account: | |||
| return AccountScreen(); | |||
| break; | |||
| default: | |||
| return PlotListScreen(); | |||
| } | |||
| }), | |||
| bottomNavigationBar: Container( | |||
| padding: EdgeInsets.all(4), | |||
| height: 70, | |||
| decoration: BoxDecoration(color: Colors.white, border: Border(top: BorderSide(color: Colors.grey, width: 0.35))), | |||
| child: GetBuilder<TabbarSelected>(builder: (tabbarSelected) { | |||
| return Center( | |||
| child: ListView.builder( | |||
| scrollDirection: Axis.horizontal, | |||
| shrinkWrap: true, | |||
| physics: NeverScrollableScrollPhysics(), | |||
| itemCount: itemsTabbar.length, | |||
| itemBuilder: (context, index) { | |||
| return GestureDetector( | |||
| child: Container( | |||
| width: (Get.width - 20) / 5, | |||
| margin: EdgeInsets.all(1), | |||
| padding: EdgeInsets.all(10), | |||
| child: Column( | |||
| mainAxisAlignment: MainAxisAlignment.center, | |||
| children: [ | |||
| index == 3 | |||
| ? Badge( | |||
| // badgeContent: textCountNoti(), | |||
| // shape: BadgeShape.circle, | |||
| // badgeColor: Colors.red, | |||
| // position: BadgePosition(top: -15, start: 10), | |||
| child: SvgPicture.asset( | |||
| itemsTabbar[index].icon, | |||
| width: 24, | |||
| height: 24, | |||
| color: (tabbarSelected.index == itemsTabbar[index].index) ? AppColors.YELLOW : AppColors.GRAY1, | |||
| ), | |||
| ) | |||
| : SvgPicture.asset( | |||
| itemsTabbar[index].icon, | |||
| width: 24, | |||
| height: 24, | |||
| color: (tabbarSelected.index == itemsTabbar[index].index) ? AppColors.YELLOW : AppColors.GRAY1, | |||
| child: GetBuilder<TabbarSelected>( | |||
| init: changeTabbar, | |||
| builder: (tabbarSelected) { | |||
| return Center( | |||
| child: ListView.builder( | |||
| scrollDirection: Axis.horizontal, | |||
| shrinkWrap: true, | |||
| physics: NeverScrollableScrollPhysics(), | |||
| itemCount: itemsTabbar.length, | |||
| itemBuilder: (context, index) { | |||
| return GestureDetector( | |||
| child: Container( | |||
| width: (Get.width - 20) / 5, | |||
| margin: EdgeInsets.all(1), | |||
| padding: EdgeInsets.all(10), | |||
| child: Column( | |||
| mainAxisAlignment: MainAxisAlignment.center, | |||
| children: [ | |||
| index == 3 | |||
| ? Badge( | |||
| // badgeContent: textCountNoti(), | |||
| // shape: BadgeShape.circle, | |||
| // badgeColor: Colors.red, | |||
| // position: BadgePosition(top: -15, start: 10), | |||
| child: SvgPicture.asset( | |||
| itemsTabbar[index].icon, | |||
| width: 24, | |||
| height: 24, | |||
| color: (tabbarSelected.index == itemsTabbar[index].index) ? AppColors.YELLOW : AppColors.GRAY1, | |||
| ), | |||
| ) | |||
| : SvgPicture.asset( | |||
| itemsTabbar[index].icon, | |||
| width: 24, | |||
| height: 24, | |||
| color: (tabbarSelected.index == itemsTabbar[index].index) ? AppColors.YELLOW : AppColors.GRAY1, | |||
| ), | |||
| Flexible( | |||
| child: Text( | |||
| itemsTabbar[index].title, | |||
| style: TextStyle( | |||
| color: (tabbarSelected.index == itemsTabbar[index].index) ? AppColors.DEFAULT : Colors.grey, | |||
| fontSize: 9), | |||
| ), | |||
| Flexible( | |||
| child: Text( | |||
| itemsTabbar[index].title, | |||
| style: TextStyle( | |||
| color: (tabbarSelected.index == itemsTabbar[index].index) ? AppColors.DEFAULT : Colors.grey, | |||
| fontSize: 9), | |||
| ), | |||
| ) | |||
| ], | |||
| )), | |||
| onTap: () { | |||
| //Open scan qr code when tap icon in tabbar | |||
| if (index == 2) { | |||
| changeTabbar.changeIndex(changeTabbar.index ?? TabBarIndex.plot); | |||
| // scan(context); | |||
| Get.to( | |||
| QrCodeScannerScreen(), | |||
| )?.then((value) { | |||
| if (value != null) { | |||
| _showAlertCheckCropCode(value); | |||
| ) | |||
| ], | |||
| )), | |||
| onTap: () { | |||
| //Open scan qr code when tap icon in tabbar | |||
| if (index == 2) { | |||
| changeTabbar.changeIndex(changeTabbar.index ?? TabBarIndex.plot); | |||
| // scan(context); | |||
| Get.to( | |||
| QrCodeScannerScreen(), | |||
| )?.then((value) { | |||
| if (value != null) { | |||
| _showAlertCheckCropCode(value); | |||
| } | |||
| }); | |||
| } else { | |||
| changeTabbar.changeIndex(itemsTabbar[index].index); | |||
| } | |||
| }); | |||
| } else { | |||
| changeTabbar.changeIndex(itemsTabbar[index].index); | |||
| } | |||
| // changeTabbar.changeIndex(itemsTabbar[index].index); | |||
| }, | |||
| ); | |||
| }), | |||
| ); | |||
| })), | |||
| // changeTabbar.changeIndex(itemsTabbar[index].index); | |||
| }, | |||
| ); | |||
| }), | |||
| ); | |||
| })), | |||
| ))); | |||
| } | |||