| import 'package:farm_tpf/utils/const_string.dart'; | |||||
| import 'package:flutter/material.dart'; | |||||
| class WidgetErrorTextField extends StatelessWidget { | |||||
| @override | |||||
| Widget build(BuildContext context) { | |||||
| return Text( | |||||
| label_validate_input_empty, | |||||
| style: TextStyle( | |||||
| fontSize: 11, color: Colors.red[400], fontWeight: FontWeight.w100), | |||||
| ); | |||||
| } | |||||
| } |
| ], | ], | ||||
| decoration: InputDecoration( | decoration: InputDecoration( | ||||
| labelText: hintValue, | labelText: hintValue, | ||||
| errorStyle: TextStyle(height: 0), | |||||
| ), | ), | ||||
| validator: validator ?? | validator: validator ?? | ||||
| (String value) { | (String value) { |
| import 'package:farm_tpf/presentation/screens/actions/state_management_helper/change_file_controller.dart'; | import 'package:farm_tpf/presentation/screens/actions/state_management_helper/change_file_controller.dart'; | ||||
| import 'package:farm_tpf/utils/const_common.dart'; | import 'package:farm_tpf/utils/const_common.dart'; | ||||
| import 'package:farm_tpf/utils/const_string.dart'; | import 'package:farm_tpf/utils/const_string.dart'; | ||||
| import 'package:farm_tpf/utils/const_style.dart'; | |||||
| import 'package:farm_tpf/utils/pref.dart'; | import 'package:farm_tpf/utils/pref.dart'; | ||||
| import 'package:farm_tpf/utils/validators.dart'; | import 'package:farm_tpf/utils/validators.dart'; | ||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
| import 'package:flutter_bloc/flutter_bloc.dart'; | import 'package:flutter_bloc/flutter_bloc.dart'; | ||||
| import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; | |||||
| import 'package:get/get.dart'; | import 'package:get/get.dart'; | ||||
| import 'package:intl/intl.dart'; | |||||
| import 'package:keyboard_dismisser/keyboard_dismisser.dart'; | import 'package:keyboard_dismisser/keyboard_dismisser.dart'; | ||||
| import 'package:pattern_formatter/pattern_formatter.dart'; | |||||
| import 'package:farm_tpf/utils/formatter.dart'; | import 'package:farm_tpf/utils/formatter.dart'; | ||||
| import '../util_action.dart'; | import '../util_action.dart'; | ||||
| } | } | ||||
| } else { | } else { | ||||
| _autoValidate = true; | _autoValidate = true; | ||||
| Utils.showSnackBarWarning(message: label_validate_input_required); | |||||
| } | } | ||||
| } | } | ||||
| decoration: InputDecoration(labelText: "Loại dịch hại *"), | decoration: InputDecoration(labelText: "Loại dịch hại *"), | ||||
| controller: _typesOfPestController, | controller: _typesOfPestController, | ||||
| validator: (String value) { | validator: (String value) { | ||||
| return Validators.validateNotNullOrEmpty(value, "Loại dịch hại"); | |||||
| return Validators.validateNotNullOrEmpty( | |||||
| value, label_validate_input_empty); | |||||
| }, | }, | ||||
| onSaved: (newValue) { | onSaved: (newValue) { | ||||
| _disease.typesOfPest = newValue; | _disease.typesOfPest = newValue; |
| import 'package:farm_tpf/custom_model/Device.dart'; | import 'package:farm_tpf/custom_model/Device.dart'; | ||||
| import 'package:farm_tpf/custom_model/SuppliesUsing.dart'; | import 'package:farm_tpf/custom_model/SuppliesUsing.dart'; | ||||
| import 'package:farm_tpf/custom_model/Supply.dart'; | import 'package:farm_tpf/custom_model/Supply.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/WidgetErrorTextField.dart'; | |||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_text_form_field.dart'; | import 'package:farm_tpf/presentation/custom_widgets/widget_text_form_field.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/actions/controller/ChangeDevice.dart'; | import 'package:farm_tpf/presentation/screens/actions/controller/ChangeDevice.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/actions/resource_device_activity/sc_device_activity.dart'; | import 'package:farm_tpf/presentation/screens/actions/resource_device_activity/sc_device_activity.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/actions/state_management_helper/change_supply.dart'; | import 'package:farm_tpf/presentation/screens/actions/state_management_helper/change_supply.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/resources/sc_resource_helper.dart'; | import 'package:farm_tpf/presentation/screens/resources/sc_resource_helper.dart'; | ||||
| import 'package:farm_tpf/utils/const_color.dart'; | |||||
| import 'package:farm_tpf/utils/const_common.dart'; | import 'package:farm_tpf/utils/const_common.dart'; | ||||
| import 'package:farm_tpf/utils/const_string.dart'; | |||||
| import 'package:farm_tpf/utils/const_style.dart'; | import 'package:farm_tpf/utils/const_style.dart'; | ||||
| import 'package:farm_tpf/utils/validators.dart'; | import 'package:farm_tpf/utils/validators.dart'; | ||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
| }, | }, | ||||
| child: GetBuilder<ChangeSupply>(builder: (_) { | child: GetBuilder<ChangeSupply>(builder: (_) { | ||||
| var isValid = changeSelectedSupply.isValid; | var isValid = changeSelectedSupply.isValid; | ||||
| return 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 ? Colors.grey : Colors.red[900])), | |||||
| ), | |||||
| child: Column( | |||||
| crossAxisAlignment: CrossAxisAlignment.start, | |||||
| children: [ | |||||
| Text( | |||||
| 'Tên thương mại *', | |||||
| style: TextStyle( | |||||
| fontSize: 13, | |||||
| fontWeight: FontWeight.normal, | |||||
| color: isValid ? Colors.black54 : Colors.red[600]), | |||||
| 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 ? Colors.grey : Colors.red[900])), | |||||
| ), | ), | ||||
| Row( | |||||
| child: Column( | |||||
| crossAxisAlignment: CrossAxisAlignment.start, | |||||
| children: [ | children: [ | ||||
| Expanded( | |||||
| child: Text( | |||||
| changeSelectedSupply.selectedSupplyName ?? | |||||
| "Tên thương mại", | |||||
| style: TextStyle( | |||||
| fontSize: 14.0, color: Colors.black87))), | |||||
| Icon( | |||||
| Icons.arrow_drop_down, | |||||
| color: Colors.grey, | |||||
| Text( | |||||
| 'Tên thương mại *', | |||||
| style: TextStyle( | |||||
| fontSize: 13, | |||||
| fontWeight: FontWeight.normal, | |||||
| color: | |||||
| isValid ? Colors.black54 : Colors.red[600]), | |||||
| ), | ), | ||||
| Row( | |||||
| children: [ | |||||
| Expanded( | |||||
| child: Text( | |||||
| changeSelectedSupply.selectedSupplyName ?? | |||||
| "Tên thương mại", | |||||
| style: TextStyle( | |||||
| fontSize: 14.0, | |||||
| color: Colors.black87))), | |||||
| Icon( | |||||
| Icons.arrow_drop_down, | |||||
| color: Colors.grey, | |||||
| ), | |||||
| ], | |||||
| ) | |||||
| ], | ], | ||||
| ), | |||||
| ], | |||||
| )); | |||||
| )), | |||||
| isValid ? SizedBox() : WidgetErrorTextField() | |||||
| ], | |||||
| ); | |||||
| })); | })); | ||||
| }); | }); | ||||
| } | } | ||||
| hintValue: "Tổng lượng sử dụng *", | hintValue: "Tổng lượng sử dụng *", | ||||
| textController: _quantityController, | textController: _quantityController, | ||||
| validator: (String value) { | validator: (String value) { | ||||
| return Validators.validateNotNullOrEmpty(value, ""); | |||||
| return Validators.validateNotNullOrEmpty( | |||||
| value, label_validate_input_empty); | |||||
| }, | }, | ||||
| onChanged: (value) { | onChanged: (value) { | ||||
| if (!Validators.stringNotNullOrEmpty(value) && | if (!Validators.stringNotNullOrEmpty(value) && |
| import 'package:farm_tpf/custom_model/Device.dart'; | import 'package:farm_tpf/custom_model/Device.dart'; | ||||
| import 'package:farm_tpf/custom_model/SuppliesUsing.dart'; | import 'package:farm_tpf/custom_model/SuppliesUsing.dart'; | ||||
| import 'package:farm_tpf/custom_model/Supply.dart'; | import 'package:farm_tpf/custom_model/Supply.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/WidgetErrorTextField.dart'; | |||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_text_form_field.dart'; | import 'package:farm_tpf/presentation/custom_widgets/widget_text_form_field.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/actions/controller/ChangeDevice.dart'; | import 'package:farm_tpf/presentation/screens/actions/controller/ChangeDevice.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/actions/resource_device_activity/sc_device_activity.dart'; | import 'package:farm_tpf/presentation/screens/actions/resource_device_activity/sc_device_activity.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/actions/state_management_helper/change_supply.dart'; | import 'package:farm_tpf/presentation/screens/actions/state_management_helper/change_supply.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/resources/sc_resource_helper.dart'; | import 'package:farm_tpf/presentation/screens/resources/sc_resource_helper.dart'; | ||||
| import 'package:farm_tpf/utils/const_color.dart'; | |||||
| import 'package:farm_tpf/utils/const_common.dart'; | import 'package:farm_tpf/utils/const_common.dart'; | ||||
| import 'package:farm_tpf/utils/const_string.dart'; | |||||
| import 'package:farm_tpf/utils/const_style.dart'; | import 'package:farm_tpf/utils/const_style.dart'; | ||||
| import 'package:farm_tpf/utils/validators.dart'; | import 'package:farm_tpf/utils/validators.dart'; | ||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
| }, | }, | ||||
| child: GetBuilder<ChangeSupply>(builder: (_) { | child: GetBuilder<ChangeSupply>(builder: (_) { | ||||
| var isValid = changeSelectedSupply.isValid; | var isValid = changeSelectedSupply.isValid; | ||||
| return 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 ? Colors.grey : Colors.red[900])), | |||||
| ), | |||||
| child: Column( | |||||
| crossAxisAlignment: CrossAxisAlignment.start, | |||||
| children: [ | |||||
| Text( | |||||
| 'Hoá chất xử lý *', | |||||
| style: TextStyle( | |||||
| fontSize: 13, | |||||
| fontWeight: FontWeight.normal, | |||||
| color: isValid ? Colors.black54 : Colors.red[600]), | |||||
| 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 ? Colors.grey : Colors.red[900])), | |||||
| ), | ), | ||||
| Row( | |||||
| child: Column( | |||||
| crossAxisAlignment: CrossAxisAlignment.start, | |||||
| children: [ | 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, | |||||
| Text( | |||||
| 'Hoá chất xử lý *', | |||||
| style: TextStyle( | |||||
| fontSize: 13, | |||||
| fontWeight: FontWeight.normal, | |||||
| color: | |||||
| isValid ? 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 ? SizedBox() : WidgetErrorTextField() | |||||
| ], | |||||
| ); | |||||
| })); | })); | ||||
| }); | }); | ||||
| } | } | ||||
| hintValue: "Tổng lượng sử dụng *", | hintValue: "Tổng lượng sử dụng *", | ||||
| textController: _quantityController, | textController: _quantityController, | ||||
| validator: (String value) { | validator: (String value) { | ||||
| return Validators.validateNotNullOrEmpty(value, ""); | |||||
| return Validators.validateNotNullOrEmpty( | |||||
| value, label_validate_input_empty); | |||||
| }, | }, | ||||
| onChanged: (value) { | onChanged: (value) { | ||||
| if (!Validators.stringNotNullOrEmpty(value) && | if (!Validators.stringNotNullOrEmpty(value) && |
| import 'package:farm_tpf/presentation/screens/actions/state_management_helper/change_supply.dart'; | import 'package:farm_tpf/presentation/screens/actions/state_management_helper/change_supply.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/resources/sc_resource_helper.dart'; | import 'package:farm_tpf/presentation/screens/resources/sc_resource_helper.dart'; | ||||
| import 'package:farm_tpf/utils/bloc/bloc/status_add_form_bloc.dart'; | import 'package:farm_tpf/utils/bloc/bloc/status_add_form_bloc.dart'; | ||||
| import 'package:farm_tpf/utils/const_color.dart'; | |||||
| import 'package:farm_tpf/utils/const_common.dart'; | import 'package:farm_tpf/utils/const_common.dart'; | ||||
| import 'package:farm_tpf/utils/const_string.dart'; | import 'package:farm_tpf/utils/const_string.dart'; | ||||
| import 'package:farm_tpf/utils/const_style.dart'; | import 'package:farm_tpf/utils/const_style.dart'; | ||||
| decoration: InputDecoration(labelText: "Tên công nhân *"), | decoration: InputDecoration(labelText: "Tên công nhân *"), | ||||
| validator: (value) { | validator: (value) { | ||||
| return Validators.validateNotNullOrEmpty( | return Validators.validateNotNullOrEmpty( | ||||
| value, "Tên công nhân"); | |||||
| value, label_validate_input_empty); | |||||
| }, | }, | ||||
| onSaved: (newValue) {}, | onSaved: (newValue) {}, | ||||
| ), | ), |
| } | } | ||||
| } else { | } else { | ||||
| _autoValidate = true; | _autoValidate = true; | ||||
| Utils.showSnackBarWarning(message: label_validate_input_required); | |||||
| } | } | ||||
| } | } | ||||
| _other.activityTypeName = newValue.name; | _other.activityTypeName = newValue.name; | ||||
| }); | }); | ||||
| }, | }, | ||||
| validator: (value) => value == null ? "Hoạt động" : null, | |||||
| validator: (value) => | |||||
| value == null ? label_validate_input_empty : null, | |||||
| isExpanded: true, | isExpanded: true, | ||||
| items: _buildDropMenu(_actionTypes)); | items: _buildDropMenu(_actionTypes)); | ||||
| } else if (snapshot.hasError) { | } else if (snapshot.hasError) { |
| import 'package:farm_tpf/custom_model/Device.dart'; | import 'package:farm_tpf/custom_model/Device.dart'; | ||||
| import 'package:farm_tpf/custom_model/SuppliesUsing.dart'; | import 'package:farm_tpf/custom_model/SuppliesUsing.dart'; | ||||
| import 'package:farm_tpf/custom_model/Supply.dart'; | import 'package:farm_tpf/custom_model/Supply.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/WidgetErrorTextField.dart'; | |||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_text_form_field.dart'; | import 'package:farm_tpf/presentation/custom_widgets/widget_text_form_field.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/actions/controller/ChangeDevice.dart'; | import 'package:farm_tpf/presentation/screens/actions/controller/ChangeDevice.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/actions/resource_device_activity/sc_device_activity.dart'; | import 'package:farm_tpf/presentation/screens/actions/resource_device_activity/sc_device_activity.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/actions/state_management_helper/change_supply.dart'; | import 'package:farm_tpf/presentation/screens/actions/state_management_helper/change_supply.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/resources/sc_resource_helper.dart'; | import 'package:farm_tpf/presentation/screens/resources/sc_resource_helper.dart'; | ||||
| import 'package:farm_tpf/utils/const_color.dart'; | |||||
| import 'package:farm_tpf/utils/const_common.dart'; | import 'package:farm_tpf/utils/const_common.dart'; | ||||
| import 'package:farm_tpf/utils/const_string.dart'; | |||||
| import 'package:farm_tpf/utils/const_style.dart'; | import 'package:farm_tpf/utils/const_style.dart'; | ||||
| import 'package:farm_tpf/utils/validators.dart'; | import 'package:farm_tpf/utils/validators.dart'; | ||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
| }, | }, | ||||
| child: GetBuilder<ChangeSupply>(builder: (_) { | child: GetBuilder<ChangeSupply>(builder: (_) { | ||||
| var isValid = changeSelectedSupply.isValid; | var isValid = changeSelectedSupply.isValid; | ||||
| return 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 ? Colors.grey : Colors.red[900])), | |||||
| ), | |||||
| child: Column( | |||||
| crossAxisAlignment: CrossAxisAlignment.start, | |||||
| children: [ | |||||
| Text( | |||||
| 'Tên thương mại *', | |||||
| style: TextStyle( | |||||
| fontSize: 13, | |||||
| fontWeight: FontWeight.normal, | |||||
| color: isValid ? Colors.black54 : Colors.red[600]), | |||||
| 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 ? Colors.grey : Colors.red[900])), | |||||
| ), | ), | ||||
| Row( | |||||
| child: Column( | |||||
| crossAxisAlignment: CrossAxisAlignment.start, | |||||
| children: [ | children: [ | ||||
| Expanded( | |||||
| child: Text( | |||||
| changeSelectedSupply.selectedSupplyName ?? | |||||
| "Tên thương mại", | |||||
| style: TextStyle( | |||||
| fontSize: 14.0, color: Colors.black87))), | |||||
| Icon( | |||||
| Icons.arrow_drop_down, | |||||
| color: Colors.grey, | |||||
| Text( | |||||
| 'Tên thương mại *', | |||||
| style: TextStyle( | |||||
| fontSize: 13, | |||||
| fontWeight: FontWeight.normal, | |||||
| color: | |||||
| isValid ? Colors.black54 : Colors.red[600]), | |||||
| ), | |||||
| Row( | |||||
| children: [ | |||||
| Expanded( | |||||
| child: Text( | |||||
| changeSelectedSupply.selectedSupplyName ?? | |||||
| "Tên thương mại", | |||||
| style: TextStyle( | |||||
| fontSize: 14.0, | |||||
| color: Colors.black87))), | |||||
| Icon( | |||||
| Icons.arrow_drop_down, | |||||
| color: Colors.grey, | |||||
| ), | |||||
| ], | |||||
| ), | ), | ||||
| ], | ], | ||||
| ), | |||||
| ], | |||||
| )); | |||||
| )), | |||||
| isValid ? SizedBox() : WidgetErrorTextField() | |||||
| ], | |||||
| ); | |||||
| })); | })); | ||||
| }); | }); | ||||
| } | } | ||||
| hintValue: "Tổng lượng sử dụng *", | hintValue: "Tổng lượng sử dụng *", | ||||
| textController: _quantityController, | textController: _quantityController, | ||||
| validator: (String value) { | validator: (String value) { | ||||
| return Validators.validateNotNullOrEmpty(value, ""); | |||||
| return Validators.validateNotNullOrEmpty( | |||||
| value, label_validate_input_empty); | |||||
| }, | }, | ||||
| onChanged: (value) { | onChanged: (value) { | ||||
| if (!Validators.stringNotNullOrEmpty(value) && | if (!Validators.stringNotNullOrEmpty(value) && |
| const String label_execute_date_must_after_result_time = | const String label_execute_date_must_after_result_time = | ||||
| "Thời gian ghi nhận kết quả phải sau thời gian thực hiện"; | "Thời gian ghi nhận kết quả phải sau thời gian thực hiện"; | ||||
| const String label_validate_input_required = | |||||
| "Vui lòng cập nhật các thông tin bắt buộc"; | |||||
| const String label_validate_input_empty = "Vui lòng không bỏ trống"; | |||||
| //Exception | //Exception | ||||
| const String exception_common = "Đã có lỗi xảy ra"; | const String exception_common = "Đã có lỗi xảy ra"; |