| @@ -1 +1 @@ | |||
| 471e09183e20ec9c20cca9b580fecc10 | |||
| d91c957b2422e26116533c8dae89710a | |||
| @@ -14,34 +14,37 @@ class AppBarWidget extends StatelessWidget implements PreferredSizeWidget { | |||
| elevation: 0, | |||
| centerTitle: false, | |||
| 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, | |||
| 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(), | |||
| automaticallyImplyLeading: false, | |||
| @@ -11,6 +11,7 @@ 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/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_field_time_picker.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart'; | |||
| @@ -447,12 +448,17 @@ class _ActionScreenState extends State<ActionScreen> { | |||
| } | |||
| } | |||
| void showDataWhenEdit() { | |||
| void showDataWhenEdit(BuildContext context) { | |||
| //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((_) { | |||
| if (widget.activityType == 'ACTIVE_TYPE_PLANTING' || | |||
| widget.activityType == 'ACTIVE_TYPE_FERTILIZE' || | |||
| @@ -565,39 +571,41 @@ class _ActionScreenState extends State<ActionScreen> { | |||
| child: Form( | |||
| key: _formKey, | |||
| 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: [ | |||
| Padding( | |||
| padding: const EdgeInsets.all(8.0), | |||
| @@ -662,13 +670,13 @@ class _ActionScreenState extends State<ActionScreen> { | |||
| }), | |||
| ), | |||
| ], | |||
| ); | |||
| } else if (state is ActionUiFailure) { | |||
| return Text(state.errorString); | |||
| } | |||
| return Container(); | |||
| }, | |||
| ), | |||
| ), | |||
| ); | |||
| } else if (state is ActionUiFailure) { | |||
| return Center(child: Text(state.errorString)); | |||
| } | |||
| return Container(); | |||
| }, | |||
| ), | |||
| )), | |||
| ))); | |||
| @@ -107,13 +107,9 @@ class PlotDetailBloc extends Bloc<PlotDetailEvent, PlotDetailState> { | |||
| response = await repository.getPlotDetailByCode(event.cropCode, | |||
| page: 0, size: pageSize); | |||
| } | |||
| var listActivities = List<Activities>(); | |||
| CropPlot cropPlot = response as CropPlot; | |||
| cropPlot.activities.forEach((element) { | |||
| listActivities.add(Activities.clone(element)); | |||
| }); | |||
| yield PlotDetailSuccess( | |||
| items: listActivities, | |||
| items: response.activities, | |||
| page: 0, | |||
| hasReachedMax: | |||
| response.activities.length < pageSize ? true : false); | |||
| @@ -1,3 +1,4 @@ | |||
| import 'package:auto_size_text/auto_size_text.dart'; | |||
| import 'package:cached_network_image/cached_network_image.dart'; | |||
| import 'package:farm_tpf/custom_model/ActionType.dart'; | |||
| import 'package:farm_tpf/data/repository/repository.dart'; | |||
| @@ -6,6 +7,7 @@ import 'package:farm_tpf/presentation/screens/actions/sc_action.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_color.dart'; | |||
| import 'package:farm_tpf/utils/const_common.dart'; | |||
| import 'package:flutter/material.dart'; | |||
| import 'package:flutter_bloc/flutter_bloc.dart'; | |||
| import 'package:get/get.dart'; | |||
| @@ -26,7 +28,6 @@ class _PlotActionScreenState extends State<PlotActionScreen> | |||
| @override | |||
| void initState() { | |||
| super.initState(); | |||
| // _initActionButtons(); | |||
| } | |||
| @override | |||
| @@ -34,80 +35,6 @@ class _PlotActionScreenState extends State<PlotActionScreen> | |||
| 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) { | |||
| return GestureDetector( | |||
| onTap: () { | |||
| @@ -122,6 +49,7 @@ class _PlotActionScreenState extends State<PlotActionScreen> | |||
| }, | |||
| child: Container( | |||
| margin: EdgeInsets.all(8), | |||
| padding: EdgeInsets.all(4), | |||
| decoration: BoxDecoration( | |||
| border: Border.all(color: Colors.grey, width: 0.1), | |||
| color: Colors.white, | |||
| @@ -137,25 +65,37 @@ class _PlotActionScreenState extends State<PlotActionScreen> | |||
| mainAxisAlignment: MainAxisAlignment.center, | |||
| crossAxisAlignment: CrossAxisAlignment.center, | |||
| 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, | |||
| 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, | |||
| ), | |||
| ), | |||
| ), | |||
| ], | |||
| @@ -58,7 +58,8 @@ extension ddMM_HHmm on String { | |||
| String formatStringToStringDecimal() { | |||
| try { | |||
| var numOfString = double.tryParse(this.toString()); | |||
| var newValue = this.replaceAll(",", ""); | |||
| var numOfString = double.tryParse(newValue); | |||
| var numWithLocalSeparator = new NumberFormat.decimalPattern("en_US"); | |||
| final str = numWithLocalSeparator.format(numOfString); | |||
| return str; | |||
| @@ -29,6 +29,13 @@ packages: | |||
| url: "https://pub.dartlang.org" | |||
| source: hosted | |||
| 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: | |||
| dependency: "direct main" | |||
| description: | |||
| @@ -41,6 +41,7 @@ dependencies: | |||
| rflutter_alert: ^1.1.0 | |||
| badges: ^1.1.1 | |||
| cached_network_image: ^2.3.2+1 | |||
| auto_size_text: ^2.1.0 | |||
| camera: ^0.5.8+5 | |||
| path_provider: ^1.6.14 | |||