Browse Source

fix bug

smf
daivp 4 years ago
parent
commit
cd9b3e47b2
10 changed files with 357 additions and 147 deletions
  1. +20
    -0
      android/app/release/output-metadata.json
  2. +30
    -15
      lib/presentation/custom_widgets/dropdown_supply_widget.dart
  3. +74
    -31
      lib/presentation/custom_widgets/widget_action_field_date.dart
  4. +9
    -2
      lib/presentation/custom_widgets/widget_text_field_area.dart
  5. +4
    -7
      lib/presentation/custom_widgets/widget_text_form_field.dart
  6. +72
    -32
      lib/presentation/screens/actions/dung/widget_dung_supply.dart
  7. +1
    -0
      lib/presentation/screens/actions/harvest_process/widget_harvest_process_supply.dart
  8. +34
    -15
      lib/presentation/screens/actions/plant/widget_plant_supply.dart
  9. +41
    -13
      lib/presentation/screens/actions/sc_action.dart
  10. +72
    -32
      lib/presentation/screens/actions/spraying/widget_spraying_supply.dart

+ 20
- 0
android/app/release/output-metadata.json View File

@@ -0,0 +1,20 @@
{
"version": 1,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "vn.azteam.farmdemo",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"properties": [],
"versionCode": 5,
"versionName": "1.0.1",
"enabled": true,
"outputFile": "app-release.apk"
}
]
}

+ 30
- 15
lib/presentation/custom_widgets/dropdown_supply_widget.dart View File

@@ -49,15 +49,25 @@ class _DropdownSupplyWidgetState extends State<DropdownSupplyWidget> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.hint ?? '',
style: TextStyle(
color:
Validators.stringNotNullOrEmpty(widget.invalidMessage)
? Colors.red
: Colors.black54,
fontSize: 13.0),
),
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,
@@ -104,12 +114,17 @@ class _DropdownSupplyWidgetState extends State<DropdownSupplyWidget> {
child: Row(
children: [
Expanded(
child: Text(
data?.currentData?.name ??
widget.hint,
style: TextStyle(
fontSize: 16.0,
color: Colors.black))),
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,

+ 74
- 31
lib/presentation/custom_widgets/widget_action_field_date.dart View File

@@ -11,14 +11,16 @@ class FieldDateWidget extends StatefulWidget {
final String hint;
final String value;
final Function(DateTime) onPressed;
final String invalidMessage;
final String tag;
final void Function(String) validator;
final bool isValidated;
FieldDateWidget(
{@required this.hint,
@required this.tag,
this.value,
@required this.onPressed,
this.invalidMessage});
this.validator,
this.isValidated});

@override
_FieldDateWidgetState createState() => _FieldDateWidgetState();
@@ -26,11 +28,16 @@ class FieldDateWidget extends StatefulWidget {

class _FieldDateWidgetState extends State<FieldDateWidget> {
ChangeDateTimePicker controller;
final textController = TextEditingController();
var isShowError = false;

@override
void initState() {
super.initState();
controller = Get.put(ChangeDateTimePicker(), tag: widget.tag);
textController.addListener(() {
print('object');
});
}

@override
@@ -40,21 +47,31 @@ class _FieldDateWidgetState extends State<FieldDateWidget> {
builder: (data) {
return SizedBox(
width: double.infinity,
height: Validators.stringNotNullOrEmpty(widget.invalidMessage)
? 85
: 65,
height: Validators.stringNotNullOrEmpty(textController.text) &&
validators != null
? 65
: widget.isValidated
? 85
: 85,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.hint ?? '',
style: TextStyle(
color:
Validators.stringNotNullOrEmpty(widget.invalidMessage)
? Colors.red
: Colors.black54,
fontSize: 13.0),
),
Validators.stringNotNullOrEmpty(
data?.selectedDateTime?.displayDateTime_DDMMYYYY_HHmm())
? Text(
widget.hint ?? '',
style: TextStyle(
color: Validators.stringNotNullOrEmpty(
textController.text) &&
validators != null
? Colors.black54
: Colors.red,
fontSize: 13.0),
)
: Text(
'',
style: TextStyle(color: Colors.black54, fontSize: 13.0),
),
SizedBox(
width: double.infinity,
height: 44,
@@ -67,6 +84,7 @@ class _FieldDateWidgetState extends State<FieldDateWidget> {
onChanged: (date) {}, onConfirm: (date) {
controller.change(date);
widget.onPressed(date);
textController.text = date.toString();
},
currentTime: data?.selectedDateTime,
locale: LocaleType.vi);
@@ -83,22 +101,33 @@ class _FieldDateWidgetState extends State<FieldDateWidget> {
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: 0.5,
color: Validators.stringNotNullOrEmpty(
widget.invalidMessage)
? Colors.red
: Colors.black54)),
width: 0.5,
color: Validators.stringNotNullOrEmpty(
textController.text) &&
validators != null
? Colors.black54
: widget.isValidated
? Colors.red
: Colors.black54,
)),
),
child: Row(
children: [
Expanded(
child: Text(
data?.selectedDateTime
?.displayDateTime_DDMMYYYY_HHmm() ??
widget.hint,
style: TextStyle(
fontSize: 14.0,
color: Colors.black))),
child: Validators.stringNotNullOrEmpty(data
?.selectedDateTime
?.displayDateTime_DDMMYYYY_HHmm())
? Text(
data?.selectedDateTime
?.displayDateTime_DDMMYYYY_HHmm(),
style: TextStyle(
fontSize: 16.0,
color: Colors.black))
: Text(widget.hint,
style: TextStyle(
fontSize: 16.0,
color: Colors.black54)),
),
Icon(
Icons.date_range,
color: Colors.grey,
@@ -108,16 +137,30 @@ class _FieldDateWidgetState extends State<FieldDateWidget> {
],
)),
),
Validators.stringNotNullOrEmpty(widget.invalidMessage)
? Text(
widget.invalidMessage ?? '',
Validators.stringNotNullOrEmpty(textController.text) &&
validators != null
? SizedBox()
: Text(
widget.isValidated
? 'Vui lòng nhập ${widget.hint}'
: '',
style: TextStyle(
fontSize: 12.0,
color: Colors.red,
fontWeight: FontWeight.normal),
textAlign: TextAlign.left,
)
: SizedBox(),
),
Container(
height: 0,
child: TextFormField(
style: TextStyle(color: Colors.white),
decoration: InputDecoration(
border: InputBorder.none,
labelStyle: TextStyle(color: Colors.white)),
validator: widget.validator,
controller: textController,
),
)
],
),
);

+ 9
- 2
lib/presentation/custom_widgets/widget_text_field_area.dart View File

@@ -3,10 +3,16 @@ import 'package:flutter/material.dart';

class TextFieldAreaWidget extends StatelessWidget {
final String hint;
final String labelText;
final TextEditingController controller;
final Function onSaved;
final void Function(String) validator;
TextFieldAreaWidget(
{@required this.hint, @required this.onSaved, @required this.controller});
{@required this.hint,
@required this.labelText,
@required this.onSaved,
this.validator,
@required this.controller});
@override
Widget build(BuildContext context) {
return Container(
@@ -18,8 +24,9 @@ class TextFieldAreaWidget extends StatelessWidget {
keyboardType: TextInputType.text,
controller: controller,
decoration: InputDecoration(
labelText: hint, hintText: hint, border: InputBorder.none),
labelText: labelText, hintText: hint, border: InputBorder.none),
onSaved: onSaved,
validator: validator,
),
);
}

+ 4
- 7
lib/presentation/custom_widgets/widget_text_form_field.dart View File

@@ -12,10 +12,12 @@ class WidgetTextFormFieldNumber extends StatelessWidget {
final void Function(String) validator;
final void Function(String) onChanged;
final String hintValue;
final String labelText;
WidgetTextFormFieldNumber(
{@required this.textController,
this.onSaved,
@required this.hintValue,
@required this.labelText,
this.validator,
this.onChanged});
@override
@@ -26,13 +28,8 @@ class WidgetTextFormFieldNumber extends StatelessWidget {
FilteringTextInputFormatter.allow(ConstCommon.regExpDecimal),
ThousandsFormatter(allowFraction: true),
],
decoration: InputDecoration(
labelText: hintValue,
),
validator: validator ??
(String value) {
return Validators.validNumberOrEmpty(value, label_invalid_number);
},
decoration: InputDecoration(labelText: labelText, hintText: hintValue),
validator: validator,
controller: textController,
onSaved: onSaved,
onChanged: onChanged,

+ 72
- 32
lib/presentation/screens/actions/dung/widget_dung_supply.dart View File

@@ -211,23 +211,41 @@ class _WidgetDungSupplyState extends State<WidgetDungSupply> {
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]),
),
Validators.stringNotNullOrEmpty(
changeSelectedSupply.selectedSupplyName)
? Text(
'Tên thương mại *',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.normal,
color: isValid
? Colors.black54
: Colors.red[600]),
)
: Text(
'',
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))),
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,
@@ -268,18 +286,46 @@ class _WidgetDungSupplyState extends State<WidgetDungSupply> {
decoration: BoxDecoration(
border: kBorderTextField,
),
child: Row(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
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,
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>(
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,
),
],
),
],
)));
@@ -320,6 +366,7 @@ class _WidgetDungSupplyState extends State<WidgetDungSupply> {
_quantityField() {
return WidgetTextFormFieldNumber(
hintValue: "Tổng lượng sử dụng *",
labelText: "Tổng lượng sử dụng *",
textController: _quantityController,
validator: (String value) {
return Validators.validateNotNullOrEmpty(
@@ -538,13 +585,6 @@ class _WidgetDungSupplyState extends State<WidgetDungSupply> {
child: _dropdownUnitTypes(),
)),
]),
Container(
width: double.infinity,
child: Text(
"Thiết bị",
style: TextStyle(color: Colors.black54, fontSize: 13.0),
),
),
_btnSelectDevice(),
TextFormField(
keyboardType: TextInputType.text,

+ 1
- 0
lib/presentation/screens/actions/harvest_process/widget_harvest_process_supply.dart View File

@@ -322,6 +322,7 @@ class _WidgetHarvestProcessSupplyState
_quantityField() {
return WidgetTextFormFieldNumber(
hintValue: "Tổng lượng sử dụng *",
labelText: "Tổng lượng sử dụng *",
textController: _quantityController,
validator: (String value) {
return Validators.validateNotNullOrEmpty(

+ 34
- 15
lib/presentation/screens/actions/plant/widget_plant_supply.dart View File

@@ -186,23 +186,41 @@ class _WidgetPlantSupplyState extends State<WidgetPlantSupply> {
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]),
),
Validators.stringNotNullOrEmpty(
changeSelectedSupply.selectedSupplyName)
? Text(
'Hoá chất xử lý *',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.normal,
color: isValid
? Colors.black54
: Colors.red[600]),
)
: Text(
'',
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))),
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,
@@ -252,6 +270,7 @@ class _WidgetPlantSupplyState extends State<WidgetPlantSupply> {
_quantityField() {
return WidgetTextFormFieldNumber(
hintValue: "Tổng lượng sử dụng *",
labelText: "Tổng lượng sử dụng *",
textController: _quantityController,
validator: (String value) {
return Validators.validateNotNullOrEmpty(
@@ -425,7 +444,7 @@ class _WidgetPlantSupplyState extends State<WidgetPlantSupply> {
Expanded(
flex: 2,
child: Container(
height: 82,
height: 86,
child: _quantityField(),
),
),

+ 41
- 13
lib/presentation/screens/actions/sc_action.dart View File

@@ -77,6 +77,7 @@ class _ActionScreenState extends State<ActionScreen> {
var _supplyUsings = <SuppliesUsing>[];

var _previousGroupFieldName = '';
var isValidated = false;

Future<Null> getSharedPrefs() async {
var currentFullName = await pref.getString(DATA_CONST.CURRENT_FULL_NAME);
@@ -236,6 +237,9 @@ class _ActionScreenState extends State<ActionScreen> {
}
} else {
//
setState(() {
isValidated = true;
});
}
}

@@ -309,7 +313,11 @@ class _ActionScreenState extends State<ActionScreen> {
groupName(field.groupName),
TextFormField(
keyboardType: TextInputType.text,
decoration: InputDecoration(labelText: field.description),
decoration: InputDecoration(
labelText: field.isMandatory
? '${field.description} *'
: '${field.description}',
hintText: field.description),
controller: textFieldControllers[field.id.toString()],
onSaved: (newValue) {},
validator: field.isMandatory
@@ -327,6 +335,9 @@ class _ActionScreenState extends State<ActionScreen> {
groupName(field.groupName),
WidgetTextFormFieldNumber(
hintValue: field.description,
labelText: field.isMandatory
? '${field.description} *'
: '${field.description}',
textController: textFieldControllers[field.id.toString()],
onSaved: (newValue) {},
validator: field.isMandatory
@@ -343,9 +354,19 @@ class _ActionScreenState extends State<ActionScreen> {
children: [
groupName(field.groupName),
TextFieldAreaWidget(
hint: field.description,
controller: textFieldControllers[field.id.toString()],
onSaved: (newValue) {}),
hint: field.description,
labelText: field.isMandatory
? '${field.description} *'
: '${field.description}',
controller: textFieldControllers[field.id.toString()],
onSaved: (newValue) {},
validator: field.isMandatory
? (String value) {
return Validators.validateNotNullOrEmpty(
value, 'Vui lòng nhập ${field.description}');
}
: null,
),
],
);
} else if (field.tbControlTypeName == 'dropdown' ||
@@ -373,15 +394,22 @@ class _ActionScreenState extends State<ActionScreen> {
children: [
groupName(field.groupName),
FieldDateWidget(
tag: field.name,
value: field.description,
hint:
'${field.description} ${field.isMandatory ? '*' : ''}',
invalidMessage: '',
onPressed: (selectedDate) {
valueObjects[field.id.toString()] = selectedDate
.convertLocalDateTimeToStringUtcDateTime();
}),
tag: field.name,
isValidated: isValidated,
value: field.description,
hint:
'${field.description} ${field.isMandatory ? '*' : ''}',
onPressed: (selectedDate) {
valueObjects[field.id.toString()] = selectedDate
.convertLocalDateTimeToStringUtcDateTime();
},
validator: field.isMandatory
? (String value) {
return Validators.validateNotNullOrEmpty(
value, 'Vui lòng nhập ${field.description}');
}
: null,
),
],
);
} else {

+ 72
- 32
lib/presentation/screens/actions/spraying/widget_spraying_supply.dart View File

@@ -211,23 +211,41 @@ class _WidgetSprayingSupplyState extends State<WidgetSprayingSupply> {
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]),
),
Validators.stringNotNullOrEmpty(
changeSelectedSupply.selectedSupplyName)
? Text(
'Tên thương mại *',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.normal,
color: isValid
? Colors.black54
: Colors.red[600]),
)
: Text(
'',
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))),
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,
@@ -268,18 +286,46 @@ class _WidgetSprayingSupplyState extends State<WidgetSprayingSupply> {
decoration: BoxDecoration(
border: kBorderTextField,
),
child: Row(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
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,
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>(
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,
),
],
),
],
)));
@@ -320,6 +366,7 @@ class _WidgetSprayingSupplyState extends State<WidgetSprayingSupply> {
_quantityField() {
return WidgetTextFormFieldNumber(
hintValue: "Tổng lượng sử dụng *",
labelText: "Tổng lượng sử dụng *",
textController: _quantityController,
validator: (String value) {
return Validators.validateNotNullOrEmpty(
@@ -537,13 +584,6 @@ class _WidgetSprayingSupplyState extends State<WidgetSprayingSupply> {
child: _dropdownUnitTypes(),
)),
]),
Container(
width: double.infinity,
child: Text(
"Thiết bị",
style: TextStyle(color: Colors.black54, fontSize: 13.0),
),
),
_btnSelectDevice(),
TextFormField(
keyboardType: TextInputType.text,

Loading…
Cancel
Save