| @@ -1 +1 @@ | |||
| c2bc17b6898e68be8222832a6d5d2d3d | |||
| 471e09183e20ec9c20cca9b580fecc10 | |||
| @@ -1,3 +1,5 @@ | |||
| import 'TbCropDTO.dart'; | |||
| class CropPlot { | |||
| TbCropDTO tbCropDTO; | |||
| List<Activities> activities; | |||
| @@ -54,99 +56,6 @@ class CropPlot { | |||
| } | |||
| } | |||
| class TbCropDTO { | |||
| int id; | |||
| String qrCode; | |||
| String code; | |||
| num areaM2; | |||
| int type; | |||
| String startDate; | |||
| String endDate; | |||
| String status; | |||
| String description; | |||
| int ageDayStartAt; | |||
| int tbSuppliesId; | |||
| String suppliesName; | |||
| int tbGuidelineId; | |||
| int netHouseId; | |||
| String netHouseName; | |||
| int areaId; | |||
| String area; | |||
| List<TbDetailUsers> tbDetailUsers; | |||
| TbCropDTO( | |||
| {this.id, | |||
| this.qrCode, | |||
| this.code, | |||
| this.areaM2, | |||
| this.type, | |||
| this.startDate, | |||
| this.endDate, | |||
| this.status, | |||
| this.description, | |||
| this.ageDayStartAt, | |||
| this.tbSuppliesId, | |||
| this.suppliesName, | |||
| this.tbGuidelineId, | |||
| this.netHouseId, | |||
| this.netHouseName, | |||
| this.areaId, | |||
| this.area, | |||
| this.tbDetailUsers}); | |||
| TbCropDTO.fromJson(Map<String, dynamic> json) { | |||
| id = json['id']; | |||
| qrCode = json['qrCode']; | |||
| code = json['code']; | |||
| areaM2 = json['areaM2']; | |||
| type = json['type']; | |||
| startDate = json['startDate']; | |||
| endDate = json['endDate']; | |||
| status = json['status']; | |||
| description = json['description']; | |||
| ageDayStartAt = json['ageDayStartAt']; | |||
| tbSuppliesId = json['tbSuppliesId']; | |||
| suppliesName = json['suppliesName']; | |||
| tbGuidelineId = json['tbGuidelineId']; | |||
| netHouseId = json['netHouseId']; | |||
| netHouseName = json['netHouseName']; | |||
| areaId = json['areaId']; | |||
| area = json['area']; | |||
| if (json['tbDetailUsers'] != null) { | |||
| tbDetailUsers = new List<TbDetailUsers>(); | |||
| json['tbDetailUsers'].forEach((v) { | |||
| tbDetailUsers.add(new TbDetailUsers.fromJson(v)); | |||
| }); | |||
| } | |||
| } | |||
| Map<String, dynamic> toJson() { | |||
| final Map<String, dynamic> data = new Map<String, dynamic>(); | |||
| data['id'] = this.id; | |||
| data['qrCode'] = this.qrCode; | |||
| data['code'] = this.code; | |||
| data['areaM2'] = this.areaM2; | |||
| data['type'] = this.type; | |||
| data['startDate'] = this.startDate; | |||
| data['endDate'] = this.endDate; | |||
| data['status'] = this.status; | |||
| data['description'] = this.description; | |||
| data['ageDayStartAt'] = this.ageDayStartAt; | |||
| data['tbSuppliesId'] = this.tbSuppliesId; | |||
| data['suppliesName'] = this.suppliesName; | |||
| data['tbGuidelineId'] = this.tbGuidelineId; | |||
| data['netHouseId'] = this.netHouseId; | |||
| data['netHouseName'] = this.netHouseName; | |||
| data['areaId'] = this.areaId; | |||
| data['area'] = this.area; | |||
| if (this.tbDetailUsers != null) { | |||
| data['tbDetailUsers'] = | |||
| this.tbDetailUsers.map((v) => v.toJson()).toList(); | |||
| } | |||
| return data; | |||
| } | |||
| } | |||
| class TbDetailUsers { | |||
| int id; | |||
| String fullName; | |||
| @@ -0,0 +1,94 @@ | |||
| import 'CropPlot.dart'; | |||
| class TbCropDTO { | |||
| int id; | |||
| String qrCode; | |||
| String code; | |||
| num areaM2; | |||
| int tbCropTypeId; | |||
| String startDate; | |||
| String endDate; | |||
| String status; | |||
| String description; | |||
| int ageDayStartAt; | |||
| int tbSuppliesId; | |||
| String suppliesName; | |||
| int tbGuidelineId; | |||
| int netHouseId; | |||
| String netHouseName; | |||
| int areaId; | |||
| String area; | |||
| List<TbDetailUsers> tbDetailUsers; | |||
| TbCropDTO( | |||
| {this.id, | |||
| this.qrCode, | |||
| this.code, | |||
| this.areaM2, | |||
| this.tbCropTypeId, | |||
| this.startDate, | |||
| this.endDate, | |||
| this.status, | |||
| this.description, | |||
| this.ageDayStartAt, | |||
| this.tbSuppliesId, | |||
| this.suppliesName, | |||
| this.tbGuidelineId, | |||
| this.netHouseId, | |||
| this.netHouseName, | |||
| this.areaId, | |||
| this.area, | |||
| this.tbDetailUsers}); | |||
| TbCropDTO.fromJson(Map<String, dynamic> json) { | |||
| id = json['id']; | |||
| qrCode = json['qrCode']; | |||
| code = json['code']; | |||
| areaM2 = json['areaM2']; | |||
| tbCropTypeId = json['tbCropTypeId']; | |||
| startDate = json['startDate']; | |||
| endDate = json['endDate']; | |||
| status = json['status']; | |||
| description = json['description']; | |||
| ageDayStartAt = json['ageDayStartAt']; | |||
| tbSuppliesId = json['tbSuppliesId']; | |||
| suppliesName = json['suppliesName']; | |||
| tbGuidelineId = json['tbGuidelineId']; | |||
| netHouseId = json['netHouseId']; | |||
| netHouseName = json['netHouseName']; | |||
| areaId = json['areaId']; | |||
| area = json['area']; | |||
| if (json['tbDetailUsers'] != null) { | |||
| tbDetailUsers = new List<TbDetailUsers>(); | |||
| json['tbDetailUsers'].forEach((v) { | |||
| tbDetailUsers.add(new TbDetailUsers.fromJson(v)); | |||
| }); | |||
| } | |||
| } | |||
| Map<String, dynamic> toJson() { | |||
| final Map<String, dynamic> data = new Map<String, dynamic>(); | |||
| data['id'] = this.id; | |||
| data['qrCode'] = this.qrCode; | |||
| data['code'] = this.code; | |||
| data['areaM2'] = this.areaM2; | |||
| data['tbCropTypeId'] = this.tbCropTypeId; | |||
| data['startDate'] = this.startDate; | |||
| data['endDate'] = this.endDate; | |||
| data['status'] = this.status; | |||
| data['description'] = this.description; | |||
| data['ageDayStartAt'] = this.ageDayStartAt; | |||
| data['tbSuppliesId'] = this.tbSuppliesId; | |||
| data['suppliesName'] = this.suppliesName; | |||
| data['tbGuidelineId'] = this.tbGuidelineId; | |||
| data['netHouseId'] = this.netHouseId; | |||
| data['netHouseName'] = this.netHouseName; | |||
| data['areaId'] = this.areaId; | |||
| data['area'] = this.area; | |||
| if (this.tbDetailUsers != null) { | |||
| data['tbDetailUsers'] = | |||
| this.tbDetailUsers.map((v) => v.toJson()).toList(); | |||
| } | |||
| return data; | |||
| } | |||
| } | |||
| @@ -26,11 +26,11 @@ class HttpLogInterceptor extends InterceptorsWrapper { | |||
| var token = await pref.getString(DATA_CONST.TOKEN_KEY); | |||
| options.headers["Authorization"] = "Bearer $token"; | |||
| options.receiveTimeout = 20000; | |||
| // log("onRequest: ${options.uri}\n" | |||
| // "data=${options.data}\n" | |||
| // "method=${options.method}\n" | |||
| // "headers=${options.headers}\n" | |||
| // "queryParameters=${options.queryParameters}"); | |||
| log("onRequest: ${options.uri}\n" | |||
| "data=${options.data}\n" | |||
| "method=${options.method}\n" | |||
| "headers=${options.headers}\n" | |||
| "queryParameters=${options.queryParameters}"); | |||
| return options; | |||
| } | |||
| @@ -5,6 +5,7 @@ import 'package:farm_tpf/custom_model/EnvironmentParameter.dart'; | |||
| import 'package:farm_tpf/custom_model/Harvest.dart'; | |||
| import 'package:farm_tpf/custom_model/LocationUnit.dart'; | |||
| import 'package:farm_tpf/custom_model/Supply.dart'; | |||
| import 'package:farm_tpf/custom_model/TbCropDTO.dart'; | |||
| import 'package:farm_tpf/custom_model/UpdateNoti.dart'; | |||
| import 'package:farm_tpf/custom_model/WaterType.dart'; | |||
| import 'package:farm_tpf/custom_model/account.dart'; | |||
| @@ -51,9 +52,8 @@ abstract class RestClient { | |||
| Future<void> deleteFcmToken(@Body() String token); | |||
| //Plot | |||
| @GET( | |||
| "/api/_search/tb-crops?page={page}&size={size}&sort=id,asc&query={query}") | |||
| Future<List<Crop>> getPlots( | |||
| @GET("/api/tb-crops?page={page}&size={size}&sort=id,asc&query={query}") | |||
| Future<List<TbCropDTO>> getPlots( | |||
| {@Path() int page = 0, @Path() int size = 20, @Path() String query = ""}); | |||
| @GET("/api/listActivityTypesOther") | |||
| @@ -9,7 +9,7 @@ part of 'rest_client.dart'; | |||
| class _RestClient implements RestClient { | |||
| _RestClient(this._dio, {this.baseUrl}) { | |||
| ArgumentError.checkNotNull(_dio, '_dio'); | |||
| this.baseUrl ??= 'https://smartfarm.aztrace.vn'; | |||
| this.baseUrl ??= 'https://smf.aztrace.vn'; | |||
| } | |||
| final Dio _dio; | |||
| @@ -189,7 +189,7 @@ class _RestClient implements RestClient { | |||
| queryParameters.removeWhere((k, v) => v == null); | |||
| final _data = <String, dynamic>{}; | |||
| final Response<List<dynamic>> _result = await _dio.request( | |||
| '/api/_search/tb-crops?page=$page&size=$size&sort=id,asc&query=$query', | |||
| '/api/tb-crops?page=$page&size=$size&sort=id,asc&query=$query', | |||
| queryParameters: queryParameters, | |||
| options: RequestOptions( | |||
| method: 'GET', | |||
| @@ -198,7 +198,7 @@ class _RestClient implements RestClient { | |||
| baseUrl: baseUrl), | |||
| data: _data); | |||
| var value = _result.data | |||
| .map((dynamic i) => Crop.fromJson(i as Map<String, dynamic>)) | |||
| .map((dynamic i) => TbCropDTO.fromJson(i as Map<String, dynamic>)) | |||
| .toList(); | |||
| return value; | |||
| } | |||
| @@ -1,3 +1,5 @@ | |||
| import 'dart:convert'; | |||
| import 'package:dio/dio.dart'; | |||
| import 'package:dio_http_cache/dio_http_cache.dart'; | |||
| import 'package:farm_tpf/custom_model/CropPlot.dart'; | |||
| @@ -7,6 +9,7 @@ import 'package:farm_tpf/custom_model/Harvest.dart'; | |||
| import 'package:farm_tpf/custom_model/LocationUnit.dart'; | |||
| import 'package:farm_tpf/custom_model/NotificationObjectDTO.dart'; | |||
| import 'package:farm_tpf/custom_model/Supply.dart'; | |||
| import 'package:farm_tpf/custom_model/TbCropDTO.dart'; | |||
| import 'package:farm_tpf/custom_model/UpdateNoti.dart'; | |||
| import 'package:farm_tpf/custom_model/WaterType.dart'; | |||
| import 'package:farm_tpf/custom_model/user.dart'; | |||
| @@ -52,7 +55,7 @@ class Repository { | |||
| return client.getCropDetailByCode(cropCode, page: page, size: size); | |||
| } | |||
| Future<List<Crop>> getPlots({int page, int size, String searchString}) { | |||
| Future<List<TbCropDTO>> getPlots({int page, int size, String searchString}) { | |||
| final client = RestClient(dio); | |||
| return client.getPlots(page: page, size: size, query: searchString); | |||
| } | |||
| @@ -144,7 +147,7 @@ class Repository { | |||
| Object getInstanceClass() { | |||
| var instanceClass; | |||
| if (1 == 1) { | |||
| instanceClass = new Crop(); | |||
| instanceClass = new TbCropDTO(); | |||
| } | |||
| return instanceClass; | |||
| } | |||
| @@ -206,4 +209,21 @@ class Repository { | |||
| final client = RestClient(dio); | |||
| return client.getEnvironmentParameters(cropId, page: page, size: size); | |||
| } | |||
| //NEW IMPLEMENT | |||
| Future<void> actionTypes(int cropTypeId, Function(List<ActionType>) onSuccess, | |||
| Function(dynamic) onError) async { | |||
| try { | |||
| var url = | |||
| '${ConstCommon.baseUrl}/api/listActivityTypesCulture/$cropTypeId'; | |||
| final Response<List<dynamic>> _result = await dio.get(url); | |||
| var value = _result.data | |||
| .map((dynamic i) => ActionType.fromJson(i as Map<String, dynamic>)) | |||
| .toList(); | |||
| onSuccess(value); | |||
| } on DioError catch (e) { | |||
| onError(e); | |||
| } | |||
| } | |||
| } | |||
| @@ -84,7 +84,7 @@ _showAlertCheckCropCode( | |||
| if (Get.isDialogOpen) Get.back(); | |||
| Get.to(PlotDetailScreen( | |||
| cropId: value.tbCropDTO.id, | |||
| cropType: value.tbCropDTO.type, | |||
| cropType: value.tbCropDTO.tbCropTypeId, | |||
| initialIndex: 0)); | |||
| }).catchError((onError) { | |||
| Utils.showDialog( | |||
| @@ -1,29 +0,0 @@ | |||
| import 'package:json_annotation/json_annotation.dart'; | |||
| part 'Crop.g.dart'; | |||
| @JsonSerializable() | |||
| class Crop { | |||
| Crop(); | |||
| num id; | |||
| String qrCode; | |||
| String code; | |||
| num areaM2; | |||
| num type; | |||
| String startDate; | |||
| String endDate; | |||
| String status; | |||
| String description; | |||
| num ageDayStartAt; | |||
| num tbSuppliesId; | |||
| String suppliesName; | |||
| num tbGuidelineId; | |||
| num netHouseId; | |||
| String netHouseName; | |||
| num areaId; | |||
| String area; | |||
| factory Crop.fromJson(Map<String,dynamic> json) => _$CropFromJson(json); | |||
| Map<String, dynamic> toJson() => _$CropToJson(this); | |||
| } | |||
| @@ -1,48 +0,0 @@ | |||
| // GENERATED CODE - DO NOT MODIFY BY HAND | |||
| part of 'Crop.dart'; | |||
| // ************************************************************************** | |||
| // JsonSerializableGenerator | |||
| // ************************************************************************** | |||
| Crop _$CropFromJson(Map<String, dynamic> json) { | |||
| return Crop() | |||
| ..id = json['id'] as num | |||
| ..qrCode = json['qrCode'] as String | |||
| ..code = json['code'] as String | |||
| ..areaM2 = json['areaM2'] as num | |||
| ..type = json['type'] as num | |||
| ..startDate = json['startDate'] as String | |||
| ..endDate = json['endDate'] as String | |||
| ..status = json['status'] as String | |||
| ..description = json['description'] as String | |||
| ..ageDayStartAt = json['ageDayStartAt'] as num | |||
| ..tbSuppliesId = json['tbSuppliesId'] as num | |||
| ..suppliesName = json['suppliesName'] as String | |||
| ..tbGuidelineId = json['tbGuidelineId'] as num | |||
| ..netHouseId = json['netHouseId'] as num | |||
| ..netHouseName = json['netHouseName'] as String | |||
| ..areaId = json['areaId'] as num | |||
| ..area = json['area'] as String; | |||
| } | |||
| Map<String, dynamic> _$CropToJson(Crop instance) => <String, dynamic>{ | |||
| 'id': instance.id, | |||
| 'qrCode': instance.qrCode, | |||
| 'code': instance.code, | |||
| 'areaM2': instance.areaM2, | |||
| 'type': instance.type, | |||
| 'startDate': instance.startDate, | |||
| 'endDate': instance.endDate, | |||
| 'status': instance.status, | |||
| 'description': instance.description, | |||
| 'ageDayStartAt': instance.ageDayStartAt, | |||
| 'tbSuppliesId': instance.tbSuppliesId, | |||
| 'suppliesName': instance.suppliesName, | |||
| 'tbGuidelineId': instance.tbGuidelineId, | |||
| 'netHouseId': instance.netHouseId, | |||
| 'netHouseName': instance.netHouseName, | |||
| 'areaId': instance.areaId, | |||
| 'area': instance.area, | |||
| }; | |||
| @@ -1,3 +1,2 @@ | |||
| export 'Crop.dart'; | |||
| export 'ResourceHelper.dart'; | |||
| export 'ActionType.dart'; | |||
| @@ -1,5 +1,5 @@ | |||
| import 'package:farm_tpf/custom_model/TbCropDTO.dart'; | |||
| import 'package:farm_tpf/data/repository/repository.dart'; | |||
| import 'package:farm_tpf/models/index.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/plot/widget_search.dart'; | |||
| @@ -134,7 +134,7 @@ class _InfinityViewState extends State<InfinityView> { | |||
| } | |||
| class ItemInfinityWidget extends StatelessWidget { | |||
| final Crop item; | |||
| final TbCropDTO item; | |||
| const ItemInfinityWidget({Key key, @required this.item}) : super(key: key); | |||
| @@ -241,7 +241,9 @@ class ItemInfinityWidget extends StatelessWidget { | |||
| context, | |||
| MaterialPageRoute( | |||
| builder: (BuildContext context) => PlotDetailScreen( | |||
| cropId: item.id, initialIndex: 0, cropType: item.type))); | |||
| cropId: item.id, | |||
| initialIndex: 0, | |||
| cropType: item.tbCropTypeId))); | |||
| }); | |||
| } | |||
| } | |||
| @@ -0,0 +1,26 @@ | |||
| import 'package:bloc/bloc.dart'; | |||
| import 'package:equatable/equatable.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'; | |||
| part 'plot_action_type_state.dart'; | |||
| class PlotActionTypeCubit extends Cubit<PlotActionTypeState> { | |||
| final Repository repository; | |||
| PlotActionTypeCubit(this.repository) : super(PlotActionTypeInitial()); | |||
| Future<void> getActionTypes(int cropTypeId) async { | |||
| try { | |||
| emit(PlotActionTypeLoading()); | |||
| await repository.actionTypes(cropTypeId, (data) { | |||
| emit(PlotActionTypeSuccess(data)); | |||
| }, (error) { | |||
| emit(PlotActionTypeError(AppException.handleError(error))); | |||
| }); | |||
| } catch (e) { | |||
| print(e); | |||
| emit(PlotActionTypeError(AppException.handleError(e))); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,22 @@ | |||
| part of 'plot_action_type_cubit.dart'; | |||
| abstract class PlotActionTypeState extends Equatable { | |||
| const PlotActionTypeState(); | |||
| @override | |||
| List<Object> get props => []; | |||
| } | |||
| class PlotActionTypeInitial extends PlotActionTypeState {} | |||
| class PlotActionTypeLoading extends PlotActionTypeState {} | |||
| class PlotActionTypeSuccess extends PlotActionTypeState { | |||
| final List<ActionType> actionTypes; | |||
| PlotActionTypeSuccess(this.actionTypes); | |||
| } | |||
| class PlotActionTypeError extends PlotActionTypeState { | |||
| final String error; | |||
| PlotActionTypeError(this.error); | |||
| } | |||
| @@ -1,18 +1,12 @@ | |||
| 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/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/plant/sc_edit_action_plant.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:cached_network_image/cached_network_image.dart'; | |||
| import 'package:farm_tpf/data/repository/repository.dart'; | |||
| import 'package:farm_tpf/models/index.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.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_string.dart'; | |||
| import 'package:flutter/material.dart'; | |||
| import 'package:flutter_bloc/flutter_bloc.dart'; | |||
| import 'package:get/get.dart'; | |||
| class PlotActionScreen extends StatefulWidget { | |||
| @@ -31,7 +25,7 @@ class _PlotActionScreenState extends State<PlotActionScreen> | |||
| @override | |||
| void initState() { | |||
| super.initState(); | |||
| _initActionButtons(); | |||
| // _initActionButtons(); | |||
| } | |||
| @override | |||
| @@ -39,85 +33,85 @@ 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)); | |||
| } | |||
| // _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)); | |||
| } | |||
| // 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: () { | |||
| Navigator.of(context).push( | |||
| MaterialPageRoute(builder: (context) => actionType.listScreen)); | |||
| // Navigator.of(context).push( | |||
| // MaterialPageRoute(builder: (context) => actionType.listScreen)); | |||
| }, | |||
| child: Container( | |||
| margin: EdgeInsets.all(8), | |||
| @@ -136,13 +130,20 @@ class _PlotActionScreenState extends State<PlotActionScreen> | |||
| mainAxisAlignment: MainAxisAlignment.center, | |||
| crossAxisAlignment: CrossAxisAlignment.center, | |||
| children: [ | |||
| Image.asset( | |||
| actionType.icon, | |||
| width: Get.width / 9, | |||
| height: Get.width / 9, | |||
| ), | |||
| 1 == 1 | |||
| ? 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.actionName, | |||
| actionType.description, | |||
| textAlign: TextAlign.center, | |||
| style: TextStyle( | |||
| fontWeight: FontWeight.bold, | |||
| @@ -157,27 +158,32 @@ class _PlotActionScreenState extends State<PlotActionScreen> | |||
| @override | |||
| Widget build(BuildContext context) { | |||
| return GridView.count( | |||
| shrinkWrap: true, | |||
| crossAxisCount: 3, | |||
| children: actions.map( | |||
| (item) { | |||
| return _createActionButtons(item, context); | |||
| return BlocProvider( | |||
| create: (contex) => | |||
| PlotActionTypeCubit(Repository())..getActionTypes(widget.cropType), | |||
| child: BlocBuilder<PlotActionTypeCubit, PlotActionTypeState>( | |||
| builder: (context, state) { | |||
| if (state is PlotActionTypeLoading) { | |||
| return LoadingListPage(); | |||
| } else if (state is PlotActionTypeSuccess) { | |||
| return GridView.count( | |||
| shrinkWrap: true, | |||
| crossAxisCount: 3, | |||
| children: state.actionTypes.map( | |||
| (item) { | |||
| return _createActionButtons(item, context); | |||
| }, | |||
| ).toList()); | |||
| } else if (state is PlotActionTypeError) { | |||
| return Center(child: Text(state.error)); | |||
| } else { | |||
| //init | |||
| return Container(); | |||
| } | |||
| }, | |||
| ).toList()); | |||
| )); | |||
| } | |||
| @override | |||
| bool get wantKeepAlive => true; | |||
| } | |||
| class ActionType { | |||
| Widget listScreen; | |||
| String actionName; | |||
| String icon; | |||
| ActionType(String actionName, Widget listScreen, String icon) { | |||
| this.actionName = actionName; | |||
| this.listScreen = listScreen; | |||
| this.icon = icon; | |||
| } | |||
| } | |||
| @@ -1,9 +1,9 @@ | |||
| import 'package:farm_tpf/custom_model/CropPlot.dart'; | |||
| import 'package:farm_tpf/custom_model/TbCropDTO.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/widget_row_plot_info.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/button_widget.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | |||
| @@ -163,14 +163,18 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> | |||
| color: AppColors.DEFAULT | |||
| .withOpacity(0.1), | |||
| name: 'Ngày gieo trồng', | |||
| value: cropPlot.tbCropDTO.type == 0 | |||
| value: cropPlot.tbCropDTO | |||
| .tbCropTypeId == | |||
| 0 | |||
| ? '${cropPlot.tbCropDTO?.startDate?.format_DDMMYY_HHmm() ?? '--'}' | |||
| : '--'), | |||
| WidgetRowPlotInfo( | |||
| color: AppColors.DEFAULT | |||
| .withOpacity(0.3), | |||
| name: 'Ngày vô khây ươm', | |||
| value: cropPlot.tbCropDTO.type == 1 | |||
| value: cropPlot.tbCropDTO | |||
| .tbCropTypeId == | |||
| 1 | |||
| ? '${cropPlot.tbCropDTO?.startDate?.format_DDMMYY_HHmm() ?? '--'}' | |||
| : '--'), | |||
| WidgetRowPlotInfo( | |||
| @@ -2,8 +2,8 @@ class ConstCommon { | |||
| static int kExpiredTime = 518400000; //6* 24 * 60 * 60 * 1000; 6days | |||
| static int kFileSize = 1000000; //1M = 1000.000 bytes | |||
| static int kMaxAgeCache = 7; // 7days | |||
| static const String baseUrl = "https://smartfarm.aztrace.vn"; | |||
| static const String baseImageUrl = "https://smartfarm.aztrace.vn/upload/"; | |||
| static const String baseUrl = "https://smf.aztrace.vn"; | |||
| static const String baseImageUrl = "https://smf.aztrace.vn/upload/"; | |||
| static RegExp regExpDecimal = RegExp("[0-9.]"); | |||
| static const String apiDetailNursery = "api/activity-nursery"; | |||