|
|
|
|
|
|
|
|
|
|
|
import 'dart:convert'; |
|
|
|
|
|
|
|
|
|
|
|
import 'package:farm_tpf/custom_model/Environment.dart'; |
|
|
|
|
|
import 'package:farm_tpf/custom_model/RequestEnvironment.dart'; |
|
|
|
|
|
import 'package:farm_tpf/data/api/app_exception.dart'; |
|
|
|
|
|
import 'package:farm_tpf/data/repository/repository.dart'; |
|
|
|
|
|
import 'package:farm_tpf/presentation/custom_widgets/bloc/media_helper_bloc.dart'; |
|
|
|
|
|
import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart'; |
|
|
|
|
|
import 'package:farm_tpf/presentation/custom_widgets/widget_media_picker.dart'; |
|
|
|
|
|
import 'package:farm_tpf/presentation/screens/actions/bloc/action_detail_bloc.dart'; |
|
|
|
|
|
import 'package:farm_tpf/presentation/screens/actions/state_management_helper/change_file_controller.dart'; |
|
|
|
|
|
import 'package:farm_tpf/presentation/screens/actions/util_action.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/validators.dart'; |
|
|
import 'package:flutter/material.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'; |
|
|
|
|
|
|
|
|
class EditActionEnvironmentUpdate extends StatefulWidget { |
|
|
class EditActionEnvironmentUpdate extends StatefulWidget { |
|
|
|
|
|
final int cropId; |
|
|
|
|
|
final bool isEdit; |
|
|
|
|
|
final int activityId; |
|
|
|
|
|
EditActionEnvironmentUpdate( |
|
|
|
|
|
{@required this.cropId, this.isEdit = false, this.activityId}); |
|
|
@override |
|
|
@override |
|
|
_EditActionEnvironmentUpdateState createState() => |
|
|
_EditActionEnvironmentUpdateState createState() => |
|
|
_EditActionEnvironmentUpdateState(); |
|
|
_EditActionEnvironmentUpdateState(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _EditActionEnvironmentUpdateState |
|
|
class _EditActionEnvironmentUpdateState |
|
|
extends State<EditActionEnvironmentUpdate> { |
|
|
extends State<EditActionEnvironmentUpdate> { |
|
|
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(); |
|
|
|
|
|
final _repository = Repository(); |
|
|
|
|
|
GlobalKey<FormState> _formKey = GlobalKey(); |
|
|
|
|
|
bool _autoValidate = false; |
|
|
|
|
|
Environment _environment = Environment(); |
|
|
|
|
|
var pref = LocalPref(); |
|
|
|
|
|
TextEditingController _ecController = TextEditingController(); |
|
|
|
|
|
TextEditingController _phController = TextEditingController(); |
|
|
|
|
|
TextEditingController _ocddController = TextEditingController(); |
|
|
|
|
|
TextEditingController _temperatureController = TextEditingController(); |
|
|
|
|
|
TextEditingController _doController = TextEditingController(); |
|
|
|
|
|
TextEditingController _llnController = TextEditingController(); |
|
|
|
|
|
|
|
|
|
|
|
String executeTimeView; |
|
|
|
|
|
DateTime executeTime = DateTime.now(); |
|
|
|
|
|
List<String> filePaths = List<String>(); |
|
|
|
|
|
var changeFileController = Get.put(ChangeFileController()); |
|
|
@override |
|
|
@override |
|
|
Widget build(BuildContext context) { |
|
|
|
|
|
return Scaffold( |
|
|
|
|
|
appBar: AppBar( |
|
|
|
|
|
title: Text(plot_action_environment_update), |
|
|
|
|
|
), |
|
|
|
|
|
|
|
|
void initState() { |
|
|
|
|
|
super.initState(); |
|
|
|
|
|
changeFileController.initValue(); |
|
|
|
|
|
//UPDATE |
|
|
|
|
|
if (_environment != null) { |
|
|
|
|
|
try { |
|
|
|
|
|
executeTime = DateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") |
|
|
|
|
|
.parse(_environment.executeDate); |
|
|
|
|
|
} catch (_) {} |
|
|
|
|
|
} else { |
|
|
|
|
|
//ADD NEW |
|
|
|
|
|
var parsedExecuteDate = |
|
|
|
|
|
DateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(executeTime); |
|
|
|
|
|
_environment.executeDate = "$parsedExecuteDate"; |
|
|
|
|
|
} |
|
|
|
|
|
executeTimeView = DateFormat("dd/MM/yyyy HH:mm").format(executeTime); |
|
|
|
|
|
_environment.cropId = widget.cropId; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_validateInputs() async { |
|
|
|
|
|
if (_formKey.currentState.validate()) { |
|
|
|
|
|
_formKey.currentState.save(); |
|
|
|
|
|
LoadingDialog.showLoadingDialog(context); |
|
|
|
|
|
filePaths = Get.find<ChangeFileController>().files; |
|
|
|
|
|
//Create request general model |
|
|
|
|
|
try { |
|
|
|
|
|
RequestEnvironment requestEnvironment = RequestEnvironment() |
|
|
|
|
|
..cropId = _environment.cropId |
|
|
|
|
|
..activityId = _environment.activityId |
|
|
|
|
|
..executeDate = _environment.executeDate; |
|
|
|
|
|
var envDetail = List<EnvDetail>(); |
|
|
|
|
|
envDetail.add(EnvDetail() |
|
|
|
|
|
..name = "EC" |
|
|
|
|
|
..index = _environment.ec); |
|
|
|
|
|
envDetail.add(EnvDetail() |
|
|
|
|
|
..name = "pH" |
|
|
|
|
|
..index = _environment.pH); |
|
|
|
|
|
envDetail.add(EnvDetail() |
|
|
|
|
|
..name = "OCDD" |
|
|
|
|
|
..index = _environment.ocdd); |
|
|
|
|
|
envDetail.add(EnvDetail() |
|
|
|
|
|
..name = "TEMPERATURE" |
|
|
|
|
|
..index = _environment.temperature); |
|
|
|
|
|
envDetail.add(EnvDetail() |
|
|
|
|
|
..name = "DO" |
|
|
|
|
|
..index = _environment.dodo); |
|
|
|
|
|
envDetail.add(EnvDetail() |
|
|
|
|
|
..name = "LLN" |
|
|
|
|
|
..index = _environment.lln); |
|
|
|
|
|
requestEnvironment.envDetail = envDetail; |
|
|
|
|
|
var activityEnvironmentUpdate = |
|
|
|
|
|
jsonEncode(requestEnvironment.toJson()).toString(); |
|
|
|
|
|
//ADD NEW |
|
|
|
|
|
if (_environment.activityId == null) { |
|
|
|
|
|
_repository.createAction((value) { |
|
|
|
|
|
LoadingDialog.hideLoadingDialog(context); |
|
|
|
|
|
Get.back(result: value); |
|
|
|
|
|
Get.snackbar(label_add_success, "Cập nhật môi trường", |
|
|
|
|
|
snackPosition: SnackPosition.BOTTOM); |
|
|
|
|
|
}, (error) { |
|
|
|
|
|
LoadingDialog.hideLoadingDialog(context); |
|
|
|
|
|
_scaffoldKey.currentState.showSnackBar(SnackBar( |
|
|
|
|
|
content: Row( |
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
|
children: <Widget>[ |
|
|
|
|
|
Flexible(child: Text(AppException.handleError(error))), |
|
|
|
|
|
Icon(Icons.error), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
backgroundColor: Colors.red, |
|
|
|
|
|
duration: Duration(seconds: 3), |
|
|
|
|
|
)); |
|
|
|
|
|
}, |
|
|
|
|
|
apiAddAction: ConstCommon.apiAddEnvUpdate, |
|
|
|
|
|
paramActivity: ConstCommon.paramsActionEnvUpdate, |
|
|
|
|
|
activityAction: activityEnvironmentUpdate, |
|
|
|
|
|
filePaths: filePaths); |
|
|
|
|
|
} else { |
|
|
|
|
|
//UPDATE |
|
|
|
|
|
_repository.updateAction((value) { |
|
|
|
|
|
LoadingDialog.hideLoadingDialog(context); |
|
|
|
|
|
Get.back(result: value); |
|
|
|
|
|
Get.snackbar(label_update_success, "Cập nhật môi trường", |
|
|
|
|
|
snackPosition: SnackPosition.BOTTOM); |
|
|
|
|
|
}, (error) { |
|
|
|
|
|
LoadingDialog.hideLoadingDialog(context); |
|
|
|
|
|
_scaffoldKey.currentState.showSnackBar(SnackBar( |
|
|
|
|
|
content: Row( |
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
|
children: <Widget>[ |
|
|
|
|
|
Flexible(child: Text(AppException.handleError(error))), |
|
|
|
|
|
Icon(Icons.error), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
backgroundColor: Colors.red, |
|
|
|
|
|
duration: Duration(seconds: 3), |
|
|
|
|
|
)); |
|
|
|
|
|
}, |
|
|
|
|
|
apiUpdateAction: ConstCommon.apiUpdateEnvUpdate, |
|
|
|
|
|
paramActivity: ConstCommon.paramsActionEnvUpdate, |
|
|
|
|
|
activityAction: activityEnvironmentUpdate, |
|
|
|
|
|
filePaths: filePaths); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
LoadingDialog.hideLoadingDialog(context); |
|
|
|
|
|
print(e.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
_autoValidate = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget _btnExecuteTimePicker() { |
|
|
|
|
|
return FlatButton( |
|
|
|
|
|
padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0.0, left: 0.0), |
|
|
|
|
|
onPressed: () { |
|
|
|
|
|
DatePicker.showDateTimePicker(context, |
|
|
|
|
|
showTitleActions: true, onChanged: (date) {}, onConfirm: (date) { |
|
|
|
|
|
setState(() { |
|
|
|
|
|
var parsedDate = |
|
|
|
|
|
DateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(date); |
|
|
|
|
|
_environment.executeDate = "$parsedDate"; |
|
|
|
|
|
executeTimeView = DateFormat("dd/MM/yyyy HH:mm").format(date); |
|
|
|
|
|
}); |
|
|
|
|
|
}, currentTime: executeTime, 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( |
|
|
|
|
|
//TODO: check condition |
|
|
|
|
|
executeTimeView == null ? "$executeTime" : executeTimeView, |
|
|
|
|
|
style: TextStyle(fontSize: 14.0, color: Colors.black87), |
|
|
|
|
|
)), |
|
|
|
|
|
Icon( |
|
|
|
|
|
Icons.date_range, |
|
|
|
|
|
color: Colors.blue, |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
))); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget _ecField() { |
|
|
|
|
|
return TextFormField( |
|
|
|
|
|
keyboardType: TextInputType.numberWithOptions(decimal: true), |
|
|
|
|
|
inputFormatters: [ |
|
|
|
|
|
ThousandsFormatter( |
|
|
|
|
|
formatter: NumberFormat("#,###.##", "es"), allowFraction: true) |
|
|
|
|
|
], |
|
|
|
|
|
decoration: InputDecoration(labelText: "EC"), |
|
|
|
|
|
controller: _ecController, |
|
|
|
|
|
validator: (String value) { |
|
|
|
|
|
return Validators.validNumber(value, "EC"); |
|
|
|
|
|
}, |
|
|
|
|
|
onSaved: (newValue) { |
|
|
|
|
|
_environment.ec = newValue; |
|
|
|
|
|
}, |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget _phField() { |
|
|
|
|
|
return TextFormField( |
|
|
|
|
|
keyboardType: TextInputType.numberWithOptions(decimal: true), |
|
|
|
|
|
inputFormatters: [ |
|
|
|
|
|
ThousandsFormatter( |
|
|
|
|
|
formatter: NumberFormat("#,###.##", "es"), allowFraction: true) |
|
|
|
|
|
], |
|
|
|
|
|
decoration: InputDecoration(labelText: "pH"), |
|
|
|
|
|
controller: _phController, |
|
|
|
|
|
validator: (String value) { |
|
|
|
|
|
return Validators.validNumber(value, "pH"); |
|
|
|
|
|
}, |
|
|
|
|
|
onSaved: (newValue) { |
|
|
|
|
|
_environment.pH = newValue; |
|
|
|
|
|
}, |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget _ocddField() { |
|
|
|
|
|
return TextFormField( |
|
|
|
|
|
keyboardType: TextInputType.numberWithOptions(decimal: true), |
|
|
|
|
|
inputFormatters: [ |
|
|
|
|
|
ThousandsFormatter( |
|
|
|
|
|
formatter: NumberFormat("#,###.##", "es"), allowFraction: true) |
|
|
|
|
|
], |
|
|
|
|
|
decoration: InputDecoration(labelText: "Nhiệt độ dung dịch"), |
|
|
|
|
|
controller: _ocddController, |
|
|
|
|
|
validator: (String value) { |
|
|
|
|
|
return Validators.validNumber(value, "Nhiệt độ dung dịch"); |
|
|
|
|
|
}, |
|
|
|
|
|
onSaved: (newValue) { |
|
|
|
|
|
_environment.ocdd = newValue; |
|
|
|
|
|
}, |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget _temperatureField() { |
|
|
|
|
|
return TextFormField( |
|
|
|
|
|
keyboardType: TextInputType.numberWithOptions(decimal: true), |
|
|
|
|
|
inputFormatters: [ |
|
|
|
|
|
ThousandsFormatter( |
|
|
|
|
|
formatter: NumberFormat("#,###.##", "es"), allowFraction: true) |
|
|
|
|
|
], |
|
|
|
|
|
decoration: InputDecoration(labelText: "Nhiệt độ môi trường"), |
|
|
|
|
|
controller: _temperatureController, |
|
|
|
|
|
validator: (String value) { |
|
|
|
|
|
return Validators.validNumber(value, "Nhiệt độ môi trường"); |
|
|
|
|
|
}, |
|
|
|
|
|
onSaved: (newValue) { |
|
|
|
|
|
_environment.temperature = newValue; |
|
|
|
|
|
}, |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget _doField() { |
|
|
|
|
|
return TextFormField( |
|
|
|
|
|
keyboardType: TextInputType.numberWithOptions(decimal: true), |
|
|
|
|
|
inputFormatters: [ |
|
|
|
|
|
ThousandsFormatter( |
|
|
|
|
|
formatter: NumberFormat("#,###.##", "es"), allowFraction: true) |
|
|
|
|
|
], |
|
|
|
|
|
decoration: InputDecoration(labelText: "Độ ẩm"), |
|
|
|
|
|
controller: _doController, |
|
|
|
|
|
validator: (String value) { |
|
|
|
|
|
return Validators.validNumber(value, "Độ ẩm"); |
|
|
|
|
|
}, |
|
|
|
|
|
onSaved: (newValue) { |
|
|
|
|
|
_environment.dodo = newValue; |
|
|
|
|
|
}, |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget _llnField() { |
|
|
|
|
|
return TextFormField( |
|
|
|
|
|
keyboardType: TextInputType.numberWithOptions(decimal: true), |
|
|
|
|
|
inputFormatters: [ |
|
|
|
|
|
ThousandsFormatter( |
|
|
|
|
|
formatter: NumberFormat("#,###.##", "es"), allowFraction: true) |
|
|
|
|
|
], |
|
|
|
|
|
decoration: InputDecoration(labelText: "Lưu lượng nước"), |
|
|
|
|
|
controller: _llnController, |
|
|
|
|
|
validator: (String value) { |
|
|
|
|
|
return Validators.validNumber(value, "Lưu lượng nước"); |
|
|
|
|
|
}, |
|
|
|
|
|
onSaved: (newValue) { |
|
|
|
|
|
_environment.lln = newValue; |
|
|
|
|
|
}, |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_actionAppBar() { |
|
|
|
|
|
IconButton iconButton; |
|
|
|
|
|
if (1 == 1) { |
|
|
|
|
|
iconButton = IconButton( |
|
|
|
|
|
icon: Icon( |
|
|
|
|
|
Icons.done, |
|
|
|
|
|
color: Colors.black, |
|
|
|
|
|
), |
|
|
|
|
|
onPressed: () { |
|
|
|
|
|
FocusScopeNode currentFocus = FocusScope.of(context); |
|
|
|
|
|
if (!currentFocus.hasPrimaryFocus) { |
|
|
|
|
|
currentFocus.unfocus(); |
|
|
|
|
|
} |
|
|
|
|
|
_validateInputs(); |
|
|
|
|
|
}, |
|
|
|
|
|
); |
|
|
|
|
|
return <Widget>[iconButton]; |
|
|
|
|
|
} |
|
|
|
|
|
return <Widget>[Container()]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
|
Widget build(BuildContext context) => KeyboardDismisser( |
|
|
|
|
|
gestures: [ |
|
|
|
|
|
GestureType.onTap, |
|
|
|
|
|
GestureType.onPanUpdateDownDirection, |
|
|
|
|
|
], |
|
|
|
|
|
child: Scaffold( |
|
|
|
|
|
key: _scaffoldKey, |
|
|
|
|
|
appBar: AppBar( |
|
|
|
|
|
centerTitle: true, |
|
|
|
|
|
title: Text(plot_action_environment_update), |
|
|
|
|
|
actions: _actionAppBar()), |
|
|
|
|
|
body: KeyboardDismisser( |
|
|
|
|
|
child: MultiBlocProvider( |
|
|
|
|
|
providers: [ |
|
|
|
|
|
BlocProvider<ActionDetailBloc>( |
|
|
|
|
|
create: (context) => |
|
|
|
|
|
ActionDetailBloc(repository: Repository()) |
|
|
|
|
|
..add(FetchData( |
|
|
|
|
|
isNeedFetchData: widget.isEdit, |
|
|
|
|
|
apiActivity: ConstCommon.apiDetailEnvUpdate, |
|
|
|
|
|
activityId: widget.activityId))), |
|
|
|
|
|
BlocProvider<MediaHelperBloc>( |
|
|
|
|
|
create: (context) => |
|
|
|
|
|
MediaHelperBloc()..add(ChangeListMedia(items: [])), |
|
|
|
|
|
) |
|
|
|
|
|
], |
|
|
|
|
|
child: Form( |
|
|
|
|
|
key: _formKey, |
|
|
|
|
|
autovalidate: _autoValidate, |
|
|
|
|
|
child: SingleChildScrollView( |
|
|
|
|
|
padding: EdgeInsets.all(8.0), |
|
|
|
|
|
child: BlocConsumer<ActionDetailBloc, ActionDetailState>( |
|
|
|
|
|
listener: (context, state) async { |
|
|
|
|
|
if (state is ActionDetailFailure) { |
|
|
|
|
|
print("fail"); |
|
|
|
|
|
LoadingDialog.hideLoadingDialog(context); |
|
|
|
|
|
} else if (state is ActionDetailSuccess) { |
|
|
|
|
|
LoadingDialog.hideLoadingDialog(context); |
|
|
|
|
|
print("success"); |
|
|
|
|
|
print(state.item); |
|
|
|
|
|
_environment = Environment.fromJson(state.item); |
|
|
|
|
|
_environment.activityId = widget.activityId; |
|
|
|
|
|
_ecController.text = |
|
|
|
|
|
_environment.ec.formatStringToStringDecimal(); |
|
|
|
|
|
_phController.text = |
|
|
|
|
|
_environment.pH.formatStringToStringDecimal(); |
|
|
|
|
|
_ocddController.text = |
|
|
|
|
|
_environment.ocdd.formatStringToStringDecimal(); |
|
|
|
|
|
_temperatureController.text = _environment |
|
|
|
|
|
.temperature |
|
|
|
|
|
.formatStringToStringDecimal(); |
|
|
|
|
|
_doController.text = |
|
|
|
|
|
_environment.dodo.formatStringToStringDecimal(); |
|
|
|
|
|
_llnController.text = |
|
|
|
|
|
_environment.lln.formatStringToStringDecimal(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
executeTime = |
|
|
|
|
|
DateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") |
|
|
|
|
|
.parse(_environment.executeDate); |
|
|
|
|
|
} catch (_) {} |
|
|
|
|
|
executeTimeView = DateFormat("dd/MM/yyyy HH:mm") |
|
|
|
|
|
.format(executeTime); |
|
|
|
|
|
//Show media |
|
|
|
|
|
if (_environment.media != null) { |
|
|
|
|
|
await UtilAction.cacheFiles(_environment.media) |
|
|
|
|
|
.then((value) { |
|
|
|
|
|
print("then: ${value.length}"); |
|
|
|
|
|
BlocProvider.of<MediaHelperBloc>(context) |
|
|
|
|
|
.add(ChangeListMedia(items: value)); |
|
|
|
|
|
}).whenComplete(() { |
|
|
|
|
|
print("completed"); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} else if (state is ActionDetailInitial) { |
|
|
|
|
|
print("init"); |
|
|
|
|
|
} else if (state is ActionDetailLoading) { |
|
|
|
|
|
print("loading"); |
|
|
|
|
|
LoadingDialog.showLoadingDialog(context); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
builder: (context, state) { |
|
|
|
|
|
return Column( |
|
|
|
|
|
children: <Widget>[ |
|
|
|
|
|
Container( |
|
|
|
|
|
width: double.infinity, |
|
|
|
|
|
child: Text( |
|
|
|
|
|
"Ngày thực hiện", |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: Colors.black54, fontSize: 13.0), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
_btnExecuteTimePicker(), |
|
|
|
|
|
SizedBox( |
|
|
|
|
|
height: 8.0, |
|
|
|
|
|
), |
|
|
|
|
|
_ecField(), |
|
|
|
|
|
SizedBox( |
|
|
|
|
|
height: 8.0, |
|
|
|
|
|
), |
|
|
|
|
|
_phField(), |
|
|
|
|
|
SizedBox( |
|
|
|
|
|
height: 8.0, |
|
|
|
|
|
), |
|
|
|
|
|
_ocddField(), |
|
|
|
|
|
SizedBox( |
|
|
|
|
|
height: 8.0, |
|
|
|
|
|
), |
|
|
|
|
|
_temperatureField(), |
|
|
|
|
|
SizedBox( |
|
|
|
|
|
height: 8.0, |
|
|
|
|
|
), |
|
|
|
|
|
_doField(), |
|
|
|
|
|
SizedBox( |
|
|
|
|
|
height: 8.0, |
|
|
|
|
|
), |
|
|
|
|
|
_llnField(), |
|
|
|
|
|
BlocBuilder<MediaHelperBloc, MediaHelperState>( |
|
|
|
|
|
builder: (context, state) { |
|
|
|
|
|
if (state is MediaHelperSuccess) { |
|
|
|
|
|
return WidgetMediaPicker( |
|
|
|
|
|
currentItems: state.items, |
|
|
|
|
|
onChangeFiles: (filePaths) async { |
|
|
|
|
|
Get.find<ChangeFileController>() |
|
|
|
|
|
.addAllFile(filePaths); |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
return Center( |
|
|
|
|
|
child: CircularProgressIndicator()); |
|
|
|
|
|
} |
|
|
|
|
|
}), |
|
|
|
|
|
], |
|
|
|
|
|
); |
|
|
|
|
|
}, |
|
|
|
|
|
), |
|
|
|
|
|
)), |
|
|
|
|
|
)))); |
|
|
|
|
|
@override |
|
|
|
|
|
void dispose() { |
|
|
|
|
|
_ecController.dispose(); |
|
|
|
|
|
_phController.dispose(); |
|
|
|
|
|
_ocddController.dispose(); |
|
|
|
|
|
_temperatureController.dispose(); |
|
|
|
|
|
_doController.dispose(); |
|
|
|
|
|
_llnController.dispose(); |
|
|
|
|
|
super.dispose(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |