| @@ -1,13 +1,18 @@ | |||
| import 'package:farm_tpf/custom_model/SuppliesUsing.dart'; | |||
| import 'package:farm_tpf/custom_model/action_form/ActionUIField.dart'; | |||
| class RequestActivity { | |||
| int tbActivityTypeId; | |||
| int tbCropId; | |||
| int totalCost; | |||
| num totalCost; | |||
| String executeDate; | |||
| String externalTable; | |||
| String description; | |||
| String media; | |||
| List<TbObjectUpdateDTO> tbObjectUpdateDTOList; | |||
| List<TbSuppliesUsingDetailsDTOs> tbSuppliesUsingDetailsDTOs; | |||
| List<SuppliesUsing> tbSuppliesUsingDetailsDTOs; | |||
| List<TbNurseryDetailsDTO> tbNurseryDetailsDTOList; | |||
| List<String> deletedImages; | |||
| RequestActivity( | |||
| {this.tbActivityTypeId, | |||
| @@ -16,9 +21,11 @@ class RequestActivity { | |||
| this.executeDate, | |||
| this.externalTable, | |||
| this.description, | |||
| this.media, | |||
| this.tbObjectUpdateDTOList, | |||
| this.tbSuppliesUsingDetailsDTOs, | |||
| this.tbNurseryDetailsDTOList}); | |||
| this.tbNurseryDetailsDTOList, | |||
| this.deletedImages}); | |||
| RequestActivity.fromJson(Map<String, dynamic> json) { | |||
| tbActivityTypeId = json['tbActivityTypeId']; | |||
| @@ -27,6 +34,7 @@ class RequestActivity { | |||
| executeDate = json['executeDate']; | |||
| externalTable = json['externalTable']; | |||
| description = json['description']; | |||
| media = json['media']; | |||
| if (json['tbObjectUpdateDTOList'] != null) { | |||
| tbObjectUpdateDTOList = new List<TbObjectUpdateDTO>(); | |||
| json['tbObjectUpdateDTOList'].forEach((v) { | |||
| @@ -34,10 +42,9 @@ class RequestActivity { | |||
| }); | |||
| } | |||
| if (json['tbSuppliesUsingDetailsDTOs'] != null) { | |||
| tbSuppliesUsingDetailsDTOs = new List<TbSuppliesUsingDetailsDTOs>(); | |||
| tbSuppliesUsingDetailsDTOs = new List<SuppliesUsing>(); | |||
| json['tbSuppliesUsingDetailsDTOs'].forEach((v) { | |||
| tbSuppliesUsingDetailsDTOs | |||
| .add(new TbSuppliesUsingDetailsDTOs.fromJson(v)); | |||
| tbSuppliesUsingDetailsDTOs.add(new SuppliesUsing.fromJson(v)); | |||
| }); | |||
| } | |||
| if (json['tbNurseryDetailsDTOList'] != null) { | |||
| @@ -56,6 +63,7 @@ class RequestActivity { | |||
| data['executeDate'] = this.executeDate; | |||
| data['externalTable'] = this.externalTable; | |||
| data['description'] = this.description; | |||
| data['media'] = this.media; | |||
| if (this.tbObjectUpdateDTOList != null) { | |||
| data['tbObjectUpdateDTOList'] = | |||
| this.tbObjectUpdateDTOList.map((v) => v.toJson()).toList(); | |||
| @@ -68,6 +76,7 @@ class RequestActivity { | |||
| data['tbNurseryDetailsDTOList'] = | |||
| this.tbNurseryDetailsDTOList.map((v) => v.toJson()).toList(); | |||
| } | |||
| data['deletedImages'] = this.deletedImages; | |||
| return data; | |||
| } | |||
| } | |||
| @@ -75,51 +84,32 @@ class RequestActivity { | |||
| class TbObjectUpdateDTO { | |||
| int tbObjectParameterId; | |||
| String index; | |||
| int id; | |||
| ActionUIField tbObjectParameterDTO; | |||
| TbObjectUpdateDTO({this.tbObjectParameterId, this.index}); | |||
| TbObjectUpdateDTO( | |||
| {this.tbObjectParameterId, | |||
| this.index, | |||
| this.id, | |||
| this.tbObjectParameterDTO}); | |||
| TbObjectUpdateDTO.fromJson(Map<String, dynamic> json) { | |||
| tbObjectParameterId = json['tbObjectParameterId']; | |||
| index = json['index']; | |||
| id = json['id']; | |||
| tbObjectParameterDTO = json['tbObjectParameterDTO'] != null | |||
| ? new ActionUIField.fromJson(json['tbObjectParameterDTO']) | |||
| : null; | |||
| } | |||
| Map<String, dynamic> toJson() { | |||
| final Map<String, dynamic> data = new Map<String, dynamic>(); | |||
| data['tbObjectParameterId'] = this.tbObjectParameterId; | |||
| data['index'] = this.index; | |||
| return data; | |||
| } | |||
| } | |||
| class TbSuppliesUsingDetailsDTOs { | |||
| int tbSuppliesInWarehouseId; | |||
| String dosage; | |||
| num quantity; | |||
| int tbEquipmentOfCustomerId; | |||
| String howToUse; | |||
| TbSuppliesUsingDetailsDTOs( | |||
| {this.tbSuppliesInWarehouseId, | |||
| this.dosage, | |||
| this.quantity, | |||
| this.tbEquipmentOfCustomerId, | |||
| this.howToUse}); | |||
| TbSuppliesUsingDetailsDTOs.fromJson(Map<String, dynamic> json) { | |||
| tbSuppliesInWarehouseId = json['tbSuppliesInWarehouseId']; | |||
| dosage = json['dosage']; | |||
| quantity = json['quantity']; | |||
| tbEquipmentOfCustomerId = json['tbEquipmentOfCustomerId']; | |||
| howToUse = json['howToUse']; | |||
| } | |||
| Map<String, dynamic> toJson() { | |||
| final Map<String, dynamic> data = new Map<String, dynamic>(); | |||
| data['tbSuppliesInWarehouseId'] = this.tbSuppliesInWarehouseId; | |||
| data['dosage'] = this.dosage; | |||
| data['quantity'] = this.quantity; | |||
| data['tbEquipmentOfCustomerId'] = this.tbEquipmentOfCustomerId; | |||
| data['howToUse'] = this.howToUse; | |||
| data['id'] = this.id; | |||
| if (this.tbObjectParameterDTO != null) { | |||
| data['tbObjectParameterDTO'] = this.tbObjectParameterDTO.toJson(); | |||
| } | |||
| return data; | |||
| } | |||
| } | |||
| @@ -11,10 +11,12 @@ import 'package:farm_tpf/custom_model/UpdateNoti.dart'; | |||
| import 'package:farm_tpf/custom_model/WaterType.dart'; | |||
| import 'package:farm_tpf/custom_model/account.dart'; | |||
| import 'package:farm_tpf/custom_model/action_form/ActionUIForm.dart'; | |||
| import 'package:farm_tpf/custom_model/action_form/RequestActivity.dart'; | |||
| import 'package:farm_tpf/custom_model/password.dart'; | |||
| import 'package:farm_tpf/custom_model/user.dart'; | |||
| import 'package:farm_tpf/custom_model/user_request.dart'; | |||
| import 'package:farm_tpf/utils/const_common.dart'; | |||
| import 'package:flutter/material.dart'; | |||
| import 'package:retrofit/retrofit.dart'; | |||
| part 'rest_client.g.dart'; | |||
| @@ -133,4 +135,8 @@ abstract class RestClient { | |||
| @GET('/api/display-object-param-dynamic-form/{idAction}') | |||
| Future<ActionUIForm> getActionUIForm( | |||
| @Path() idAction, @DioOptions() Options options); | |||
| @GET('/api/get-detail-common-activity/{actionType}/{activityId}') | |||
| Future<RequestActivity> getDetailActivityCommon( | |||
| {@required @Path() String actionType, @required @Path() int activityId}); | |||
| } | |||
| @@ -23,7 +23,6 @@ class _RestClient implements RestClient { | |||
| final queryParameters = <String, dynamic>{}; | |||
| final _data = <String, dynamic>{}; | |||
| _data.addAll(userRequest?.toJson() ?? <String, dynamic>{}); | |||
| _data.removeWhere((k, v) => v == null); | |||
| final _result = await _dio.request<Map<String, dynamic>>( | |||
| '/api/authenticate', | |||
| queryParameters: queryParameters, | |||
| @@ -78,7 +77,6 @@ class _RestClient implements RestClient { | |||
| final queryParameters = <String, dynamic>{}; | |||
| final _data = <String, dynamic>{}; | |||
| _data.addAll(password?.toJson() ?? <String, dynamic>{}); | |||
| _data.removeWhere((k, v) => v == null); | |||
| await _dio.request<void>('/api/account/reset-password/finish', | |||
| queryParameters: queryParameters, | |||
| options: RequestOptions( | |||
| @@ -97,7 +95,6 @@ class _RestClient implements RestClient { | |||
| final queryParameters = <String, dynamic>{}; | |||
| final _data = <String, dynamic>{}; | |||
| _data.addAll(password?.toJson() ?? <String, dynamic>{}); | |||
| _data.removeWhere((k, v) => v == null); | |||
| await _dio.request<void>('/api/account/change-password', | |||
| queryParameters: queryParameters, | |||
| options: RequestOptions( | |||
| @@ -116,7 +113,6 @@ class _RestClient implements RestClient { | |||
| final queryParameters = <String, dynamic>{}; | |||
| final _data = <String, dynamic>{}; | |||
| _data.addAll(account?.toJson() ?? <String, dynamic>{}); | |||
| _data.removeWhere((k, v) => v == null); | |||
| final _result = await _dio.request<Map<String, dynamic>>( | |||
| '/api/update-my-profile', | |||
| queryParameters: queryParameters, | |||
| @@ -308,7 +304,6 @@ class _RestClient implements RestClient { | |||
| final queryParameters = <String, dynamic>{}; | |||
| final _data = <String, dynamic>{}; | |||
| _data.addAll(updateNoti?.toJson() ?? <String, dynamic>{}); | |||
| _data.removeWhere((k, v) => v == null); | |||
| await _dio.request<void>('/api/notifications/update', | |||
| queryParameters: queryParameters, | |||
| options: RequestOptions( | |||
| @@ -454,7 +449,6 @@ class _RestClient implements RestClient { | |||
| final queryParameters = <String, dynamic>{}; | |||
| final _data = <String, dynamic>{}; | |||
| _data.addAll(crop?.toJson() ?? <String, dynamic>{}); | |||
| _data.removeWhere((k, v) => v == null); | |||
| await _dio.request<void>('/api/tb-crops', | |||
| queryParameters: queryParameters, | |||
| options: RequestOptions( | |||
| @@ -530,6 +524,28 @@ class _RestClient implements RestClient { | |||
| return value; | |||
| } | |||
| @override | |||
| Future<RequestActivity> getDetailActivityCommon( | |||
| {actionType, activityId}) async { | |||
| ArgumentError.checkNotNull(actionType, 'actionType'); | |||
| ArgumentError.checkNotNull(activityId, 'activityId'); | |||
| const _extra = <String, dynamic>{}; | |||
| final queryParameters = <String, dynamic>{}; | |||
| queryParameters.removeWhere((k, v) => v == null); | |||
| final _data = <String, dynamic>{}; | |||
| final _result = await _dio.request<Map<String, dynamic>>( | |||
| '/api/get-detail-common-activity/$actionType/$activityId', | |||
| queryParameters: queryParameters, | |||
| options: RequestOptions( | |||
| method: 'GET', | |||
| headers: <String, dynamic>{}, | |||
| extra: _extra, | |||
| baseUrl: baseUrl), | |||
| data: _data); | |||
| final value = RequestActivity.fromJson(_result.data); | |||
| return value; | |||
| } | |||
| RequestOptions newRequestOptions(Options options) { | |||
| if (options is RequestOptions) { | |||
| return options; | |||
| @@ -13,6 +13,7 @@ import 'package:farm_tpf/custom_model/UpdateNoti.dart'; | |||
| import 'package:farm_tpf/custom_model/WaterType.dart'; | |||
| import 'package:farm_tpf/custom_model/action_form/ActionUIForm.dart'; | |||
| import 'package:farm_tpf/custom_model/action_form/CommonData.dart'; | |||
| import 'package:farm_tpf/custom_model/action_form/RequestActivity.dart'; | |||
| import 'package:farm_tpf/custom_model/user.dart'; | |||
| import 'package:farm_tpf/custom_model/user_request.dart'; | |||
| import 'package:farm_tpf/data/api/dio_provider.dart'; | |||
| @@ -291,4 +292,11 @@ class Repository { | |||
| onError(e); | |||
| } | |||
| } | |||
| Future<RequestActivity> detailCommonAction( | |||
| {@required int activityId, @required String activityType}) async { | |||
| final client = RestClient(dio); | |||
| return client.getDetailActivityCommon( | |||
| actionType: activityType, activityId: activityId); | |||
| } | |||
| } | |||
| @@ -1,6 +1,8 @@ | |||
| import 'package:bloc/bloc.dart'; | |||
| import 'package:dio/dio.dart'; | |||
| import 'package:equatable/equatable.dart'; | |||
| import 'package:farm_tpf/custom_model/action_form/ActionUIForm.dart'; | |||
| import 'package:farm_tpf/custom_model/action_form/RequestActivity.dart'; | |||
| import 'package:farm_tpf/data/api/app_exception.dart'; | |||
| import 'package:farm_tpf/data/repository/repository.dart'; | |||
| import 'package:meta/meta.dart'; | |||
| @@ -11,12 +13,26 @@ class ActionUiCubit extends Cubit<ActionUiState> { | |||
| final Repository repository; | |||
| ActionUiCubit({@required this.repository}) : super(ActionUiInitial()); | |||
| Future<void> getActionUIForm(int idAction) async { | |||
| Future<void> getActionUIForm( | |||
| {@required bool isEdit, | |||
| @required int actionId, | |||
| @required String actionType, | |||
| @required int activityId}) async { | |||
| try { | |||
| emit(ActionUiLoading()); | |||
| repository.getActionUIForm(idAction: idAction).then((value) { | |||
| emit(ActionUiSuccess(item: value)); | |||
| }); | |||
| var actionDetail = RequestActivity(); | |||
| var actionUIForm = await repository.getActionUIForm(idAction: actionId); | |||
| if (isEdit) { | |||
| try { | |||
| actionDetail = await repository.detailCommonAction( | |||
| activityId: activityId, activityType: actionType); | |||
| print(actionDetail); | |||
| } catch (e) { | |||
| print(e); | |||
| } | |||
| } | |||
| emit(ActionUiSuccess( | |||
| actionUIForm: actionUIForm, activityDetail: actionDetail)); | |||
| } on DioError catch (e) { | |||
| emit(ActionUiFailure(errorString: AppException.handleError(e))); | |||
| } | |||
| @@ -16,11 +16,12 @@ class ActionUiFailure extends ActionUiState { | |||
| ActionUiFailure({@required this.errorString}); | |||
| } | |||
| class ActionUiSuccess<T> extends ActionUiState { | |||
| final T item; | |||
| class ActionUiSuccess extends ActionUiState { | |||
| final ActionUIForm actionUIForm; | |||
| final RequestActivity activityDetail; | |||
| ActionUiSuccess({this.item}); | |||
| ActionUiSuccess({this.actionUIForm, this.activityDetail}); | |||
| @override | |||
| List<Object> get props => [item]; | |||
| List<Object> get props => [actionUIForm, activityDetail]; | |||
| } | |||
| @@ -29,8 +29,8 @@ class _WidgetWorkerState extends State<WidgetWorker> { | |||
| Widget _buildListWorker() { | |||
| return GetBuilder<ChangeWorker>(builder: (data) { | |||
| widget.onChangeWorkers(data.currentItems); | |||
| if (data.currentItems.length == 0) { | |||
| widget.onChangeWorkers(data.currentItems ?? []); | |||
| if (data.currentItems?.length == 0 || data.currentItems == null) { | |||
| return Container(); | |||
| } else { | |||
| return Container( | |||
| @@ -3,6 +3,7 @@ import 'dart:convert'; | |||
| import 'package:farm_tpf/custom_model/SuppliesUsing.dart'; | |||
| import 'package:farm_tpf/custom_model/action_form/ActionUIField.dart'; | |||
| import 'package:farm_tpf/custom_model/action_form/ActionUIForm.dart'; | |||
| import 'package:farm_tpf/custom_model/action_form/CommonData.dart'; | |||
| import 'package:farm_tpf/custom_model/action_form/RequestActivity.dart'; | |||
| import 'package:farm_tpf/data/api/app_exception.dart'; | |||
| import 'package:farm_tpf/data/repository/repository.dart'; | |||
| @@ -22,27 +23,36 @@ import 'package:farm_tpf/utils/const_string.dart'; | |||
| import 'package:farm_tpf/utils/pref.dart'; | |||
| import 'package:farm_tpf/utils/validators.dart'; | |||
| import 'package:flutter/material.dart'; | |||
| import 'package:flutter/scheduler.dart'; | |||
| import 'package:flutter_bloc/flutter_bloc.dart'; | |||
| import 'package:get/get.dart'; | |||
| import 'package:keyboard_dismisser/keyboard_dismisser.dart'; | |||
| import 'package:farm_tpf/utils/formatter.dart'; | |||
| import 'controller/ChangeSupplyUsing.dart'; | |||
| import 'controller/ChangeWorker.dart'; | |||
| import 'dung/widget_dung_supply.dart'; | |||
| import 'nursery/widget_worker.dart'; | |||
| import 'plant/widget_plant_supply.dart'; | |||
| import 'spraying/widget_spraying_supply.dart'; | |||
| import 'state_management_helper/change_dropdown_controller.dart'; | |||
| import 'state_management_helper/change_file_controller.dart'; | |||
| import 'util_action.dart'; | |||
| class ActionScreen extends StatefulWidget { | |||
| final bool isEdit; | |||
| final int cropId; | |||
| final int idAction; | |||
| final String activityType; | |||
| final String title; | |||
| final int activityId; | |||
| ActionScreen( | |||
| {@required this.cropId, | |||
| {@required this.isEdit, | |||
| @required this.cropId, | |||
| @required this.idAction, | |||
| @required this.title, | |||
| @required this.activityType}); | |||
| @required this.activityType, | |||
| @required this.activityId}); | |||
| @override | |||
| _ActionScreenState createState() => _ActionScreenState(); | |||
| @@ -112,29 +122,10 @@ class _ActionScreenState extends State<ActionScreen> { | |||
| //CHECK NURSERY | |||
| if (widget.activityType == 'ACTIVE_TYPE_NURSERY') { | |||
| _requestActivity.tbNurseryDetailsDTOList = _nurseryDetails; | |||
| } else if (widget.activityType == 'ACTIVE_TYPE_PLANTING') { | |||
| var _listSupplyUsingDetail = <TbSuppliesUsingDetailsDTOs>[]; | |||
| _supplyUsings.forEach((element) { | |||
| var usingSupplyDetail = TbSuppliesUsingDetailsDTOs() | |||
| ..tbSuppliesInWarehouseId = element.tbSuppliesInWarehouseId | |||
| ..dosage = element.dosage | |||
| ..quantity = element.quantity; | |||
| _listSupplyUsingDetail.add(usingSupplyDetail); | |||
| }); | |||
| _requestActivity.tbSuppliesUsingDetailsDTOs = _listSupplyUsingDetail; | |||
| } else if (widget.activityType == 'ACTIVE_TYPE_FERTILIZE' || | |||
| } else if (widget.activityType == 'ACTIVE_TYPE_PLANTING' || | |||
| widget.activityType == 'ACTIVE_TYPE_FERTILIZE' || | |||
| widget.activityType == 'ACTIVE_TYPE_SPRAYING_PESTICIDES') { | |||
| var _listSupplyUsingDetail = <TbSuppliesUsingDetailsDTOs>[]; | |||
| _supplyUsings.forEach((element) { | |||
| var usingSupplyDetail = TbSuppliesUsingDetailsDTOs() | |||
| ..tbSuppliesInWarehouseId = element.tbSuppliesInWarehouseId | |||
| ..dosage = element.dosage | |||
| ..quantity = element.quantity | |||
| ..howToUse = element.howToUse ?? '' | |||
| ..tbEquipmentOfCustomerId = element.equipmentOfCustomerId; | |||
| _listSupplyUsingDetail.add(usingSupplyDetail); | |||
| }); | |||
| _requestActivity.tbSuppliesUsingDetailsDTOs = _listSupplyUsingDetail; | |||
| _requestActivity.tbSuppliesUsingDetailsDTOs = _supplyUsings; | |||
| } | |||
| //convert data to json | |||
| var activityCommonData = | |||
| @@ -329,6 +320,67 @@ class _ActionScreenState extends State<ActionScreen> { | |||
| } | |||
| } | |||
| void showDataWhenEdit() { | |||
| //Show media | |||
| if (Validators.stringNotNullOrEmpty(_requestActivity.media)) { | |||
| BlocProvider.of<MediaHelperBloc>(context).add(ChangeListMedia( | |||
| items: UtilAction.convertFilePathToMedia(_requestActivity.media))); | |||
| } | |||
| SchedulerBinding.instance.addPostFrameCallback((_) { | |||
| if (widget.activityType == 'ACTIVE_TYPE_PLANTING' || | |||
| widget.activityType == 'ACTIVE_TYPE_FERTILIZE' || | |||
| widget.activityType == 'ACTIVE_TYPE_SPRAYING_PESTICIDES') { | |||
| //list supply | |||
| Get.find<ChangeSupplyUsing>() | |||
| .changeInitList(_requestActivity.tbSuppliesUsingDetailsDTOs); | |||
| } else if (widget.activityType == 'ACTIVE_TYPE_NURSERY') { | |||
| //list nursery | |||
| Get.find<ChangeWorker>() | |||
| .changeInitList(_requestActivity.tbNurseryDetailsDTOList); | |||
| } | |||
| }); | |||
| //Show value textfield | |||
| if (_requestActivity.tbObjectUpdateDTOList != null) { | |||
| print(textFieldControllers.keys.toList()); | |||
| _requestActivity.tbObjectUpdateDTOList.forEach((element) { | |||
| if (element.tbObjectParameterDTO.tbControlTypeName == 'text' || | |||
| element.tbObjectParameterDTO.tbControlTypeName == 'textarea') { | |||
| SchedulerBinding.instance.addPostFrameCallback((_) { | |||
| textFieldControllers[element.tbObjectParameterId.toString()].text = | |||
| element.index; | |||
| }); | |||
| } else if (element.tbObjectParameterDTO.tbControlTypeName == 'number') { | |||
| SchedulerBinding.instance.addPostFrameCallback((_) { | |||
| textFieldControllers[element.tbObjectParameterId.toString()].text = | |||
| element.index.formatStringToStringDecimal(); | |||
| }); | |||
| } else { | |||
| SchedulerBinding.instance.addPostFrameCallback((_) { | |||
| print("SchedulerBinding"); | |||
| if (element.tbObjectParameterDTO.tbControlTypeName == 'dropdown' || | |||
| element.tbObjectParameterDTO.tbControlTypeName == 'radio') { | |||
| var commonData = CommonData() | |||
| ..id = int.tryParse(element.index) | |||
| ..name = ''; | |||
| Get.find<ChangeDropdownController>( | |||
| tag: element.tbObjectParameterDTO.name) | |||
| .change(commonData); | |||
| } else if (element.tbObjectParameterDTO.tbControlTypeName == | |||
| 'date') { | |||
| Get.find<ChangeDateTimePicker>( | |||
| tag: element.tbObjectParameterDTO.name) | |||
| .change(element.index | |||
| .convertStringServerDateTimeToLocalDateTime()); | |||
| } | |||
| }); | |||
| } | |||
| }); | |||
| } else { | |||
| // | |||
| } | |||
| } | |||
| @override | |||
| Widget build(BuildContext context) => KeyboardDismisser( | |||
| gestures: [ | |||
| @@ -337,7 +389,7 @@ class _ActionScreenState extends State<ActionScreen> { | |||
| ], | |||
| child: Scaffold( | |||
| backgroundColor: Colors.white, | |||
| key: _scaffoldKey, | |||
| // key: _scaffoldKey, | |||
| appBar: AppBarWidget( | |||
| isBack: true, | |||
| action: InkWell( | |||
| @@ -347,21 +399,24 @@ class _ActionScreenState extends State<ActionScreen> { | |||
| color: Colors.red, fontWeight: FontWeight.normal), | |||
| ), | |||
| onTap: () { | |||
| FocusScopeNode currentFocus = FocusScope.of(context); | |||
| if (!currentFocus.hasPrimaryFocus) { | |||
| currentFocus.unfocus(); | |||
| } | |||
| // FocusScopeNode currentFocus = FocusScope.of(context); | |||
| // if (!currentFocus.hasPrimaryFocus) { | |||
| // currentFocus.unfocus(); | |||
| // } | |||
| _validateInputs(); | |||
| }, | |||
| ), | |||
| ), | |||
| body: KeyboardDismisser( | |||
| child: MultiBlocProvider( | |||
| body: MultiBlocProvider( | |||
| providers: [ | |||
| BlocProvider<ActionUiCubit>( | |||
| create: (context) => | |||
| ActionUiCubit(repository: Repository()) | |||
| ..getActionUIForm(widget.idAction)), | |||
| ..getActionUIForm( | |||
| actionId: widget.idAction, | |||
| actionType: widget.activityType, | |||
| isEdit: widget.isEdit, | |||
| activityId: widget.activityId)), | |||
| BlocProvider<MediaHelperBloc>( | |||
| create: (context) => | |||
| MediaHelperBloc()..add(ChangeListMedia(items: [])), | |||
| @@ -377,7 +432,10 @@ class _ActionScreenState extends State<ActionScreen> { | |||
| print('loading...'); | |||
| return Center(child: CircularProgressIndicator()); | |||
| } else if (state is ActionUiSuccess) { | |||
| _actionUIForm = state.item as ActionUIForm; | |||
| _actionUIForm = state.actionUIForm; | |||
| _requestActivity = state.activityDetail; | |||
| //CREATE UI | |||
| _actionUIForm.objectParameterDTOList | |||
| .forEach((element) { | |||
| //generate controller | |||
| @@ -394,6 +452,11 @@ class _ActionScreenState extends State<ActionScreen> { | |||
| valueObjects.putIfAbsent( | |||
| element.id.toString(), () => ''); | |||
| }); | |||
| //SHOW EDIT DATA | |||
| if (widget.isEdit) { | |||
| showDataWhenEdit(); | |||
| } | |||
| return Column( | |||
| children: [ | |||
| Padding( | |||
| @@ -461,15 +524,14 @@ class _ActionScreenState extends State<ActionScreen> { | |||
| ], | |||
| ); | |||
| } else if (state is ActionUiFailure) { | |||
| print('error'); | |||
| return Text(state.errorString); | |||
| // LoadingDialog.hideLoadingDialog(context); | |||
| } | |||
| return Container(); | |||
| }, | |||
| ), | |||
| ), | |||
| )), | |||
| )))); | |||
| ))); | |||
| @override | |||
| void dispose() { | |||
| _executeByController.dispose(); | |||
| @@ -112,10 +112,13 @@ class _PlotActionScreenState extends State<PlotActionScreen> | |||
| return GestureDetector( | |||
| onTap: () { | |||
| Get.to(ActionScreen( | |||
| cropId: widget.cropId, | |||
| idAction: actionType.id, | |||
| title: actionType.description, | |||
| activityType: actionType.name)); | |||
| cropId: widget.cropId, | |||
| idAction: actionType.id, | |||
| title: actionType.description, | |||
| activityType: actionType.name, | |||
| activityId: -1, | |||
| isEdit: false, | |||
| )); | |||
| }, | |||
| child: Container( | |||
| margin: EdgeInsets.all(8), | |||
| @@ -3,20 +3,7 @@ import 'package:farm_tpf/data/repository/repository.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/bloc/widget_row_plot_info.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/bottom_loader.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/crop_status/sc_edit_action_crop_status.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/disease/sc_edit_action_disease.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/dung/sc_edit_action_dung.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/end/sc_edit_action_end.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/environment_update/sc_edit_action_environment_update.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/harvest/sc_edit_action_harvest.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/harvest_process/sc_edit_action_harvest_process.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/nursery/sc_edit_action_nursery.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/other/sc_edit_action_other.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/packing/sc_edit_action_packing.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/plant/sc_edit_action_plant.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/sell/sc_edit_action_sell.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/spraying/sc_edit_action_spraying.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/use_water/sc_edit_action_user_water.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/sc_action.dart'; | |||
| import 'package:farm_tpf/utils/const_color.dart'; | |||
| import 'package:flutter/material.dart'; | |||
| import 'package:flutter_bloc/flutter_bloc.dart'; | |||
| @@ -182,92 +169,14 @@ class ItemInfinityWidget extends StatelessWidget { | |||
| name: '${item.activityTypeDescription ?? ''}', | |||
| value: item.executeDate.format_DDMMYY_HHmm() ?? ''), | |||
| onTap: () { | |||
| if (item.activityTypeName == "ACTIVE_TYPE_NURSERY") { | |||
| Get.to(EditActionNurseryScreen( | |||
| cropId: item.cropId, | |||
| activityId: item.id, | |||
| isEdit: true, | |||
| )); | |||
| } else if (item.activityTypeName == "ACTIVE_TYPE_STATUS_CROP") { | |||
| Get.to(EditActionCropStatusScreen( | |||
| cropId: item.cropId, | |||
| activityId: item.id, | |||
| isEdit: true, | |||
| )); | |||
| } else if (item.activityTypeName == "ACTIVE_TYPE_UPDATE_ENV") { | |||
| Get.to(EditActionEnvironmentUpdate( | |||
| cropId: item.cropId, | |||
| activityId: item.id, | |||
| isEdit: true, | |||
| )); | |||
| } else if (item.activityTypeName == | |||
| "ACTIVE_TYPE_PESTS_INVESTIGATION") { | |||
| Get.to(EditActionDiseaseScreen( | |||
| cropId: item.cropId, | |||
| activityId: item.id, | |||
| isEdit: true, | |||
| )); | |||
| } else if (item.activityTypeName == "ACTIVE_TYPE_USE_WATER") { | |||
| Get.to(EditActionUseWaterScreen( | |||
| cropId: item.cropId, | |||
| activityId: item.id, | |||
| isEdit: true, | |||
| )); | |||
| } else if (item.activityTypeName == "ACTIVE_TYPE_HARVEST") { | |||
| Get.to(EditActionHarvestScreen( | |||
| cropId: item.cropId, | |||
| activityId: item.id, | |||
| isEdit: true, | |||
| )); | |||
| } else if (item.activityTypeName == "ACTIVE_TYPE_PACKING") { | |||
| Get.to(EditActionPackingScreen( | |||
| cropId: item.cropId, | |||
| activityId: item.id, | |||
| isEdit: true, | |||
| )); | |||
| } else if (item.activityTypeName == "ACTIVE_TYPE_SELL") { | |||
| Get.to(EditActionSellScreen( | |||
| cropId: item.cropId, | |||
| activityId: item.id, | |||
| isEdit: true, | |||
| )); | |||
| } else if (item.activityTypeName == "ACTIVE_TYPE_END") { | |||
| Get.to(EditActionEndScreen( | |||
| cropId: item.cropId, | |||
| activityId: item.id, | |||
| isEdit: true, | |||
| )); | |||
| } else if (item.activityTypeName == "ACTIVE_TYPE_STATUS_GROW") { | |||
| Get.to(EditActionPlantScreen( | |||
| cropId: item.cropId, | |||
| activityId: item.id, | |||
| isEdit: true, | |||
| )); | |||
| } else if (item.activityTypeName == "ACTIVE_TYPE_MANURING") { | |||
| Get.to(EditActionDungScreen( | |||
| cropId: item.cropId, | |||
| activityId: item.id, | |||
| isEdit: true, | |||
| )); | |||
| } else if (item.activityTypeName == "ACTIVE_TYPE_SPRAY") { | |||
| Get.to(EditActionSprayingScreen( | |||
| cropId: item.cropId, | |||
| activityId: item.id, | |||
| isEdit: true, | |||
| )); | |||
| } else if (item.activityTypeName == "ACTIVE_TYPE_PROCESS") { | |||
| Get.to(EditActionHarvestProcessScreen( | |||
| cropId: item.cropId, | |||
| activityId: item.id, | |||
| isEdit: true, | |||
| )); | |||
| } else { | |||
| Get.to(EditActionOtherScreen( | |||
| cropId: item.cropId, | |||
| activityId: item.id, | |||
| isEdit: true, | |||
| )); | |||
| } | |||
| Get.to(ActionScreen( | |||
| isEdit: true, | |||
| cropId: item.cropId, | |||
| activityId: item.id, | |||
| activityType: item.activityTypeName, | |||
| title: 'ActionScreen', | |||
| idAction: item.activityTypeId, | |||
| )); | |||
| }); | |||
| } | |||
| } | |||