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

{
"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

child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ 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( SizedBox(
width: double.infinity, width: double.infinity,
height: 44, height: 44,
child: Row( child: Row(
children: [ children: [
Expanded( 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( Icon(
Icons.arrow_drop_down, Icons.arrow_drop_down,
color: Colors.grey, color: Colors.grey,

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

final String hint; final String hint;
final String value; final String value;
final Function(DateTime) onPressed; final Function(DateTime) onPressed;
final String invalidMessage;
final String tag; final String tag;
final void Function(String) validator;
final bool isValidated;
FieldDateWidget( FieldDateWidget(
{@required this.hint, {@required this.hint,
@required this.tag, @required this.tag,
this.value, this.value,
@required this.onPressed, @required this.onPressed,
this.invalidMessage});
this.validator,
this.isValidated});


@override @override
_FieldDateWidgetState createState() => _FieldDateWidgetState(); _FieldDateWidgetState createState() => _FieldDateWidgetState();


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


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


@override @override
builder: (data) { builder: (data) {
return SizedBox( return SizedBox(
width: double.infinity, width: double.infinity,
height: Validators.stringNotNullOrEmpty(widget.invalidMessage)
? 85
: 65,
height: Validators.stringNotNullOrEmpty(textController.text) &&
validators != null
? 65
: widget.isValidated
? 85
: 85,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ 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( SizedBox(
width: double.infinity, width: double.infinity,
height: 44, height: 44,
onChanged: (date) {}, onConfirm: (date) { onChanged: (date) {}, onConfirm: (date) {
controller.change(date); controller.change(date);
widget.onPressed(date); widget.onPressed(date);
textController.text = date.toString();
}, },
currentTime: data?.selectedDateTime, currentTime: data?.selectedDateTime,
locale: LocaleType.vi); locale: LocaleType.vi);
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border( border: Border(
bottom: BorderSide( 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( child: Row(
children: [ children: [
Expanded( 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( Icon(
Icons.date_range, Icons.date_range,
color: Colors.grey, color: Colors.grey,
], ],
)), )),
), ),
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( style: TextStyle(
fontSize: 12.0, fontSize: 12.0,
color: Colors.red, color: Colors.red,
fontWeight: FontWeight.normal), fontWeight: FontWeight.normal),
textAlign: TextAlign.left, 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



class TextFieldAreaWidget extends StatelessWidget { class TextFieldAreaWidget extends StatelessWidget {
final String hint; final String hint;
final String labelText;
final TextEditingController controller; final TextEditingController controller;
final Function onSaved; final Function onSaved;
final void Function(String) validator;
TextFieldAreaWidget( 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
controller: controller, controller: controller,
decoration: InputDecoration( decoration: InputDecoration(
labelText: hint, hintText: hint, border: InputBorder.none),
labelText: labelText, hintText: hint, border: InputBorder.none),
onSaved: onSaved, onSaved: onSaved,
validator: validator,
), ),
); );
} }

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

final void Function(String) validator; final void Function(String) validator;
final void Function(String) onChanged; final void Function(String) onChanged;
final String hintValue; final String hintValue;
final String labelText;
WidgetTextFormFieldNumber( WidgetTextFormFieldNumber(
{@required this.textController, {@required this.textController,
this.onSaved, this.onSaved,
@required this.hintValue, @required this.hintValue,
@required this.labelText,
this.validator, this.validator,
this.onChanged}); this.onChanged});
@override @override
FilteringTextInputFormatter.allow(ConstCommon.regExpDecimal), FilteringTextInputFormatter.allow(ConstCommon.regExpDecimal),
ThousandsFormatter(allowFraction: true), 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, controller: textController,
onSaved: onSaved, onSaved: onSaved,
onChanged: onChanged, onChanged: onChanged,

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

child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ 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( Row(
children: [ children: [
Expanded( 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( Icon(
Icons.arrow_drop_down, Icons.arrow_drop_down,
color: Colors.grey, color: Colors.grey,
decoration: BoxDecoration( decoration: BoxDecoration(
border: kBorderTextField, border: kBorderTextField,
), ),
child: Row(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ 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,
),
],
), ),
], ],
))); )));
_quantityField() { _quantityField() {
return WidgetTextFormFieldNumber( return WidgetTextFormFieldNumber(
hintValue: "Tổng lượng sử dụng *", hintValue: "Tổng lượng sử dụng *",
labelText: "Tổng lượng sử dụng *",
textController: _quantityController, textController: _quantityController,
validator: (String value) { validator: (String value) {
return Validators.validateNotNullOrEmpty( return Validators.validateNotNullOrEmpty(
child: _dropdownUnitTypes(), child: _dropdownUnitTypes(),
)), )),
]), ]),
Container(
width: double.infinity,
child: Text(
"Thiết bị",
style: TextStyle(color: Colors.black54, fontSize: 13.0),
),
),
_btnSelectDevice(), _btnSelectDevice(),
TextFormField( TextFormField(
keyboardType: TextInputType.text, keyboardType: TextInputType.text,

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

_quantityField() { _quantityField() {
return WidgetTextFormFieldNumber( return WidgetTextFormFieldNumber(
hintValue: "Tổng lượng sử dụng *", hintValue: "Tổng lượng sử dụng *",
labelText: "Tổng lượng sử dụng *",
textController: _quantityController, textController: _quantityController,
validator: (String value) { validator: (String value) {
return Validators.validateNotNullOrEmpty( return Validators.validateNotNullOrEmpty(

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

child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ 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( Row(
children: [ children: [
Expanded( 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( Icon(
Icons.arrow_drop_down, Icons.arrow_drop_down,
color: Colors.grey, color: Colors.grey,
_quantityField() { _quantityField() {
return WidgetTextFormFieldNumber( return WidgetTextFormFieldNumber(
hintValue: "Tổng lượng sử dụng *", hintValue: "Tổng lượng sử dụng *",
labelText: "Tổng lượng sử dụng *",
textController: _quantityController, textController: _quantityController,
validator: (String value) { validator: (String value) {
return Validators.validateNotNullOrEmpty( return Validators.validateNotNullOrEmpty(
Expanded( Expanded(
flex: 2, flex: 2,
child: Container( child: Container(
height: 82,
height: 86,
child: _quantityField(), child: _quantityField(),
), ),
), ),

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

var _supplyUsings = <SuppliesUsing>[]; var _supplyUsings = <SuppliesUsing>[];


var _previousGroupFieldName = ''; var _previousGroupFieldName = '';
var isValidated = false;


Future<Null> getSharedPrefs() async { Future<Null> getSharedPrefs() async {
var currentFullName = await pref.getString(DATA_CONST.CURRENT_FULL_NAME); var currentFullName = await pref.getString(DATA_CONST.CURRENT_FULL_NAME);
} }
} else { } else {
// //
setState(() {
isValidated = true;
});
} }
} }


groupName(field.groupName), groupName(field.groupName),
TextFormField( TextFormField(
keyboardType: TextInputType.text, 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()], controller: textFieldControllers[field.id.toString()],
onSaved: (newValue) {}, onSaved: (newValue) {},
validator: field.isMandatory validator: field.isMandatory
groupName(field.groupName), groupName(field.groupName),
WidgetTextFormFieldNumber( WidgetTextFormFieldNumber(
hintValue: field.description, hintValue: field.description,
labelText: field.isMandatory
? '${field.description} *'
: '${field.description}',
textController: textFieldControllers[field.id.toString()], textController: textFieldControllers[field.id.toString()],
onSaved: (newValue) {}, onSaved: (newValue) {},
validator: field.isMandatory validator: field.isMandatory
children: [ children: [
groupName(field.groupName), groupName(field.groupName),
TextFieldAreaWidget( 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' || } else if (field.tbControlTypeName == 'dropdown' ||
children: [ children: [
groupName(field.groupName), groupName(field.groupName),
FieldDateWidget( 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 { } else {

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

child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ 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( Row(
children: [ children: [
Expanded( 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( Icon(
Icons.arrow_drop_down, Icons.arrow_drop_down,
color: Colors.grey, color: Colors.grey,
decoration: BoxDecoration( decoration: BoxDecoration(
border: kBorderTextField, border: kBorderTextField,
), ),
child: Row(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ 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,
),
],
), ),
], ],
))); )));
_quantityField() { _quantityField() {
return WidgetTextFormFieldNumber( return WidgetTextFormFieldNumber(
hintValue: "Tổng lượng sử dụng *", hintValue: "Tổng lượng sử dụng *",
labelText: "Tổng lượng sử dụng *",
textController: _quantityController, textController: _quantityController,
validator: (String value) { validator: (String value) {
return Validators.validateNotNullOrEmpty( return Validators.validateNotNullOrEmpty(
child: _dropdownUnitTypes(), child: _dropdownUnitTypes(),
)), )),
]), ]),
Container(
width: double.infinity,
child: Text(
"Thiết bị",
style: TextStyle(color: Colors.black54, fontSize: 13.0),
),
),
_btnSelectDevice(), _btnSelectDevice(),
TextFormField( TextFormField(
keyboardType: TextInputType.text, keyboardType: TextInputType.text,

Loading…
Cancel
Save