From 9fe152b793f0ceeb33443f0deede85943b8a34d2 Mon Sep 17 00:00:00 2001 From: cyzoox Date: Fri, 22 Sep 2023 16:00:14 +0800 Subject: [PATCH] Fixed minor bugs on adding land faas and editing land faas --- .../additional_item/additional_item_bloc.dart | 2 + .../property_appraisal_bloc.dart | 9 +- .../property_assessment_bloc.dart | 5 +- .../property_assessment_edit_bloc.dart | 2 - .../land_appraisal/land_appraisal_bloc.dart | 13 + .../land_appraisal/land_appraisal_event.dart | 10 + .../land_ext_bloc/land_ext_edit_bloc.dart | 53 + .../land_ext_bloc/land_ext_edit_event.dart | 39 + .../land_ext_bloc/land_ext_edit_state.dart | 28 + .../land_property_assessment_bloc.dart | 13 + .../land_property_assessment_event.dart | 11 + .../land_value_adjustments_bloc.dart | 13 + .../land_value_adjustments_event.dart | 10 + .../other_improvements_bloc.dart | 15 + .../other_improvements_event.dart | 10 + lib/bloc/passo/memoranda/memoranda_bloc.dart | 18 +- lib/bloc/passo/memoranda/memoranda_state.dart | 5 +- lib/model/passo/property_appraisal.dart | 49 +- .../bldg_location_landref.dart | 24 +- .../general_description.dart | 13 - .../property_appraisal.dart | 1001 +++++----- .../property_assessment.dart | 1712 ++++++----------- .../edit_building/bldgloc_landref.dart | 13 +- .../edit_building/property_appraisal.dart | 1223 ++++++------ .../property_assessement_edit.dart | 73 +- .../edit_building/property_owner_info.dart | 14 +- lib/screens/passo/Land/edit_land.dart | 27 +- .../Land/edit_land/AddLandAppraisalEdit.dart | 464 +++++ .../AddOtherImprovementEditModal.dart | 357 ++++ .../AddPropertyAssessmentEditModal.dart | 356 ++++ .../passo/Land/edit_land/land_appraisal.dart | 464 ++--- .../location_and_boundaries_edit.dart | 32 +- .../edit_land/other_improvements_edit.dart | 492 ++--- .../property_assessment_cont_edit.dart | 1135 ++++++----- .../edit_land/property_assessment_edit.dart | 452 +++-- .../edit_land/value_adjustments_edit.dart | 449 +++-- lib/screens/passo/building_home.dart | 7 +- lib/screens/passo/land_home .dart | 30 +- lib/screens/passo/passo_dashboard.dart | 2 +- .../building/property_appraisal_services.dart | 2 +- .../property_assessment_services.dart | 1 + lib/sevices/passo/land/land_ext.dart | 94 +- .../passo/land/land_other_improvements.dart | 8 +- .../passo/land/land_value_adjustment.dart | 8 +- lib/sevices/passo/memoranda.dart | 22 +- lib/sevices/passo/signatories_service.dart | 25 +- pubspec.yaml | 2 +- 47 files changed, 5042 insertions(+), 3765 deletions(-) create mode 100644 lib/bloc/passo/land/land_ext_bloc/land_ext_edit_bloc.dart create mode 100644 lib/bloc/passo/land/land_ext_bloc/land_ext_edit_event.dart create mode 100644 lib/bloc/passo/land/land_ext_bloc/land_ext_edit_state.dart create mode 100644 lib/screens/passo/Land/edit_land/AddLandAppraisalEdit.dart create mode 100644 lib/screens/passo/Land/edit_land/AddOtherImprovementEditModal.dart create mode 100644 lib/screens/passo/Land/edit_land/AddPropertyAssessmentEditModal.dart diff --git a/lib/bloc/passo/bulding/additional_item/additional_item_bloc.dart b/lib/bloc/passo/bulding/additional_item/additional_item_bloc.dart index 2d77bc3..e7aa87a 100644 --- a/lib/bloc/passo/bulding/additional_item/additional_item_bloc.dart +++ b/lib/bloc/passo/bulding/additional_item/additional_item_bloc.dart @@ -41,6 +41,8 @@ class AdditionalItemBloc globalAdditionalItems.add(newAdditional); emit(AdditionalItemsLoaded(globalAdditionalItems)); + } else { + emit(AdditionalItemsErrorState('error')); } } catch (e) { emit(AdditionalItemsErrorState(e.toString())); diff --git a/lib/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart b/lib/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart index cd11afb..10a5fdc 100644 --- a/lib/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart +++ b/lib/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart @@ -18,7 +18,7 @@ class PropertyAppraisalBloc emit(PropertyAppraisalLoading()); try { final appraisal = await PropertyAppraisalServices.instance.fetch(); - + print(appraisal); emit(PropertyAppraisalLoaded(appraisal)); } catch (e) { emit(PropertyAppraisalErrorState(e.toString())); @@ -30,11 +30,16 @@ class PropertyAppraisalBloc try { http.Response response = (await PropertyAppraisalServices.instance .update(event.appraisal, tempID.getInt('tempid')! - 1))!; - + print('Appraisal'); + print(tempID.getInt('tempid')! - 1); + print(event.appraisal.toJson()); + print(response.body); if (response.statusCode == 200) { emit(ShowPropertyAppraisalSuccessAlertState()); } } catch (e) { + print('app error'); + print(e.toString()); emit(ShowPropertyAppraisalErrorAlertState()); } }); diff --git a/lib/bloc/passo/bulding/property_assessment/property_assessment_bloc.dart b/lib/bloc/passo/bulding/property_assessment/property_assessment_bloc.dart index 9bf078b..80fd6b3 100644 --- a/lib/bloc/passo/bulding/property_assessment/property_assessment_bloc.dart +++ b/lib/bloc/passo/bulding/property_assessment/property_assessment_bloc.dart @@ -18,10 +18,11 @@ class PropertyAssessmentBloc emit(PropertyAssessmentLoading()); try { final tempID = await SharedPreferences.getInstance(); - + print(tempID.getInt('tempid')! - 1); final assessments = await PropertyAssessmentServices.instance - .fetch(tempID.getInt('tempid')! + 1); + .fetch(tempID.getInt('tempid')! - 1); + print(assessments); emit(PropertyAssessmentLoaded(assessments)); } catch (e) { emit(PropertyAssessmentErrorState(e.toString())); diff --git a/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.dart b/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.dart index 517d0fb..c09cf14 100644 --- a/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.dart +++ b/lib/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.dart @@ -18,8 +18,6 @@ class PropertyAssessmentEditBloc on((event, emit) async { emit(PropertyAssessmentEditLoading()); try { - final tempID = await SharedPreferences.getInstance(); - final assessments = await PropertyAssessmentServices.instance.fetchEdit(event.id); diff --git a/lib/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart b/lib/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart index 9d8ac0d..8409c00 100644 --- a/lib/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart +++ b/lib/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart @@ -27,6 +27,19 @@ class LandAppraisalBloc extends Bloc { emit(LandAppraisalErrorState(e.toString())); } }); + on((event, emit) async { + emit(LandAppraisalLoading()); + try { + final additionalItems = + await LandAppraisalServices.instance.fetch(event.id); + globalLandAppraisal.clear(); + globalLandAppraisal + .addAll(additionalItems); // Append all items to the list + emit(LandAppraisalLoaded(globalLandAppraisal)); + } catch (e) { + emit(LandAppraisalErrorState(e.toString())); + } + }); on((event, emit) async { http.Response response = (await LandAppraisalServices.instance.add(event.land_appr))!; diff --git a/lib/bloc/passo/land/land_appraisal/land_appraisal_event.dart b/lib/bloc/passo/land/land_appraisal/land_appraisal_event.dart index 50c1007..a5a90ba 100644 --- a/lib/bloc/passo/land/land_appraisal/land_appraisal_event.dart +++ b/lib/bloc/passo/land/land_appraisal/land_appraisal_event.dart @@ -16,6 +16,16 @@ class LoadLandAppraisal extends LandAppraisalEvent { List get props => [land_appr]; } +class LoadLandAppraisalEdit extends LandAppraisalEvent { + final List land_appr; + final int id; + + const LoadLandAppraisalEdit({required this.land_appr, required this.id}); + + @override + List get props => [land_appr]; +} + class AddLandAppraisal extends LandAppraisalEvent { final LandAppr land_appr; diff --git a/lib/bloc/passo/land/land_ext_bloc/land_ext_edit_bloc.dart b/lib/bloc/passo/land/land_ext_bloc/land_ext_edit_bloc.dart new file mode 100644 index 0000000..6f781ab --- /dev/null +++ b/lib/bloc/passo/land/land_ext_bloc/land_ext_edit_bloc.dart @@ -0,0 +1,53 @@ +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/model/passo/land_ext.dart'; +import 'package:unit2/sevices/passo/land/land_ext.dart'; +import 'package:http/http.dart' as http; +part 'land_ext_edit_event.dart'; +part 'land_ext_edit_state.dart'; + +class LandExtEditBloc extends Bloc { + LandExtEditBloc() : super(LandExtEditInitial()) { + on((event, emit) async { + emit(LandExtEditLoading()); + try { + final tempID = await SharedPreferences.getInstance(); + + final assessments = await LandExtServices.instance.fetchEdit(event.id); + + emit(LandExtEditLoaded(assessments)); + } catch (e) { + print(e.toString()); + emit(LandExtEditErrorState(e.toString())); + } + }); + // on((event, emit) async { + // http.Response response = (await LandLocationService.instance + // .addEdit(event.land_loc_edit))!; + // print('Assessment'); + // print(response.statusCode); + // print(response.body); + // if (response.statusCode == 201) { + // var jsonResponse = jsonDecode(response.body); + // LandPropertyLoc newAssessment = + // LandPropertyLoc.fromJson(jsonResponse['data']); + + // globalLandLocationEdit = newAssessment; + + // emit(LandLocationEditLoaded(globalLandLocationEdit)); + // } + // }); + on((event, emit) async { + http.Response response = (await LandExtServices.instance + .updateEdit(event.land_ext_edit, event.id))!; + print('landloc edit'); + print(response.statusCode); + print(response.body); + // if (response.statusCode == 201) { + // final faas = await PropertyInfoRepository.getUsers(); + // emit(FaasLoaded(faas)); + // } + }); + } +} diff --git a/lib/bloc/passo/land/land_ext_bloc/land_ext_edit_event.dart b/lib/bloc/passo/land/land_ext_bloc/land_ext_edit_event.dart new file mode 100644 index 0000000..2ea8f87 --- /dev/null +++ b/lib/bloc/passo/land/land_ext_bloc/land_ext_edit_event.dart @@ -0,0 +1,39 @@ +part of 'land_ext_edit_bloc.dart'; + +class LandExtEditEvent extends Equatable { + const LandExtEditEvent(); + + @override + List get props => []; +} + +class LoadLandExtEdit extends LandExtEditEvent { + final LandExt land_ext_edit; + final int? id; + + const LoadLandExtEdit({required this.land_ext_edit, required this.id}); + + @override + List get props => [land_ext_edit]; +} + +class AddLandExtEdit extends LandExtEditEvent { + final LandExt land_ext_edit; + + const AddLandExtEdit({required this.land_ext_edit}); + + @override + List get props => [land_ext_edit]; +} + +class UpdateLandExtEdit extends LandExtEditEvent { + // ignore: non_constant_identifier_names + final LandExt land_ext_edit; + final int id; + + // ignore: non_constant_identifier_names + const UpdateLandExtEdit({required this.land_ext_edit, required this.id}); + + @override + List get props => [land_ext_edit]; +} diff --git a/lib/bloc/passo/land/land_ext_bloc/land_ext_edit_state.dart b/lib/bloc/passo/land/land_ext_bloc/land_ext_edit_state.dart new file mode 100644 index 0000000..30f3e9a --- /dev/null +++ b/lib/bloc/passo/land/land_ext_bloc/land_ext_edit_state.dart @@ -0,0 +1,28 @@ +part of 'land_ext_edit_bloc.dart'; + +class LandExtEditState extends Equatable { + const LandExtEditState(); + + @override + List get props => []; +} + +class LandExtEditInitial extends LandExtEditState {} + +class LandExtEditLoading extends LandExtEditState {} + +class LandExtEditLoaded extends LandExtEditState { + LandExtEditLoaded(this.land_ext_edit); + final LandExt land_ext_edit; + + @override + List get props => [land_ext_edit]; +} + +class LandExtEditErrorState extends LandExtEditState { + LandExtEditErrorState(this.error); + final String error; + + @override + List get props => [error]; +} diff --git a/lib/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart b/lib/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart index 08d18b0..7abf025 100644 --- a/lib/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart +++ b/lib/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart @@ -29,6 +29,19 @@ class LandPropertyAssessmentBloc emit(LandPropertyAssessmentErrorState(e.toString())); } }); + on((event, emit) async { + emit(LandPropertyAssessmentLoading()); + try { + final additionalItems = + await LandPropertyAssessmentServices.instance.fetch(event.id); + globalLandPropertyAssessment.clear(); + globalLandPropertyAssessment + .addAll(additionalItems); // Append all items to the list + emit(LandPropertyAssessmentLoaded(globalLandPropertyAssessment)); + } catch (e) { + emit(LandPropertyAssessmentErrorState(e.toString())); + } + }); on((event, emit) async { http.Response response = (await LandPropertyAssessmentServices.instance .add(event.assessment))!; diff --git a/lib/bloc/passo/land/land_property_assessment/land_property_assessment_event.dart b/lib/bloc/passo/land/land_property_assessment/land_property_assessment_event.dart index 7eb84e0..43b56e5 100644 --- a/lib/bloc/passo/land/land_property_assessment/land_property_assessment_event.dart +++ b/lib/bloc/passo/land/land_property_assessment/land_property_assessment_event.dart @@ -17,6 +17,17 @@ class LoadLandPropertyAssessment extends LandPropertyAssessmentEvent { List get props => [assessment]; } +class LoadLandPropertyAssessmentEdit extends LandPropertyAssessmentEvent { + final List assessment; + final int id; + + const LoadLandPropertyAssessmentEdit( + {required this.assessment, required this.id}); + + @override + List get props => [assessment]; +} + class AddLandPropertyAssessment extends LandPropertyAssessmentEvent { final LandPropertyAssessment assessment; diff --git a/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart b/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart index 7655903..18ee5ff 100644 --- a/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart +++ b/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart @@ -25,6 +25,19 @@ class LandValueAdjustmentsBloc emit(LandValueAdjustmentsErrorState(e.toString())); } }); + on((event, emit) async { + emit(LandValueAdjustmentsLoading()); + try { + final additionalItems = + await ValueAdjustmentsServices.instance.fetch(event.id); + globalLandValueAdjustments.clear(); + globalLandValueAdjustments + .addAll(additionalItems); // Append all items to the list + emit(LandValueAdjustmentsLoaded(globalLandValueAdjustments)); + } catch (e) { + emit(LandValueAdjustmentsErrorState(e.toString())); + } + }); on((event, emit) async { http.Response response = (await ValueAdjustmentsServices.instance.add(event.val_adj))!; diff --git a/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_event.dart b/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_event.dart index 857e6f8..b94b9fa 100644 --- a/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_event.dart +++ b/lib/bloc/passo/land/land_value_adjustments/land_value_adjustments_event.dart @@ -16,6 +16,16 @@ class LoadLandValueAdjustments extends LandValueAdjustmentsEvent { List get props => [val_adj]; } +class LoadLandValueAdjustmentsEdit extends LandValueAdjustmentsEvent { + final List val_adj; + final int id; + + const LoadLandValueAdjustmentsEdit({required this.val_adj, required this.id}); + + @override + List get props => [val_adj]; +} + class AddLandValueAdjustments extends LandValueAdjustmentsEvent { final ValueAdjustments val_adj; diff --git a/lib/bloc/passo/land/other_improvements/other_improvements_bloc.dart b/lib/bloc/passo/land/other_improvements/other_improvements_bloc.dart index 3271961..239fcf8 100644 --- a/lib/bloc/passo/land/other_improvements/other_improvements_bloc.dart +++ b/lib/bloc/passo/land/other_improvements/other_improvements_bloc.dart @@ -25,6 +25,21 @@ class OtherImprovementsBloc emit(OtherImprovementErrorState(e.toString())); } }); + on((event, emit) async { + emit(OtherImprovementLoading()); + try { + final additionalItems = + await OtherImprovementServices.instance.fetch(event.ids); + print(additionalItems); + globalOtherImprovement.clear(); + globalOtherImprovement + .addAll(additionalItems); // Append all items to the list + emit(OtherImprovementLoaded(globalOtherImprovement)); + } catch (e) { + print(e.toString()); + emit(OtherImprovementErrorState(e.toString())); + } + }); on((event, emit) async { http.Response response = (await OtherImprovementServices.instance.add(event.other_imp))!; diff --git a/lib/bloc/passo/land/other_improvements/other_improvements_event.dart b/lib/bloc/passo/land/other_improvements/other_improvements_event.dart index 135746f..8adc624 100644 --- a/lib/bloc/passo/land/other_improvements/other_improvements_event.dart +++ b/lib/bloc/passo/land/other_improvements/other_improvements_event.dart @@ -16,6 +16,16 @@ class LoadOtherImprovement extends OtherImprovementsEvent { List get props => [other_imp]; } +class LoadOtherImprovementEdit extends OtherImprovementsEvent { + final List other_imps; + final int ids; + + const LoadOtherImprovementEdit({required this.other_imps, required this.ids}); + + @override + List get props => [other_imps]; +} + class AddOtherImprovement extends OtherImprovementsEvent { final OtherImprovements other_imp; diff --git a/lib/bloc/passo/memoranda/memoranda_bloc.dart b/lib/bloc/passo/memoranda/memoranda_bloc.dart index c1b1a31..4481611 100644 --- a/lib/bloc/passo/memoranda/memoranda_bloc.dart +++ b/lib/bloc/passo/memoranda/memoranda_bloc.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:unit2/model/passo/memoranda.dart'; @@ -7,12 +9,22 @@ part 'memoranda_event.dart'; part 'memoranda_state.dart'; class MemorandaBloc extends Bloc { - MemorandaBloc() : super(MemorandaInitial()) { + MemorandaBloc() : super(MemorandaLoading()) { on((event, emit) async { emit(MemorandaLoading()); try { - final municipality = await MemorandaServices.instance.fetch(); - emit(MemorandaLoaded(municipality)); + final response = await MemorandaServices.instance.fetch(); + print('Memoranda bloc'); + print(response.statusCode); + print(response.body); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + emit(MemorandaLoaded( + result.map(((e) => Memoranda.fromJson(e))).toList())); + } else { + emit(MemorandaErrorState(response.reasonPhrase!)); + } } catch (e) { emit(MemorandaErrorState(e.toString())); } diff --git a/lib/bloc/passo/memoranda/memoranda_state.dart b/lib/bloc/passo/memoranda/memoranda_state.dart index 1803cd8..08b93c7 100644 --- a/lib/bloc/passo/memoranda/memoranda_state.dart +++ b/lib/bloc/passo/memoranda/memoranda_state.dart @@ -12,15 +12,14 @@ class MemorandaInitial extends MemorandaState {} class MemorandaLoading extends MemorandaState {} class MemorandaLoaded extends MemorandaState { - MemorandaLoaded(this.memorada); final List memorada; - + const MemorandaLoaded(this.memorada); @override List get props => [memorada]; } class MemorandaErrorState extends MemorandaState { - MemorandaErrorState(this.error); + const MemorandaErrorState(this.error); final String error; @override diff --git a/lib/model/passo/property_appraisal.dart b/lib/model/passo/property_appraisal.dart index 9ebe509..24271b0 100644 --- a/lib/model/passo/property_appraisal.dart +++ b/lib/model/passo/property_appraisal.dart @@ -27,6 +27,7 @@ class PropertyAppraisal { final String? totalpercentDepreciation; final String? marketValue; final String? totalArea; + final String? actualUse; PropertyAppraisal( {this.id, @@ -44,31 +45,32 @@ class PropertyAppraisal { this.addItemsSubtotal, this.totalpercentDepreciation, this.marketValue, - this.totalArea}); + this.totalArea, + this.actualUse}); factory PropertyAppraisal.fromJson(Map json) => PropertyAppraisal( - id: json["id"], - bldgapprDetailsId: json["bldgappr_details_id"], - assessedById: json["assessed_by_id"], - assessedByName: json["assessed_by_name"], - dateCreated: json["date_created"] == null - ? null - : DateTime.parse(json["date_created"]), - dateModified: json["date_modified"] == null - ? null - : DateTime.parse(json["date_modified"]), - unitconstructCost: json["unitconstruct_cost"], - buildingCore: json["building_core"], - unitconstructSubtotal: json["unitconstruct_subtotal"], - depreciationRate: json["depreciation_rate"], - depreciationCost: json["depreciation_cost"], - costAddItems: json["cost_add_items"], - addItemsSubtotal: json["add_items_subtotal"], - totalpercentDepreciation: json["totalpercent_depreciation"], - marketValue: json["market_value"], - totalArea: json["total_area"], - ); + id: json["id"], + bldgapprDetailsId: json["bldgappr_details_id"], + assessedById: json["assessed_by_id"], + assessedByName: json["assessed_by_name"], + dateCreated: json["date_created"] == null + ? null + : DateTime.parse(json["date_created"]), + dateModified: json["date_modified"] == null + ? null + : DateTime.parse(json["date_modified"]), + unitconstructCost: json["unitconstruct_cost"], + buildingCore: json["building_core"], + unitconstructSubtotal: json["unitconstruct_subtotal"], + depreciationRate: json["depreciation_rate"], + depreciationCost: json["depreciation_cost"], + costAddItems: json["cost_add_items"], + addItemsSubtotal: json["add_items_subtotal"], + totalpercentDepreciation: json["totalpercent_depreciation"], + marketValue: json["market_value"], + totalArea: json["total_area"], + actualUse: json["actual_use"]); Map toJson() => { "id": id, @@ -86,6 +88,7 @@ class PropertyAppraisal { "add_items_subtotal": addItemsSubtotal, "totalpercent_depreciation": totalpercentDepreciation, "market_value": marketValue, - "total_area": totalArea + "total_area": totalArea, + "actual_use": actualUse }; } diff --git a/lib/screens/passo/Building/add_building_components/bldg_location_landref.dart b/lib/screens/passo/Building/add_building_components/bldg_location_landref.dart index 7346172..3374a9e 100644 --- a/lib/screens/passo/Building/add_building_components/bldg_location_landref.dart +++ b/lib/screens/passo/Building/add_building_components/bldg_location_landref.dart @@ -49,20 +49,10 @@ class _BldgLocationLandrefPage extends State { final progress = ProgressHUD.of(context); progress!.showWithText("Please wait..."); } - if (state is MunicipalityLoaded) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - } + if (state is MunicipalityErrorState) { final progress = ProgressHUD.of(context); progress?.dismiss(); - // Fluttertoast.showToast( - // msg: onError, - // fontSize: 24, - // toastLength: Toast.LENGTH_LONG, - // gravity: ToastGravity.CENTER, - // backgroundColor: Colors.black, - // textColor: Colors.white); } }, builder: (context, state) { @@ -75,6 +65,7 @@ class _BldgLocationLandrefPage extends State { final progress = ProgressHUD.of(context); progress!.showWithText("Please wait..."); } + if (state is BarangayLoaded) { final progress = ProgressHUD.of(context); progress?.dismiss(); @@ -82,13 +73,6 @@ class _BldgLocationLandrefPage extends State { if (state is BarangayErrorState) { final progress = ProgressHUD.of(context); progress?.dismiss(); - // Fluttertoast.showToast( - // msg: onError, - // fontSize: 24, - // toastLength: Toast.LENGTH_LONG, - // gravity: ToastGravity.CENTER, - // backgroundColor: Colors.black, - // textColor: Colors.white); } }, builder: (context, state) { @@ -130,7 +114,7 @@ class _BldgLocationLandrefPage extends State { borderRadius: BorderRadius.circular(5.0), ), - child: Align( + child: const Align( alignment: Alignment.center, child: Text( "AGUSAN DEL NORTE", @@ -244,7 +228,7 @@ class _BldgLocationLandrefPage extends State { child: customTextField("Area", "", 'area')) ]), - SizedBox( + const SizedBox( height: 50, ), Row( diff --git a/lib/screens/passo/Building/add_building_components/general_description.dart b/lib/screens/passo/Building/add_building_components/general_description.dart index e4a5abd..05077ef 100644 --- a/lib/screens/passo/Building/add_building_components/general_description.dart +++ b/lib/screens/passo/Building/add_building_components/general_description.dart @@ -231,17 +231,4 @@ class _GeneralDescriptionPage extends State { ), ); } - - Future _waitForAddPropertyInfoToComplete() async { - // Wait for the state change indicating completion - final propertyInfoState = context.read().state; - - if (propertyInfoState is ShowGenDescErrorAlertState) { - // Check if the add operation was unsuccessful - return true; // You'll need to define this in your state class - } - - // Return false if the state didn't change as expected - return false; - } } diff --git a/lib/screens/passo/Building/add_building_components/property_appraisal.dart b/lib/screens/passo/Building/add_building_components/property_appraisal.dart index e53d76d..3ad760d 100644 --- a/lib/screens/passo/Building/add_building_components/property_appraisal.dart +++ b/lib/screens/passo/Building/add_building_components/property_appraisal.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:intl/intl.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -502,402 +504,418 @@ class _PropertyAppraisalPage extends State { @override Widget build(BuildContext context) { - return BlocConsumer( - listener: (context, state) {}, - builder: (context, state) { - if (state is AdditionalItemsLoaded) { - return SingleChildScrollView( - child: Container( - margin: const EdgeInsets.only(left: 20.0, right: 20.0), - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 20), - child: const Text('PROPERTY APPRAISAL', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) { + if (state is AdditionalItemsLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is AdditionalItemsLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is AdditionalItemsErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, + builder: (context, state) { + if (state is AdditionalItemsLoaded) { + return SingleChildScrollView( + child: Container( + margin: const EdgeInsets.only(left: 20.0, right: 20.0), + child: Column( children: [ Container( - child: Text( - "Unit Construction Cost", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 20), + child: const Text('PROPERTY APPRAISAL', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), ), - Container( - child: Text( - formKey.currentState!.value['bldg_type'].unitValue + - ' sq.m', - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Building Core", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Unit Construction Cost", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + formKey.currentState!.value['bldg_type'] + .unitValue + + ' sq.m', + textAlign: TextAlign.right, + ), + ) + ], ), - Container( - child: Text( - '', - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 40), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Sub-total", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Building Core", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + '', + textAlign: TextAlign.right, + ), + ) + ], ), - Container( - child: Text( - (double.parse(formKey - .currentState!.value['total_area']) * - double.parse(formKey.currentState! - .value['bldg_type'].unitValue)) - .toString(), - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 40), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Cost of Additional Items", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - '', - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Sub-total", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - calculateAdditionalItems(state.items).toString(), - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Total Construction Cost", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - calculateTotalConstructionCost( - (double.parse(formKey + const SizedBox(height: 40), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Sub-total", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + (double.parse(formKey .currentState!.value['total_area']) * double.parse(formKey.currentState! - .value['bldg_type'].unitValue)), - state.items) - .toString(), - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 40), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Depreciation Rate", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), + .value['bldg_type'].unitValue)) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], ), - SizedBox( - width: 90, - height: 25, - child: FormBuilderTextField( - name: 'depRate', - decoration: normalTextFieldStyle("", ""), - validator: FormBuilderValidators.compose([]), - onChanged: (value) { - setState(() { - depRate = double.parse(value!); - }); - }, - ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Cost of Additional Items", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + '', + textAlign: TextAlign.right, + ), + ) + ], ), - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Depreciation Cost", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Sub-total", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateAdditionalItems(state.items).toString(), + textAlign: TextAlign.right, + ), + ) + ], ), - Container( - child: Text( - calculateDepCost( - (double.parse(formKey - .currentState!.value['total_area']) * - double.parse(formKey.currentState! - .value['bldg_type'].unitValue)), - state.items, - depRate) - .toString(), - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Total % Depreciation", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Total Construction Cost", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateTotalConstructionCost( + (double.parse(formKey.currentState! + .value['total_area']) * + double.parse(formKey.currentState! + .value['bldg_type'].unitValue)), + state.items) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], ), - Container( - child: Text( - '${(depRate * 100).toStringAsFixed(2)}%', - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Market Value", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Depreciation Rate", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + SizedBox( + width: 90, + height: 25, + child: FormBuilderTextField( + name: 'depRate', + decoration: normalTextFieldStyle("", ""), + validator: FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + depRate = double.parse(value!); + }); + }, + ), + ), + ], ), - Container( - child: Text( - calculateMarketValue( - (double.parse(formKey - .currentState!.value['total_area']) * - double.parse(formKey.currentState! - .value['bldg_type'].unitValue)), - state.items, - depRate) - .toString(), - textAlign: TextAlign.right, - ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Depreciation Cost", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateDepCost( + (double.parse(formKey.currentState! + .value['total_area']) * + double.parse(formKey.currentState! + .value['bldg_type'].unitValue)), + state.items, + depRate) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], ), - ], - ), - Row( - children: [ - Expanded( - flex: 1, - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Container( - margin: const EdgeInsets.only( - left: 20.0, right: 20.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, - top: 20, - right: 0, - bottom: 20), - child: const Text('PROPERTY ASSESSMENT', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18), - textAlign: TextAlign.left), - ), - Column( + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Total % Depreciation", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + '${(depRate * 100).toStringAsFixed(2)}%', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Market Value", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateMarketValue( + (double.parse(formKey.currentState! + .value['total_area']) * + double.parse(formKey.currentState! + .value['bldg_type'].unitValue)), + state.items, + depRate) + .toString(), + textAlign: TextAlign.right, + ), + ), + ], + ), + Row( + children: [ + Expanded( + flex: 1, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Container( + margin: const EdgeInsets.only( + left: 20.0, right: 20.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, children: [ - Row( - children: [ - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: const Text( - 'Actual Use', - style: TextStyle( + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 20), + child: const Text( + 'PROPERTY ASSESSMENT', + style: TextStyle( fontWeight: FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: const Text( - 'Market Value', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: const Text( - 'Ass. Level', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: const Text( - 'Ass. Value', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - ], + fontSize: 18), + textAlign: TextAlign.left), ), - SizedBox( - height: 59, - child: Row( - children: [ - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: Text( - formKey.currentState - ?.value['actual_use']!, - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, + Column( + children: [ + Row( + children: [ + Container( + width: 100, + margin: + const EdgeInsets.only( + top: 15, left: 15), + padding: + const EdgeInsets.all( + 5.0), + child: const Text( + 'Actual Use', + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 13, + ), + textAlign: + TextAlign.center, ), - textAlign: TextAlign.center, ), - ), - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: Text( - calculateMarketValue( - (double.parse(formKey - .currentState! - .value[ - 'total_area']) * - double.parse(formKey - .currentState! - .value[ - 'bldg_type'] - .unitValue)), - state.items, - depRate) - .toString(), - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, + Container( + width: 100, + margin: + const EdgeInsets.only( + top: 15, left: 15), + padding: + const EdgeInsets.all( + 5.0), + child: const Text( + 'Market Value', + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 13, + ), + textAlign: + TextAlign.center, ), - textAlign: TextAlign.center, ), - ), - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: Text( - assessmentLevel( + Container( + width: 100, + margin: + const EdgeInsets.only( + top: 15, left: 15), + padding: + const EdgeInsets.all( + 5.0), + child: const Text( + 'Ass. Level', + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 13, + ), + textAlign: + TextAlign.center, + ), + ), + Container( + width: 100, + margin: + const EdgeInsets.only( + top: 15, left: 15), + padding: + const EdgeInsets.all( + 5.0), + child: const Text( + 'Ass. Value', + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 13, + ), + textAlign: + TextAlign.center, + ), + ), + ], + ), + SizedBox( + height: 59, + child: Row( + children: [ + Container( + width: 100, + margin: + const EdgeInsets.only( + top: 15, + left: 15), + padding: + const EdgeInsets.all( + 5.0), + child: Text( + formKey.currentState + ?.value[ + 'actual_use']!, + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 13, + ), + textAlign: + TextAlign.center, + ), + ), + Container( + width: 100, + margin: + const EdgeInsets.only( + top: 15, + left: 15), + padding: + const EdgeInsets.all( + 5.0), + child: Text( calculateMarketValue( (double.parse(formKey .currentState! @@ -911,25 +929,26 @@ class _PropertyAppraisalPage extends State { state.items, depRate) .toString(), - formKey.currentState - ?.value[ - 'actual_use']), - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 13, + ), + textAlign: + TextAlign.center, + ), ), - textAlign: TextAlign.center, - ), - ), - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: Text( - assessmentValue( + Container( + width: 100, + margin: + const EdgeInsets.only( + top: 15, + left: 15), + padding: + const EdgeInsets.all( + 5.0), + child: Text( + assessmentLevel( calculateMarketValue( (double.parse(formKey.currentState!.value[ 'total_area']) * @@ -943,91 +962,131 @@ class _PropertyAppraisalPage extends State { .toString(), formKey.currentState ?.value[ - 'actual_use']) - .toString(), - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, + 'actual_use']), + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 13, + ), + textAlign: + TextAlign.center, + ), ), - textAlign: TextAlign.center, - ), + Container( + width: 100, + margin: + const EdgeInsets.only( + top: 15, + left: 15), + padding: + const EdgeInsets.all( + 5.0), + child: Text( + assessmentValue( + calculateMarketValue( + (double.parse(formKey.currentState!.value['total_area']) * + double.parse(formKey + .currentState! + .value[ + 'bldg_type'] + .unitValue)), + state + .items, + depRate) + .toString(), + formKey.currentState + ?.value[ + 'actual_use']) + .toString(), + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 13, + ), + textAlign: + TextAlign.center, + ), + ), + ], ), - ], - ), - ) - ], - ), - ]))), + ) + ], + ), + ]))), + ), + ], ), - ], - ), - SizedBox( - height: 50, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - CustomButton( - icon: const Icon(Icons.chevron_left_rounded, - color: Colors.white), - onPressed: () { - { - widget.PrevBtn(); - } - ; - }, + SizedBox( + height: 50, ), - CustomButton( - icon: const Icon(Icons.chevron_right_rounded, - color: Colors.white), - onPressed: () async { - { - final tempID = - await SharedPreferences.getInstance(); - print(tempID.getInt('tempid')); - var appraisals = PropertyAppraisal( - id: 1, - bldgapprDetailsId: tempID.getInt('tempid')!, - unitconstructCost: formKey - .currentState!.value['bldg_type'].unitValue, - buildingCore: 'test', - unitconstructSubtotal: - (double.parse(formKey.currentState!.value['total_area']) * - double.parse(formKey.currentState! - .value['bldg_type'].unitValue)) - .toString(), - depreciationRate: depRate.toString(), - depreciationCost: calculateDepCost( + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () async { + { + final tempID = + await SharedPreferences.getInstance(); + print(tempID.getInt('tempid')); + var appraisals = PropertyAppraisal( + id: 1, + bldgapprDetailsId: + tempID.getInt('tempid')! - 1, + unitconstructCost: formKey.currentState! + .value['bldg_type'].unitValue, + buildingCore: 'test', + unitconstructSubtotal: (double.parse(formKey.currentState!.value['total_area']) * - double.parse( - formKey.currentState!.value['bldg_type'].unitValue)), - state.items, - depRate) - .toString(), - costAddItems: calculateAdditionalItems(state.items).toString(), - addItemsSubtotal: calculateAdditionalItems(state.items).toString(), - totalpercentDepreciation: (depRate * 100).toStringAsFixed(2), - marketValue: calculateMarketValue((double.parse(formKey.currentState!.value['total_area']) * double.parse(formKey.currentState!.value['bldg_type'].unitValue)), state.items, depRate).toString(), - totalArea: formKey.currentState!.value['total_area']); - context.read() - ..add( - AddPropertyAppraisal(appraisal: appraisals)); + double.parse(formKey + .currentState! + .value['bldg_type'] + .unitValue)) + .toString(), + depreciationRate: depRate.toString(), + depreciationCost: calculateDepCost( + (double.parse(formKey.currentState!.value['total_area']) * + double.parse(formKey.currentState!.value['bldg_type'].unitValue)), + state.items, + depRate) + .toString(), + costAddItems: calculateAdditionalItems(state.items).toString(), + addItemsSubtotal: calculateAdditionalItems(state.items).toString(), + totalpercentDepreciation: (depRate * 100).toStringAsFixed(2), + marketValue: calculateMarketValue((double.parse(formKey.currentState!.value['total_area']) * double.parse(formKey.currentState!.value['bldg_type'].unitValue)), state.items, depRate).toString(), + totalArea: formKey.currentState!.value['total_area'], + actualUse: "Residential"); + context.read() + ..add(AddPropertyAppraisal( + appraisal: appraisals)); - widget.NextBtn(); - } - ; - }, - ) + widget.NextBtn(); + } + ; + }, + ) + ], + ), ], ), - ], - ), - ), - ); - } - return Container(); - }, + ), + ); + } + return Container(); + }, + ), + ), ); } diff --git a/lib/screens/passo/Building/add_building_components/property_assessment.dart b/lib/screens/passo/Building/add_building_components/property_assessment.dart index e670b78..386df67 100644 --- a/lib/screens/passo/Building/add_building_components/property_assessment.dart +++ b/lib/screens/passo/Building/add_building_components/property_assessment.dart @@ -40,1157 +40,585 @@ class _PropertyAssessmentPage extends State { String _memoranda = ''; final focus = FocusNode(); - String assessmentLevel(marketValues, property_class) { - final marketValue = double.parse(marketValues); - switch (property_class) { - case 'Residential': - if (marketValue < 175000) { - // setState(() { - // assessment_level = 0; - // }); - return '0 '; - } else if (marketValue < 300000 && marketValue > 175000) { - // setState(() { - // assessment_level = 0.10; - // }); - return '10 '; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.20; - // }); - return '20 '; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.25; - // }); - return '25 '; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.30; - // }); - return '30 '; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.35; - // }); - return '35 '; - } else if (marketValue < 5000000 && marketValue > 2000000) { - // setState(() { - // assessment_level = 0.40; - // }); - return '40 '; - } else if (marketValue < 10000000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.50; - // }); - return '50 '; - } else if (marketValue > 10000000) { - // setState(() { - // assessment_level = 0.60; - // }); - return '60 '; - } - break; - case 'Agricultural': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.45; - // }); - return '45 '; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.50; - // }); - return '50 '; - } else if (marketValue < 750000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.55; - // }); - return '55 '; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.60; - // }); - return '60 '; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.65; - // }); - return '65 '; - } else if (marketValue > 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return '70 '; - } - break; - case 'Commercial': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.30; - // }); - return '30 '; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.35; - // }); - return '35 '; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.40; - // }); - return '40 '; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.50; - // }); - return '50 '; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.60; - // }); - return '60 '; - } else if (marketValue < 5000000 && marketValue > 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return '70 '; - } else if (marketValue < 10000000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.75; - // }); - return '75 '; - } else if (marketValue > 10000000) { - // setState(() { - // assessment_level = 0.80; - // }); - } - break; - case 'Industrial': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.30; - // }); - return '30 '; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.35; - // }); - return '35 '; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.40; - // }); - return '40 '; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.50; - // }); - return '50 '; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.60; - // }); - return '60 '; - } else if (marketValue < 5000000 && marketValue > 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return '70 '; - } else if (marketValue < 10000000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.75; - // }); - return '75 '; - } else if (marketValue > 10000000) { - // setState(() { - // assessment_level = 0.80; - // }); - return '80 '; - } - break; - case 'Mineral': - break; - case 'Timberland': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.45; - // }); - return '45 '; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.50; - // }); - return '50 '; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.55; - // }); - return '55 '; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.60; - // }); - return '60 '; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.65; - // }); - return '65 '; - } else if (marketValue < 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return '70 '; - } - break; - default: - } - return ''; - } - - double assessmentValue(marketValues, property_class) { - final marketValue = double.parse(marketValues); - switch (property_class) { - case 'Residential': - if (marketValue < 175000) { - // setState(() { - // assessment_level = 0; - // }); - return marketValue * 0; - } else if (marketValue < 300000 && marketValue > 175000) { - // setState(() { - // assessment_level = 0.10; - // }); - return marketValue * 0.10; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.20; - // }); - return marketValue * 0.20; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.25; - // }); - return marketValue * 0.25; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.30; - // }); - return marketValue * 0.30; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.35; - // }); - return marketValue * 0.35; - } else if (marketValue < 5000000 && marketValue > 2000000) { - // setState(() { - // assessment_level = 0.40; - // }); - return marketValue * 0.40; - } else if (marketValue < 10000000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.50; - // }); - return marketValue * 0.50; - } else if (marketValue > 10000000) { - // setState(() { - // assessment_level = 0.60; - // }); - return marketValue * 0.60; - } - break; - case 'Agricultural': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.45; - // }); - return marketValue * 0.45; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.50; - // }); - return marketValue * 0.50; - } else if (marketValue < 750000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.55; - // }); - return marketValue * 0.55; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.60; - // }); - return marketValue * 0.60; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.65; - // }); - return marketValue * 0.65; - } else if (marketValue > 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return marketValue * 0.70; - } - break; - case 'Commercial': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.30; - // }); - return marketValue * 0.30; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.35; - // }); - return marketValue * 0.35; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.40; - // }); - return marketValue * 0.40; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.50; - // }); - return marketValue * 0.50; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.60; - // }); - return marketValue * 0.60; - } else if (marketValue < 5000000 && marketValue > 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return marketValue * 0.70; - } else if (marketValue < 10000000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.75; - // }); - return marketValue * 0.75; - } else if (marketValue > 10000000) { - // setState(() { - // assessment_level = 0.80; - // }); - } - break; - case 'Industrial': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.30; - // }); - return marketValue * 0.30; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.35; - // }); - return marketValue * 0.35; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.40; - // }); - return marketValue * 0.40; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.50; - // }); - return marketValue * 0.50; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.60; - // }); - return marketValue * 0.60; - } else if (marketValue < 5000000 && marketValue > 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return marketValue * 0.70; - } else if (marketValue < 10000000 && marketValue > 5000000) { - // setState(() { - // assessment_level = 0.75; - // }); - return marketValue * 0.75; - } else if (marketValue > 10000000) { - // setState(() { - // assessment_level = 0.80; - // }); - return marketValue * 0.80; - } - break; - case 'Mineral': - break; - case 'Timberland': - if (marketValue < 300000) { - // setState(() { - // assessment_level = 0.45; - // }); - return marketValue * 0.45; - } else if (marketValue < 500000 && marketValue > 300000) { - // setState(() { - // assessment_level = 0.50; - // }); - return marketValue * 0.50; - } else if (marketValue < 750000 && marketValue > 500000) { - // setState(() { - // assessment_level = 0.55; - // }); - return marketValue * 0.55; - } else if (marketValue < 1000000 && marketValue > 750000) { - // setState(() { - // assessment_level = 0.60; - // }); - return marketValue * 0.60; - } else if (marketValue < 2000000 && marketValue > 1000000) { - // setState(() { - // assessment_level = 0.65; - // }); - return marketValue * 0.65; - } else if (marketValue < 2000000) { - // setState(() { - // assessment_level = 0.70; - // }); - return marketValue * 0.70; - } - break; - default: - } - return 0; - } - @override Widget build(BuildContext context) { return Scaffold( - resizeToAvoidBottomInset: true, - body: ProgressHUD( - padding: const EdgeInsets.all(24), - backgroundColor: Colors.black87, - indicatorWidget: const SpinKitFadingCircle(color: Colors.white), - child: BlocConsumer( - listener: (context, state) { - if (state is PropertyAssessmentLoading) { - final progress = ProgressHUD.of(context); - progress!.showWithText("Please wait..."); - } - if (state is PropertyAssessmentLoaded) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - } - if (state is PropertyAssessmentErrorState) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - // Fluttertoast.showToast( - // msg: onError, - // fontSize: 24, - // toastLength: Toast.LENGTH_LONG, - // gravity: ToastGravity.CENTER, - // backgroundColor: Colors.black, - // textColor: Colors.white); - } - }, - builder: (context, state) { - if (state is PropertyAssessmentLoaded) { - return BlocConsumer( - listener: (context, state) { - if (state is SignatoriesLoading) { - final progress = ProgressHUD.of(context); - progress!.showWithText("Please wait..."); - } - if (state is SignatoriesLoaded) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - } - if (state is SignatoriesErrorState) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - // Fluttertoast.showToast( - // msg: onError, - // fontSize: 24, - // toastLength: Toast.LENGTH_LONG, - // gravity: ToastGravity.CENTER, - // backgroundColor: Colors.black, - // textColor: Colors.white); - } - }, - builder: (context, state) { - if (state is SignatoriesLoaded) { - final signatories = state.signatories; - return BlocConsumer( - listener: (context, state) { - if (state is MemorandaLoading) { - final progress = ProgressHUD.of(context); - progress!.showWithText("Please wait..."); - } - if (state is MemorandaLoaded) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - } - if (state is MemorandaErrorState) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - // Fluttertoast.showToast( - // msg: onError, - // fontSize: 24, - // toastLength: Toast.LENGTH_LONG, - // gravity: ToastGravity.CENTER, - // backgroundColor: Colors.black, - // textColor: Colors.white); - } - }, - builder: (context, state) { - if (state is MemorandaLoaded) { - final memoranda = state.memorada; - return BlocConsumer( - listener: (context, state) { - if (state is PropertyAppraisalLoading) { - final progress = ProgressHUD.of(context); - progress!.showWithText("Please wait..."); - } - if (state is PropertyAppraisalLoaded) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - } - if (state is PropertyAppraisalErrorState) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - // Fluttertoast.showToast( - // msg: onError, - // fontSize: 24, - // toastLength: Toast.LENGTH_LONG, - // gravity: ToastGravity.CENTER, - // backgroundColor: Colors.black, - // textColor: Colors.white); - } - }, builder: (context, state) { - if (state is PropertyAppraisalLoaded) { - return ListView( - children: [ + resizeToAvoidBottomInset: true, + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is SignatoriesLoaded) { + final signatories = state.signatories; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is MemorandaLoaded) { + final memoranda = state.memorada; + return ListView( + children: [ + Align( + alignment: Alignment.center, + child: Container( + margin: const EdgeInsets.fromLTRB(0, 20, 0, 20), + child: const Text( + 'PROPERTY ASSESSMENT cont..', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18, + ), + textAlign: TextAlign.left, + ), + ), + ), + Expanded( + flex: 3, + child: SingleChildScrollView( + padding: + EdgeInsets.only(left: 20.0, right: 20.0), + scrollDirection: Axis.vertical, + child: Column(children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Row( + children: [ + const Text('Taxable'), + Checkbox( + checkColor: Colors.white, + value: isTaxable, + onChanged: (bool? value) { + setState(() { + isTaxable = value!; + }); + }, + ) + ], + ), + Row( + children: [ + const Text('Exempt'), + Checkbox( + checkColor: Colors.white, + value: isExempt, + onChanged: (bool? value) { + setState(() { + isExempt = value!; + }); + }, + ) + ], + ), + ], + ), + Column( + children: [ + const SizedBox( + height: 20, + ), + const Text( + 'EFFECTIVITY OF ASSESSMENT / REASSESSMENT :', + style: TextStyle( + fontWeight: FontWeight.bold), + ), + const SizedBox( + height: 20, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + const Text('Qtr.'), + SizedBox( + width: 70, + height: 25, + child: FormBuilderTextField( + name: 'qtr', + validator: + FormBuilderValidators.compose( + []), + ), + ), + const SizedBox( + width: 20, + ), + const Text('Yr.'), + SizedBox( + width: 70, + height: 25, + child: FormBuilderTextField( + name: 'yr', + validator: + FormBuilderValidators.compose( + []), + ), + ), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), Align( - alignment: Alignment.center, - child: Container( - margin: const EdgeInsets.fromLTRB( - 0, 20, 0, 20), - child: const Text( - 'PROPERTY ASSESSMENT cont..', + alignment: Alignment.centerLeft, + child: Text( + 'APPRAISED/ASSESSED BY:', + style: TextStyle( + fontWeight: FontWeight.bold), + textAlign: TextAlign.start, + ), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDropdown< + Signatories>( + name: 'appraised_by', + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'app_date', + initialEntryMode: + DatePickerEntryMode + .calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'RECOMMENDING APPROVAL:', + style: TextStyle( + fontWeight: FontWeight.bold), + )), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDropdown< + Signatories>( + name: 'rec_approval', + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'rec_date', + initialEntryMode: + DatePickerEntryMode + .calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'APPROVED BY:', style: TextStyle( fontWeight: FontWeight.bold, - fontSize: 18, ), - textAlign: TextAlign.left, + )), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDropdown< + Signatories>( + name: 'apprvd_by', + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + Text('Name'), + ], + ), + ], + ), + const SizedBox( + height: 50, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'MEMORANDA: ', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + )), + SizedBox( + height: 30, + ), + SizedBox( + width: 500, + height: 100, + child: SearchField( + itemHeight: 70, + suggestions: memoranda + .map((Memoranda memoranda) => + SearchFieldListItem( + '${memoranda.memoranda}', + item: + memoranda, // Change: Use individual Memoranda object + child: ListTile( + title: Text( + '${memoranda.memoranda}', + overflow: + TextOverflow.ellipsis, + ), + ), + )) + .toList(), + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + // searchInputDecoration: + // normalTextFieldStyle( + // "Memoranda", "") + // .copyWith( + // suffixIcon: const Icon( + // Icons.arrow_drop_down), + // ), + // focusNode: focus, + suggestionState: Suggestion.expand, + onSuggestionTap: (memoranda) { + setState(() { + _memoranda = + memoranda.item!.memoranda!; + }); + focus.unfocus(); + }, + )), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text('Sworn Statement No. :'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderTextField( + name: 'sworn_statement', + decoration: InputDecoration(), + validator: + FormBuilderValidators.compose([]), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text('Date Received:'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderDateTimePicker( + name: 'date_received', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Date of Entry in the Rec. of Ass. :'), + SizedBox( + width: 100, + height: 20, + child: FormBuilderDateTimePicker( + name: 'date_of_entry', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text('By:'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderTextField( + name: 'by', + decoration: InputDecoration(), + validator: + FormBuilderValidators.compose([]), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences.getInstance(); + print(tempID.getInt('tempid')! - 1); + final List + propertyAssessments = []; + + PropertyAssessment ass = + PropertyAssessment( + id: 1, + bldgapprDetailsId: + tempID.getInt('tempid')! - 1, + actualUse: formKey.currentState! + .value['actual_use'] ?? + '', // Replace null with an empty string + marketValue: '0.00', + assessmentLevel: '0.00', + assessedValue: '0.00', + taxable: isTaxable, + exempt: isExempt, + qtr: int.parse(formKey + .currentState!.value['qtr'] ?? + '0'), // Replace null with '0' + yr: int.parse( + formKey.currentState!.value['yr'] ?? + '0'), // Replace null with '0' + appraisedbyName: (formKey + .currentState! + .value['appraised_by'] + ?.firstname ?? + '') + + ' ' + + (formKey + .currentState! + .value['appraised_by'] + ?.middlename ?? + '') + + ' ' + + (formKey + .currentState! + .value['appraised_by'] + ?.lastname ?? + ''), + appraisedbyDate: formKey.currentState! + .value['app_date'] + as DateTime? ?? + DateTime + .now(), // Replace null with current date + recommendapprName: (formKey + .currentState! + .value['rec_approval'] + ?.firstname ?? + '') + + ' ' + + (formKey + .currentState! + .value['rec_approval'] + ?.middlename ?? + '') + + ' ' + + (formKey + .currentState! + .value['rec_approval'] + ?.lastname ?? + ''), + recommendapprDate: formKey.currentState! + .value['rec_date'] + as DateTime? ?? + DateTime + .now(), // Replace null with current date + approvedbyName: (formKey + .currentState! + .value['apprvd_by'] + ?.firstname ?? + '') + + ' ' + + (formKey + .currentState! + .value['apprvd_by'] + ?.middlename ?? + '') + + ' ' + + (formKey + .currentState! + .value['apprvd_by'] + ?.lastname ?? + ''), + memoranda: _memoranda, + swornstatementNo: formKey.currentState! + .value['sworn_statement'] ?? + '', // Replace null with an empty string + dateReceived: formKey.currentState! + .value['date_received'] + as DateTime? ?? + DateTime + .now(), // Replace null with current date + entryDateAssessment: formKey + .currentState! + .value['date_of_entry'] + as DateTime? ?? + DateTime + .now(), // Replace null with current date + entryDateBy: formKey + .currentState!.value['by'] ?? + '', // Replace null with an empty string + ); + + propertyAssessments.add(ass); + + context.read() + ..add(UpdatePropertyAssessment( + assessment: + propertyAssessments[0])); + widget.function(); + }, + style: ElevatedButton.styleFrom( + backgroundColor: primary, + foregroundColor: Colors.red), + child: SizedBox( + width: 200, + height: 50, + child: Align( + alignment: Alignment.center, + child: Text( + 'Save', + style: TextStyle( + color: Colors.white, + ), + textAlign: TextAlign.center, + ), ), ), ), - Expanded( - flex: 3, - child: SingleChildScrollView( - padding: EdgeInsets.only( - left: 20.0, right: 20.0), - scrollDirection: Axis.vertical, - child: Column(children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceAround, - children: [ - Row( - children: [ - const Text('Taxable'), - Checkbox( - checkColor: Colors.white, - value: isTaxable, - onChanged: (bool? value) { - setState(() { - isTaxable = value!; - }); - }, - ) - ], - ), - Row( - children: [ - const Text('Exempt'), - Checkbox( - checkColor: Colors.white, - value: isExempt, - onChanged: (bool? value) { - setState(() { - isExempt = value!; - }); - }, - ) - ], - ), - ], - ), - Column( - children: [ - const SizedBox( - height: 20, - ), - const Text( - 'EFFECTIVITY OF ASSESSMENT / REASSESSMENT :', - style: TextStyle( - fontWeight: FontWeight.bold), - ), - const SizedBox( - height: 20, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceAround, - children: [ - const Text('Qtr.'), - SizedBox( - width: 70, - height: 25, - child: FormBuilderTextField( - name: 'qtr', - validator: - FormBuilderValidators - .compose([]), - ), - ), - const SizedBox( - width: 20, - ), - const Text('Yr.'), - SizedBox( - width: 70, - height: 25, - child: FormBuilderTextField( - name: 'yr', - validator: - FormBuilderValidators - .compose([]), - ), - ), - ], - ), - ], - ), - const SizedBox( - height: 30, - ), - Align( - alignment: Alignment.centerLeft, - child: Text( - 'APPRAISED/ASSESSED BY:', - style: TextStyle( - fontWeight: FontWeight.bold), - textAlign: TextAlign.start, - ), - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceAround, - children: [ - Column( - children: [ - SizedBox( - width: 200, - child: FormBuilderDropdown< - Signatories>( - name: 'appraised_by', - autofocus: false, - items: signatories - .map((signatories) => - DropdownMenuItem( - value: - signatories, - child: Text( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), - )) - .toList()), - ), - Text('Name'), - ], - ), - const SizedBox( - width: 15, - ), - Column( - children: [ - SizedBox( - width: 100, - child: - FormBuilderDateTimePicker( - name: 'app_date', - initialEntryMode: - DatePickerEntryMode - .calendarOnly, - initialValue: - DateTime.now(), - inputType: InputType.date, - - initialTime: - const TimeOfDay( - hour: 8, minute: 0), - // locale: const Locale.fromSubtags(languageCode: 'fr'), - ), - ), - Text('Date'), - ], - ), - ], - ), - const SizedBox( - height: 30, - ), - const Align( - alignment: Alignment.centerLeft, - child: Text( - 'RECOMMENDING APPROVAL:', - style: TextStyle( - fontWeight: FontWeight.bold), - )), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceAround, - children: [ - Column( - children: [ - SizedBox( - width: 200, - child: FormBuilderDropdown< - Signatories>( - name: 'rec_approval', - autofocus: false, - items: signatories - .map((signatories) => - DropdownMenuItem( - value: - signatories, - child: Text( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), - )) - .toList()), - ), - Text('Name'), - ], - ), - const SizedBox( - width: 15, - ), - Column( - children: [ - SizedBox( - width: 100, - child: - FormBuilderDateTimePicker( - name: 'rec_date', - initialEntryMode: - DatePickerEntryMode - .calendarOnly, - initialValue: - DateTime.now(), - inputType: InputType.date, - - initialTime: - const TimeOfDay( - hour: 8, minute: 0), - // locale: const Locale.fromSubtags(languageCode: 'fr'), - ), - ), - Text('Date'), - ], - ), - ], - ), - const SizedBox( - height: 30, - ), - const Align( - alignment: Alignment.centerLeft, - child: Text( - 'APPROVED BY:', - style: TextStyle( - fontWeight: FontWeight.bold, - ), - )), - Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Column( - children: [ - SizedBox( - width: 200, - child: FormBuilderDropdown< - Signatories>( - name: 'apprvd_by', - autofocus: false, - items: signatories - .map((signatories) => - DropdownMenuItem( - value: - signatories, - child: Text( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), - )) - .toList()), - ), - Text('Name'), - ], - ), - ], - ), - const SizedBox( - height: 50, - ), - const Align( - alignment: Alignment.centerLeft, - child: Text( - 'MEMORANDA: ', - style: TextStyle( - fontWeight: FontWeight.bold, - ), - )), - SizedBox( - height: 30, - ), - SizedBox( - width: 500, - height: 100, - child: SearchField( - itemHeight: 70, - suggestions: memoranda - .map((Memoranda memoranda) => - SearchFieldListItem( - '${memoranda.memoranda}', - item: - memoranda, // Change: Use individual Memoranda object - child: ListTile( - title: Text( - '${memoranda.memoranda}', - overflow: - TextOverflow - .ellipsis, - ), - ), - )) - .toList(), - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - // searchInputDecoration: - // normalTextFieldStyle( - // "Memoranda", "") - // .copyWith( - // suffixIcon: const Icon( - // Icons.arrow_drop_down), - // ), - // focusNode: focus, - suggestionState: - Suggestion.expand, - onSuggestionTap: (memoranda) { - setState(() { - _memoranda = memoranda - .item!.memoranda!; - }); - focus.unfocus(); - }, - )), - SizedBox( - height: 30, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text('Sworn Statement No. :'), - SizedBox( - width: 150, - height: 20, - child: FormBuilderTextField( - name: 'sworn_statement', - decoration: InputDecoration(), - validator: FormBuilderValidators - .compose([]), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text('Date Received:'), - SizedBox( - width: 150, - height: 20, - child: FormBuilderDateTimePicker( - name: 'date_received', - initialEntryMode: - DatePickerEntryMode - .calendarOnly, - initialValue: DateTime.now(), - inputType: InputType.date, - - initialTime: const TimeOfDay( - hour: 8, minute: 0), - // locale: const Locale.fromSubtags(languageCode: 'fr'), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Date of Entry in the Rec. of Ass. :'), - SizedBox( - width: 100, - height: 20, - child: FormBuilderDateTimePicker( - name: 'date_of_entry', - initialEntryMode: - DatePickerEntryMode - .calendarOnly, - initialValue: DateTime.now(), - inputType: InputType.date, - - initialTime: const TimeOfDay( - hour: 8, minute: 0), - // locale: const Locale.fromSubtags(languageCode: 'fr'), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text('By:'), - SizedBox( - width: 150, - height: 20, - child: FormBuilderTextField( - name: 'by', - decoration: InputDecoration(), - validator: FormBuilderValidators - .compose([]), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - ElevatedButton( - onPressed: () async { - final tempID = - await SharedPreferences - .getInstance(); - print(tempID.getInt('tempid')! - 1); - final List - propertyAssessments = []; - - PropertyAssessment ass = - PropertyAssessment( - id: 1, - bldgapprDetailsId: - tempID.getInt('tempid')! - 1, - actualUse: formKey.currentState! - .value['actual_use'] ?? - '', // Replace null with an empty string - marketValue: '0.00', - assessmentLevel: '0.00', - assessedValue: '0.00', - taxable: isTaxable, - exempt: isExempt, - qtr: int.parse(formKey - .currentState! - .value['qtr'] ?? - '0'), // Replace null with '0' - yr: int.parse(formKey - .currentState! - .value['yr'] ?? - '0'), // Replace null with '0' - appraisedbyName: (formKey - .currentState! - .value['appraised_by'] - ?.firstname ?? - '') + - ' ' + - (formKey - .currentState! - .value['appraised_by'] - ?.middlename ?? - '') + - ' ' + - (formKey - .currentState! - .value['appraised_by'] - ?.lastname ?? - ''), - appraisedbyDate: formKey - .currentState! - .value['app_date'] - as DateTime? ?? - DateTime - .now(), // Replace null with current date - recommendapprName: (formKey - .currentState! - .value['rec_approval'] - ?.firstname ?? - '') + - ' ' + - (formKey - .currentState! - .value['rec_approval'] - ?.middlename ?? - '') + - ' ' + - (formKey - .currentState! - .value['rec_approval'] - ?.lastname ?? - ''), - recommendapprDate: formKey - .currentState! - .value['rec_date'] - as DateTime? ?? - DateTime - .now(), // Replace null with current date - approvedbyName: (formKey - .currentState! - .value['apprvd_by'] - ?.firstname ?? - '') + - ' ' + - (formKey - .currentState! - .value['apprvd_by'] - ?.middlename ?? - '') + - ' ' + - (formKey - .currentState! - .value['apprvd_by'] - ?.lastname ?? - ''), - memoranda: _memoranda, - swornstatementNo: formKey - .currentState!.value[ - 'sworn_statement'] ?? - '', // Replace null with an empty string - dateReceived: formKey - .currentState! - .value['date_received'] - as DateTime? ?? - DateTime - .now(), // Replace null with current date - entryDateAssessment: formKey - .currentState! - .value['date_of_entry'] - as DateTime? ?? - DateTime - .now(), // Replace null with current date - entryDateBy: formKey.currentState! - .value['by'] ?? - '', // Replace null with an empty string - ); - - propertyAssessments.add(ass); - - context - .read() - ..add(UpdatePropertyAssessment( - assessment: - propertyAssessments[0])); - widget.function(); - }, - style: ElevatedButton.styleFrom( - backgroundColor: primary, - foregroundColor: Colors.red), - child: SizedBox( - width: 200, - height: 50, - child: Align( - alignment: Alignment.center, - child: Text( - 'Save', - style: TextStyle( - color: Colors.white, - ), - textAlign: TextAlign.center, - ), - ), - ), - ), - SizedBox( - height: 30, - ), - ]), - ), - ) - ], - ); - } - if (state is PropertyAppraisalErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context.read().add( - LoadPropertyAppraisal( - appraisal: PropertyAppraisal())); - }, - ); - } - return Container(); - }); - } - if (state is MemorandaErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context - .read() - .add(LoadMemoranda()); - }, - ); - } - return Container(); - }, - ); - } - if (state is SignatoriesErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context.read().add(LoadSignatories()); - }, - ); - } - return Container(); - }, - ); - } - if (state is PropertyAssessmentErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context - .read() - .add(LoadPropertyAssessment()); - }, - ); - } - return Container(); - }, - ), - ), - ); + SizedBox( + height: 30, + ), + ]), + ), + ) + ], + ); + } + return Container(); + }, + ); + } + return Container(); + }, + ))); } } diff --git a/lib/screens/passo/Building/edit_building/bldgloc_landref.dart b/lib/screens/passo/Building/edit_building/bldgloc_landref.dart index 24ed3cd..f0d70b7 100644 --- a/lib/screens/passo/Building/edit_building/bldgloc_landref.dart +++ b/lib/screens/passo/Building/edit_building/bldgloc_landref.dart @@ -46,10 +46,7 @@ class _BldgLocLandRefEdit extends State { final progress = ProgressHUD.of(context); progress!.showWithText("Please wait..."); } - if (state is LocationLoaded) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - } + if (state is LocationErrorState) { final progress = ProgressHUD.of(context); progress?.dismiss(); @@ -64,10 +61,6 @@ class _BldgLocLandRefEdit extends State { final progress = ProgressHUD.of(context); progress!.showWithText("Please wait..."); } - if (state is LandrefLoaded) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - } if (state is LandrefErrorState) { final progress = ProgressHUD.of(context); progress?.dismiss(); @@ -82,10 +75,6 @@ class _BldgLocLandRefEdit extends State { final progress = ProgressHUD.of(context); progress!.showWithText("Please wait..."); } - if (state is MunicipalityLoaded) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - } if (state is MunicipalityErrorState) { final progress = ProgressHUD.of(context); progress?.dismiss(); diff --git a/lib/screens/passo/Building/edit_building/property_appraisal.dart b/lib/screens/passo/Building/edit_building/property_appraisal.dart index b6dc672..aa6a967 100644 --- a/lib/screens/passo/Building/edit_building/property_appraisal.dart +++ b/lib/screens/passo/Building/edit_building/property_appraisal.dart @@ -33,24 +33,24 @@ class PropertyAppraisalEditPage extends StatefulWidget { class _PropertyAppraisalEditPage extends State { double depRate = 0; - int totalAreas = 0; - String actualUse = ""; + // int totalAreas = 0; + // String actualUse = ""; - @override - void initState() { - super.initState(); - _loadDataFromSharedPreferences(); // Call the method to load data - } + // @override + // void initState() { + // super.initState(); + // _loadDataFromSharedPreferences(); // Call the method to load data + // } // Method to load data from SharedPreferences - _loadDataFromSharedPreferences() async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - setState(() { - actualUse = prefs.getString('actualUse') ?? ''; - totalAreas = prefs.getInt('totalArea') ?? - 0; // Provide a default value if the key doesn't exist - }); - } + // _loadDataFromSharedPreferences() async { + // SharedPreferences prefs = await SharedPreferences.getInstance(); + // setState(() { + // actualUse = prefs.getString('actualUse') ?? ''; + // totalAreas = prefs.getInt('totalArea') ?? + // 0; // Provide a default value if the key doesn't exist + // }); + // } calculateAdditionalItems(List items) { double sum = 0; @@ -529,10 +529,7 @@ class _PropertyAppraisalEditPage extends State { final progress = ProgressHUD.of(context); progress!.showWithText("Please wait..."); } - if (state is PropertyAppraisalEditLoaded) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - } + if (state is PropertyAppraisalEditErrorState) { final progress = ProgressHUD.of(context); progress?.dismiss(); @@ -543,580 +540,684 @@ class _PropertyAppraisalEditPage extends State { final appraisal = state.appraisalEdit; return BlocConsumer(listener: (context, state) { - // TODO: implement listener + if (state is PropertyAppraisalEditLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is AdditionalItemsEditLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is AdditionalItemsEditErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } }, builder: (context, state) { if (state is AdditionalItemsEditLoaded) { final item = state.items; - double totalArea = double.tryParse(totalAreas.toString() ?? - appraisal.totalArea.toString()) ?? - 0.0; + return BlocConsumer( + listener: (context, state) { + if (state is GenDescLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is GenDescLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is GenDescErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, + builder: (context, state) { + if (state is GenDescLoaded) { + double totalArea = double.tryParse( + (state.gendesc.totalFloorArea ?? + appraisal.totalArea) + ?.toString() ?? + '0.0') ?? + 0.0; - double bldgUnitValue = double.tryParse( - keys.currentState?.value['bldg_type']?.unitValue ?? - appraisal.unitconstructCost) ?? - 0.0; - return Expanded( - child: SingleChildScrollView( - child: Container( - margin: const EdgeInsets.only(left: 20.0, right: 20.0), - child: Column( + double bldgUnitValue = double.tryParse(keys.currentState + ?.value['bldg_type']?.unitValue ?? + appraisal.unitconstructCost) ?? + 0.0; + return Column( children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 20), - child: const Text('PROPERTY APPRAISAL', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Unit Construction Cost", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - bldgUnitValue.toString() + ' sq.m', - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Building Core", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - '', - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 40), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Sub-total", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - bldgUnitValue.toString(), - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 40), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Cost of Additional Items", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - '', - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Sub-total", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - appraisal.addItemsSubtotal ?? '0.00', - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Total Construction Cost", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - calculateConstructionCost( - double.parse( - appraisal.unitconstructSubtotal!), - double.parse( - appraisal.addItemsSubtotal!)) - .toString()!, - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 40), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Depreciation Rate", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13), - textAlign: TextAlign.left, - ), - ), - SizedBox( - width: 90, - height: 25, - child: FormBuilderTextField( - name: 'depRate', - decoration: normalTextFieldStyle("0.00", ""), - validator: FormBuilderValidators.compose([]), - onChanged: (value) { - setState(() { - depRate = double.parse(value!); - }); - }, - ), - ), - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Depreciation Cost", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - calculateDepCost( - (totalArea * bldgUnitValue), - item, - double.parse(keys.currentState - ?.value['depRate'] ?? - appraisal.depreciationRate)) - .toString(), - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Total % Depreciation", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - '${(double.parse(keys.currentState?.value['depRate'] ?? appraisal.depreciationRate) * 100).toStringAsFixed(2)}%', - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Market Value", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - calculateMarketValue( - (totalArea * bldgUnitValue), - item, - double.parse(keys.currentState - ?.value['depRate'] ?? - appraisal.depreciationRate)) - .toString(), - textAlign: TextAlign.right, - ), - ) - ], - ), - Row( - children: [ - Expanded( - flex: 1, - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Container( - margin: const EdgeInsets.symmetric( - horizontal: 20.0), - child: Column( + Expanded( + child: SingleChildScrollView( + child: Container( + margin: const EdgeInsets.only( + left: 20.0, right: 20.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 20), + child: const Text('PROPERTY APPRAISAL', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + Row( mainAxisAlignment: - MainAxisAlignment.start, + MainAxisAlignment.spaceBetween, children: [ Container( - margin: const EdgeInsets.fromLTRB( - 0, 20, 0, 20), child: const Text( - 'PROPERTY ASSESSMENT', + "Unit Construction Cost", style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - ), + fontWeight: FontWeight.bold, + fontSize: 13), textAlign: TextAlign.left, ), ), - Column( - children: [ - Row( - children: [ - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: const Text( - 'Actual Use', - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - Container( - width: 150, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: const Text( - 'Market Value', - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - Container( - width: 100, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: const Text( - 'Ass. Level', - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - Container( - width: 150, - margin: const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all(5.0), - child: const Text( - 'Ass. Value', - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, - ), - textAlign: TextAlign.center, - ), - ), - ], - ), - SizedBox( - height: 50, - child: SingleChildScrollView( - scrollDirection: - Axis.horizontal, - child: Row(children: [ + Container( + child: Text( + bldgUnitValue.toString() + ' sq.m', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Building Core", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: const Text( + '', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Sub-total", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + bldgUnitValue.toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Cost of Additional Items", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: const Text( + '', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Sub-total", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + appraisal.addItemsSubtotal ?? + '0.00', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Total Construction Cost", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateConstructionCost( + double.parse(appraisal + .unitconstructSubtotal!), + double.parse(appraisal + .addItemsSubtotal!)) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Depreciation Rate", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + SizedBox( + width: 90, + height: 25, + child: FormBuilderTextField( + name: 'depRate', + decoration: normalTextFieldStyle( + "0.00", ""), + validator: + FormBuilderValidators.compose( + []), + onChanged: (value) { + setState(() { + depRate = double.parse(value!); + }); + }, + ), + ), + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Depreciation Cost", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateDepCost( + (totalArea * bldgUnitValue), + item, + double.parse(keys + .currentState + ?.value[ + 'depRate'] ?? + appraisal + .depreciationRate)) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Total % Depreciation", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + '${(double.parse(keys.currentState?.value['depRate'] ?? appraisal.depreciationRate) * 100).toStringAsFixed(2)}%', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + child: const Text( + "Market Value", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateMarketValue( + (totalArea * bldgUnitValue), + item, + double.parse(keys + .currentState + ?.value[ + 'depRate'] ?? + appraisal + .depreciationRate)) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + Row( + children: [ + Expanded( + flex: 1, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Container( + margin: + const EdgeInsets.symmetric( + horizontal: 20.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ Container( - height: 100, - child: Row( - children: [ - Container( - width: 100, - margin: - const EdgeInsets - .only( - top: 15, - left: 15), - padding: - const EdgeInsets - .all(5.0), - child: Text( - actualUse ?? "", - style: TextStyle( - fontWeight: - FontWeight - .bold, - fontSize: 13, + margin: const EdgeInsets + .fromLTRB(0, 20, 0, 20), + child: const Text( + 'PROPERTY ASSESSMENT', + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 18, + ), + textAlign: TextAlign.left, + ), + ), + Column( + children: [ + Row( + children: [ + Container( + width: 100, + margin: + const EdgeInsets + .only( + top: 15, + left: 15), + padding: + const EdgeInsets + .all(5.0), + child: const Text( + 'Actual Use', + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 13, + ), + textAlign: + TextAlign + .center, ), - textAlign: TextAlign - .center, ), - ), - Container( - width: 150, - margin: - const EdgeInsets - .only( - top: 15, - left: 15), - padding: - const EdgeInsets - .all(5.0), - child: Text( - NumberFormat - .currency( - locale: 'en-PH', - symbol: "₱", - ).format( - calculateMarketValue( - (totalArea * - bldgUnitValue), - item, - double.parse(keys - .currentState - ?.value[ - 'depRate'] ?? - appraisal - .depreciationRate)), + Container( + width: 150, + margin: + const EdgeInsets + .only( + top: 15, + left: 15), + padding: + const EdgeInsets + .all(5.0), + child: const Text( + 'Market Value', + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 13, + ), + textAlign: + TextAlign + .center, ), - style: TextStyle( - fontWeight: - FontWeight - .bold, - fontSize: 13, - ), - textAlign: TextAlign - .center, ), - ), - Container( - width: 100, - margin: - const EdgeInsets - .only( - top: 15, - left: 15), - padding: - const EdgeInsets - .all(5.0), - child: Text( - assessmentLevel( - calculateMarketValue( + Container( + width: 100, + margin: + const EdgeInsets + .only( + top: 15, + left: 15), + padding: + const EdgeInsets + .all(5.0), + child: const Text( + 'Ass. Level', + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 13, + ), + textAlign: + TextAlign + .center, + ), + ), + Container( + width: 150, + margin: + const EdgeInsets + .only( + top: 15, + left: 15), + padding: + const EdgeInsets + .all(5.0), + child: const Text( + 'Ass. Value', + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 13, + ), + textAlign: + TextAlign + .center, + ), + ), + ], + ), + SizedBox( + height: 50, + child: + SingleChildScrollView( + scrollDirection: + Axis.horizontal, + child: Row(children: [ + Container( + height: 100, + child: Row( + children: [ + Container( + width: 100, + margin: const EdgeInsets + .only( + top: 15, + left: + 15), + padding: + const EdgeInsets.all( + 5.0), + child: Text( + state.gendesc + .actualUse ?? + "", + style: + const TextStyle( + fontWeight: + FontWeight.bold, + fontSize: + 13, + ), + textAlign: + TextAlign + .center, + ), + ), + Container( + width: 150, + margin: const EdgeInsets + .only( + top: 15, + left: + 15), + padding: + const EdgeInsets.all( + 5.0), + child: Text( + NumberFormat + .currency( + locale: + 'en-PH', + symbol: + "₱", + ).format( + calculateMarketValue( (totalArea * bldgUnitValue), item, double.parse(keys.currentState?.value['depRate'] ?? - appraisal.depreciationRate)) - .toString(), - actualUse) + - '%', - style: TextStyle( - fontWeight: - FontWeight - .bold, - fontSize: 13, - ), - textAlign: TextAlign - .center, - ), + appraisal.depreciationRate)), + ), + style: + const TextStyle( + fontWeight: + FontWeight.bold, + fontSize: + 13, + ), + textAlign: + TextAlign + .center, + ), + ), + Container( + width: 100, + margin: const EdgeInsets + .only( + top: 15, + left: + 15), + padding: + const EdgeInsets.all( + 5.0), + child: Text( + '${assessmentLevel(calculateMarketValue((totalArea * bldgUnitValue), item, double.parse(keys.currentState?.value['depRate'] ?? appraisal.depreciationRate)).toString(), state.gendesc.actualUse)}%', + style: + const TextStyle( + fontWeight: + FontWeight.bold, + fontSize: + 13, + ), + textAlign: + TextAlign + .center, + ), + ), + Container( + width: 150, + margin: const EdgeInsets + .only( + top: 15, + left: + 15), + padding: + const EdgeInsets.all( + 5.0), + child: Text( + NumberFormat + .currency( + locale: + 'en-PH', + symbol: + "₱", + ).format(assessmentValue( + calculateMarketValue((totalArea * bldgUnitValue), item, double.parse(keys.currentState?.value['depRate'] ?? appraisal.depreciationRate)) + .toString(), + state + .gendesc + .actualUse)), + style: + const TextStyle( + fontWeight: + FontWeight.bold, + fontSize: + 13, + ), + textAlign: + TextAlign + .center, + ), + ), + const SizedBox( + height: 80, + ), + ], + ), + ) + ]), ), - Container( - width: 150, - margin: - const EdgeInsets - .only( - top: 15, - left: 15), - padding: - const EdgeInsets - .all(5.0), - child: Text( - NumberFormat - .currency( - locale: 'en-PH', - symbol: "₱", - ).format(assessmentValue( - calculateMarketValue( - (totalArea * - bldgUnitValue), - item, - double.parse(keys.currentState?.value['depRate'] ?? - appraisal.depreciationRate)) - .toString(), - actualUse)), - style: TextStyle( - fontWeight: - FontWeight - .bold, - fontSize: 13, - ), - textAlign: TextAlign - .center, - ), - ), - const SizedBox( - height: 80, - ), - ], - ), + ) + ], ) - ]), + ], ), - ) - ], - ) + ), + ), + ), ], ), - ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon( + Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon( + Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () async { + final tempID = + await SharedPreferences + .getInstance(); + + final id = + tempID.getInt('tempid')! - 1; + { + var appraisals = PropertyAppraisalEdit( + id: 1, + bldgapprDetailsId: id, + unitconstructCost: + bldgUnitValue.toString(), + buildingCore: 'test', + unitconstructSubtotal: + (totalArea * bldgUnitValue) + .toString(), + depreciationRate: + depRate.toString(), + depreciationCost: + calculateDepCost((totalArea * bldgUnitValue), item, depRate) + .toString(), + costAddItems: + calculateAdditionalItems(item) + .toString(), + addItemsSubtotal: + calculateAdditionalItems(item) + .toString(), + totalpercentDepreciation: + (depRate * 100) + .toStringAsFixed(2), + marketValue: calculateMarketValue( + (totalArea * bldgUnitValue), + item, + depRate) + .toString(), + totalArea: totalArea.toString()); + context + .read< + PropertyAppraisalEditBloc>() + .add( + UpdatePropertyAppraisalEdit( + appraisalEdit: + appraisals, + id: widget.tempId)); + + widget.NextBtn(); + } + ; + }, + ) + ], + ) + ], ), ), - ], + ), ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - CustomButton( - icon: const Icon(Icons.chevron_left_rounded, - color: Colors.white), - onPressed: () { - { - widget.PrevBtn(); - } - ; - }, - ), - CustomButton( - icon: const Icon(Icons.chevron_right_rounded, - color: Colors.white), - onPressed: () async { - final tempID = - await SharedPreferences.getInstance(); - - final id = tempID.getInt('tempid')! - 1; - { - var appraisals = PropertyAppraisalEdit( - id: 1, - bldgapprDetailsId: id, - unitconstructCost: bldgUnitValue - .toString(), - buildingCore: 'test', - unitconstructSubtotal: (totalArea * - bldgUnitValue) - .toString(), - depreciationRate: depRate.toString(), - depreciationCost: calculateDepCost( - (totalArea * bldgUnitValue), - item, - depRate) - .toString(), - costAddItems: calculateAdditionalItems(item) - .toString(), - addItemsSubtotal: - calculateAdditionalItems(item) - .toString(), - totalpercentDepreciation: - (depRate * 100).toStringAsFixed(2), - marketValue: calculateMarketValue( - (totalArea * bldgUnitValue), - item, - depRate) - .toString(), - totalArea: totalArea.toString()); - context.read() - ..add(UpdatePropertyAppraisalEdit( - appraisalEdit: appraisals, - id: widget.tempId)); - - widget.NextBtn(); - } - ; - }, - ) - ], - ) ], - ), - ), - ), + ); + } + return Container(); + }, ); } return Container(); diff --git a/lib/screens/passo/Building/edit_building/property_assessement_edit.dart b/lib/screens/passo/Building/edit_building/property_assessement_edit.dart index 3439bba..dd4dea0 100644 --- a/lib/screens/passo/Building/edit_building/property_assessement_edit.dart +++ b/lib/screens/passo/Building/edit_building/property_assessement_edit.dart @@ -484,7 +484,15 @@ class _PropertyAssessmentEditPage extends State { final assessment = state.assessmentsEdit; return BlocConsumer( listener: (context, state) { - // TODO: implement listener + if (state is SignatoriesLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + + if (state is SignatoriesErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } }, builder: (context, state) { if (state is SignatoriesLoaded) { @@ -492,26 +500,39 @@ class _PropertyAssessmentEditPage extends State { return BlocConsumer( listener: (context, state) { - // TODO: implement listener + if (state is MemorandaLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is MemorandaLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is MemorandaErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } }, builder: (context, state) { if (state is MemorandaLoaded) { return FormBuilder( key: keys, initialValue: { - 'qtr': assessment.qtr.toString(), - 'yr': assessment.qtr.toString(), - // 'appraised_by': assessment.appraisedbyName, - 'app_date': assessment.appraisedbyDate.toString(), - // 'rec_approval': assessment.recommendapprName, - 'rec_date': assessment.recommendapprDate.toString(), - // 'apprvd_by': assessment.approvedbyName, - 'memoranda': assessment.memoranda, - 'sworn_statement': assessment.swornstatementNo, - 'date_received': assessment.dateReceived.toString(), + 'qtr': assessment.qtr?.toString() ?? '', + 'yr': assessment.qtr?.toString() ?? '', + 'app_date': + assessment.appraisedbyDate?.toString() ?? '', + 'rec_date': + assessment.recommendapprDate?.toString() ?? '', + 'memoranda': assessment.memoranda ?? '', + 'sworn_statement': + assessment.swornstatementNo ?? '', + 'date_received': + assessment.dateReceived?.toString() ?? '', 'date_of_entry': - assessment.entryDateAssessment.toString(), - 'by': assessment.entryDateBy + assessment.entryDateAssessment?.toString() ?? + '', + 'by': assessment.entryDateBy ?? '', }, enabled: true, onChanged: () { @@ -649,7 +670,8 @@ class _PropertyAssessmentEditPage extends State { decoration: InputDecoration( labelText: assessment - .appraisedbyName!, + .appraisedbyName ?? + "", labelStyle: const TextStyle( color: Colors @@ -723,7 +745,8 @@ class _PropertyAssessmentEditPage extends State { decoration: InputDecoration( labelText: assessment - .recommendapprName!, + .recommendapprName ?? + "", labelStyle: const TextStyle( color: Colors @@ -798,7 +821,8 @@ class _PropertyAssessmentEditPage extends State { decoration: InputDecoration( labelText: assessment - .approvedbyName!, + .approvedbyName ?? + "", labelStyle: const TextStyle( color: Colors @@ -1087,12 +1111,13 @@ class _PropertyAssessmentEditPage extends State { propertyAssessments.add(ass); - context.read< - PropertyAssessmentEditBloc>() - ..add(UpdatePropertyAssessmentEdit( - assessmentsEdit: - propertyAssessments[ - 0])); + context + .read< + PropertyAssessmentEditBloc>() + .add(UpdatePropertyAssessmentEdit( + assessmentsEdit: + propertyAssessments[ + 0])); }, ), ), @@ -1114,7 +1139,7 @@ class _PropertyAssessmentEditPage extends State { } if (state is PropertyAssessmentEditErrorState) { return SomethingWentWrong( - message: onError, + message: state.error, onpressed: () { context.read().add( LoadPropertyAssessmentEdit( diff --git a/lib/screens/passo/Building/edit_building/property_owner_info.dart b/lib/screens/passo/Building/edit_building/property_owner_info.dart index f184b9a..5a32955 100644 --- a/lib/screens/passo/Building/edit_building/property_owner_info.dart +++ b/lib/screens/passo/Building/edit_building/property_owner_info.dart @@ -62,7 +62,19 @@ class _PropertyOwnerInfoEdit extends State { Widget build(BuildContext context) { return BlocConsumer( listener: (context, state) { - // TODO: implement listener + if (state is PropertyInfoLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is PropertyInfoLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + + if (state is PropertyInfoErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } }, builder: (context, state) { if (state is PropertyInfoLoaded) { return SingleChildScrollView( diff --git a/lib/screens/passo/Land/edit_land.dart b/lib/screens/passo/Land/edit_land.dart index 13a7513..2491dce 100644 --- a/lib/screens/passo/Land/edit_land.dart +++ b/lib/screens/passo/Land/edit_land.dart @@ -79,20 +79,8 @@ class _EditLand extends State { }, ), Expanded( - child: FormBuilder( - key: landKey, - - // enabled: false, - onChanged: () { - landKey.currentState?.save(); - - print(landKey.currentState?.value.toString()); - }, - autovalidateMode: AutovalidateMode.disabled, - skipDisabled: true, - child: Container( - child: content(PrevBtn, NextBtn, onSAveAll), - ), + child: Container( + child: content(PrevBtn, NextBtn, onSAveAll), ), ), ], @@ -111,15 +99,16 @@ class _EditLand extends State { case 1: return LandLocationAndBoundariesEdit(PrevBtn, NextBtn, widget.faas!); case 2: - return LandAppraisalEdit(PrevBtn, NextBtn); + return LandAppraisalEdit(PrevBtn, NextBtn, widget.faas.id!); case 3: - return OtherImprovementEditPage(PrevBtn, NextBtn); + return OtherImprovementEditPage(PrevBtn, NextBtn, widget.faas.id!); case 4: - return ValueAdjustmentEditPage(PrevBtn, NextBtn); + return ValueAdjustmentEditPage(PrevBtn, NextBtn, widget.faas.id!); case 5: - return LandPropertyAssessmentEditPage(PrevBtn, NextBtn); + return LandPropertyAssessmentEditPage( + PrevBtn, NextBtn, widget.faas.id!); case 6: - return LandSignatoriesEdit(onSAveAll); + return LandSignatoriesEdit(onSAveAll, widget.faas.id!); default: return LandPropertyOwnerInfoEdit(NextBtn, widget.faas!); diff --git a/lib/screens/passo/Land/edit_land/AddLandAppraisalEdit.dart b/lib/screens/passo/Land/edit_land/AddLandAppraisalEdit.dart new file mode 100644 index 0000000..10da057 --- /dev/null +++ b/lib/screens/passo/Land/edit_land/AddLandAppraisalEdit.dart @@ -0,0 +1,464 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:intl/intl.dart'; +import 'package:searchfield/searchfield.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/passo/bulding/additional_item/additional_item_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_classification/land_classification_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_subclassification/land_subclassification_bloc.dart'; +import 'package:unit2/bloc/passo/municipality/municipality_bloc.dart'; +import 'package:unit2/model/passo/additional_items.dart'; +import 'package:unit2/model/passo/city.dart'; +import 'package:unit2/model/passo/class_components.dart'; +import 'package:unit2/model/passo/land_appr.dart'; +import 'package:unit2/model/passo/land_classification.dart'; +import 'package:unit2/model/passo/land_subclassification.dart'; +import 'package:unit2/model/passo/unit_construct.dart'; +import 'package:unit2/screens/passo/Land/add_land.dart'; +import 'package:unit2/theme-data.dart/form-style.dart'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; +import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +class AddLandAppraisalEditModal extends StatefulWidget { + // final List unit; + // final List options; + final int tempId; + + AddLandAppraisalEditModal(this.tempId); + + @override + _AddLandAppraisalEditModal createState() => _AddLandAppraisalEditModal(); +} + +class _AddLandAppraisalEditModal extends State { + final focus = FocusNode(); + bool isPainted = false; + bool isSecondHand = false; + TextEditingController textEditingController = TextEditingController(); + double _unitBase = 0; + int _areaValue = 0; + final double _depValue = 0; + double _unitValue = 0; + String _subClassDesc = ""; + int _classId = 0; + String _structureType = ""; + bool _withoutBUCC = false; + int _notPaintedUnitVal = 0; + int _secondHandUnitVal = 0; + String cityCode = ''; + String cityDesc = ''; + int classCode = 1; + String _classDesc = ''; + + GlobalKey appraisalLandKey = GlobalKey(); + + BoxDecoration box1() { + return const BoxDecoration(boxShadow: [ + BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5) + ], color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(3))); + } + + double _amountofDepreciation(unitVal, unitBase, area, depreciation) { + return ((unitVal * unitBase) * area) * depreciation; + } + + double _totalMarketValue(unitBase, area) { + return unitBase * area; + } + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + if (state is LandAppraisalLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is LandAppraisalLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is LandAppraisalErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, buildWhen: (previous, current) { + return false; + }, builder: (context, state) { + if (state is ShowAddLandAppraisalScreen) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is LandClassificationLoaded) { + final classification = state.land_classification; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is LandSubClassificationLoaded) { + final subclassification = state.land_subclassification; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is MunicipalityLoaded) { + return FormBuilder( + key: appraisalLandKey, + onChanged: () { + appraisalLandKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: SingleChildScrollView( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: + FormBuilderDropdown( + name: + 'appraisal_municipality', + autofocus: false, + decoration: + normalTextFieldStyle( + cityDesc ?? + "Municipality", + ""), + items: state.municipality + .map((municipality) => + DropdownMenuItem< + City>( + value: municipality, + child: Text(municipality + .cityDescription!), // Use cityDescription instead of cityName + )) + .toList(), + onChanged: (selectedCity) { + if (selectedCity != null) { + final selectedCityCode = + selectedCity.cityCode; + setState(() { + cityCode = + selectedCityCode!; + cityDesc = selectedCity + .cityDescription!; + }); + final barangayBloc = + context.read< + LandSubClassificationBloc>(); + barangayBloc.add( + LoadLandSubClassification( + classCode: + classCode!, + cityCode: + selectedCityCode!)); // Use selectedCityCode directly + } + }, + )), + ), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown< + LandClassification>( + name: 'classification', + autofocus: false, + decoration: + normalTextFieldStyle( + _classDesc + .toString() ?? + "Classification", + ""), + items: classification + .map((classification) => + DropdownMenuItem< + LandClassification>( + value: + classification, + child: Text( + classification + .description!), // Use cityDescription instead of cityName + )) + .toList(), + onChanged: (selectedClass) { + if (selectedClass != null) { + final selectedClassCode = + selectedClass.id; + setState(() { + classCode = + selectedClassCode!; + _classDesc = + selectedClass + .description!; + }); + final barangayBloc = + context.read< + LandSubClassificationBloc>(); + barangayBloc.add( + LoadLandSubClassification( + classCode: + selectedClassCode!, + cityCode: + cityCode)); // Use selectedCityCode directly + } + }, + )), + ), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: SizedBox( + height: 45, + child: SearchField( + itemHeight: 70, + suggestions: subclassification + .map((LandSubClassification + subclass) => + SearchFieldListItem( + '${subclass.subclassCode} - ${subclass.subclassDescription}', + item: subclass, + child: ListTile( + title: Text( + '${subclass.subclassCode} - ${subclass.subclassDescription!.toUpperCase()}', + overflow: + TextOverflow + .ellipsis, + ), + ))) + .toList(), + + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + + searchInputDecoration: + normalTextFieldStyle( + "Structure Type", + "") + .copyWith( + suffixIcon: + const Icon(Icons + .arrow_drop_down)), + ////agency suggestion tap + focusNode: focus, + suggestionState: + Suggestion.expand, + onSuggestionTap: (subclass) { + setState(() { + _unitBase = double.parse( + subclass.item! + .baseUnitMarketval!); + _subClassDesc = + '${subclass.item!.subclassCode} - ${subclass.item!.subclassDescription}'; + }); + focus.unfocus(); + }, + ), + ), + ), + const SizedBox(height: 10), + FormBuilderTextField( + name: 'land_appraisal_area', + decoration: normalTextFieldStyle( + "Area", ""), + validator: + FormBuilderValidators.compose( + []), + onChanged: (value) { + setState(() { + _areaValue = int.parse(value!); + }); + }, + ), + const SizedBox(height: 10), + const Text('Market Value'), + const SizedBox(height: 5), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: + BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text( + NumberFormat.currency( + locale: 'en-PH', + symbol: "₱") + .format( + _totalMarketValue( + _unitBase, + _areaValue)))), + ), + const SizedBox(height: 10), + Row( + children: [ + Container( + width: 120, + height: 60, + padding: + const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences + .getInstance(); + print(tempID + .getInt('landid')); + var land_appraisal = LandAppr( + landapprDetailsId: + widget.tempId, + classification: + _classDesc, + subClass: _subClassDesc, + area: _areaValue + .toString(), + unitValue: _unitBase + .toString(), + baseMarketval: + _totalMarketValue( + _unitBase, + _areaValue) + .toString()); + + context + .read< + LandAppraisalBloc>() + .add(AddLandAppraisal( + land_appr: + land_appraisal)); + }, + style: + ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Submit"), + ), + ), + const SizedBox( + width: + 5), // Use SizedBox for horizontal spacing in a Row + Container( + width: 120, + height: 60, + padding: + const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () { + context + .read< + LandAppraisalBloc>() + .add( + LoadLandAppraisalEdit( + land_appr: < + LandAppr>[], + id: widget.tempId, + )); + }, + style: + ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ), + ], + ), + ), + ))); + } + if (state is MunicipalityErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadMunicipality()); + }, + ); + } + return Container(); + }, + ); + } + if (state is LandSubClassificationErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add( + const LoadLandSubClassification( + cityCode: '1', classCode: 1)); + }, + ); + } + return Container(); + }, + ); + } + if (state is LandClassificationErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadLandClassification()); + }, + ); + } + return Container(); + }, + ); + } + if (state is LandAppraisalErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadLandAppraisal()); + }, + ); + } + return Container(); + }); + } +} diff --git a/lib/screens/passo/Land/edit_land/AddOtherImprovementEditModal.dart b/lib/screens/passo/Land/edit_land/AddOtherImprovementEditModal.dart new file mode 100644 index 0000000..30df942 --- /dev/null +++ b/lib/screens/passo/Land/edit_land/AddOtherImprovementEditModal.dart @@ -0,0 +1,357 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:intl/intl.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/passo/land/land_trees_improvements/land_trees_improvements_bloc.dart'; +import 'package:unit2/bloc/passo/land/other_improvements/other_improvements_bloc.dart'; +import 'package:unit2/model/passo/other_improvements.dart'; +import 'package:unit2/model/passo/trees_improvements.dart'; +import 'package:unit2/theme-data.dart/form-style.dart'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; + +class AddOtherImprovementEditModal extends StatefulWidget { + // final List unit; + // final List options; + final int tempId; + + AddOtherImprovementEditModal(this.tempId); + + @override + _AddOtherImprovementEditModal createState() => + _AddOtherImprovementEditModal(); +} + +class _AddOtherImprovementEditModal + extends State { + final focus = FocusNode(); + bool isPainted = false; + bool isSecondHand = false; + TextEditingController textEditingController = TextEditingController(); + double _unitBase = 0; + int _areaValue = 0; + final double _depValue = 0; + double _unitValue = 0; + String _subClassDesc = ""; + int _classId = 0; + String _structureType = ""; + int _notPaintedUnitVal = 0; + int _secondHandUnitVal = 0; + String cityCode = ''; + String cityDesc = ''; + int classCode = 1; + String _classDesc = ''; + String _treeType = ""; + bool _nonfruitBearing = false; + bool _fruitBearing = false; + int qty = 0; + int pr_qty = 0; + int nonpr_qty = 0; + + GlobalKey otherImpKey = GlobalKey(); + + final typeOfTree = [ + "Non-Fruit Bearing", + "Fruit Bearing", + ]; + + _calculateBaseMarketValue() { + double base = 0.00; + if (_fruitBearing) { + base = (pr_qty + nonpr_qty) * _unitValue; + } else { + base = qty * _unitValue; + } + return base; + } + + BoxDecoration box1() { + return const BoxDecoration(boxShadow: [ + BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5) + ], color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(3))); + } + + double _amountofDepreciation(unitVal, unitBase, area, depreciation) { + return ((unitVal * unitBase) * area) * depreciation; + } + + double _totalMarketValue(unitBase, area) { + return unitBase * area; + } + + @override + Widget build(BuildContext context) { + return BlocBuilder( + buildWhen: (previous, current) { + return false; + }, builder: (context, state) { + if (state is ShowAddOtherImprovementScreen) { + return BlocConsumer(listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is LandTreesImprovementsLoaded) { + final trees = state.trees_imp; + return FormBuilder( + key: otherImpKey, + onChanged: () { + otherImpKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: SingleChildScrollView( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 10, right: 0, bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown( + name: 'kinds_of_trees', + autofocus: false, + decoration: normalTextFieldStyle( + "Kinds of Trees", ""), + items: state.trees_imp + .map((trees) => + DropdownMenuItem( + value: trees, + child: Text( + (trees.improvement ?? "") + + " " + + (trees.subclassCode ?? ""), + ), + )) + .toList(), + onChanged: (selectedTree) { + if (selectedTree != null) { + setState(() { + _unitValue = double.parse( + selectedTree.pricePerTree!); + _treeType = selectedTree.improvement!; + }); + } + }, + )), + ), + Container( + child: Row( + children: [ + Row( + children: [ + Checkbox( + value: _fruitBearing, + onChanged: (bool? value) { + setState(() { + _fruitBearing = value!; + }); + }, + ), + Text('Fruit Bearing ?'), + ], + ), + ], + ), + ), + Visibility( + visible: !_fruitBearing, + child: Row( + children: [ + Expanded( + child: FormBuilderTextField( + name: 'subClass', + decoration: normalTextFieldStyle( + "SubClass/Age", ""), + validator: + FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + _subClassDesc = value!; + }); + }, + ), + ), + SizedBox( + width: 10, + ), + Expanded( + child: FormBuilderTextField( + name: 'qty', + decoration: normalTextFieldStyle("No.", ""), + validator: + FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + qty = int.parse(value!); + }); + }, + ), + ), + ], + ), + replacement: Column( + children: [ + FormBuilderTextField( + name: 'no_of_productive', + decoration: normalTextFieldStyle( + "No. of Productive", ""), + validator: FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + pr_qty = int.parse(value!); + }); + }, + ), + const SizedBox(height: 10), + FormBuilderTextField( + name: 'no_of_nonproductive', + decoration: normalTextFieldStyle( + "No. of Non-Productive", ""), + validator: FormBuilderValidators.compose([]), + onChanged: (value) { + setState(() { + nonpr_qty = int.parse(value!); + }); + }, + ), + ], + ), + ), + const SizedBox(height: 10), + const Text('Market Value'), + const SizedBox(height: 5), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', symbol: "₱") + .format(_unitValue))), + ), + const SizedBox(height: 10), + const Text('Base Market Value'), + const SizedBox(height: 5), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(_calculateBaseMarketValue().toString() == + "0.00" + ? "00.0" + : _calculateBaseMarketValue())), + ), + ), + const SizedBox(height: 10), + Row( + children: [ + Container( + width: 120, + height: 60, + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () async { + var improvement = OtherImprovements( + landapprDetailsId: widget.tempId, + kindsOfTrees: _treeType, + subclassAge: _subClassDesc, + quantity: qty, + unitValue: _unitValue.toString(), + baseMarketval: + _calculateBaseMarketValue() + .toString(), + noOfProductive: pr_qty, + noOfNonproductive: nonpr_qty, + fruitBearing: _fruitBearing); + + context.read().add( + AddOtherImprovement( + other_imp: improvement)); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Submit"), + ), + ), + const SizedBox( + width: + 5), // Use SizedBox for horizontal spacing in a Row + Container( + width: 120, + height: 60, + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () { + context.read().add( + LoadOtherImprovementEdit( + other_imps: [], + ids: widget.tempId)); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ) + ], + ), + ), + ), + )); + } + if (state is LandTreesImprovementsErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadLandTreesImprovements()); + }, + ); + } + return Container(); + }); + } + if (state is OtherImprovementErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadOtherImprovement()); + }, + ); + } + return Container(); + }); + } +} diff --git a/lib/screens/passo/Land/edit_land/AddPropertyAssessmentEditModal.dart b/lib/screens/passo/Land/edit_land/AddPropertyAssessmentEditModal.dart new file mode 100644 index 0000000..b96977d --- /dev/null +++ b/lib/screens/passo/Land/edit_land/AddPropertyAssessmentEditModal.dart @@ -0,0 +1,356 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:intl/intl.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart'; +import 'package:unit2/model/passo/land_property_assessment.dart'; +import 'package:unit2/model/passo/land_value_adjustment.dart'; +import 'package:unit2/theme-data.dart/form-style.dart'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; + +class AddPropertyAssessmentEditModal extends StatefulWidget { + // final List unit; + // final List options; + final int tempId; + + AddPropertyAssessmentEditModal(this.tempId); + + @override + _AddPropertyAssessmentEditModal createState() => + _AddPropertyAssessmentEditModal(); +} + +class _AddPropertyAssessmentEditModal + extends State { + final focus = FocusNode(); + bool isPainted = false; + bool isSecondHand = false; + TextEditingController textEditingController = TextEditingController(); + double _unitBase = 0; + int _areaValue = 0; + final double _depValue = 0; + double _unitValue = 0; + String _subClassDesc = ""; + int _classId = 0; + String _structureType = ""; + int _notPaintedUnitVal = 0; + int _secondHandUnitVal = 0; + String cityCode = ''; + String cityDesc = ''; + int classCode = 1; + String _classDesc = ''; + String _treeType = ""; + bool _nonfruitBearing = false; + bool _fruitBearing = false; + int qty = 0; + int pr_qty = 0; + int nonpr_qty = 0; + String _actualUse = "Residential"; + String _assessmentLevel = ""; + + GlobalKey assessmentKey = GlobalKey(); + + final typeOfTree = [ + "Non-Fruit Bearing", + "Fruit Bearing", + ]; + + final actual_use = [ + "Residential", + "Agricultural", + "Commercial", + "Industrial", + "Mineral", + "Timberland", + ]; + + calculateAssessmentValue() { + switch (_actualUse) { + case "Residential": + return _unitValue * 0.20; + break; + case "Agricultural": + return _unitValue * 0.40; + break; + case "Commercial": + return _unitValue * 0.50; + break; + case "Industrial": + return _unitValue * 0.50; + break; + case "Mineral": + return _unitValue * 0.50; + break; + case "Timberland": + return _unitValue * 0.20; + break; + default: + } + } + + BoxDecoration box1() { + return const BoxDecoration(boxShadow: [ + BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5) + ], color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(3))); + } + + double _amountofDepreciation(unitVal, unitBase, area, depreciation) { + return ((unitVal * unitBase) * area) * depreciation; + } + + double _totalMarketValue(unitBase, area) { + return unitBase * area; + } + + @override + Widget build(BuildContext context) { + return BlocBuilder( + buildWhen: (previous, current) { + return false; + }, builder: (context, state) { + if (state is ShowAddLandPropertyAssessmentScreen) { + return BlocConsumer(listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is LandValueAdjustmentsLoaded) { + final assessment = state.val_adj; + return FormBuilder( + key: assessmentKey, + onChanged: () { + assessmentKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: SingleChildScrollView( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 10, right: 0, bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown( + name: 'value_adjustments', + autofocus: false, + decoration: normalTextFieldStyle( + "Value Adjustments", ""), + items: state.val_adj + .map((adj) => + DropdownMenuItem( + value: adj, + child: Text( + (adj.adjustmentFactors ?? ""), + ), + )) + .toList(), + onChanged: (selectedAdj) { + if (selectedAdj != null) { + setState(() { + _unitValue = double.parse( + selectedAdj.marketValue!); + }); + } + }, + )), + ), + SizedBox( + height: 10, + ), + FormBuilderDropdown( + name: "land_actual_use", + autofocus: false, + decoration: normalTextFieldStyle("Actual Use", ""), + items: actual_use + .map((item) => DropdownMenuItem( + value: item, + child: Text(item), + )) + .toList(), + onChanged: (value) { + setState(() { + _actualUse = value!; + + switch (value) { + case "Residential": + setState(() { + _assessmentLevel = '20'; + }); + + break; + case "Agricultural": + setState(() { + _assessmentLevel = '40'; + }); + + break; + case "Commercial": + setState(() { + _assessmentLevel = '50'; + }); + + break; + case "Industrial": + setState(() { + _assessmentLevel = '50'; + }); + + break; + case "Mineral": + setState(() { + _assessmentLevel = '50'; + }); + + break; + case "Timberland": + setState(() { + _assessmentLevel = '20'; + }); + + break; + default: + } + }); + }, + ), + SizedBox( + height: 10, + ), + Text('Assessment Level'), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(_assessmentLevel + '%'), + ), + ), + SizedBox( + height: 10, + ), + Text('Assessment Value'), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(calculateAssessmentValue().toString() == + "0.00" + ? "00.0" + : calculateAssessmentValue())), + ), + ), + const SizedBox(height: 10), + Row( + children: [ + Container( + width: 120, + height: 60, + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () async { + var assessment = LandPropertyAssessment( + landapprDetailsId: widget.tempId, + actualUse: _actualUse, + marketval: _unitValue.toString(), + assessmentLevel: _assessmentLevel, + assessedValue: + calculateAssessmentValue() + .toString(), + totalMarketval: '0', + totalAssessedval: '0'); + + context + .read() + .add(AddLandPropertyAssessment( + assessment: assessment)); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Submit"), + ), + ), + const SizedBox( + width: + 5), // Use SizedBox for horizontal spacing in a Row + Container( + width: 120, + height: 60, + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () { + context + .read() + .add( + const LoadLandPropertyAssessment()); + }, + style: ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), + ), + ], + ) + ], + ), + ), + ), + )); + } + if (state is LandValueAdjustmentsErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadLandValueAdjustments()); + }, + ); + } + return Container(); + }); + } + if (state is LandPropertyAssessmentErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadLandPropertyAssessment()); + }, + ); + } + return Container(); + }); + } +} diff --git a/lib/screens/passo/Land/edit_land/land_appraisal.dart b/lib/screens/passo/Land/edit_land/land_appraisal.dart index 9c6a6b2..7cb966e 100644 --- a/lib/screens/passo/Land/edit_land/land_appraisal.dart +++ b/lib/screens/passo/Land/edit_land/land_appraisal.dart @@ -1,9 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:intl/intl.dart'; import 'package:unit2/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart'; import 'package:unit2/model/passo/land_appr.dart'; -import 'package:unit2/screens/passo/Land/add_land/AddLandAppraisal.dart'; +import 'package:unit2/screens/passo/Land/edit_land/AddLandAppraisalEdit.dart'; + import 'package:unit2/utils/alerts.dart'; import 'package:unit2/utils/text_container.dart'; import 'package:unit2/widgets/error_state.dart'; @@ -12,7 +15,8 @@ import 'package:unit2/widgets/passo/custom_button.dart'; class LandAppraisalEdit extends StatefulWidget { Function PrevBtn; Function NextBtn; - LandAppraisalEdit(this.PrevBtn, this.NextBtn); + final int faasId; + LandAppraisalEdit(this.PrevBtn, this.NextBtn, this.faasId); @override _LandAppraisalEdit createState() => _LandAppraisalEdit(); } @@ -32,231 +36,259 @@ class _LandAppraisalEdit extends State { @override Widget build(BuildContext context) { - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, builder: (context, state) { - final state = context.watch().state; - if (state is LandAppraisalLoaded) { - return Column( - children: [ - Expanded( - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 10), - child: const Text('LAND APPRAISAL', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Align( - alignment: Alignment.topRight, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red, - ), - onPressed: () { - context - .read() - .add(ShowLandAppraisal()); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - const Text('ADD ITEM'), // <-- Text - const SizedBox( - width: 5, - ), - const Icon( - // <-- Icon - Icons.add, - size: 24.0, - ), - ], + return ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) { + if (state is LandAppraisalLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is LandAppraisalLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is LandAppraisalErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, builder: (context, state) { + final state = context.watch().state; + if (state is LandAppraisalLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('LAND APPRAISAL', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + ), + onPressed: () { + context + .read() + .add(ShowLandAppraisal()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('ADD ITEM'), // <-- Text + const SizedBox( + width: 5, + ), + const Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), ), ), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Classification'), + ), + const DataColumn( + label: Text('Sub-Classification'), + ), + const DataColumn( + label: Text('Area'), + ), + const DataColumn( + label: Text('Unit Value'), + ), + const DataColumn( + label: Text('Base MArket Value'), + ), + const DataColumn( + label: Text('Action'), + ) + ], + rows: state.land_appr.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.classification!)), + DataCell(Text(dataRow.subClass!)), + DataCell(Text(dataRow.area!)), + DataCell(Text( + ((double.parse(dataRow.unitValue!))) + .toString())), + DataCell(Text( + ((double.parse(dataRow.baseMarketval!))) + .toString())), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + deleteItem(dataRow.id!); + }, + ), + SizedBox( + width: 10, + ), + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.edit, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () {}, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, ), - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: DataTable( - // ignore: prefer_const_literals_to_create_immutables - columns: [ - const DataColumn( - label: Text('Classification'), - ), - const DataColumn( - label: Text('Sub-Classification'), - ), - const DataColumn( - label: Text('Area'), - ), - const DataColumn( - label: Text('Unit Value'), - ), - const DataColumn( - label: Text('Base MArket Value'), - ), - const DataColumn( - label: Text('Action'), - ) - ], - rows: state.land_appr.map((dataRow) { - return DataRow( - cells: [ - DataCell(Text(dataRow.classification!)), - DataCell(Text(dataRow.subClass!)), - DataCell(Text(dataRow.area!)), - DataCell(Text( - ((double.parse(dataRow.unitValue!))) - .toString())), - DataCell(Text( - ((double.parse(dataRow.baseMarketval!))) - .toString())), - DataCell(Row( - children: [ - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.delete, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () { - deleteItem(dataRow.id!); - }, - ), - SizedBox( - width: 10, - ), - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.edit, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () {}, - ), - ], - )) - ], - ); - }).toList())) + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) ], ), ), - )), - // Padding( - // padding: const EdgeInsets.only(left: 20.0, right: 20.0), - // child: Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // Text( - // 'Total', - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ), - // Text( - // NumberFormat.currency(locale: 'en-PH', symbol: "₱") - // .format('1.0'), - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ) - // ], - // ), - // ), - Padding( - padding: const EdgeInsets.all(15.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + ], + ); + } + if (state is LandAppraisalDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context.read().add(LoadLandAppraisalEdit( + land_appr: const [], id: widget.faasId!)); + }); + }); + } + } + if (state is ShowAddLandAppraisalScreen) { + return ConstrainedBox( + constraints: const BoxConstraints( + maxHeight: 700.0, + ), + child: AlertDialog( + insetPadding: const EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: const Text( + 'ADD LAND APPRAISAL', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - CustomButton( - icon: const Icon(Icons.chevron_left_rounded, - color: Colors.white), - onPressed: () { - { - widget.PrevBtn(); - } - ; - }, + Align( + alignment: Alignment.topCenter, + child: Container( + child: ConstrainedBox( + constraints: BoxConstraints(maxHeight: 500), + child: Container( + child: AddLandAppraisalEditModal(widget.faasId), + ), + ), + ), ), - CustomButton( - icon: const Icon(Icons.chevron_right_rounded, - color: Colors.white), - onPressed: () { - { - widget.NextBtn(); - } - ; - }, - ) ], ), ), - ], - ); - } - if (state is LandAppraisalDeletedState) { - if (state.success) { - WidgetsBinding.instance.addPostFrameCallback((_) { - successAlert(context, "Deletion Successful", - "Extra item has been deleted successfully", () { - Navigator.of(context).pop(); - context.read().add(const LoadLandAppraisal()); - }); - }); + ); } - } - if (state is ShowAddLandAppraisalScreen) { - return ConstrainedBox( - constraints: BoxConstraints( - maxHeight: 700.0, - ), - child: AlertDialog( - insetPadding: EdgeInsets.symmetric( - horizontal: 20.0, - vertical: 10.0, - ), - title: Text( - 'ADD LAND APPRAISAL', - textAlign: TextAlign.center, - ), - content: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container(child: AddLandAppraisalModal()), - ], - ), - ), - ); - } - if (state is LandAppraisalErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context.read().add(LoadLandAppraisal()); - }, - ); - } - return Container(); - }); + if (state is LandAppraisalErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadLandAppraisalEdit( + land_appr: [], id: widget.faasId!)); + }, + ); + } + return Container(); + }), + ); } } diff --git a/lib/screens/passo/Land/edit_land/location_and_boundaries_edit.dart b/lib/screens/passo/Land/edit_land/location_and_boundaries_edit.dart index 12f786d..658720b 100644 --- a/lib/screens/passo/Land/edit_land/location_and_boundaries_edit.dart +++ b/lib/screens/passo/Land/edit_land/location_and_boundaries_edit.dart @@ -5,11 +5,9 @@ import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:unit2/bloc/passo/land/land_boundaries_edit/land_boundaries_edit_bloc.dart'; import 'package:unit2/bloc/passo/land/land_location_edit/land_location_edit_bloc.dart'; -import 'package:unit2/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart'; import 'package:unit2/model/passo/land_property_boundaries.dart'; import 'package:unit2/model/passo/land_property_loc.dart'; import 'package:unit2/model/passo/land_property_owner.dart'; -import 'package:unit2/screens/passo/Land/add_land.dart'; import 'package:unit2/screens/passo/Land/edit_land/property_owner_info_edit.dart'; import 'package:unit2/utils/text_container.dart'; import 'package:unit2/widgets/error_state.dart'; @@ -53,7 +51,7 @@ class _LandLocationAndBoundariesEdit return BlocConsumer( listener: (context, state) { - if (state is LandLocationEditLoaded) { + if (state is LandBoundariesEditLoaded) { final progress = ProgressHUD.of(context); progress?.dismiss(); } @@ -70,7 +68,11 @@ class _LandLocationAndBoundariesEdit 'street': landLoc.street, 'brgy': landLoc.barangay, 'municipality': landLoc.municipality, - 'province': landLoc.province + 'province': landLoc.province, + 'north': state.land_boundaries_edit.north, + 'south': state.land_boundaries_edit.south, + 'east': state.land_boundaries_edit.east, + 'west': state.land_boundaries_edit.west }, enabled: true, onChanged: () { @@ -169,7 +171,7 @@ class _LandLocationAndBoundariesEdit child: customTextField( "West", "", "west")) ]), - SizedBox( + const SizedBox( height: 50, ), Row( @@ -212,16 +214,18 @@ class _LandLocationAndBoundariesEdit ?.value['province'], ); - context.read() - ..add(UpdateLandLocationEdit( - land_loc_edit: location, - id: widget.land.id!)); + context + .read() + .add(UpdateLandLocationEdit( + land_loc_edit: location, + id: widget.land.id!)); - context.read() - ..add(UpdateLandBoundariesEdit( - land_boundaries_edit: - boundaries, - id: widget.land.id!)); + context + .read() + .add(UpdateLandBoundariesEdit( + land_boundaries_edit: + boundaries, + id: widget.land.id!)); widget.NextBtn(); }) diff --git a/lib/screens/passo/Land/edit_land/other_improvements_edit.dart b/lib/screens/passo/Land/edit_land/other_improvements_edit.dart index a750977..13cf33c 100644 --- a/lib/screens/passo/Land/edit_land/other_improvements_edit.dart +++ b/lib/screens/passo/Land/edit_land/other_improvements_edit.dart @@ -1,14 +1,21 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:unit2/bloc/passo/land/other_improvements/other_improvements_bloc.dart'; +import 'package:unit2/model/passo/other_improvements.dart'; import 'package:unit2/screens/passo/Land/add_land/AddOtherImprovementModal.dart'; +import 'package:unit2/screens/passo/Land/edit_land/AddOtherImprovementEditModal.dart'; import 'package:unit2/utils/alerts.dart'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; import 'package:unit2/widgets/passo/custom_button.dart'; class OtherImprovementEditPage extends StatefulWidget { Function PrevBtn; Function NextBtn; - OtherImprovementEditPage(this.PrevBtn, this.NextBtn); + final int faasId; + OtherImprovementEditPage(this.PrevBtn, this.NextBtn, this.faasId); @override _OtherImprovementEditPage createState() => _OtherImprovementEditPage(); } @@ -30,234 +37,277 @@ class _OtherImprovementEditPage extends State { @override Widget build(BuildContext context) { - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, builder: (context, state) { - final state = context.watch().state; - if (state is OtherImprovementLoaded) { - return Column( - children: [ - Expanded( - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 10), - child: const Text('OTHER IMPROVEMENTS', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Align( - alignment: Alignment.topRight, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red, + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) { + if (state is OtherImprovementLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is OtherImprovementLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is OtherImprovementErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, builder: (context, state) { + final state = context.watch().state; + if (state is OtherImprovementLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('OTHER IMPROVEMENTS', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + ), + onPressed: () { + context + .read() + .add(ShowOtherImprovement()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('ADD ITEM'), // <-- Text + const SizedBox( + width: 5, + ), + const Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Kinds of Tress'), + ), + const DataColumn( + label: Text('Sub-Class / Age'), + ), + const DataColumn( + label: Text('Type of Tree'), + ), + const DataColumn( + label: Text('No.'), + ), + const DataColumn( + label: Text('No. of Productive'), + ), + const DataColumn( + label: Text('No. of Non-Productive'), + ), + const DataColumn( + label: Text('Unit Value'), + ), + const DataColumn( + label: Text('Base Market Value'), + ), + const DataColumn( + label: Text('Action'), + ) + ], + rows: state.other_imp.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.kindsOfTrees!)), + DataCell(Text(dataRow.subclassAge!)), + DataCell(Text(dataRow.fruitBearing! + ? "Fruit Bearing" + : "Non-Fruit Bearing")), + DataCell( + Text(dataRow.quantity.toString()!)), + DataCell(Text( + dataRow.noOfProductive.toString()!)), + DataCell(Text(dataRow.noOfNonproductive + .toString()!)), + DataCell( + Text(dataRow.unitValue.toString()!)), + DataCell(Text( + dataRow.baseMarketval.toString()!)), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + deleteItem(dataRow.id!); + }, + ), + SizedBox( + width: 10, + ), + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.edit, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () {}, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), onPressed: () { - context - .read() - .add(ShowOtherImprovement()); + { + widget.PrevBtn(); + } + ; }, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - const Text('ADD ITEM'), // <-- Text - const SizedBox( - width: 5, - ), - const Icon( - // <-- Icon - Icons.add, - size: 24.0, - ), - ], + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is OtherImprovementDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context + .read() + .add(const LoadOtherImprovement()); + }); + }); + } + } + if (state is ShowAddOtherImprovementScreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: Text( + 'ADD OTHER IMPROVEMENTS', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Align( + alignment: Alignment.topCenter, + child: Container( + child: ConstrainedBox( + constraints: BoxConstraints(maxHeight: 500), + child: Container( + child: AddOtherImprovementEditModal(widget.faasId), + ), ), ), ), - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: DataTable( - // ignore: prefer_const_literals_to_create_immutables - columns: [ - const DataColumn( - label: Text('Kinds of Tress'), - ), - const DataColumn( - label: Text('Sub-Class / Age'), - ), - const DataColumn( - label: Text('Type of Tree'), - ), - const DataColumn( - label: Text('No.'), - ), - const DataColumn( - label: Text('No. of Productive'), - ), - const DataColumn( - label: Text('No. of Non-Productive'), - ), - const DataColumn( - label: Text('Unit Value'), - ), - const DataColumn( - label: Text('Base Market Value'), - ), - const DataColumn( - label: Text('Action'), - ) - ], - rows: state.other_imp.map((dataRow) { - return DataRow( - cells: [ - DataCell(Text(dataRow.kindsOfTrees!)), - DataCell(Text(dataRow.subclassAge!)), - DataCell(Text(dataRow.fruitBearing! - ? "Fruit Bearing" - : "Non-Fruit Bearing")), - DataCell(Text(dataRow.quantity.toString()!)), - DataCell( - Text(dataRow.noOfProductive.toString()!)), - DataCell(Text( - dataRow.noOfNonproductive.toString()!)), - DataCell(Text(dataRow.unitValue.toString()!)), - DataCell( - Text(dataRow.baseMarketval.toString()!)), - DataCell(Row( - children: [ - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.delete, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () { - deleteItem(dataRow.id!); - }, - ), - SizedBox( - width: 10, - ), - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.edit, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () {}, - ), - ], - )) - ], - ); - }).toList())) ], ), ), - )), - // Padding( - // padding: const EdgeInsets.only(left: 20.0, right: 20.0), - // child: Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // Text( - // 'Total', - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ), - // Text( - // NumberFormat.currency(locale: 'en-PH', symbol: "₱") - // .format('1.0'), - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ) - // ], - // ), - // ), - Padding( - padding: const EdgeInsets.all(15.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - CustomButton( - icon: const Icon(Icons.chevron_left_rounded, - color: Colors.white), - onPressed: () { - { - widget.PrevBtn(); - } - ; - }, - ), - CustomButton( - icon: const Icon(Icons.chevron_right_rounded, - color: Colors.white), - onPressed: () { - { - widget.NextBtn(); - } - ; - }, - ) - ], - ), - ), - ], - ); - } - if (state is OtherImprovementDeletedState) { - if (state.success) { - WidgetsBinding.instance.addPostFrameCallback((_) { - successAlert(context, "Deletion Successful", - "Extra item has been deleted successfully", () { - Navigator.of(context).pop(); - context - .read() - .add(const LoadOtherImprovement()); - }); - }); - } - } - if (state is ShowAddOtherImprovementScreen) { - return ConstrainedBox( - constraints: BoxConstraints(maxHeight: 1000.0), - child: AlertDialog( - insetPadding: EdgeInsets.symmetric( - horizontal: 20.0, - vertical: 10.0, - ), - title: Text( - 'ADD OTHER IMPROVEMENTS', - textAlign: TextAlign.center, - ), - content: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [Container(child: AddOtherImprovementModal())], - ), - ), - ); - } - return Container(); - }); + ); + } + if (state is OtherImprovementErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add( + LoadOtherImprovementEdit( + other_imps: const [], + ids: widget.faasId)); + }, + ); + } + return Container(); + }), + ), + ); } } diff --git a/lib/screens/passo/Land/edit_land/property_assessment_cont_edit.dart b/lib/screens/passo/Land/edit_land/property_assessment_cont_edit.dart index efc7768..4d43bb5 100644 --- a/lib/screens/passo/Land/edit_land/property_assessment_cont_edit.dart +++ b/lib/screens/passo/Land/edit_land/property_assessment_cont_edit.dart @@ -1,21 +1,26 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:searchfield/searchfield.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:unit2/bloc/passo/land/land_ext/land_ext_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_ext_bloc/land_ext_edit_bloc.dart'; import 'package:unit2/bloc/passo/memoranda/memoranda_bloc.dart'; import 'package:unit2/bloc/passo/signatories/signatories_bloc.dart'; import 'package:unit2/model/passo/land_ext.dart'; import 'package:unit2/model/passo/memoranda.dart'; import 'package:unit2/model/passo/signatories.dart'; -import 'package:unit2/screens/passo/Land/add_land.dart'; +import 'package:unit2/screens/passo/Land/edit_land/property_owner_info_edit.dart'; import 'package:unit2/theme-data.dart/colors.dart'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; class LandSignatoriesEdit extends StatefulWidget { Function onSAve; - LandSignatoriesEdit(this.onSAve); + final int faasId; + LandSignatoriesEdit(this.onSAve, this.faasId); @override _LandSignatoriesEdit createState() => _LandSignatoriesEdit(); @@ -28,514 +33,628 @@ class _LandSignatoriesEdit extends State { String _memoranda = ""; @override Widget build(BuildContext context) { - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, - builder: (context, state) { - if (state is LandExtLoaded) { - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, - builder: (context, state) { - if (state is SignatoriesLoaded) { - final signatories = state.signatories; - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, - builder: (context, state) { - if (state is MemorandaLoaded) { - return SingleChildScrollView( - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 10), - child: const Text('PROPERTY ASSESSMENT cont..', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Row( - children: [ - const Text('Taxable'), - Checkbox( - checkColor: Colors.white, - value: isTaxable, - onChanged: (bool? value) { - setState(() { - isTaxable = value!; - }); - }, - ) - ], - ), - Row( - children: [ - const Text('Exempt'), - Checkbox( - checkColor: Colors.white, - value: isExempt, - onChanged: (bool? value) { - setState(() { - isExempt = value!; - }); - }, - ) - ], - ), - ], - ), - Column( - children: [ - const SizedBox( - height: 20, - ), - const Text( - 'EFFECTIVITY OF ASSESSMENT / REASSESSMENT :', - style: TextStyle(fontWeight: FontWeight.bold), - ), - const SizedBox( - height: 20, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceAround, - children: [ - const Text('Qtr.'), - SizedBox( - width: 70, - height: 25, - child: FormBuilderTextField( - name: 'land_qtr', - validator: - FormBuilderValidators.compose([]), - ), - ), - const SizedBox( - width: 20, - ), - const Text('Yr.'), - SizedBox( - width: 70, - height: 25, - child: FormBuilderTextField( - name: 'land_yr', - validator: - FormBuilderValidators.compose([]), - ), - ), - ], - ), - ], - ), - Container( - margin: const EdgeInsets.only( - left: 0, top: 40, right: 0, bottom: 10), - child: const Text('SIGNATORIES', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - const SizedBox( - height: 30, - ), - Align( - alignment: Alignment.centerLeft, - child: Text( - 'APPRAISED/ASSESSED BY:', - style: TextStyle(fontWeight: FontWeight.bold), - textAlign: TextAlign.start, - ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( - children: [ - SizedBox( - width: 200, - child: FormBuilderDropdown( - name: 'appraised_by_land', - autofocus: false, - items: signatories - .map((signatories) => - DropdownMenuItem( - value: signatories, - child: Text( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), - )) - .toList()), - ), - Text('Name'), - ], - ), - const SizedBox( - width: 15, - ), - Column( - children: [ - SizedBox( - width: 100, - child: FormBuilderDateTimePicker( - name: 'app_date_land', - initialEntryMode: - DatePickerEntryMode.calendarOnly, - initialValue: DateTime.now(), - inputType: InputType.date, + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) { + if (state is LandExtEditLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } - initialTime: - const TimeOfDay(hour: 8, minute: 0), - // locale: const Locale.fromSubtags(languageCode: 'fr'), - ), - ), - Text('Date'), - ], - ), - ], - ), - const SizedBox( - height: 30, - ), - const Align( - alignment: Alignment.centerLeft, - child: Text( - 'RECOMMENDING APPROVAL:', - style: TextStyle(fontWeight: FontWeight.bold), - )), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( - children: [ - SizedBox( - width: 200, - child: FormBuilderDropdown( - name: 'rec_approval_land', - autofocus: false, - items: signatories - .map((signatories) => - DropdownMenuItem( - value: signatories, - child: Text( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), - )) - .toList()), - ), - Text('Name'), - ], - ), - const SizedBox( - width: 15, - ), - Column( - children: [ - SizedBox( - width: 100, - child: FormBuilderDateTimePicker( - name: 'rec_date_land', - initialEntryMode: - DatePickerEntryMode.calendarOnly, - initialValue: DateTime.now(), - inputType: InputType.date, - - initialTime: - const TimeOfDay(hour: 8, minute: 0), - // locale: const Locale.fromSubtags(languageCode: 'fr'), - ), - ), - Text('Date'), - ], - ), - ], - ), - const SizedBox( - height: 30, - ), - const Align( - alignment: Alignment.centerLeft, - child: Text( - 'APPROVED BY:', - style: TextStyle( - fontWeight: FontWeight.bold, - ), - )), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Column( - children: [ - SizedBox( - width: 200, - child: FormBuilderDropdown( - name: 'apprvd_by_land', - autofocus: false, - items: signatories - .map((signatories) => - DropdownMenuItem( - value: signatories, - child: Text( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), - )) - .toList()), - ), - Text('Name'), - ], - ), - const SizedBox( - width: 15, - ), - Column( - children: [ - SizedBox( - width: 100, - child: FormBuilderDateTimePicker( - name: 'apprvd_by_date_land', - initialEntryMode: - DatePickerEntryMode.calendarOnly, - initialValue: DateTime.now(), - inputType: InputType.date, - - initialTime: - const TimeOfDay(hour: 8, minute: 0), - // locale: const Locale.fromSubtags(languageCode: 'fr'), - ), - ), - Text('Date'), - ], - ), - ], - ), - const SizedBox( - height: 50, - ), - const Align( - alignment: Alignment.centerLeft, - child: Text( - 'MEMORANDA: ', - style: TextStyle( - fontWeight: FontWeight.bold, - ), - )), - SizedBox( - height: 50, - ), - SizedBox( - width: 500, - height: 100, - child: SearchField( - suggestions: state.memorada - .map((Memoranda memoranda) => - SearchFieldListItem( - '${memoranda.memoranda}', - item: - memoranda, // Change: Use individual Memoranda object - child: ListTile( - title: Text( - '${memoranda.memoranda}', - overflow: TextOverflow.ellipsis, - ), - ), - )) - .toList(), - validator: FormBuilderValidators.required( - errorText: "This field is required"), - // searchInputDecoration: - // normalTextFieldStyle( - // "Memoranda", "") - // .copyWith( - // suffixIcon: const Icon( - // Icons.arrow_drop_down), - // ), - // focusNode: focus, - suggestionState: Suggestion.expand, - onSuggestionTap: (memoranda) { - setState(() { - _memoranda = memoranda.item!.memoranda!; - }); - focus.unfocus(); - }, - )), - SizedBox( - height: 30, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('Sworn Statement No. :'), - SizedBox( - width: 150, - height: 20, - child: FormBuilderTextField( - name: 'sworn_statement_land', - decoration: InputDecoration(), - validator: FormBuilderValidators.compose([]), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('Date Received:'), - SizedBox( - width: 150, - height: 20, - child: FormBuilderDateTimePicker( - name: 'date_received_land', - initialEntryMode: - DatePickerEntryMode.calendarOnly, - initialValue: DateTime.now(), - inputType: InputType.date, - - initialTime: - const TimeOfDay(hour: 8, minute: 0), - // locale: const Locale.fromSubtags(languageCode: 'fr'), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('Date of Entry in the Rec. of Ass. :'), - SizedBox( - width: 100, - height: 20, - child: FormBuilderDateTimePicker( - name: 'date_of_entry_land', - initialEntryMode: - DatePickerEntryMode.calendarOnly, - initialValue: DateTime.now(), - inputType: InputType.date, - - initialTime: - const TimeOfDay(hour: 8, minute: 0), - // locale: const Locale.fromSubtags(languageCode: 'fr'), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('By:'), - SizedBox( - width: 150, - height: 20, - child: FormBuilderTextField( - name: 'by_land', - decoration: InputDecoration(), - validator: FormBuilderValidators.compose([]), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - ElevatedButton( - onPressed: () async { - final tempID = - await SharedPreferences.getInstance(); - var ext = LandExt( - landapprDetailsId: - tempID.getInt('landid')! - 1, - taxable: isTaxable, - exempt: isExempt, - qtr: int.parse( - landKey.currentState!.value['land_qtr']), - yr: int.parse( - landKey.currentState!.value['land_yr']), - appraisedbyName: landKey.currentState!.value['appraised_by_land'].firstname + - ' ' + - landKey - .currentState! - .value['appraised_by_land'] - .middlename + - ' ' + - landKey.currentState! - .value['appraised_by_land'].lastname, - appraisedbyDate: landKey - .currentState!.value['app_date_land'], - recommendapprName: landKey - .currentState! - .value['rec_approval_land'] - .firstname + - ' ' + - landKey - .currentState! - .value['rec_approval_land'] - .middlename + - ' ' + - landKey.currentState! - .value['rec_approval_land'].lastname, - recommendapprDate: landKey - .currentState!.value['rec_date_land'], - approvedbyName: landKey.currentState!.value['apprvd_by_land'].firstname + - ' ' + - landKey.currentState!.value['apprvd_by_land'].middlename + - ' ' + - landKey.currentState!.value['apprvd_by_land'].lastname, - approvedbyDate: landKey.currentState!.value['apprvd_by_date_land'], - memoranda: _memoranda, - swornstatementNo: landKey.currentState!.value['sworn_statement_land'], - dateReceived: landKey.currentState!.value['date_received_land'], - entryDateAssessment: landKey.currentState!.value['date_of_entry_land'], - entryDateBy: landKey.currentState!.value['by_land']); - - context.read() - ..add(UpdateLandExt(landext: ext)); - widget.onSAve(); + if (state is LandExtEditErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, + builder: (context, state) { + if (state is LandExtEditLoaded) { + final landext = state.land_ext_edit; + return BlocConsumer( + listener: (context, state) { + if (state is SignatoriesErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, + builder: (context, state) { + if (state is SignatoriesLoaded) { + final signatories = state.signatories; + return BlocConsumer( + listener: (context, state) { + if (state is MemorandaLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is MemorandaErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, + builder: (context, state) { + if (state is MemorandaLoaded) { + return FormBuilder( + key: landEditKey, + initialValue: { + 'land_qtr': landext.qtr.toString(), + 'land_yr': landext.yr.toString(), + 'app_date_land': landext.appraisedbyDate, + 'rec_date_land': landext.recommendapprDate, + 'apprvd_by_date_land': landext.approvedbyDate, + 'sworn_statement_land': landext.swornstatementNo, + 'date_received_land': landext.dateReceived, + 'date_of_entry_land': landext.entryDateAssessment, + 'by_land': landext.entryDateBy }, - style: ElevatedButton.styleFrom( - backgroundColor: primary, - foregroundColor: Colors.red), - child: SizedBox( - width: 250, - height: 50, - child: Align( - alignment: Alignment.center, - child: Text( - 'Save', - style: TextStyle( - color: Colors.white, - ), - textAlign: TextAlign.center, + enabled: true, + onChanged: () { + landEditKey.currentState!.save(); + debugPrint( + landEditKey.currentState!.value.toString()); + }, + autovalidateMode: AutovalidateMode.disabled, + skipDisabled: true, + child: SingleChildScrollView( + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text( + 'PROPERTY ASSESSMENT cont..', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), ), - ), - ), - ), - SizedBox( - height: 30, - ), - ], - )); - } - return Container(); - }, - ); - } - return Container(); - }, - ); - } - return Container(); - }, + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Row( + children: [ + const Text('Taxable'), + Checkbox( + checkColor: Colors.white, + value: isTaxable, + onChanged: (bool? value) { + setState(() { + isTaxable = value!; + }); + }, + ) + ], + ), + Row( + children: [ + const Text('Exempt'), + Checkbox( + checkColor: Colors.white, + value: isExempt, + onChanged: (bool? value) { + setState(() { + isExempt = value!; + }); + }, + ) + ], + ), + ], + ), + Column( + children: [ + const SizedBox( + height: 20, + ), + const Text( + 'EFFECTIVITY OF ASSESSMENT / REASSESSMENT :', + style: TextStyle( + fontWeight: FontWeight.bold), + ), + const SizedBox( + height: 20, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + const Text('Qtr.'), + SizedBox( + width: 70, + height: 25, + child: FormBuilderTextField( + name: 'land_qtr', + validator: + FormBuilderValidators.compose( + []), + ), + ), + const SizedBox( + width: 20, + ), + const Text('Yr.'), + SizedBox( + width: 70, + height: 25, + child: FormBuilderTextField( + name: 'land_yr', + validator: + FormBuilderValidators.compose( + []), + ), + ), + ], + ), + ], + ), + Container( + margin: const EdgeInsets.only( + left: 0, top: 40, right: 0, bottom: 10), + child: const Text('SIGNATORIES', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'APPRAISED/ASSESSED BY:', + style: + TextStyle(fontWeight: FontWeight.bold), + textAlign: TextAlign.start, + ), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: + FormBuilderDropdown( + name: 'appraised_by_land', + decoration: InputDecoration( + labelText: landext + .appraisedbyName!, + labelStyle: const TextStyle( + color: Colors.black), + ), + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + const Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'app_date_land', + initialEntryMode: + DatePickerEntryMode + .calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + const Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'RECOMMENDING APPROVAL:', + style: TextStyle( + fontWeight: FontWeight.bold), + )), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: + FormBuilderDropdown( + name: 'rec_approval_land', + decoration: InputDecoration( + labelText: landext + .recommendapprName!, + labelStyle: const TextStyle( + color: Colors.black), + ), + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + const Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'rec_date_land', + initialEntryMode: + DatePickerEntryMode + .calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + const Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'APPROVED BY:', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + )), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: + FormBuilderDropdown( + name: 'apprvd_by_land', + decoration: InputDecoration( + labelText: + landext.approvedbyName!, + labelStyle: const TextStyle( + color: Colors.black), + ), + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + const Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'apprvd_by_date_land', + initialEntryMode: + DatePickerEntryMode + .calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 50, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'MEMORANDA: ', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + )), + const SizedBox( + height: 50, + ), + SizedBox( + width: 500, + height: 100, + child: SearchField( + suggestions: state.memorada + .map((Memoranda memoranda) => + SearchFieldListItem( + '${memoranda.memoranda}', + item: + memoranda, // Change: Use individual Memoranda object + child: ListTile( + title: Text( + '${memoranda.memoranda}', + overflow: + TextOverflow.ellipsis, + ), + ), + )) + .toList(), + validator: FormBuilderValidators.required( + errorText: "This field is required"), + // searchInputDecoration: + // normalTextFieldStyle( + // "Memoranda", "") + // .copyWith( + // suffixIcon: const Icon( + // Icons.arrow_drop_down), + // ), + // focusNode: focus, + suggestionState: Suggestion.expand, + onSuggestionTap: (memoranda) { + setState(() { + _memoranda = + memoranda.item!.memoranda!; + }); + focus.unfocus(); + }, + )), + const SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text('Sworn Statement No. :'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderTextField( + name: 'sworn_statement_land', + decoration: InputDecoration(), + validator: + FormBuilderValidators.compose([]), + ), + ), + ], + ), + const SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text('Date Received:'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderDateTimePicker( + name: 'date_received_land', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: + const TimeOfDay(hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + ], + ), + const SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + const Text( + 'Date of Entry in the Rec. of Ass. :'), + SizedBox( + width: 100, + height: 20, + child: FormBuilderDateTimePicker( + name: 'date_of_entry_land', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: + const TimeOfDay(hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + ], + ), + const SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + const Text('By:'), + SizedBox( + width: 150, + height: 20, + child: FormBuilderTextField( + name: 'by_land', + decoration: const InputDecoration(), + validator: + FormBuilderValidators.compose([]), + ), + ), + ], + ), + const SizedBox( + height: 30, + ), + ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences.getInstance(); + var ext = LandExt( + landapprDetailsId: + tempID.getInt('landid')! - 1, + taxable: isTaxable, + exempt: isExempt, + qtr: int.parse(landEditKey + .currentState!.value['land_qtr']), + yr: int.parse(landEditKey + .currentState!.value['land_yr']), + appraisedbyName: landEditKey.currentState!.value['appraised_by_land'].firstname + + ' ' + + landEditKey + .currentState! + .value['appraised_by_land'] + .middlename + + ' ' + + landEditKey + .currentState! + .value['appraised_by_land'] + .lastname, + appraisedbyDate: landEditKey + .currentState! + .value['app_date_land'], + recommendapprName: landEditKey.currentState!.value['rec_approval_land'].firstname + + ' ' + + landEditKey.currentState!.value['rec_approval_land'].middlename + + ' ' + + landEditKey.currentState!.value['rec_approval_land'].lastname, + recommendapprDate: landEditKey.currentState!.value['rec_date_land'], + approvedbyName: landEditKey.currentState!.value['apprvd_by_land'].firstname + ' ' + landEditKey.currentState!.value['apprvd_by_land'].middlename + ' ' + landEditKey.currentState!.value['apprvd_by_land'].lastname, + approvedbyDate: landEditKey.currentState!.value['apprvd_by_date_land'], + memoranda: _memoranda, + swornstatementNo: landEditKey.currentState!.value['sworn_statement_land'], + dateReceived: landEditKey.currentState!.value['date_received_land'], + entryDateAssessment: landEditKey.currentState!.value['date_of_entry_land'], + entryDateBy: landEditKey.currentState!.value['by_land']); + + context.read().add( + UpdateLandExtEdit( + land_ext_edit: ext, + id: widget.faasId)); + widget.onSAve(); + }, + style: ElevatedButton.styleFrom( + backgroundColor: primary, + foregroundColor: Colors.red), + child: const SizedBox( + width: 250, + height: 50, + child: Align( + alignment: Alignment.center, + child: Text( + 'Save', + style: TextStyle( + color: Colors.white, + ), + textAlign: TextAlign.center, + ), + ), + ), + ), + const SizedBox( + height: 30, + ), + ], + )), + ); + } + if (state is MemorandaErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(const LoadMemoranda()); + }, + ); + } + return Container(); + }, + ); + } + if (state is SignatoriesErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(const LoadSignatories()); + }, + ); + } + return Container(); + }, + ); + } + if (state is LandExtEditErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadLandExtEdit( + land_ext_edit: LandExt(), id: widget.faasId)); + }, + ); + } + return Container(); + }, + ), + ), ); } } diff --git a/lib/screens/passo/Land/edit_land/property_assessment_edit.dart b/lib/screens/passo/Land/edit_land/property_assessment_edit.dart index b009435..097dabe 100644 --- a/lib/screens/passo/Land/edit_land/property_assessment_edit.dart +++ b/lib/screens/passo/Land/edit_land/property_assessment_edit.dart @@ -1,14 +1,22 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:unit2/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.dart'; import 'package:unit2/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart'; +import 'package:unit2/model/passo/land_property_assessment.dart'; import 'package:unit2/screens/passo/Land/add_land/AddPropertyAssessmentModal.dart'; +import 'package:unit2/screens/passo/Land/edit_land/AddPropertyAssessmentEditModal.dart'; import 'package:unit2/utils/alerts.dart'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; import 'package:unit2/widgets/passo/custom_button.dart'; class LandPropertyAssessmentEditPage extends StatefulWidget { Function PrevBtn; Function NextBtn; - LandPropertyAssessmentEditPage(this.PrevBtn, this.NextBtn); + final int faasId; + LandPropertyAssessmentEditPage(this.PrevBtn, this.NextBtn, this.faasId); @override _LandPropertyAssessmentEditPage createState() => _LandPropertyAssessmentEditPage(); @@ -32,214 +40,248 @@ class _LandPropertyAssessmentEditPage @override Widget build(BuildContext context) { - return BlocConsumer(listener: (context, state) { - // TODO: implement listener - }, builder: (context, state) { - final state = context.watch().state; - if (state is LandPropertyAssessmentLoaded) { - return Column( - children: [ - Expanded( - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: Column( + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer(listener: (context, state) { + if (state is LandPropertyAssessmentLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is LandPropertyAssessmentLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is LandPropertyAssessmentErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, builder: (context, state) { + final state = context.watch().state; + if (state is LandPropertyAssessmentLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('PROPERTY ASSESSMENT', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + ), + onPressed: () { + context + .read() + .add(ShowLandPropertyAssessment()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('ADD ITEM'), // <-- Text + const SizedBox( + width: 5, + ), + const Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], + ), + ), + ), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Actual Use'), + ), + const DataColumn( + label: Text('Market Value'), + ), + const DataColumn( + label: Text('Assessment Level'), + ), + const DataColumn( + label: Text('Assessed Value'), + ), + const DataColumn( + label: Text('Action'), + ) + ], + rows: state.assessment.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.actualUse!)), + DataCell(Text(dataRow.marketval!)), + DataCell( + Text(dataRow.assessmentLevel! + '%')), + DataCell(Text(dataRow.assessedValue!)), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + deleteItem(dataRow.id!); + }, + ), + SizedBox( + width: 10, + ), + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.edit, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () {}, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is LandPropertyAssessmentDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context.read().add( + LoadLandPropertyAssessmentEdit( + assessment: [], + id: widget.faasId)); + }); + }); + } + } + if (state is ShowAddLandPropertyAssessmentScreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: Text( + 'ADD PROPERTY ASSESSMENT', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 10), - child: const Text('PROPERTY ASSESSMENT', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Align( - alignment: Alignment.topRight, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red, - ), - onPressed: () { - context - .read() - .add(ShowLandPropertyAssessment()); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - const Text('ADD ITEM'), // <-- Text - const SizedBox( - width: 5, - ), - const Icon( - // <-- Icon - Icons.add, - size: 24.0, - ), - ], - ), - ), - ), - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: DataTable( - // ignore: prefer_const_literals_to_create_immutables - columns: [ - const DataColumn( - label: Text('Actual Use'), - ), - const DataColumn( - label: Text('Market Value'), - ), - const DataColumn( - label: Text('Assessment Level'), - ), - const DataColumn( - label: Text('Assessed Value'), - ), - const DataColumn( - label: Text('Action'), - ) - ], - rows: state.assessment.map((dataRow) { - return DataRow( - cells: [ - DataCell(Text(dataRow.actualUse!)), - DataCell(Text(dataRow.marketval!)), - DataCell( - Text(dataRow.assessmentLevel! + '%')), - DataCell(Text(dataRow.assessedValue!)), - DataCell(Row( - children: [ - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.delete, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () { - deleteItem(dataRow.id!); - }, - ), - SizedBox( - width: 10, - ), - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.edit, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () {}, - ), - ], - )) - ], - ); - }).toList())) + child: AddPropertyAssessmentEditModal(widget.faasId)) ], ), ), - )), - // Padding( - // padding: const EdgeInsets.only(left: 20.0, right: 20.0), - // child: Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // Text( - // 'Total', - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ), - // Text( - // NumberFormat.currency(locale: 'en-PH', symbol: "₱") - // .format('1.0'), - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ) - // ], - // ), - // ), - Padding( - padding: const EdgeInsets.all(15.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - CustomButton( - icon: const Icon(Icons.chevron_left_rounded, - color: Colors.white), - onPressed: () { - { - widget.PrevBtn(); - } - ; - }, - ), - CustomButton( - icon: const Icon(Icons.chevron_right_rounded, - color: Colors.white), - onPressed: () { - { - widget.NextBtn(); - } - ; - }, - ) - ], - ), - ), - ], - ); - } - if (state is LandPropertyAssessmentDeletedState) { - if (state.success) { - WidgetsBinding.instance.addPostFrameCallback((_) { - successAlert(context, "Deletion Successful", - "Extra item has been deleted successfully", () { - Navigator.of(context).pop(); - context - .read() - .add(const LoadLandPropertyAssessment()); - }); - }); - } - } - if (state is ShowAddLandPropertyAssessmentScreen) { - return ConstrainedBox( - constraints: BoxConstraints(maxHeight: 1000.0), - child: AlertDialog( - insetPadding: EdgeInsets.symmetric( - horizontal: 20.0, - vertical: 10.0, - ), - title: Text( - 'ADD PROPERTY ASSESSMENT', - textAlign: TextAlign.center, - ), - content: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [Container(child: AddPropertyAssessmentModal())], - ), - ), - ); - } - return Container(); - }); + ); + } + if (state is LandPropertyAssessmentErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add( + LoadLandPropertyAssessmentEdit( + assessment: const [], + id: widget.faasId)); + }, + ); + } + + return Container(); + }), + ), + ); } } diff --git a/lib/screens/passo/Land/edit_land/value_adjustments_edit.dart b/lib/screens/passo/Land/edit_land/value_adjustments_edit.dart index 6dabf25..d969ca8 100644 --- a/lib/screens/passo/Land/edit_land/value_adjustments_edit.dart +++ b/lib/screens/passo/Land/edit_land/value_adjustments_edit.dart @@ -1,14 +1,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:unit2/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart'; +import 'package:unit2/model/passo/land_value_adjustment.dart'; import 'package:unit2/screens/passo/Land/add_land/AddLandValueAdjustmentModal.dart'; import 'package:unit2/utils/alerts.dart'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; import 'package:unit2/widgets/passo/custom_button.dart'; class ValueAdjustmentEditPage extends StatefulWidget { Function PrevBtn; Function NextBtn; - ValueAdjustmentEditPage(this.PrevBtn, this.NextBtn); + final int faasId; + ValueAdjustmentEditPage(this.PrevBtn, this.NextBtn, this.faasId); @override _ValueAdjustmentEditPage createState() => _ValueAdjustmentEditPage(); } @@ -30,217 +36,248 @@ class _ValueAdjustmentEditPage extends State { @override Widget build(BuildContext context) { - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, builder: (context, state) { - final state = context.watch().state; - if (state is LandValueAdjustmentsLoaded) { - return Column( - children: [ - Expanded( - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 10), - child: const Text('VALUE ADJUSTMENTS', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Align( - alignment: Alignment.topRight, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red, + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: + BlocConsumer( + listener: (context, state) { + if (state is LandValueAdjustmentsLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is LandValueAdjustmentsLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is LandValueAdjustmentsErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, builder: (context, state) { + final state = context.watch().state; + if (state is LandValueAdjustmentsLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('VALUE ADJUSTMENTS', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), ), - onPressed: () { - context - .read() - .add(ShowLandValueAdjustments()); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - const Text('ADD ITEM'), // <-- Text - const SizedBox( - width: 5, + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, ), - const Icon( - // <-- Icon - Icons.add, - size: 24.0, + onPressed: () { + context + .read() + .add(ShowLandValueAdjustments()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('ADD ITEM'), // <-- Text + const SizedBox( + width: 5, + ), + const Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], ), - ], + ), ), - ), - ), - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: DataTable( - // ignore: prefer_const_literals_to_create_immutables - columns: [ - const DataColumn( - label: Text('Base Market Value'), - ), - const DataColumn( - label: Text('Adjustment Factors'), - ), - const DataColumn( - label: Text('% Adjustment'), - ), - const DataColumn( - label: Text('Value Adjustment'), - ), - const DataColumn( - label: Text('Market Value'), - ), - const DataColumn( - label: Text('Action'), - ) - ], - rows: state.val_adj.map((dataRow) { - return DataRow( - cells: [ - DataCell(Text(dataRow.baseMarketval!)), - DataCell(Text(dataRow.adjustmentFactors!)), - DataCell(Text(dataRow.adjustment!)), - DataCell(Text(dataRow.valueAdjustment!)), - DataCell(Text(dataRow.marketValue!)), - DataCell(Row( - children: [ - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.delete, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () { - deleteItem(dataRow.id!); - }, - ), - SizedBox( - width: 10, - ), - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.edit, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () {}, - ), - ], - )) + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Base Market Value'), + ), + const DataColumn( + label: Text('Adjustment Factors'), + ), + const DataColumn( + label: Text('% Adjustment'), + ), + const DataColumn( + label: Text('Value Adjustment'), + ), + const DataColumn( + label: Text('Market Value'), + ), + const DataColumn( + label: Text('Action'), + ) ], - ); - }).toList())) - ], + rows: state.val_adj.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.baseMarketval!)), + DataCell( + Text(dataRow.adjustmentFactors!)), + DataCell(Text(dataRow.adjustment!)), + DataCell(Text(dataRow.valueAdjustment!)), + DataCell(Text(dataRow.marketValue!)), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + deleteItem(dataRow.id!); + }, + ), + SizedBox( + width: 10, + ), + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.edit, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () {}, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is LandValueAdjustmentsDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context.read().add( + LoadLandValueAdjustmentsEdit( + val_adj: [], id: widget.faasId)); + }); + }); + } + } + if (state is ShowAddLandValueAdjustmentsScreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: Text( + 'ADD VALUE ADJUSTMENTS', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [Expanded(child: AddLandValueAdjustmentModal())], ), ), - )), - // Padding( - // padding: const EdgeInsets.only(left: 20.0, right: 20.0), - // child: Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // Text( - // 'Total', - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ), - // Text( - // NumberFormat.currency(locale: 'en-PH', symbol: "₱") - // .format('1.0'), - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ) - // ], - // ), - // ), - Padding( - padding: const EdgeInsets.all(15.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - CustomButton( - icon: const Icon(Icons.chevron_left_rounded, - color: Colors.white), - onPressed: () { - { - widget.PrevBtn(); - } - ; - }, - ), - CustomButton( - icon: const Icon(Icons.chevron_right_rounded, - color: Colors.white), - onPressed: () { - { - widget.NextBtn(); - } - ; - }, - ) - ], - ), - ), - ], - ); - } - if (state is LandValueAdjustmentsDeletedState) { - if (state.success) { - WidgetsBinding.instance.addPostFrameCallback((_) { - successAlert(context, "Deletion Successful", - "Extra item has been deleted successfully", () { - Navigator.of(context).pop(); - context - .read() - .add(const LoadLandValueAdjustments()); - }); - }); - } - } - if (state is ShowAddLandValueAdjustmentsScreen) { - return ConstrainedBox( - constraints: BoxConstraints(maxHeight: 1000.0), - child: AlertDialog( - insetPadding: EdgeInsets.symmetric( - horizontal: 20.0, - vertical: 10.0, - ), - title: Text( - 'ADD VALUE ADJUSTMENTS', - textAlign: TextAlign.center, - ), - content: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [Expanded(child: AddLandValueAdjustmentModal())], - ), - ), - ); - } - return Container(); - }); + ); + } + if (state is LandValueAdjustmentsErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add( + LoadLandValueAdjustmentsEdit( + val_adj: const [], + id: widget.faasId)); + }, + ); + } + return Container(); + }), + ), + ); } } diff --git a/lib/screens/passo/building_home.dart b/lib/screens/passo/building_home.dart index eabc80c..08d7cbd 100644 --- a/lib/screens/passo/building_home.dart +++ b/lib/screens/passo/building_home.dart @@ -90,8 +90,11 @@ class BuildingHome extends StatelessWidget { final progress = ProgressHUD.of(context); progress!.showWithText("Please wait..."); } - if (state is PropertyInfoLoaded || - state is PropertyInfoErrorState) { + if (state is PropertyInfoLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is PropertyInfoErrorState) { final progress = ProgressHUD.of(context); progress?.dismiss(); } diff --git a/lib/screens/passo/land_home .dart b/lib/screens/passo/land_home .dart index 91e26bc..a101d7e 100644 --- a/lib/screens/passo/land_home .dart +++ b/lib/screens/passo/land_home .dart @@ -21,6 +21,7 @@ import 'package:unit2/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart'; import 'package:unit2/bloc/passo/land/land_boundaries_edit/land_boundaries_edit_bloc.dart'; import 'package:unit2/bloc/passo/land/land_classification/land_classification_bloc.dart'; import 'package:unit2/bloc/passo/land/land_ext/land_ext_bloc.dart'; +import 'package:unit2/bloc/passo/land/land_ext_bloc/land_ext_edit_bloc.dart'; import 'package:unit2/bloc/passo/land/land_location_edit/land_location_edit_bloc.dart'; import 'package:unit2/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart'; import 'package:unit2/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart'; @@ -39,10 +40,15 @@ import 'package:unit2/bloc/passo/signatories/signatories_bloc.dart'; import 'package:unit2/bloc/user/user_bloc.dart'; import 'package:unit2/model/passo/additional_items.dart'; import 'package:unit2/model/passo/general_description.dart'; +import 'package:unit2/model/passo/land_appr.dart'; +import 'package:unit2/model/passo/land_ext.dart'; +import 'package:unit2/model/passo/land_property_assessment.dart'; import 'package:unit2/model/passo/land_property_boundaries.dart'; import 'package:unit2/model/passo/land_property_loc.dart'; import 'package:unit2/model/passo/land_property_owner.dart'; import 'package:unit2/model/passo/land_ref.dart'; +import 'package:unit2/model/passo/land_value_adjustment.dart'; +import 'package:unit2/model/passo/other_improvements.dart'; import 'package:unit2/model/passo/property_appraisal.dart'; import 'package:unit2/model/passo/property_appraisal_edit.dart'; import 'package:unit2/model/passo/property_assessment_edit.dart'; @@ -300,14 +306,20 @@ Card _listCard(LandPropertyOwner property_info, context, index) { ..add(LoadLandLocationEdit( land_loc_edit: LandPropertyLoc(), id: property_info.id))), + BlocProvider( + create: (context) => LandExtEditBloc() + ..add(LoadLandExtEdit( + land_ext_edit: LandExt(), id: property_info.id))), BlocProvider( create: (context) => LandBoundariesEditBloc() ..add(LoadLandBoundariesEdit( land_boundaries_edit: LandPropertyBoundaries(), id: property_info.id))), BlocProvider( - create: (context) => - LandAppraisalBloc()..add(LoadLandAppraisal())), + create: (context) => LandAppraisalBloc() + ..add(LoadLandAppraisalEdit( + land_appr: const [], + id: property_info.id!))), BlocProvider( create: (context) => LandClassificationBloc() ..add(LoadLandClassification())), @@ -316,8 +328,10 @@ Card _listCard(LandPropertyOwner property_info, context, index) { ..add(LoadLandSubClassification( cityCode: "1", classCode: 1))), BlocProvider( - create: (context) => - OtherImprovementsBloc()..add(LoadOtherImprovement())), + create: (context) => OtherImprovementsBloc() + ..add(LoadOtherImprovementEdit( + other_imps: const [], + ids: property_info.id!))), BlocProvider( create: (context) => TypeOfLocationBloc()..add(LoadTypeOfLocation())), @@ -326,7 +340,9 @@ Card _listCard(LandPropertyOwner property_info, context, index) { TypeOfRoadBloc()..add(LoadTypeOfRoad())), BlocProvider( create: (context) => LandPropertyAssessmentBloc() - ..add(LoadLandPropertyAssessment())), + ..add(LoadLandPropertyAssessmentEdit( + assessment: [], + id: property_info.id!))), BlocProvider( create: (context) => LandTreesImprovementsBloc() ..add(LoadLandTreesImprovements())), @@ -334,7 +350,9 @@ Card _listCard(LandPropertyOwner property_info, context, index) { create: (context) => LandExtBloc()..add(LoadLandExt())), BlocProvider( create: (context) => LandValueAdjustmentsBloc() - ..add(LoadLandValueAdjustments())), + ..add(LoadLandValueAdjustmentsEdit( + val_adj: [], + id: property_info.id!))), BlocProvider( create: (context) => SignatoriesBloc()..add(LoadSignatories())), diff --git a/lib/screens/passo/passo_dashboard.dart b/lib/screens/passo/passo_dashboard.dart index c423b8f..2380afe 100644 --- a/lib/screens/passo/passo_dashboard.dart +++ b/lib/screens/passo/passo_dashboard.dart @@ -51,7 +51,7 @@ class _PassoDashBoard extends State { child: const LandHome(), ), EmptyData( - message: "Development ongoing ...", + message: "Sorry, this page is under construction.", ) ], ), diff --git a/lib/sevices/passo/building/property_appraisal_services.dart b/lib/sevices/passo/building/property_appraisal_services.dart index 2000441..69527ba 100644 --- a/lib/sevices/passo/building/property_appraisal_services.dart +++ b/lib/sevices/passo/building/property_appraisal_services.dart @@ -90,7 +90,7 @@ class PropertyAppraisalServices { http.Response response = await Request.instance .getRequest(param: params, path: path, headers: headers); print('Property_Apraisaledit'); - print(response.statusCode); + print(response.body); if (response.statusCode == 200) { final jsonData = jsonDecode(response.body); final dataList = jsonData['data'] as List; diff --git a/lib/sevices/passo/building/property_assessment_services.dart b/lib/sevices/passo/building/property_assessment_services.dart index 3ac71ca..a18da40 100644 --- a/lib/sevices/passo/building/property_assessment_services.dart +++ b/lib/sevices/passo/building/property_assessment_services.dart @@ -98,6 +98,7 @@ class PropertyAssessmentServices { http.Response response = await Request.instance .getRequest(param: params, path: path, headers: headers); print('Assessment'); + print(response.statusCode); print(response.body); if (response.statusCode == 200) { final jsonData = jsonDecode(response.body); diff --git a/lib/sevices/passo/land/land_ext.dart b/lib/sevices/passo/land/land_ext.dart index 4d23162..01194a3 100644 --- a/lib/sevices/passo/land/land_ext.dart +++ b/lib/sevices/passo/land/land_ext.dart @@ -84,53 +84,55 @@ class LandExtServices { return response; } - // Future fetchEdit(tempID) async { - // http.Response response = await http.get(Uri.parse( - // '$baseUrl${Url.instance.getLandExt()}?bldgappr_details_id=$tempID')); - // print('Assessment'); - // print(response.body); - // if (response.statusCode == 200) { - // final jsonData = jsonDecode(response.body); - // final dataList = jsonData['data'] as List; - // final result = - // LandExtEdit.fromJson(dataList[0] as Map); + Future updateEdit(LandExt data, id) async { + String path = Url.instance.getLandExt(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "landappr_details_id": id.toString(), + }; + http.Response? response; + try { + response = await Request.instance.putRequest( + path: path, body: data.toJson(), headers: headers, param: params); + } catch (e) { + log(e.toString()); + } + return response; + } - // return result; - // } else { - // throw Exception(response.reasonPhrase); - // } - // } + Future fetchEdit(tempID) async { + String path = Url.instance.getLandExt(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "landappr_details_id": tempID.toString(), + }; + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); - // Future addEdit(LandExtEdit assessment) async { - // http.Response? response; - // try { - // response = await http.post( - // Uri.parse("$baseUrl${Url.instance.getLandExt()}"), - // headers: { - // HttpHeaders.contentTypeHeader: "application/json", - // }, - // body: jsonEncode(assessment.toJson())); - // } catch (e) { - // log(e.toString()); - // } - // return response; - // } + print('Landextedit'); + print(response.body); - // Future updateEdit( - // LandExtEdit assessment, id) async { - // print(id); - // http.Response? response; - // try { - // response = await http.put(Uri.parse( - // // ignore: unnecessary_brace_in_string_interps - // "$baseUrl${Url.instance.getLandExt()}?bldgappr_details_id=${id}"), - // headers: { - // HttpHeaders.contentTypeHeader: "application/json", - // }, - // body: jsonEncode(assessment.toJson())); - // } catch (e) { - // log(e.toString()); - // } - // return response; - // } + if (response.statusCode == 200) { + final jsonData = jsonDecode(response.body); + final dataList = jsonData['data'] as List; + final result = LandExt.fromJson(dataList[0] as Map); + + return result; + } else { + print(response.reasonPhrase); + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } } diff --git a/lib/sevices/passo/land/land_other_improvements.dart b/lib/sevices/passo/land/land_other_improvements.dart index d23652a..52e1f54 100644 --- a/lib/sevices/passo/land/land_other_improvements.dart +++ b/lib/sevices/passo/land/land_other_improvements.dart @@ -24,11 +24,11 @@ class OtherImprovementServices { 'X-Client-Secret': xClientKeySecret }; Map params = { - "landappr_details_id": tempID, + "landappr_details_id": tempID.toString(), }; try { http.Response response = await Request.instance - .getRequest(param: {}, path: path, headers: headers); + .getRequest(param: params, path: path, headers: headers); if (response.statusCode == 200) { final List result = jsonDecode(response.body)['data']; @@ -67,11 +67,11 @@ class OtherImprovementServices { 'X-Client-Secret': xClientKeySecret }; Map params = { - "id": id, + "id": id.toString(), }; try { http.Response response = await Request.instance - .deleteRequest(path: path, headers: headers, body: {}, param: {}); + .deleteRequest(path: path, headers: headers, body: {}, param: params); print(id); if (response.statusCode == 200) { print(response.body); diff --git a/lib/sevices/passo/land/land_value_adjustment.dart b/lib/sevices/passo/land/land_value_adjustment.dart index 8fda18f..b52e113 100644 --- a/lib/sevices/passo/land/land_value_adjustment.dart +++ b/lib/sevices/passo/land/land_value_adjustment.dart @@ -25,11 +25,11 @@ class ValueAdjustmentsServices { 'X-Client-Secret': xClientKeySecret }; Map params = { - "landappr_details_id": tempID, + "landappr_details_id": tempID.toString(), }; try { http.Response response = await Request.instance - .getRequest(param: {}, path: path, headers: headers); + .getRequest(param: params, path: path, headers: headers); if (response.statusCode == 200) { final List result = jsonDecode(response.body)['data']; print(result); @@ -67,11 +67,11 @@ class ValueAdjustmentsServices { 'X-Client-Secret': xClientKeySecret }; Map params = { - "id": id, + "id": id.toString(), }; try { http.Response response = await Request.instance - .deleteRequest(path: path, headers: headers, body: {}, param: {}); + .deleteRequest(path: path, headers: headers, body: {}, param: params); print(id); if (response.statusCode == 200) { print(response.body); diff --git a/lib/sevices/passo/memoranda.dart b/lib/sevices/passo/memoranda.dart index c29a6be..3ec32ce 100644 --- a/lib/sevices/passo/memoranda.dart +++ b/lib/sevices/passo/memoranda.dart @@ -1,9 +1,4 @@ -import 'dart:convert'; - -import 'package:unit2/model/passo/barangay.dart'; -import 'package:unit2/model/passo/class_components.dart'; import 'package:http/http.dart' as http; -import 'package:unit2/model/passo/memoranda.dart'; import 'package:unit2/utils/request.dart'; import 'package:unit2/utils/urls.dart'; @@ -14,25 +9,16 @@ class MemorandaServices { String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; String xClientKeySecret = "unitcYqAN7GGalyz"; - Future> fetch() async { + Future fetch() async { String path = Url.instance.getMemoranda(); Map headers = { 'Content-Type': 'application/json; charset=UTF-8', 'X-Client-Key': xClientKey, 'X-Client-Secret': xClientKeySecret }; - try { - http.Response response = await Request.instance - .getRequest(param: {}, path: path, headers: headers); - if (response.statusCode == 200) { - final List result = jsonDecode(response.body)['data']; - return result.map(((e) => Memoranda.fromJson(e))).toList(); - } else { - throw Exception(response.reasonPhrase); - } - } catch (e) { - throw e.toString(); - } + http.Response response = await Request.instance + .getRequest(param: {}, path: path, headers: headers); + return response; } } diff --git a/lib/sevices/passo/signatories_service.dart b/lib/sevices/passo/signatories_service.dart index 1d527f2..26eed58 100644 --- a/lib/sevices/passo/signatories_service.dart +++ b/lib/sevices/passo/signatories_service.dart @@ -19,22 +19,19 @@ class SignatoriesServices { 'X-Client-Key': xClientKey, 'X-Client-Secret': xClientKeySecret }; - try { - http.Response response = await Request.instance - .getRequest(param: {}, path: path, headers: headers); - print('Signatories'); - print(response.statusCode); - if (response.statusCode == 200) { - final List result = jsonDecode(response.body)['data']; + http.Response response = await Request.instance + .getRequest(param: {}, path: path, headers: headers); - return result.map(((e) => Signatories.fromJson(e))).toList(); - } else { - print(response.reasonPhrase); - throw Exception(response.reasonPhrase); - } - } catch (e) { - throw e.toString(); + print('Signatories'); + print(response.statusCode); + if (response.statusCode == 200) { + final List result = jsonDecode(response.body)['data']; + + return result.map(((e) => Signatories.fromJson(e))).toList(); + } else { + print(response.reasonPhrase); + throw Exception(response.reasonPhrase); } } } diff --git a/pubspec.yaml b/pubspec.yaml index 2f532b8..b7a4a78 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -98,7 +98,7 @@ dependencies: url_launcher: ^6.1.11 url_launcher_android: ^6.0.38 share_plus: ^7.1.0 - + dev_dependencies: