| @@ -0,0 +1,10 @@ | |||
| <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> | |||
| <path fill-rule="evenodd" clip-rule="evenodd" d="M12 3.75C12.4142 3.75 12.75 4.08579 12.75 4.5V7.5C12.75 7.91421 12.4142 8.25 12 8.25C11.5858 8.25 11.25 7.91421 11.25 7.5V4.5C11.25 4.08579 11.5858 3.75 12 3.75Z" fill="#EECE52"/> | |||
| <path fill-rule="evenodd" clip-rule="evenodd" d="M12 15.75C12.4142 15.75 12.75 16.0858 12.75 16.5V19.5C12.75 19.9142 12.4142 20.25 12 20.25C11.5858 20.25 11.25 19.9142 11.25 19.5V16.5C11.25 16.0858 11.5858 15.75 12 15.75Z" fill="#EECE52"/> | |||
| <path fill-rule="evenodd" clip-rule="evenodd" d="M6.16694 6.16718C6.45983 5.87429 6.9347 5.87429 7.2276 6.16718L9.3501 8.28968C9.64299 8.58257 9.64299 9.05745 9.3501 9.35034C9.0572 9.64323 8.58233 9.64323 8.28944 9.35034L6.16694 7.22784C5.87404 6.93495 5.87404 6.46007 6.16694 6.16718Z" fill="#EECE52"/> | |||
| <path fill-rule="evenodd" clip-rule="evenodd" d="M14.6498 14.6496C14.9427 14.3567 15.4176 14.3567 15.7105 14.6496L17.833 16.7721C18.1259 17.065 18.1259 17.5399 17.833 17.8328C17.5401 18.1257 17.0652 18.1257 16.7723 17.8328L14.6498 15.7103C14.357 15.4174 14.357 14.9425 14.6498 14.6496Z" fill="#EECE52"/> | |||
| <path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 12C3.75 11.5858 4.08579 11.25 4.5 11.25H7.5C7.91421 11.25 8.25 11.5858 8.25 12C8.25 12.4142 7.91421 12.75 7.5 12.75H4.5C4.08579 12.75 3.75 12.4142 3.75 12Z" fill="#EECE52"/> | |||
| <path fill-rule="evenodd" clip-rule="evenodd" d="M15.75 12C15.75 11.5858 16.0858 11.25 16.5 11.25H19.5C19.9142 11.25 20.25 11.5858 20.25 12C20.25 12.4142 19.9142 12.75 19.5 12.75H16.5C16.0858 12.75 15.75 12.4142 15.75 12Z" fill="#EECE52"/> | |||
| <path fill-rule="evenodd" clip-rule="evenodd" d="M9.3501 14.6496C9.64299 14.9425 9.64299 15.4174 9.3501 15.7103L7.2276 17.8328C6.9347 18.1257 6.45983 18.1257 6.16694 17.8328C5.87404 17.5399 5.87404 17.065 6.16694 16.7721L8.28944 14.6496C8.58233 14.3567 9.0572 14.3567 9.3501 14.6496Z" fill="#EECE52"/> | |||
| <path fill-rule="evenodd" clip-rule="evenodd" d="M17.833 6.16718C18.1259 6.46007 18.1259 6.93495 17.833 7.22784L15.7105 9.35034C15.4176 9.64323 14.9427 9.64323 14.6498 9.35034C14.357 9.05745 14.357 8.58257 14.6498 8.28968L16.7723 6.16718C17.0652 5.87429 17.5401 5.87429 17.833 6.16718Z" fill="#EECE52"/> | |||
| </svg> | |||
| @@ -0,0 +1,6 @@ | |||
| <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> | |||
| <path fill-rule="evenodd" clip-rule="evenodd" d="M11.667 4.75893C11.6667 4.75904 11.6665 4.75915 11.6663 4.75926L5.66795 7.75843L5.66629 7.75926C5.54133 7.82135 5.43618 7.91707 5.36264 8.03565C5.28913 8.15419 5.25014 8.29088 5.25004 8.43037C5.25004 8.43032 5.25004 8.43041 5.25004 8.43037V15.5753C5.24906 15.7151 5.28715 15.8524 5.36004 15.9716C5.43281 16.0907 5.53735 16.1871 5.6619 16.25C5.6617 16.2499 5.66211 16.2501 5.6619 16.25L11.6604 19.2493C11.7646 19.3014 11.8798 19.3287 11.9963 19.3287C12.1128 19.3287 12.2277 19.3015 12.3319 19.2494L18.3321 16.2493L18.3338 16.2485C18.4587 16.1864 18.5639 16.0907 18.6374 15.9721C18.711 15.8535 18.75 15.7167 18.75 15.5772V8.43051C18.75 8.29098 18.711 8.15423 18.6374 8.03565C18.5639 7.91707 18.4587 7.82135 18.3338 7.75926L18.3321 7.75843L12.3338 4.75926C12.3336 4.75915 12.3333 4.75904 12.3331 4.75893C12.2296 4.70761 12.1156 4.68091 12 4.68091C11.8845 4.68091 11.7705 4.70761 11.667 4.75893ZM12.6675 4.08761L13.0013 3.41596C12.6902 3.26136 12.3475 3.18091 12 3.18091C11.6526 3.18091 11.3099 3.26136 10.9988 3.41596L10.9971 3.41679L4.99879 6.41596C4.99848 6.41612 4.99817 6.41627 4.99786 6.41642C4.6234 6.60271 4.30827 6.88969 4.08785 7.24514C3.86725 7.60089 3.75026 8.01112 3.75004 8.42971L3.75004 15.5678C3.74766 15.9861 3.86195 16.3968 4.08012 16.7538C4.29878 17.1116 4.61307 17.4012 4.98755 17.5899L4.98963 17.5909L10.9894 20.5908C11.302 20.7472 11.6467 20.8287 11.9963 20.8287C12.3458 20.8287 12.6904 20.7473 13.0029 20.5909C13.003 20.5909 13.0029 20.591 13.0029 20.5909L19.0013 17.5918C19.0015 17.5916 19.0018 17.5915 19.002 17.5914C19.3766 17.4051 19.6918 17.1181 19.9122 16.7626C20.1328 16.4068 20.2498 15.9966 20.25 15.578V8.43011C20.2498 8.01152 20.1328 7.60089 19.9122 7.24514C19.6918 6.8897 19.3767 6.60273 19.0022 6.41644C19.0019 6.41628 19.0016 6.41612 19.0013 6.41596L13.0029 3.41679L12.6675 4.08761Z" fill="#EECE52"/> | |||
| <path fill-rule="evenodd" clip-rule="evenodd" d="M4.06922 7.2847C4.25446 6.91422 4.70496 6.76405 5.07545 6.94929L12 10.4116L18.9246 6.94929C19.2951 6.76405 19.7456 6.91422 19.9309 7.2847C20.1161 7.65519 19.9659 8.10569 19.5954 8.29093L12.3354 11.9209C12.1243 12.0265 11.8758 12.0265 11.6646 11.9209L4.40463 8.29093C4.03414 8.10569 3.88397 7.65519 4.06922 7.2847Z" fill="#EECE52"/> | |||
| <path fill-rule="evenodd" clip-rule="evenodd" d="M12 10.5001C12.4143 10.5001 12.75 10.8359 12.75 11.2501V20.0701C12.75 20.4843 12.4143 20.8201 12 20.8201C11.5858 20.8201 11.25 20.4843 11.25 20.0701V11.2501C11.25 10.8359 11.5858 10.5001 12 10.5001Z" fill="#EECE52"/> | |||
| <path fill-rule="evenodd" clip-rule="evenodd" d="M7.57922 5.2897C7.76446 4.91922 8.21496 4.76905 8.58545 4.95429L16.0854 8.70429C16.4559 8.88953 16.6061 9.34004 16.4209 9.71052C16.2356 10.081 15.7851 10.2312 15.4146 10.0459L7.91463 6.29593C7.54414 6.11069 7.39397 5.66019 7.57922 5.2897Z" fill="#EECE52"/> | |||
| </svg> | |||
| @@ -0,0 +1,7 @@ | |||
| <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> | |||
| <g clip-path="url(#clip0)"> | |||
| <path fill-rule="evenodd" clip-rule="evenodd" d="M8.25 18.75C8.25 17.9216 8.92157 17.25 9.75 17.25C10.5784 17.25 11.25 17.9216 11.25 18.75C11.25 19.5784 10.5784 20.25 9.75 20.25C8.92157 20.25 8.25 19.5784 8.25 18.75Z" fill="#EECE52"/> | |||
| <path fill-rule="evenodd" clip-rule="evenodd" d="M16.5 18.75C16.5 17.9216 17.1716 17.25 18 17.25C18.8284 17.25 19.5 17.9216 19.5 18.75C19.5 19.5784 18.8284 20.25 18 20.25C17.1716 20.25 16.5 19.5784 16.5 18.75Z" fill="#EECE52"/> | |||
| <path fill-rule="evenodd" clip-rule="evenodd" d="M3 3.75C3 3.33579 3.33579 3 3.75 3H6.75C7.10747 3 7.41526 3.25229 7.48541 3.60281L8.11532 6.75H20.25C20.4735 6.75 20.6854 6.8497 20.8279 7.02192C20.9704 7.19414 21.0286 7.42093 20.9867 7.6405L19.7857 13.9386C19.6828 14.4566 19.401 14.9218 18.9896 15.2529C18.5803 15.5824 18.0687 15.7582 17.5435 15.75H10.2665C9.74128 15.7582 9.22965 15.5824 8.82036 15.2529C8.40919 14.922 8.12748 14.4569 8.0245 13.9392C8.02445 13.939 8.02454 13.9395 8.0245 13.9392L6.77159 7.6794C6.76651 7.6587 6.76229 7.63765 6.75896 7.61631L6.13524 4.5H3.75C3.33579 4.5 3 4.16421 3 3.75ZM8.41555 8.25L9.49563 13.6464C9.52992 13.819 9.62385 13.9741 9.76096 14.0845C9.89807 14.1949 10.0696 14.2535 10.2456 14.2501L10.26 14.25H17.55L17.5644 14.2501C17.7404 14.2535 17.9119 14.1949 18.049 14.0845C18.1855 13.9746 18.2792 13.8205 18.3139 13.6488L19.3435 8.25H8.41555Z" fill="#EECE52"/> | |||
| </g> | |||
| </svg> | |||
| @@ -3,10 +3,14 @@ import 'dart:convert'; | |||
| import 'package:farm_tpf/custom_model/Harvest.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/app_bar_widget.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/bloc/media_helper_bloc.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/button_icon_widget.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/button_widget.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/widget_field_time_picker.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/custom_widgets/widget_text_field_description.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/bloc/action_detail_bloc.dart'; | |||
| @@ -16,6 +20,7 @@ import 'package:farm_tpf/presentation/screens/actions/sell/sc_edit_action_sell.d | |||
| 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_icons.dart'; | |||
| import 'package:farm_tpf/utils/const_string.dart'; | |||
| import 'package:farm_tpf/utils/const_style.dart'; | |||
| import 'package:farm_tpf/utils/pref.dart'; | |||
| @@ -167,14 +172,11 @@ class _EditActionHarvestScreenState extends State<EditActionHarvestScreen> { | |||
| } | |||
| Widget _descriptionField() { | |||
| return TextFormField( | |||
| keyboardType: TextInputType.text, | |||
| decoration: InputDecoration(labelText: "Ghi chú"), | |||
| controller: _descriptionController, | |||
| onSaved: (newValue) { | |||
| _harvest.description = newValue; | |||
| }, | |||
| ); | |||
| return TextFieldDescriptionWidget( | |||
| controller: _descriptionController, | |||
| onSaved: (newValue) { | |||
| _harvest.description = newValue; | |||
| }); | |||
| } | |||
| Widget _executeByField() { | |||
| @@ -187,27 +189,6 @@ class _EditActionHarvestScreenState extends State<EditActionHarvestScreen> { | |||
| ); | |||
| } | |||
| _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: [ | |||
| @@ -215,11 +196,22 @@ class _EditActionHarvestScreenState extends State<EditActionHarvestScreen> { | |||
| GestureType.onPanUpdateDownDirection, | |||
| ], | |||
| child: Scaffold( | |||
| backgroundColor: Colors.white, | |||
| key: _scaffoldKey, | |||
| appBar: AppBar( | |||
| centerTitle: true, | |||
| title: Text(plot_action_harvest), | |||
| actions: _actionAppBar()), | |||
| appBar: AppBarWidget( | |||
| isBack: true, | |||
| action: InkWell( | |||
| child: Text( | |||
| 'Huỷ', | |||
| style: TextStyle( | |||
| color: Colors.red, fontWeight: FontWeight.normal), | |||
| ), | |||
| onTap: () { | |||
| if (Get.isSnackbarOpen) Get.back(); | |||
| Get.back(); | |||
| }, | |||
| ), | |||
| ), | |||
| body: KeyboardDismisser( | |||
| child: MultiBlocProvider( | |||
| providers: [ | |||
| @@ -238,195 +230,197 @@ class _EditActionHarvestScreenState extends State<EditActionHarvestScreen> { | |||
| 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) { | |||
| LoadingDialog.hideLoadingDialog(context); | |||
| } else if (state is ActionDetailSuccess) { | |||
| LoadingDialog.hideLoadingDialog(context); | |||
| print(state.item); | |||
| _harvest = Harvest.fromJson(state.item); | |||
| _harvest.activityId = widget.activityId; | |||
| _l1Controller.text = _harvest.collectedQuantityLv1 | |||
| .formatNumtoStringDecimal(); | |||
| _l2Controller.text = _harvest.collectedQuantityLv2 | |||
| .formatNumtoStringDecimal(); | |||
| _l3Controller.text = _harvest.collectedQuantityLv3 | |||
| .formatNumtoStringDecimal(); | |||
| _removedQuantityController.text = _harvest | |||
| .removedQuantity | |||
| .formatNumtoStringDecimal(); | |||
| _descriptionController.text = | |||
| _harvest.description ?? ""; | |||
| _executeByController.text = _harvest.executeBy; | |||
| child: SafeArea( | |||
| child: SingleChildScrollView( | |||
| child: | |||
| BlocConsumer<ActionDetailBloc, ActionDetailState>( | |||
| listener: (context, state) async { | |||
| if (state is ActionDetailFailure) { | |||
| LoadingDialog.hideLoadingDialog(context); | |||
| } else if (state is ActionDetailSuccess) { | |||
| LoadingDialog.hideLoadingDialog(context); | |||
| print(state.item); | |||
| _harvest = Harvest.fromJson(state.item); | |||
| _harvest.activityId = widget.activityId; | |||
| _l1Controller.text = _harvest.collectedQuantityLv1 | |||
| .formatNumtoStringDecimal(); | |||
| _l2Controller.text = _harvest.collectedQuantityLv2 | |||
| .formatNumtoStringDecimal(); | |||
| _l3Controller.text = _harvest.collectedQuantityLv3 | |||
| .formatNumtoStringDecimal(); | |||
| _removedQuantityController.text = _harvest | |||
| .removedQuantity | |||
| .formatNumtoStringDecimal(); | |||
| _descriptionController.text = | |||
| _harvest.description ?? ""; | |||
| _executeByController.text = _harvest.executeBy; | |||
| Get.find<ChangeDateTimePicker>().change(_harvest | |||
| .executeDate | |||
| .convertStringServerDateTimeToLocalDateTime()); | |||
| //Show media | |||
| if (Validators.stringNotNullOrEmpty( | |||
| _harvest.media)) { | |||
| BlocProvider.of<MediaHelperBloc>(context).add( | |||
| ChangeListMedia( | |||
| items: UtilAction.convertFilePathToMedia( | |||
| _harvest.media))); | |||
| Get.find<ChangeDateTimePicker>().change(_harvest | |||
| .executeDate | |||
| .convertStringServerDateTimeToLocalDateTime()); | |||
| //Show media | |||
| if (Validators.stringNotNullOrEmpty( | |||
| _harvest.media)) { | |||
| BlocProvider.of<MediaHelperBloc>(context).add( | |||
| ChangeListMedia( | |||
| items: | |||
| UtilAction.convertFilePathToMedia( | |||
| _harvest.media))); | |||
| } | |||
| } else if (state is ActionDetailInitial) { | |||
| } else if (state is ActionDetailLoading) { | |||
| LoadingDialog.showLoadingDialog(context); | |||
| } | |||
| } else if (state is ActionDetailInitial) { | |||
| } else if (state is ActionDetailLoading) { | |||
| 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, | |||
| ), | |||
| _l1Field(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| _l2Field(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| _l3Field(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| _removedQuantityField(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| _descriptionField(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| _executeByField(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| BlocBuilder<MediaHelperBloc, MediaHelperState>( | |||
| builder: (context, state) { | |||
| if (state is MediaHelperSuccess) { | |||
| return WidgetMediaPicker( | |||
| currentItems: state.items, | |||
| onChangeFiles: (newPathFiles, | |||
| deletePathFiles) async { | |||
| Get.find<ChangeFileController>().change( | |||
| newPathFiles, deletePathFiles); | |||
| }); | |||
| } else { | |||
| return Center( | |||
| child: CircularProgressIndicator()); | |||
| } | |||
| }), | |||
| Row( | |||
| mainAxisAlignment: | |||
| MainAxisAlignment.spaceBetween, | |||
| children: [ | |||
| SizedBox( | |||
| width: Get.width / 2 - 16, | |||
| child: FlatButton( | |||
| padding: EdgeInsets.all(14), | |||
| shape: RoundedRectangleBorder( | |||
| borderRadius: | |||
| new BorderRadius.circular(8.0)), | |||
| color: Colors.lightGreen, | |||
| onPressed: () { | |||
| if (_harvest.id != null) { | |||
| Get.to(EditActionHarvestProcessScreen( | |||
| cropId: widget.cropId, | |||
| harvestId: _harvest.id, | |||
| )); | |||
| } else { | |||
| Get.to(EditActionHarvestProcessScreen( | |||
| cropId: widget.cropId)); | |||
| } | |||
| }, | |||
| child: Text( | |||
| plot_action_harvest_process, | |||
| }, | |||
| builder: (context, state) { | |||
| return Column( | |||
| children: [ | |||
| Padding( | |||
| padding: const EdgeInsets.all(8.0), | |||
| child: Column( | |||
| crossAxisAlignment: | |||
| CrossAxisAlignment.start, | |||
| children: <Widget>[ | |||
| Text( | |||
| plot_action_harvest, | |||
| style: TextStyle( | |||
| color: Colors.white, fontSize: 14), | |||
| fontWeight: FontWeight.w500, | |||
| fontSize: 22), | |||
| ), | |||
| ), | |||
| ), | |||
| SizedBox( | |||
| width: Get.width / 2 - 16, | |||
| child: FlatButton( | |||
| padding: EdgeInsets.all(14), | |||
| shape: RoundedRectangleBorder( | |||
| borderRadius: | |||
| new BorderRadius.circular(8.0)), | |||
| color: Colors.lightGreen, | |||
| onPressed: () { | |||
| if (_harvest.id != null) { | |||
| Get.to(EditActionPackingScreen( | |||
| cropId: widget.cropId, | |||
| harvestId: _harvest.id, | |||
| )); | |||
| } else { | |||
| Get.to(EditActionPackingScreen( | |||
| cropId: widget.cropId)); | |||
| } | |||
| }, | |||
| child: Text( | |||
| plot_action_packing, | |||
| style: TextStyle( | |||
| color: Colors.white, fontSize: 14), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| ), | |||
| ) | |||
| ], | |||
| ), | |||
| SizedBox( | |||
| height: 8, | |||
| ), | |||
| Row( | |||
| mainAxisAlignment: MainAxisAlignment.start, | |||
| children: [ | |||
| SizedBox( | |||
| width: Get.width / 2 - 16, | |||
| child: FlatButton( | |||
| padding: EdgeInsets.all(14), | |||
| shape: RoundedRectangleBorder( | |||
| borderRadius: | |||
| new BorderRadius.circular(8.0)), | |||
| color: Colors.lightGreen, | |||
| 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, | |||
| ), | |||
| _l1Field(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| _l2Field(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| _l3Field(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| _removedQuantityField(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| _descriptionField(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| _executeByField(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| ], | |||
| ), | |||
| ), | |||
| Container( | |||
| width: double.infinity, | |||
| height: 16, | |||
| color: Colors.grey[200], | |||
| ), | |||
| BlocBuilder<MediaHelperBloc, MediaHelperState>( | |||
| builder: (context, state) { | |||
| if (state is MediaHelperSuccess) { | |||
| return WidgetMediaPicker( | |||
| currentItems: state.items, | |||
| onChangeFiles: (newPathFiles, | |||
| deletePathFiles) async { | |||
| Get.find<ChangeFileController>() | |||
| .change(newPathFiles, | |||
| deletePathFiles); | |||
| }); | |||
| } else { | |||
| return Center( | |||
| child: CircularProgressIndicator()); | |||
| } | |||
| }), | |||
| Container( | |||
| width: double.infinity, | |||
| height: 16, | |||
| color: Colors.grey[200], | |||
| ), | |||
| ButtonIconWidget( | |||
| leadingIcon: AppIcons.icHarvestProcess, | |||
| trailingIcon: AppIcons.icArrowRight, | |||
| title: plot_action_harvest_process, | |||
| onTap: () { | |||
| if (_harvest.id != null) { | |||
| Get.to(EditActionHarvestProcessScreen( | |||
| cropId: widget.cropId, | |||
| harvestId: _harvest.id, | |||
| )); | |||
| } else { | |||
| Get.to(EditActionHarvestProcessScreen( | |||
| cropId: widget.cropId)); | |||
| } | |||
| }), | |||
| ButtonIconWidget( | |||
| leadingIcon: AppIcons.icPacking, | |||
| trailingIcon: AppIcons.icArrowRight, | |||
| title: plot_action_packing, | |||
| onTap: () { | |||
| if (_harvest.id != null) { | |||
| Get.to(EditActionPackingScreen( | |||
| cropId: widget.cropId, | |||
| harvestId: _harvest.id, | |||
| )); | |||
| } else { | |||
| Get.to(EditActionPackingScreen( | |||
| cropId: widget.cropId)); | |||
| } | |||
| }), | |||
| ButtonIconWidget( | |||
| leadingIcon: AppIcons.icSell, | |||
| trailingIcon: AppIcons.icArrowRight, | |||
| title: plot_action_sell, | |||
| onTap: () { | |||
| if (_harvest.id != null) { | |||
| Get.to(EditActionSellScreen( | |||
| cropId: widget.cropId, | |||
| harvestId: _harvest.id, | |||
| )); | |||
| } else { | |||
| Get.to(EditActionSellScreen( | |||
| cropId: widget.cropId)); | |||
| } | |||
| }), | |||
| SizedBox( | |||
| height: 16, | |||
| ), | |||
| Padding( | |||
| padding: const EdgeInsets.all(8.0), | |||
| child: ButtonWidget( | |||
| title: 'CẬP NHẬT', | |||
| onPressed: () { | |||
| if (_harvest.id != null) { | |||
| Get.to(EditActionSellScreen( | |||
| cropId: widget.cropId, | |||
| harvestId: _harvest.id, | |||
| )); | |||
| } else { | |||
| Get.to(EditActionSellScreen( | |||
| cropId: widget.cropId)); | |||
| FocusScopeNode currentFocus = | |||
| FocusScope.of(context); | |||
| if (!currentFocus.hasPrimaryFocus) { | |||
| currentFocus.unfocus(); | |||
| } | |||
| }, | |||
| child: Text( | |||
| plot_action_sell, | |||
| style: TextStyle( | |||
| color: Colors.white, fontSize: 14), | |||
| ), | |||
| ), | |||
| ) | |||
| ], | |||
| ), | |||
| ], | |||
| ); | |||
| }, | |||
| _validateInputs(); | |||
| }), | |||
| ), | |||
| ], | |||
| ); | |||
| }, | |||
| ), | |||
| ), | |||
| )), | |||
| )))); | |||
| @@ -4,24 +4,24 @@ import 'package:farm_tpf/custom_model/Other.dart'; | |||
| import 'package:farm_tpf/data/api/app_exception.dart'; | |||
| import 'package:farm_tpf/data/repository/repository.dart'; | |||
| import 'package:farm_tpf/models/index.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/app_bar_widget.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/bloc/media_helper_bloc.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/button_widget.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/widget_field_time_picker.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/custom_widgets/widget_text_field_description.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/bloc/action_detail_bloc.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/other/bloc_get_action_type.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_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:farm_tpf/utils/formatter.dart'; | |||
| @@ -164,10 +164,8 @@ class _EditActionOtherScreenState extends State<EditActionOtherScreen> { | |||
| ); | |||
| } | |||
| Widget _desciptionField() { | |||
| return TextFormField( | |||
| keyboardType: TextInputType.text, | |||
| decoration: InputDecoration(labelText: "Ghi chú"), | |||
| Widget _descriptionField() { | |||
| return TextFieldDescriptionWidget( | |||
| controller: _descriptionController, | |||
| onSaved: (newValue) { | |||
| _other.description = newValue; | |||
| @@ -185,27 +183,6 @@ class _EditActionOtherScreenState extends State<EditActionOtherScreen> { | |||
| ); | |||
| } | |||
| _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: [ | |||
| @@ -213,11 +190,22 @@ class _EditActionOtherScreenState extends State<EditActionOtherScreen> { | |||
| GestureType.onPanUpdateDownDirection, | |||
| ], | |||
| child: Scaffold( | |||
| backgroundColor: Colors.white, | |||
| key: _scaffoldKey, | |||
| appBar: AppBar( | |||
| centerTitle: true, | |||
| title: Text(plot_action_other), | |||
| actions: _actionAppBar()), | |||
| appBar: AppBarWidget( | |||
| isBack: true, | |||
| action: InkWell( | |||
| child: Text( | |||
| 'Huỷ', | |||
| style: TextStyle( | |||
| color: Colors.red, fontWeight: FontWeight.normal), | |||
| ), | |||
| onTap: () { | |||
| if (Get.isSnackbarOpen) Get.back(); | |||
| Get.back(); | |||
| }, | |||
| ), | |||
| ), | |||
| body: KeyboardDismisser( | |||
| child: MultiBlocProvider( | |||
| providers: [ | |||
| @@ -236,91 +224,133 @@ class _EditActionOtherScreenState extends State<EditActionOtherScreen> { | |||
| 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) { | |||
| LoadingDialog.hideLoadingDialog(context); | |||
| } else if (state is ActionDetailSuccess) { | |||
| LoadingDialog.hideLoadingDialog(context); | |||
| _other = Other.fromJson(state.item); | |||
| _other.activityId = widget.activityId; | |||
| _descriptionController.text = | |||
| _other.description ?? ""; | |||
| _executeByController.text = _other.createdByName; | |||
| child: SafeArea( | |||
| child: SingleChildScrollView( | |||
| child: | |||
| BlocConsumer<ActionDetailBloc, ActionDetailState>( | |||
| listener: (context, state) async { | |||
| if (state is ActionDetailFailure) { | |||
| LoadingDialog.hideLoadingDialog(context); | |||
| } else if (state is ActionDetailSuccess) { | |||
| LoadingDialog.hideLoadingDialog(context); | |||
| _other = Other.fromJson(state.item); | |||
| _other.activityId = widget.activityId; | |||
| _descriptionController.text = | |||
| _other.description ?? ""; | |||
| _executeByController.text = _other.createdByName; | |||
| //select harvest | |||
| getActionTypeBloc.getActionTypes((data) { | |||
| _actionTypes = data; | |||
| for (var item in _actionTypes) { | |||
| if (item.name == _other.activityTypeName) { | |||
| _actionType = item; | |||
| break; | |||
| //select harvest | |||
| getActionTypeBloc.getActionTypes((data) { | |||
| _actionTypes = data; | |||
| for (var item in _actionTypes) { | |||
| if (item.name == _other.activityTypeName) { | |||
| _actionType = item; | |||
| break; | |||
| } | |||
| } | |||
| } | |||
| }, (err) {}); | |||
| Get.find<ChangeDateTimePicker>().change(_other | |||
| .executeDate | |||
| .convertStringServerDateTimeToLocalDateTime()); | |||
| }, (err) {}); | |||
| Get.find<ChangeDateTimePicker>().change(_other | |||
| .executeDate | |||
| .convertStringServerDateTimeToLocalDateTime()); | |||
| //Show media | |||
| if (Validators.stringNotNullOrEmpty(_other.media)) { | |||
| BlocProvider.of<MediaHelperBloc>(context).add( | |||
| ChangeListMedia( | |||
| items: UtilAction.convertFilePathToMedia( | |||
| _other.media))); | |||
| //Show media | |||
| if (Validators.stringNotNullOrEmpty( | |||
| _other.media)) { | |||
| BlocProvider.of<MediaHelperBloc>(context).add( | |||
| ChangeListMedia( | |||
| items: | |||
| UtilAction.convertFilePathToMedia( | |||
| _other.media))); | |||
| } | |||
| } else if (state is ActionDetailInitial) { | |||
| } else if (state is ActionDetailLoading) { | |||
| LoadingDialog.showLoadingDialog(context); | |||
| } | |||
| } else if (state is ActionDetailInitial) { | |||
| } else if (state is ActionDetailLoading) { | |||
| 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), | |||
| }, | |||
| builder: (context, state) { | |||
| return Column( | |||
| children: [ | |||
| Padding( | |||
| padding: const EdgeInsets.all(8.0), | |||
| child: Column( | |||
| crossAxisAlignment: | |||
| CrossAxisAlignment.start, | |||
| children: <Widget>[ | |||
| Text( | |||
| plot_action_other, | |||
| style: TextStyle( | |||
| fontWeight: FontWeight.w500, | |||
| fontSize: 22), | |||
| ), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| 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, | |||
| ), | |||
| _dropdownAcionTypes(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| _descriptionField(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| _executeByField(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| ], | |||
| ), | |||
| ), | |||
| ), | |||
| _btnExecuteTimePicker(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| _dropdownAcionTypes(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| _desciptionField(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| _executeByField(), | |||
| SizedBox( | |||
| height: 8.0, | |||
| ), | |||
| BlocBuilder<MediaHelperBloc, MediaHelperState>( | |||
| builder: (context, state) { | |||
| if (state is MediaHelperSuccess) { | |||
| return WidgetMediaPicker( | |||
| currentItems: state.items, | |||
| onChangeFiles: (newPathFiles, | |||
| deletePathFiles) async { | |||
| Get.find<ChangeFileController>().change( | |||
| newPathFiles, deletePathFiles); | |||
| }); | |||
| } else { | |||
| return Center( | |||
| child: CircularProgressIndicator()); | |||
| } | |||
| }), | |||
| ], | |||
| ); | |||
| }, | |||
| Container( | |||
| width: double.infinity, | |||
| height: 16, | |||
| color: Colors.grey[200], | |||
| ), | |||
| BlocBuilder<MediaHelperBloc, MediaHelperState>( | |||
| builder: (context, state) { | |||
| if (state is MediaHelperSuccess) { | |||
| return WidgetMediaPicker( | |||
| currentItems: state.items, | |||
| onChangeFiles: (newPathFiles, | |||
| deletePathFiles) async { | |||
| Get.find<ChangeFileController>() | |||
| .change(newPathFiles, | |||
| deletePathFiles); | |||
| }); | |||
| } else { | |||
| return Center( | |||
| child: CircularProgressIndicator()); | |||
| } | |||
| }), | |||
| Padding( | |||
| padding: const EdgeInsets.all(8.0), | |||
| child: ButtonWidget( | |||
| title: 'CẬP NHẬT', | |||
| onPressed: () { | |||
| FocusScopeNode currentFocus = | |||
| FocusScope.of(context); | |||
| if (!currentFocus.hasPrimaryFocus) { | |||
| currentFocus.unfocus(); | |||
| } | |||
| _validateInputs(); | |||
| }), | |||
| ), | |||
| ], | |||
| ); | |||
| }, | |||
| ), | |||
| ), | |||
| )), | |||
| )))); | |||
| @@ -12,4 +12,7 @@ class AppIcons { | |||
| static const icSecurity = baseAssets + 'ic_security.svg'; | |||
| static const icArrowRight = baseAssets + 'ic_arrow_right.svg'; | |||
| static const icLogout = baseAssets + 'ic_logout.svg'; | |||
| static const icHarvestProcess = baseAssets + 'ic_harvest_process.svg'; | |||
| static const icPacking = baseAssets + 'ic_packing.svg'; | |||
| static const icSell = baseAssets + 'ic_sell.svg'; | |||
| } | |||