| 471e09183e20ec9c20cca9b580fecc10 | |||||
| d91c957b2422e26116533c8dae89710a |
| elevation: 0, | elevation: 0, | ||||
| centerTitle: false, | centerTitle: false, | ||||
| title: isBack | title: isBack | ||||
| ? InkWell( | |||||
| child: Row( | |||||
| mainAxisSize: MainAxisSize.min, | |||||
| children: [ | |||||
| Icon( | |||||
| Icons.keyboard_arrow_left, | |||||
| color: AppColors.YELLOW, | |||||
| size: 35, | |||||
| ), | |||||
| Text( | |||||
| 'Quay lại', | |||||
| maxLines: 1, | |||||
| style: TextStyle( | |||||
| ? Row( | |||||
| mainAxisSize: MainAxisSize.min, | |||||
| children: [ | |||||
| InkWell( | |||||
| onTap: () { | |||||
| if (Get.isSnackbarOpen) Get.back(); | |||||
| Get.back(); | |||||
| }, | |||||
| child: Row( | |||||
| children: [ | |||||
| Icon( | |||||
| Icons.keyboard_arrow_left, | |||||
| color: AppColors.YELLOW, | color: AppColors.YELLOW, | ||||
| fontWeight: FontWeight.normal), | |||||
| size: 35, | |||||
| ), | |||||
| Text( | |||||
| 'Quay lại', | |||||
| maxLines: 1, | |||||
| style: TextStyle( | |||||
| color: AppColors.YELLOW, | |||||
| fontWeight: FontWeight.normal), | |||||
| ), | |||||
| ], | |||||
| ), | ), | ||||
| SizedBox(width: 4), | |||||
| Expanded( | |||||
| child: Align( | |||||
| alignment: Alignment.centerRight, | |||||
| child: action ?? SizedBox(), | |||||
| )) | |||||
| ], | |||||
| ), | |||||
| onTap: () { | |||||
| if (Get.isSnackbarOpen) Get.back(); | |||||
| Get.back(); | |||||
| }, | |||||
| ), | |||||
| Expanded(child: Container()), | |||||
| Align( | |||||
| alignment: Alignment.centerRight, | |||||
| child: action ?? SizedBox(), | |||||
| ) | |||||
| ], | |||||
| ) | ) | ||||
| : SizedBox(), | : SizedBox(), | ||||
| automaticallyImplyLeading: false, | automaticallyImplyLeading: false, |
| import 'package:farm_tpf/presentation/custom_widgets/bloc/media_helper_bloc.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/button_widget.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/dropdown_supply_widget.dart'; | import 'package:farm_tpf/presentation/custom_widgets/dropdown_supply_widget.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; | |||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_action_field_date.dart'; | import 'package:farm_tpf/presentation/custom_widgets/widget_action_field_date.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_field_time_picker.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_loading.dart'; | ||||
| } | } | ||||
| } | } | ||||
| void showDataWhenEdit() { | |||||
| void showDataWhenEdit(BuildContext context) { | |||||
| //Show media | //Show media | ||||
| if (Validators.stringNotNullOrEmpty(_requestActivity.media)) { | |||||
| BlocProvider.of<MediaHelperBloc>(context).add(ChangeListMedia( | |||||
| items: UtilAction.convertFilePathToMedia(_requestActivity.media))); | |||||
| try { | |||||
| if (Validators.stringNotNullOrEmpty(_requestActivity.media)) { | |||||
| BlocProvider.of<MediaHelperBloc>(context).add(ChangeListMedia( | |||||
| items: UtilAction.convertFilePathToMedia(_requestActivity.media))); | |||||
| } | |||||
| } catch (e) { | |||||
| print(e); | |||||
| } | } | ||||
| SchedulerBinding.instance.addPostFrameCallback((_) { | SchedulerBinding.instance.addPostFrameCallback((_) { | ||||
| if (widget.activityType == 'ACTIVE_TYPE_PLANTING' || | if (widget.activityType == 'ACTIVE_TYPE_PLANTING' || | ||||
| widget.activityType == 'ACTIVE_TYPE_FERTILIZE' || | widget.activityType == 'ACTIVE_TYPE_FERTILIZE' || | ||||
| child: Form( | child: Form( | ||||
| key: _formKey, | key: _formKey, | ||||
| child: SafeArea( | child: SafeArea( | ||||
| child: SingleChildScrollView( | |||||
| child: BlocBuilder<ActionUiCubit, ActionUiState>( | |||||
| builder: (context, state) { | |||||
| if (state is ActionUiLoading) { | |||||
| print('loading...'); | |||||
| return Center(child: CircularProgressIndicator()); | |||||
| } else if (state is ActionUiSuccess) { | |||||
| _actionUIForm = state.actionUIForm; | |||||
| _requestActivity = state.activityDetail; | |||||
| child: BlocBuilder<ActionUiCubit, ActionUiState>( | |||||
| builder: (context, state) { | |||||
| if (state is ActionUiLoading) { | |||||
| print('loading...'); | |||||
| return Center( | |||||
| child: LoadingListPage(), | |||||
| ); | |||||
| } else if (state is ActionUiSuccess) { | |||||
| _actionUIForm = state.actionUIForm; | |||||
| _requestActivity = state.activityDetail; | |||||
| //CREATE UI | |||||
| _actionUIForm.objectParameterDTOList | |||||
| .forEach((element) { | |||||
| //generate controller | |||||
| if (element.tbControlTypeName == 'text' || | |||||
| element.tbControlTypeName == 'number' || | |||||
| element.tbControlTypeName == 'textarea') { | |||||
| var textEditingController = | |||||
| new TextEditingController(); | |||||
| textFieldControllers.putIfAbsent( | |||||
| element.id.toString(), | |||||
| () => textEditingController); | |||||
| } | |||||
| // generate value each parameter | |||||
| valueObjects.putIfAbsent( | |||||
| element.id.toString(), () => ''); | |||||
| }); | |||||
| //SHOW EDIT DATA | |||||
| if (widget.isEdit) { | |||||
| showDataWhenEdit(); | |||||
| //CREATE UI | |||||
| _actionUIForm.objectParameterDTOList | |||||
| .forEach((element) { | |||||
| //generate controller | |||||
| if (element.tbControlTypeName == 'text' || | |||||
| element.tbControlTypeName == 'number' || | |||||
| element.tbControlTypeName == 'textarea') { | |||||
| var textEditingController = | |||||
| new TextEditingController(); | |||||
| textFieldControllers.putIfAbsent( | |||||
| element.id.toString(), | |||||
| () => textEditingController); | |||||
| } | } | ||||
| // generate value each parameter | |||||
| valueObjects.putIfAbsent( | |||||
| element.id.toString(), () => ''); | |||||
| }); | |||||
| //SHOW EDIT DATA | |||||
| if (widget.isEdit) { | |||||
| showDataWhenEdit(context); | |||||
| } | |||||
| return Column( | |||||
| return SingleChildScrollView( | |||||
| child: Column( | |||||
| children: [ | children: [ | ||||
| Padding( | Padding( | ||||
| padding: const EdgeInsets.all(8.0), | padding: const EdgeInsets.all(8.0), | ||||
| }), | }), | ||||
| ), | ), | ||||
| ], | ], | ||||
| ); | |||||
| } else if (state is ActionUiFailure) { | |||||
| return Text(state.errorString); | |||||
| } | |||||
| return Container(); | |||||
| }, | |||||
| ), | |||||
| ), | |||||
| ); | |||||
| } else if (state is ActionUiFailure) { | |||||
| return Center(child: Text(state.errorString)); | |||||
| } | |||||
| return Container(); | |||||
| }, | |||||
| ), | ), | ||||
| )), | )), | ||||
| ))); | ))); |
| response = await repository.getPlotDetailByCode(event.cropCode, | response = await repository.getPlotDetailByCode(event.cropCode, | ||||
| page: 0, size: pageSize); | page: 0, size: pageSize); | ||||
| } | } | ||||
| var listActivities = List<Activities>(); | |||||
| CropPlot cropPlot = response as CropPlot; | |||||
| cropPlot.activities.forEach((element) { | |||||
| listActivities.add(Activities.clone(element)); | |||||
| }); | |||||
| yield PlotDetailSuccess( | yield PlotDetailSuccess( | ||||
| items: listActivities, | |||||
| items: response.activities, | |||||
| page: 0, | page: 0, | ||||
| hasReachedMax: | hasReachedMax: | ||||
| response.activities.length < pageSize ? true : false); | response.activities.length < pageSize ? true : false); |
| import 'package:auto_size_text/auto_size_text.dart'; | |||||
| import 'package:cached_network_image/cached_network_image.dart'; | import 'package:cached_network_image/cached_network_image.dart'; | ||||
| import 'package:farm_tpf/custom_model/ActionType.dart'; | import 'package:farm_tpf/custom_model/ActionType.dart'; | ||||
| import 'package:farm_tpf/data/repository/repository.dart'; | import 'package:farm_tpf/data/repository/repository.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/plot_detail/bloc/cubit/plot_action_type_cubit.dart'; | import 'package:farm_tpf/presentation/screens/plot_detail/bloc/cubit/plot_action_type_cubit.dart'; | ||||
| import 'package:farm_tpf/utils/const_assets.dart'; | import 'package:farm_tpf/utils/const_assets.dart'; | ||||
| import 'package:farm_tpf/utils/const_color.dart'; | import 'package:farm_tpf/utils/const_color.dart'; | ||||
| import 'package:farm_tpf/utils/const_common.dart'; | |||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
| import 'package:flutter_bloc/flutter_bloc.dart'; | import 'package:flutter_bloc/flutter_bloc.dart'; | ||||
| import 'package:get/get.dart'; | import 'package:get/get.dart'; | ||||
| @override | @override | ||||
| void initState() { | void initState() { | ||||
| super.initState(); | super.initState(); | ||||
| // _initActionButtons(); | |||||
| } | } | ||||
| @override | @override | ||||
| super.dispose(); | super.dispose(); | ||||
| } | } | ||||
| // _initActionButtons() { | |||||
| // //type: 0- Trồng, 1- ướm | |||||
| // if (widget.cropType == 1) { | |||||
| // actions.add(ActionType( | |||||
| // plot_action_nursery, | |||||
| // EditActionNurseryScreen( | |||||
| // cropId: widget.cropId, | |||||
| // ), | |||||
| // AppAssets.icActionNursery)); | |||||
| // } else if (widget.cropType == 0) { | |||||
| // actions.add(ActionType( | |||||
| // plot_action_plant, | |||||
| // EditActionPlantScreen( | |||||
| // cropId: widget.cropId, | |||||
| // ), | |||||
| // AppAssets.icActionPlant)); | |||||
| // } | |||||
| // actions.add(ActionType( | |||||
| // plot_action_crop_status, | |||||
| // EditActionCropStatusScreen( | |||||
| // cropId: widget.cropId, | |||||
| // ), | |||||
| // AppAssets.icActionCropStatus)); | |||||
| // actions.add(ActionType( | |||||
| // plot_action_environment_update, | |||||
| // EditActionEnvironmentUpdate( | |||||
| // cropId: widget.cropId, | |||||
| // ), | |||||
| // AppAssets.icActionEnvironment)); | |||||
| // actions.add(ActionType( | |||||
| // plot_action_dung, | |||||
| // EditActionDungScreen( | |||||
| // cropId: widget.cropId, | |||||
| // ), | |||||
| // AppAssets.icActionDung)); | |||||
| // actions.add(ActionType( | |||||
| // plot_action_spraying, | |||||
| // EditActionSprayingScreen( | |||||
| // cropId: widget.cropId, | |||||
| // ), | |||||
| // AppAssets.icActionSpraying)); | |||||
| // actions.add(ActionType( | |||||
| // plot_action_disease, | |||||
| // EditActionDiseaseScreen( | |||||
| // cropId: widget.cropId, | |||||
| // ), | |||||
| // AppAssets.icActionDisease)); | |||||
| // actions.add(ActionType( | |||||
| // plot_action_use_water, | |||||
| // EditActionUseWaterScreen( | |||||
| // cropId: widget.cropId, | |||||
| // ), | |||||
| // AppAssets.icActionUseWater)); | |||||
| // actions.add(ActionType( | |||||
| // plot_action_other, | |||||
| // EditActionOtherScreen( | |||||
| // cropId: widget.cropId, | |||||
| // ), | |||||
| // AppAssets.icActionOther)); | |||||
| // actions.add(ActionType( | |||||
| // plot_action_harvest, | |||||
| // EditActionHarvestScreen( | |||||
| // cropId: widget.cropId, | |||||
| // ), | |||||
| // AppAssets.icActionHarvest)); | |||||
| // actions.add(ActionType( | |||||
| // plot_action_finish, | |||||
| // EditActionEndScreen( | |||||
| // cropId: widget.cropId, | |||||
| // ), | |||||
| // AppAssets.icActionEnd)); | |||||
| // } | |||||
| Widget _createActionButtons(ActionType actionType, BuildContext _context) { | Widget _createActionButtons(ActionType actionType, BuildContext _context) { | ||||
| return GestureDetector( | return GestureDetector( | ||||
| onTap: () { | onTap: () { | ||||
| }, | }, | ||||
| child: Container( | child: Container( | ||||
| margin: EdgeInsets.all(8), | margin: EdgeInsets.all(8), | ||||
| padding: EdgeInsets.all(4), | |||||
| decoration: BoxDecoration( | decoration: BoxDecoration( | ||||
| border: Border.all(color: Colors.grey, width: 0.1), | border: Border.all(color: Colors.grey, width: 0.1), | ||||
| color: Colors.white, | color: Colors.white, | ||||
| mainAxisAlignment: MainAxisAlignment.center, | mainAxisAlignment: MainAxisAlignment.center, | ||||
| crossAxisAlignment: CrossAxisAlignment.center, | crossAxisAlignment: CrossAxisAlignment.center, | ||||
| children: [ | children: [ | ||||
| 1 == 1 | |||||
| ? Image.asset( | |||||
| Expanded( | |||||
| flex: 1, | |||||
| child: SizedBox( | |||||
| width: Get.width / 10, | |||||
| height: Get.height / 10, | |||||
| child: CachedNetworkImage( | |||||
| imageUrl: | |||||
| '${ConstCommon.baseImageUrl}${actionType.urlLogo}', | |||||
| placeholder: (context, url) => Icon( | |||||
| Icons.broken_image, | |||||
| ), | |||||
| errorWidget: (context, url, error) => Image.asset( | |||||
| AppAssets.logo, | AppAssets.logo, | ||||
| width: Get.width / 9, | |||||
| height: Get.width / 9, | |||||
| ) | |||||
| : CachedNetworkImage( | |||||
| imageUrl: "http://via.placeholder.com/350x150", | |||||
| placeholder: (context, url) => | |||||
| CircularProgressIndicator(), | |||||
| errorWidget: (context, url, error) => Icon(Icons.error), | |||||
| ), | ), | ||||
| Text( | |||||
| actionType.description, | |||||
| textAlign: TextAlign.center, | |||||
| style: TextStyle( | |||||
| fontWeight: FontWeight.bold, | |||||
| fontSize: 13, | |||||
| color: AppColors.BLACK2, | |||||
| ), | |||||
| ), | |||||
| ), | |||||
| Expanded( | |||||
| flex: 1, | |||||
| child: Align( | |||||
| alignment: Alignment.center, | |||||
| child: AutoSizeText( | |||||
| actionType.description, | |||||
| textAlign: TextAlign.center, | |||||
| style: TextStyle( | |||||
| fontWeight: FontWeight.bold, | |||||
| fontSize: 13, | |||||
| color: AppColors.BLACK2, | |||||
| ), | |||||
| maxLines: 2, | |||||
| ), | |||||
| ), | ), | ||||
| ), | ), | ||||
| ], | ], |
| String formatStringToStringDecimal() { | String formatStringToStringDecimal() { | ||||
| try { | try { | ||||
| var numOfString = double.tryParse(this.toString()); | |||||
| var newValue = this.replaceAll(",", ""); | |||||
| var numOfString = double.tryParse(newValue); | |||||
| var numWithLocalSeparator = new NumberFormat.decimalPattern("en_US"); | var numWithLocalSeparator = new NumberFormat.decimalPattern("en_US"); | ||||
| final str = numWithLocalSeparator.format(numOfString); | final str = numWithLocalSeparator.format(numOfString); | ||||
| return str; | return str; |
| url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
| source: hosted | source: hosted | ||||
| version: "2.5.0-nullsafety.1" | version: "2.5.0-nullsafety.1" | ||||
| auto_size_text: | |||||
| dependency: "direct main" | |||||
| description: | |||||
| name: auto_size_text | |||||
| url: "https://pub.dartlang.org" | |||||
| source: hosted | |||||
| version: "2.1.0" | |||||
| badges: | badges: | ||||
| dependency: "direct main" | dependency: "direct main" | ||||
| description: | description: |
| rflutter_alert: ^1.1.0 | rflutter_alert: ^1.1.0 | ||||
| badges: ^1.1.1 | badges: ^1.1.1 | ||||
| cached_network_image: ^2.3.2+1 | cached_network_image: ^2.3.2+1 | ||||
| auto_size_text: ^2.1.0 | |||||
| camera: ^0.5.8+5 | camera: ^0.5.8+5 | ||||
| path_provider: ^1.6.14 | path_provider: ^1.6.14 |