Browse Source

fix Bug #7893

master
daivph 5 years ago
parent
commit
1d714a1dbc
9 changed files with 152 additions and 108 deletions
  1. +13
    -0
      lib/presentation/custom_widgets/WidgetErrorTextField.dart
  2. +0
    -1
      lib/presentation/custom_widgets/widget_text_form_field.dart
  3. +3
    -5
      lib/presentation/screens/actions/disease/sc_edit_action_disease.dart
  4. +43
    -33
      lib/presentation/screens/actions/dung/widget_dung_supply.dart
  5. +43
    -33
      lib/presentation/screens/actions/harvest_process/widget_harvest_process_supply.dart
  6. +1
    -2
      lib/presentation/screens/actions/nursery/sc_edit_action_nursery.dart
  7. +3
    -1
      lib/presentation/screens/actions/other/sc_edit_action_other.dart
  8. +43
    -33
      lib/presentation/screens/actions/spraying/widget_spraying_supply.dart
  9. +3
    -0
      lib/utils/const_string.dart

+ 13
- 0
lib/presentation/custom_widgets/WidgetErrorTextField.dart View File

@@ -0,0 +1,13 @@
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),
);
}
}

+ 0
- 1
lib/presentation/custom_widgets/widget_text_form_field.dart View File

@@ -29,7 +29,6 @@ class WidgetTextFormFieldNumber extends StatelessWidget {
],
decoration: InputDecoration(
labelText: hintValue,
errorStyle: TextStyle(height: 0),
),
validator: validator ??
(String value) {

+ 3
- 5
lib/presentation/screens/actions/disease/sc_edit_action_disease.dart View File

@@ -17,16 +17,12 @@ import 'package:farm_tpf/presentation/screens/actions/bloc/action_detail_bloc.da
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_string.dart';
import 'package:farm_tpf/utils/const_style.dart';
import 'package:farm_tpf/utils/pref.dart';
import 'package:farm_tpf/utils/validators.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:keyboard_dismisser/keyboard_dismisser.dart';
import 'package:pattern_formatter/pattern_formatter.dart';
import 'package:farm_tpf/utils/formatter.dart';

import '../util_action.dart';
@@ -145,6 +141,7 @@ class _EditActionDiseaseScreenState extends State<EditActionDiseaseScreen> {
}
} else {
_autoValidate = true;
Utils.showSnackBarWarning(message: label_validate_input_required);
}
}

@@ -163,7 +160,8 @@ class _EditActionDiseaseScreenState extends State<EditActionDiseaseScreen> {
decoration: InputDecoration(labelText: "Loại dịch hại *"),
controller: _typesOfPestController,
validator: (String value) {
return Validators.validateNotNullOrEmpty(value, "Loại dịch hại");
return Validators.validateNotNullOrEmpty(
value, label_validate_input_empty);
},
onSaved: (newValue) {
_disease.typesOfPest = newValue;

+ 43
- 33
lib/presentation/screens/actions/dung/widget_dung_supply.dart View File

@@ -1,6 +1,7 @@
import 'package:farm_tpf/custom_model/Device.dart';
import 'package:farm_tpf/custom_model/SuppliesUsing.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_utils.dart';
import 'package:farm_tpf/presentation/screens/actions/controller/ChangeDevice.dart';
@@ -11,8 +12,8 @@ import 'package:farm_tpf/presentation/screens/actions/controller/ChangeUnit.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/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_string.dart';
import 'package:farm_tpf/utils/const_style.dart';
import 'package:farm_tpf/utils/validators.dart';
import 'package:flutter/material.dart';
@@ -195,41 +196,49 @@ class _WidgetDungSupplyState extends State<WidgetDungSupply> {
},
child: GetBuilder<ChangeSupply>(builder: (_) {
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: [
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()
],
);
}));
});
}
@@ -313,7 +322,8 @@ class _WidgetDungSupplyState extends State<WidgetDungSupply> {
hintValue: "Tổng lượng sử dụng *",
textController: _quantityController,
validator: (String value) {
return Validators.validateNotNullOrEmpty(value, "");
return Validators.validateNotNullOrEmpty(
value, label_validate_input_empty);
},
onChanged: (value) {
if (!Validators.stringNotNullOrEmpty(value) &&

+ 43
- 33
lib/presentation/screens/actions/harvest_process/widget_harvest_process_supply.dart View File

@@ -1,6 +1,7 @@
import 'package:farm_tpf/custom_model/Device.dart';
import 'package:farm_tpf/custom_model/SuppliesUsing.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_utils.dart';
import 'package:farm_tpf/presentation/screens/actions/controller/ChangeDevice.dart';
@@ -11,8 +12,8 @@ import 'package:farm_tpf/presentation/screens/actions/controller/ChangeUnit.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/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_string.dart';
import 'package:farm_tpf/utils/const_style.dart';
import 'package:farm_tpf/utils/validators.dart';
import 'package:flutter/material.dart';
@@ -197,41 +198,49 @@ class _WidgetHarvestProcessSupplyState
},
child: GetBuilder<ChangeSupply>(builder: (_) {
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: [
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()
],
);
}));
});
}
@@ -315,7 +324,8 @@ class _WidgetHarvestProcessSupplyState
hintValue: "Tổng lượng sử dụng *",
textController: _quantityController,
validator: (String value) {
return Validators.validateNotNullOrEmpty(value, "");
return Validators.validateNotNullOrEmpty(
value, label_validate_input_empty);
},
onChanged: (value) {
if (!Validators.stringNotNullOrEmpty(value) &&

+ 1
- 2
lib/presentation/screens/actions/nursery/sc_edit_action_nursery.dart View File

@@ -20,7 +20,6 @@ import 'package:farm_tpf/presentation/screens/actions/state_management_helper/ch
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/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_string.dart';
import 'package:farm_tpf/utils/const_style.dart';
@@ -272,7 +271,7 @@ class _EditActionNurseryState extends State<EditActionNurseryScreen> {
decoration: InputDecoration(labelText: "Tên công nhân *"),
validator: (value) {
return Validators.validateNotNullOrEmpty(
value, "Tên công nhân");
value, label_validate_input_empty);
},
onSaved: (newValue) {},
),

+ 3
- 1
lib/presentation/screens/actions/other/sc_edit_action_other.dart View File

@@ -115,6 +115,7 @@ class _EditActionOtherScreenState extends State<EditActionOtherScreen> {
}
} else {
_autoValidate = true;
Utils.showSnackBarWarning(message: label_validate_input_required);
}
}

@@ -150,7 +151,8 @@ class _EditActionOtherScreenState extends State<EditActionOtherScreen> {
_other.activityTypeName = newValue.name;
});
},
validator: (value) => value == null ? "Hoạt động" : null,
validator: (value) =>
value == null ? label_validate_input_empty : null,
isExpanded: true,
items: _buildDropMenu(_actionTypes));
} else if (snapshot.hasError) {

+ 43
- 33
lib/presentation/screens/actions/spraying/widget_spraying_supply.dart View File

@@ -1,6 +1,7 @@
import 'package:farm_tpf/custom_model/Device.dart';
import 'package:farm_tpf/custom_model/SuppliesUsing.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_utils.dart';
import 'package:farm_tpf/presentation/screens/actions/controller/ChangeDevice.dart';
@@ -11,8 +12,8 @@ import 'package:farm_tpf/presentation/screens/actions/controller/ChangeUnit.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/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_string.dart';
import 'package:farm_tpf/utils/const_style.dart';
import 'package:farm_tpf/utils/validators.dart';
import 'package:flutter/material.dart';
@@ -195,41 +196,49 @@ class _WidgetSprayingSupplyState extends State<WidgetSprayingSupply> {
},
child: GetBuilder<ChangeSupply>(builder: (_) {
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: [
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()
],
);
}));
});
}
@@ -313,7 +322,8 @@ class _WidgetSprayingSupplyState extends State<WidgetSprayingSupply> {
hintValue: "Tổng lượng sử dụng *",
textController: _quantityController,
validator: (String value) {
return Validators.validateNotNullOrEmpty(value, "");
return Validators.validateNotNullOrEmpty(
value, label_validate_input_empty);
},
onChanged: (value) {
if (!Validators.stringNotNullOrEmpty(value) &&

+ 3
- 0
lib/utils/const_string.dart View File

@@ -50,6 +50,9 @@ const String label_invalid_number = "Vui lòng nhập số";

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";
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
const String exception_common = "Đã có lỗi xảy ra";

Loading…
Cancel
Save