From 42bd0312a4b8073341ef940223c47f772b4aeab6 Mon Sep 17 00:00:00 2001 From: cyzoox Date: Tue, 12 Sep 2023 16:33:07 +0800 Subject: [PATCH] Added delete on all building faas; Experimental modification for next button to effectively check wether PUT request is successful or not;Implemented ProgressHUD on edit buildig faas to avoid blank screens --- .../property_info/property_info_bloc.dart | 30 + .../property_info/property_info_event.dart | 13 + .../property_info/property_info_state.dart | 23 + .../land_appraisal/land_appraisal_bloc.dart | 2 +- lib/screens/passo/Building/add_building.dart | 27 +- .../bldg_location_landref.dart | 131 +- .../general_description.dart | 89 +- .../property_appraisal.dart | 14 + .../property_info.dart | 79 +- .../structural_materials.dart | 76 +- lib/screens/passo/Building/edit_building.dart | 229 +-- .../edit_building/additional_items.dart | 517 +++---- .../edit_building/bldgloc_landref.dart | 737 +++++----- .../edit_building/general_description.dart | 560 +++---- .../edit_building/property_appraisal.dart | 1262 ++++++++-------- .../property_assessement_edit.dart | 1294 +++++++++-------- .../edit_building/property_owner_info.dart | 297 ++-- .../edit_building/structural_materials.dart | 720 ++++----- .../structural_materials_edit.dart | 481 ++++++ .../passo/Land/add_land/land_appraisal.dart | 10 + lib/screens/passo/building_home.dart | 34 +- .../building/property_info_services.dart | 25 + lib/utils/request.dart | 8 +- lib/utils/urls.dart | 6 +- 24 files changed, 3795 insertions(+), 2869 deletions(-) create mode 100644 lib/screens/passo/Building/edit_building/structural_materials_edit.dart diff --git a/lib/bloc/passo/bulding/property_info/property_info_bloc.dart b/lib/bloc/passo/bulding/property_info/property_info_bloc.dart index 37a75b9..1df521b 100644 --- a/lib/bloc/passo/bulding/property_info/property_info_bloc.dart +++ b/lib/bloc/passo/bulding/property_info/property_info_bloc.dart @@ -65,6 +65,11 @@ class PropertyInfoBloc extends Bloc { .updateBldg(event.bldg_loc, event.bldg_loc.id))!; print('bldgLoc'); print(response.statusCode); + if (response.statusCode == 200) { + emit(ShowBldgLocSuccessAlertState()); + } else { + emit(ShowBldgLocErrorAlertState()); + } } catch (e) { emit(PropertyInfoErrorState(e.toString())); } @@ -77,6 +82,11 @@ class PropertyInfoBloc extends Bloc { .updateLandRef(event.land_ref, event.land_ref.id))!; print('landref'); print(response.body); + if (response.statusCode == 200) { + emit(ShowLandRefSuccessAlertState()); + } else { + emit(ShowLandRefErrorAlertState()); + } } catch (e) { emit(PropertyInfoErrorState(e.toString())); } @@ -90,6 +100,11 @@ class PropertyInfoBloc extends Bloc { .updateGenDesc(event.gen_desc, event.gen_desc.id))!; print('genDesc'); print(response.body); + if (response.statusCode == 200) { + emit(ShowGenDescSuccessAlertState()); + } else { + emit(ShowGenDescErrorAlertState()); + } } catch (e) { emit(PropertyInfoErrorState(e.toString())); } @@ -104,9 +119,24 @@ class PropertyInfoBloc extends Bloc { .update(event.data, event.data.id))!; print('struc Material'); print(response.body); + if (response.statusCode == 200) { + emit(ShowStrucMatSuccessAlertState()); + } else { + emit(ShowStrucMatErrorAlertState()); + } } catch (e) { emit(PropertyInfoErrorState(e.toString())); } }); + + on((event, emit) async { + print(event.id); + http.Response response = + (await PropertyInfoService.instance.remove(event.id)); + print(response.statusCode); + if (response.statusCode == 200) { + emit(BuildingFaasDeletedState(success: true)); + } + }); } } diff --git a/lib/bloc/passo/bulding/property_info/property_info_event.dart b/lib/bloc/passo/bulding/property_info/property_info_event.dart index 0b678c8..36d02d4 100644 --- a/lib/bloc/passo/bulding/property_info/property_info_event.dart +++ b/lib/bloc/passo/bulding/property_info/property_info_event.dart @@ -73,3 +73,16 @@ class UpdateStrucMaterials extends PropertyInfoEvent { @override List get props => [data]; } + +class DeleteBuildingFaas extends PropertyInfoEvent { + final int id; + + const DeleteBuildingFaas({required this.id}); + + @override + List get props => [id]; +} + +class ShowBldgLocErrorAlert extends PropertyInfoEvent {} + +class ShowLandRefErrorAlert extends PropertyInfoEvent {} diff --git a/lib/bloc/passo/bulding/property_info/property_info_state.dart b/lib/bloc/passo/bulding/property_info/property_info_state.dart index b325da5..4de820f 100644 --- a/lib/bloc/passo/bulding/property_info/property_info_state.dart +++ b/lib/bloc/passo/bulding/property_info/property_info_state.dart @@ -24,3 +24,26 @@ class PropertyInfoErrorState extends PropertyInfoState { @override List get props => [error]; } + +class BuildingFaasDeletedState extends PropertyInfoState { + final bool success; + const BuildingFaasDeletedState({required this.success}); + @override + List get props => [success]; +} + +class ShowBldgLocErrorAlertState extends PropertyInfoState {} + +class ShowLandRefErrorAlertState extends PropertyInfoState {} + +class ShowGenDescErrorAlertState extends PropertyInfoState {} + +class ShowStrucMatErrorAlertState extends PropertyInfoState {} + +class ShowStrucMatSuccessAlertState extends PropertyInfoState {} + +class ShowBldgLocSuccessAlertState extends PropertyInfoState {} + +class ShowLandRefSuccessAlertState extends PropertyInfoState {} + +class ShowGenDescSuccessAlertState extends PropertyInfoState {} 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 b542dbf..9d8ac0d 100644 --- a/lib/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart +++ b/lib/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart @@ -18,7 +18,7 @@ class LandAppraisalBloc extends Bloc { final tempID = await SharedPreferences.getInstance(); print(tempID.getInt('landid')); final additionalItems = - await LandAppraisalServices.instance.fetch(tempID.getInt('tempid')); + await LandAppraisalServices.instance.fetch(tempID.getInt('landid')); globalLandAppraisal .addAll(additionalItems); // Append all items to the list diff --git a/lib/screens/passo/Building/add_building.dart b/lib/screens/passo/Building/add_building.dart index d2d94a8..790fc37 100644 --- a/lib/screens/passo/Building/add_building.dart +++ b/lib/screens/passo/Building/add_building.dart @@ -120,17 +120,30 @@ class _AddBuilding extends State { if (state is PropertyInfoErrorState) { final progress = ProgressHUD.of(context); progress?.dismiss(); + } + if (state is ShowBldgLocErrorAlertState || + state is ShowGenDescErrorAlertState || + state is ShowLandRefErrorAlertState || + state is ShowStrucMatErrorAlertState) { Fluttertoast.showToast( - msg: onError, - fontSize: 24, - toastLength: Toast.LENGTH_LONG, - gravity: ToastGravity.CENTER, - backgroundColor: Colors.black, - textColor: Colors.white); + msg: "Slow internet connection, please try again!"); + } + if (state is ShowLandRefSuccessAlertState || + state is ShowGenDescSuccessAlertState || + state is ShowStrucMatSuccessAlertState) { + NextBtn(); } }, builder: (context, state) { if (state is PropertyInfoLoaded || - state is PropertyInfoErrorState) { + state is PropertyInfoErrorState || + state is ShowBldgLocErrorAlertState || + state is ShowGenDescErrorAlertState || + state is ShowLandRefErrorAlertState || + state is ShowStrucMatErrorAlertState || + state is ShowBldgLocSuccessAlertState || + state is ShowLandRefSuccessAlertState || + state is ShowGenDescSuccessAlertState || + state is ShowStrucMatSuccessAlertState) { return BlocConsumer( listener: ( context, 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 0ecfe0a..5491d8b 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 @@ -4,6 +4,7 @@ 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:fluttertoast/fluttertoast.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:unit2/bloc/passo/barangay/barangay_bloc.dart'; import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; @@ -15,7 +16,9 @@ import 'package:unit2/model/passo/bldg_loc.dart'; import 'package:unit2/model/passo/city.dart'; import 'package:unit2/model/passo/land_ref.dart'; import 'package:unit2/screens/passo/Building/add_building.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/form-style.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'; @@ -114,10 +117,27 @@ class _BldgLocationLandrefPage extends State { MainAxisAlignment.spaceEvenly, children: [ Expanded( - // optional flex property if flex is 1 because the default flex is 1 - flex: 1, - child: customTextField( - "Province / City", "", 'province')), + child: 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( + "AGUSAN DEL NORTE", + style: TextStyle(fontSize: 15), + ), + ), + ), + ), const SizedBox(width: 10.0), Expanded( flex: 1, @@ -244,45 +264,47 @@ class _BldgLocationLandrefPage extends State { color: Colors.white), onPressed: () async { { - final tempID = - await SharedPreferences.getInstance(); - var bldgLocData = BldgLoc( - id: tempID.getInt('tempid')! - 1, - street: formKey - .currentState?.value['street'], - barangay: - formKey.currentState?.value['brgy'], - municipality: formKey - .currentState - ?.value['municipality'] - .cityDescription, - province: formKey - .currentState?.value['province'], - ); - var landRefData = LandRef( - id: tempID.getInt('tempid')! - 1, - owner: formKey - .currentState?.value['l_owner'], - cloaNo: formKey.currentState - ?.value['oct_tct_cloa'], - lotNo: formKey - .currentState?.value['lot_no'], - tdn: formKey - .currentState?.value['l_td_arp'], - area: - formKey.currentState?.value['area'], - surveyNo: formKey - .currentState?.value['survey_no'], - blkNo: formKey - .currentState?.value['blk_no'], - ); - context.read() - ..add(UpdateBldgLoc( - bldg_loc: bldgLocData)) - ..add(UpdateLandRef( - land_ref: landRefData)); - - widget.NextBtn(); + try { + final tempID = await SharedPreferences + .getInstance(); + var bldgLocData = BldgLoc( + id: tempID.getInt('tempid')! - 1, + street: formKey + .currentState?.value['street'], + barangay: formKey + .currentState?.value['brgy'], + municipality: formKey + .currentState + ?.value['municipality'] + .cityDescription, + province: "Agusan Del Norte"); + var landRefData = LandRef( + id: tempID.getInt('tempid')! - 1, + owner: formKey + .currentState?.value['l_owner'], + cloaNo: formKey.currentState + ?.value['oct_tct_cloa'], + lotNo: formKey + .currentState?.value['lot_no'], + tdn: formKey + .currentState?.value['l_td_arp'], + area: formKey + .currentState?.value['area'], + surveyNo: formKey + .currentState?.value['survey_no'], + blkNo: formKey + .currentState?.value['blk_no'], + ); + context.read() + ..add(UpdateBldgLoc( + bldg_loc: bldgLocData)) + ..add(UpdateLandRef( + land_ref: landRefData)); + } catch (e) { + Fluttertoast.showToast( + msg: + "Slow internet connection, please try again!"); + } } ; }, @@ -314,6 +336,22 @@ class _BldgLocationLandrefPage extends State { }, ); } + if (state is ShowBldgLocErrorAlertState) { + WidgetsBinding.instance.addPostFrameCallback((_) { + errorAlert( + context, "Something went wrong", "Please try again...", () { + Navigator.of(context).pop(); + }); + }); + } + if (state is ShowLandRefErrorAlertState) { + WidgetsBinding.instance.addPostFrameCallback((_) { + errorAlert( + context, "Something went wrong", "Please try again...", () { + Navigator.of(context).pop(); + }); + }); + } return Container(); }, ), @@ -325,12 +363,13 @@ class _BldgLocationLandrefPage extends State { // Wait for the state change indicating completion final propertyInfoState = context.read().state; - if (propertyInfoState is PropertyInfoErrorState) { + if (propertyInfoState is ShowBldgLocErrorAlertState || + propertyInfoState is ShowLandRefErrorAlertState) { // Check if the add operation was successful - return true; // You'll need to define this in your state class + return false; // You'll need to define this in your state class } // Return false if the state didn't change as expected - return false; + return true; } } 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 78bbbe2..e4a5abd 100644 --- a/lib/screens/passo/Building/add_building_components/general_description.dart +++ b/lib/screens/passo/Building/add_building_components/general_description.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; import 'package:unit2/model/passo/general_description.dart'; @@ -177,41 +178,48 @@ class _GeneralDescriptionPage extends State { color: Colors.white), onPressed: () async { { - final tempID = await SharedPreferences.getInstance(); - widget.onPutGeneralDescription(); - var genDescData = GeneralDesc( - id: tempID.getInt('tempid')! - 1, - bldgKind: - formKey.currentState?.value['bldg_type'].building, - strucType: - formKey.currentState?.value['bldg_type'].bldgType, - bldgPermit: - formKey.currentState?.value['bldg_permit'], - dateIssued: formKey.currentState?.value['coc_issued'], - cct: formKey.currentState?.value['cct'], - certCompletionIssued: - formKey.currentState?.value['coc_issued'], - certOccupancyIssued: - formKey.currentState?.value['coo_issued'], - dateCompleted: - formKey.currentState?.value['date_cnstructed'], - dateOccupied: - formKey.currentState?.value['date_occupied'], - bldgAge: int.tryParse( - formKey.currentState?.value['bldg_age']), - noStoreys: int.tryParse( - formKey.currentState?.value['no_of_storeys']), - area1Stfloor: '0', - area2Ndfloor: '0', - area3Rdfloor: '0', - area4Thfloor: '0', - totalFloorArea: - formKey.currentState?.value['total_area'], - floorSketch: null, - actualUse: formKey.currentState?.value['actual_use']); + try { + final tempID = await SharedPreferences.getInstance(); - context.read() - ..add(UpdateGeneralDesc(gen_desc: genDescData)); + var genDescData = GeneralDesc( + id: tempID.getInt('tempid')! - 1, + bldgKind: formKey + .currentState?.value['bldg_type'].building, + strucType: formKey + .currentState?.value['bldg_type'].bldgType, + bldgPermit: + formKey.currentState?.value['bldg_permit'], + dateIssued: + formKey.currentState?.value['coc_issued'], + cct: formKey.currentState?.value['cct'], + certCompletionIssued: + formKey.currentState?.value['coc_issued'], + certOccupancyIssued: + formKey.currentState?.value['coo_issued'], + dateCompleted: + formKey.currentState?.value['date_cnstructed'], + dateOccupied: + formKey.currentState?.value['date_occupied'], + bldgAge: int.tryParse( + formKey.currentState?.value['bldg_age']), + noStoreys: int.tryParse( + formKey.currentState?.value['no_of_storeys']), + area1Stfloor: '0', + area2Ndfloor: '0', + area3Rdfloor: '0', + area4Thfloor: '0', + totalFloorArea: + formKey.currentState?.value['total_area'], + floorSketch: null, + actualUse: + formKey.currentState?.value['actual_use']); + + context.read() + ..add(UpdateGeneralDesc(gen_desc: genDescData)); + } catch (e) { + Fluttertoast.showToast( + msg: "Slow internet connection, please try again!"); + } } ; }, @@ -223,4 +231,17 @@ 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 e746860..e53d76d 100644 --- a/lib/screens/passo/Building/add_building_components/property_appraisal.dart +++ b/lib/screens/passo/Building/add_building_components/property_appraisal.dart @@ -6,6 +6,7 @@ import 'package:intl/intl.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/bulding/property_appraisal/property_appraisal_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; import 'package:unit2/model/passo/additional_items.dart'; import 'package:unit2/model/passo/property_appraisal.dart'; import 'package:unit2/screens/passo/Building/add_building.dart'; @@ -1029,4 +1030,17 @@ class _PropertyAppraisalPage extends State { }, ); } + + Future _waitForAddPropertyInfoToComplete() async { + // Wait for the state change indicating completion + final propertyInfoState = context.read().state; + + if (propertyInfoState is PropertyInfoErrorState) { + // 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_info.dart b/lib/screens/passo/Building/add_building_components/property_info.dart index 6cad1fc..80fafaa 100644 --- a/lib/screens/passo/Building/add_building_components/property_info.dart +++ b/lib/screens/passo/Building/add_building_components/property_info.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; import 'package:unit2/model/passo/property_info.dart'; import 'package:unit2/screens/passo/Building/add_building.dart'; @@ -98,42 +99,52 @@ class _PropertyInfoPage extends State { CustomButton( icon: const Icon(Icons.chevron_right, color: Colors.white), onPressed: () async { - var property_info = PropertyInfo( - id: 1, - transCode: formKey.currentState!.value['transaction_code'] - .toString(), - tdn: formKey.currentState!.value['arp_td'], - pin: formKey.currentState!.value['pin'], - owner: formKey.currentState!.value['owner'], - address: formKey.currentState!.value['address'], - telno: formKey.currentState!.value['tel_no'], - tin: formKey.currentState!.value['tin'], - adminUser: formKey.currentState!.value['benificiary'], - adminAddress: - formKey.currentState!.value['benificiary_address'], - adminTin: formKey.currentState!.value['benificiary_tin'], - adminTelno: - formKey.currentState!.value['benificiary_telno'], - assessedById: '1', - assessedByName: 'Cyril', - faasType: "BUILDING", - dateModified: DateTime.now(), - dateCreated: DateTime.now()); + try { + var property_info = PropertyInfo( + id: 1, + transCode: formKey + .currentState!.value['transaction_code'] + .toString(), + tdn: formKey.currentState!.value['arp_td'], + pin: formKey.currentState!.value['pin'], + owner: formKey.currentState!.value['owner'], + address: formKey.currentState!.value['address'], + telno: formKey.currentState!.value['tel_no'], + tin: formKey.currentState!.value['tin'], + adminUser: formKey.currentState!.value['benificiary'], + adminAddress: + formKey.currentState!.value['benificiary_address'], + adminTin: + formKey.currentState!.value['benificiary_tin'], + adminTelno: + formKey.currentState!.value['benificiary_telno'], + assessedById: '1', + assessedByName: 'Cyril', + faasType: "BUILDING", + dateModified: DateTime.now(), + dateCreated: DateTime.now()); - // Dispatch the event to add the property_info - context.read().add( - AddPropertyInfo(property_info: property_info), - ); + // Dispatch the event to add the property_info + context.read().add( + AddPropertyInfo(property_info: property_info), + ); + widget.handleButtonPress(); + } catch (e) { + Fluttertoast.showToast( + msg: "Slow internet connection, please try again!"); + } // Wait for the event to complete and get the result - bool success = await _waitForAddPropertyInfoToComplete(); + // bool failed = await _waitForAddPropertyInfoToComplete(); - if (success) { - // Proceed to the next step or perform an action - widget.handleButtonPress(); - } else { - // Stay or show an error message - } + // if (failed) { + // // Proceed to the next step or perform an action + // Fluttertoast.showToast( + // msg: "Slow internet connection, please try again!"); + // } else { + // // Stay or show an error message + // widget.handleButtonPress(); + // } }, ) ]), @@ -145,8 +156,8 @@ class _PropertyInfoPage extends State { // Wait for the state change indicating completion final propertyInfoState = context.read().state; - if (propertyInfoState is PropertyInfoLoaded) { - // Check if the add operation was successful + if (propertyInfoState is PropertyInfoErrorState) { + // Check if the add operation was unsuccessful return true; // You'll need to define this in your state class } diff --git a/lib/screens/passo/Building/add_building_components/structural_materials.dart b/lib/screens/passo/Building/add_building_components/structural_materials.dart index 67f6edd..2546e30 100644 --- a/lib/screens/passo/Building/add_building_components/structural_materials.dart +++ b/lib/screens/passo/Building/add_building_components/structural_materials.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:multiselect/multiselect.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; @@ -364,7 +365,7 @@ class _StructuralMaterialsPage extends State { const Icon(Icons.chevron_left_rounded, color: Colors.white), onPressed: () { { - widget.NextBtn(); + widget.PrevBtn(); } ; }, @@ -374,40 +375,45 @@ class _StructuralMaterialsPage extends State { color: Colors.white), onPressed: () async { { - final tempID = await SharedPreferences.getInstance(); - var strucMaterials = StructureMaterialsII( - id: tempID.getInt('tempid')! - 1, - foundation: foundationOthers - ? formKey.currentState!.value['other_foundation'] - .split(',') - : foundation, - columns: columOthers - ? formKey.currentState!.value['other_column'] - .split(',') - : column, - beams: beamsOthers - ? formKey.currentState!.value['other_beam'] - .split(',') - : beam, - trussFraming: tfOthers - ? formKey.currentState!.value['other_tf'].split(',') - : truss_framing, - roof: roofOthers - ? formKey.currentState!.value['other_roof'] - .split(',') - : roof, - flooring: flooringOthers - ? formKey.currentState!.value['other_flooring'] - .split(',') - : flooring, - walls: wpOthers - ? formKey.currentState!.value['other_wp'].split(',') - : walls, - others: ["Others"]); - context.read() - ..add(UpdateStrucMaterials(data: strucMaterials)); - - widget.PrevBtn(); + try { + final tempID = await SharedPreferences.getInstance(); + var strucMaterials = StructureMaterialsII( + id: tempID.getInt('tempid')! - 1, + foundation: foundationOthers + ? formKey.currentState!.value['other_foundation'] + .split(',') + : foundation, + columns: columOthers + ? formKey.currentState!.value['other_column'] + .split(',') + : column, + beams: beamsOthers + ? formKey.currentState!.value['other_beam'] + .split(',') + : beam, + trussFraming: tfOthers + ? formKey.currentState!.value['other_tf'] + .split(',') + : truss_framing, + roof: roofOthers + ? formKey.currentState!.value['other_roof'] + .split(',') + : roof, + flooring: flooringOthers + ? formKey.currentState!.value['other_flooring'] + .split(',') + : flooring, + walls: wpOthers + ? formKey.currentState!.value['other_wp'] + .split(',') + : walls, + others: ["Others"]); + context.read() + ..add(UpdateStrucMaterials(data: strucMaterials)); + } catch (e) { + Fluttertoast.showToast( + msg: "Slow internet connection, please try again!"); + } } ; }, diff --git a/lib/screens/passo/Building/edit_building.dart b/lib/screens/passo/Building/edit_building.dart index 6a1dde5..326dd35 100644 --- a/lib/screens/passo/Building/edit_building.dart +++ b/lib/screens/passo/Building/edit_building.dart @@ -1,5 +1,6 @@ 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'; @@ -16,6 +17,8 @@ import 'package:unit2/screens/passo/Building/edit_building/property_appraisal.da import 'package:unit2/screens/passo/Building/edit_building/property_assessement_edit.dart'; import 'package:unit2/screens/passo/Building/edit_building/property_owner_info.dart'; import 'package:unit2/screens/passo/Building/edit_building/structural_materials.dart'; +import 'package:unit2/screens/passo/Building/edit_building/structural_materials_edit.dart'; +import 'package:unit2/screens/passo/Land/add_land.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/utils/text_container.dart'; import 'package:unit2/widgets/error_state.dart'; @@ -54,117 +57,121 @@ class _EditBuilding extends State { @override Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - appBar: AppBar( - centerTitle: true, - backgroundColor: primary, - title: Text('Building FAAS Edit'), - ), - body: ProgressHUD( - padding: const EdgeInsets.all(24), - backgroundColor: Colors.black87, - indicatorWidget: const SpinKitFadingCircle(color: Colors.white), - child: BlocConsumer( - listener: (context, state) { - if (state is UnitConstructLoading) { - final progress = ProgressHUD.of(context); - progress!.showWithText("Please wait..."); - } - if (state is UnitConstructLoaded) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - } - if (state is UnitConstructErrorState) { - 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 UnitConstructLoaded) { - final unit = state.unit; - return BlocConsumer( - listener: (context, state) { - if (state is ClassComponentLoading) { - final progress = ProgressHUD.of(context); - progress!.showWithText("Please wait..."); - } - if (state is ClassComponentLoaded) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - } - if (state is ClassComponentErrorState) { - 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 ClassComponentLoaded) { - return Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - NumberStepper( - numbers: [1, 2, 3, 4, 5, 6, 7], - activeStepColor: primary, - numberStyle: TextStyle(color: Colors.white), - lineColor: primary, - // activeStep property set to activeStep variable defined above. - activeStep: activeStep, - activeStepBorderColor: Colors.white, - activeStepBorderWidth: 1, - // This ensures step-tapping updates the activeStep. - onStepReached: (index) { - setState(() { - activeStep = index; - }); - }, - ), - content(unit, state.classes), - ], + return Scaffold( + appBar: AppBar( + centerTitle: true, + backgroundColor: primary, + title: Text('Building FAAS Edit'), + ), + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) { + if (state is UnitConstructLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is UnitConstructLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is UnitConstructErrorState) { + 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 UnitConstructLoaded) { + final unit = state.unit; + return BlocConsumer( + listener: (context, state) { + if (state is ClassComponentLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is ClassComponentLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is ClassComponentErrorState) { + 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 ClassComponentLoaded) { + return Column( + children: [ + NumberStepper( + numbers: [1, 2, 3, 4, 5, 6, 7], + activeStepColor: primary, + numberStyle: TextStyle(color: Colors.white), + lineColor: primary, + // activeStep property set to activeStep variable defined above. + activeStep: activeStep, + activeStepBorderColor: Colors.white, + activeStepBorderWidth: 1, + // This ensures step-tapping updates the activeStep. + onStepReached: (index) { + setState(() { + activeStep = index; + }); + }, ), - ); - } - if (state is ClassComponentErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context - .read() - .add(LoadClassComponents()); - }, - ); - } - return Container(); - }, - ); - } - if (state is UnitConstructErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context.read().add(LoadUnitConstruct()); - }, - ); - } - return Container(); - }, - ), + Expanded( + child: StatefulBuilder(builder: + (BuildContext context, StateSetter setState) { + return Container( + child: content( + unit, + state.classes, + ), + ); + }), + ), + ], + ); + } + if (state is ClassComponentErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadClassComponents()); + }, + ); + } + return Container(); + }, + ); + } + if (state is UnitConstructErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadUnitConstruct()); + }, + ); + } + return Container(); + }, ), ), ); @@ -184,7 +191,7 @@ class _EditBuilding extends State { return GeneralDescriptionEdit(unit, widget.faas.id!, NextBtn, PrevBtn); case 3: - return StructuralMaterialsPageEdit(widget.faas.id!, NextBtn, PrevBtn); + return StructuralMaterialsEditPage(widget.faas.id!, NextBtn, PrevBtn); case 4: return AdditionalItemEditPage( diff --git a/lib/screens/passo/Building/edit_building/additional_items.dart b/lib/screens/passo/Building/edit_building/additional_items.dart index b5b9872..1f8ff0d 100644 --- a/lib/screens/passo/Building/edit_building/additional_items.dart +++ b/lib/screens/passo/Building/edit_building/additional_items.dart @@ -1,5 +1,7 @@ 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/bulding/additional_item/additional_item_bloc.dart'; import 'package:unit2/bloc/passo/bulding/additional_items_edit/additional_items_edit_bloc.dart'; @@ -41,265 +43,286 @@ class _AdditionalItemEditPage 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 AdditionalItemsEditLoaded) { - return Column( - children: [ - Container( - height: 500, - child: 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('ADDITIONAL ITEMS', - 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 AdditionalItemsEditLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is AdditionalItemsEditLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is AdditionalItemsEditErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, + builder: (context, state) { + final state = context.watch().state; + if (state is AdditionalItemsEditLoaded) { + return Column( + children: [ + Container( + height: 500, + child: 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('ADDITIONAL ITEMS', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), ), - onPressed: () { - context - .read() - .add(ShowAdditionalItemsEdit()); - }, - 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(ShowAdditionalItemsEdit()); + }, + 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('Items'), - ), - const DataColumn( - label: Text('Unit Value'), - ), - const DataColumn( - label: Text('% of BUCC'), - ), - const DataColumn( - label: Text('Market Value'), - ), - const DataColumn( - label: Text('Action'), - ) - ], - rows: state.items.map((dataRow) { - return DataRow( - cells: [ - DataCell(Text(dataRow.className)), - DataCell(Text(dataRow.baseUnitValue)), - DataCell(Text(dataRow.unitValue)), - DataCell(Text(((double.parse( - dataRow.adjustedMarketVal))) - .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: () {}, - ), - ], - )) + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Items'), + ), + const DataColumn( + label: Text('Unit Value'), + ), + const DataColumn( + label: Text('% of BUCC'), + ), + const DataColumn( + label: Text('Market Value'), + ), + const DataColumn( + label: Text('Action'), + ) ], - ); - }).toList(), - ), + rows: state.items.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.className)), + DataCell(Text(dataRow.baseUnitValue)), + DataCell(Text(dataRow.unitValue)), + DataCell(Text(((double.parse( + dataRow.adjustedMarketVal))) + .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(_totalMarketValue(state.items)), + // 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 AdditionalItemsEditDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context.read().add( + LoadAdditionalItemsEdit( + items: const [], + id: widget.tempId)); + }); + }); + } + } + if (state is ShowAddItemsScreenEdit) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: Text( + 'ADD EXTRA ITEMS', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: AddExtraItemsEdit( + widget.unit, widget.options, widget.tempId)) + ], + ), + ), + ); + } + return Container( + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('ADDITIONAL MATERIALS', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + onPressed: () { + context + .read() + .add(ShowAdditionalItems()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('ADD ITEM'), // <-- Text + const SizedBox( + width: 5, + ), + const Icon( + // <-- Icon + Icons.add, + size: 24.0, ), ], ), ), ), - ), - ), - // 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(_totalMarketValue(state.items)), - // 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 AdditionalItemsEditDeletedState) { - if (state.success) { - WidgetsBinding.instance.addPostFrameCallback((_) { - successAlert(context, "Deletion Successful", - "Extra item has been deleted successfully", () { - Navigator.of(context).pop(); - context.read().add( - LoadAdditionalItemsEdit( - items: const [], id: widget.tempId)); - }); - }); - } - } - if (state is ShowAddItemsScreenEdit) { - return ConstrainedBox( - constraints: BoxConstraints(maxHeight: 1000.0), - child: AlertDialog( - insetPadding: EdgeInsets.symmetric( - horizontal: 20.0, - vertical: 10.0, - ), - title: Text( - 'ADD EXTRA ITEMS', - textAlign: TextAlign.center, - ), - content: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: AddExtraItemsEdit( - widget.unit, widget.options, widget.tempId)) ], ), - ), - ); - } - return Container( - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 10), - child: const Text('ADDITIONAL MATERIALS', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Align( - alignment: Alignment.topRight, - child: ElevatedButton( - onPressed: () { - context - .read() - .add(ShowAdditionalItems()); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - const Text('ADD ITEM'), // <-- Text - const SizedBox( - width: 5, - ), - const Icon( - // <-- Icon - Icons.add, - size: 24.0, - ), - ], - ), - ), - ), - ], - ), - ); - }, + ); + }, + ), + ), ); } } diff --git a/lib/screens/passo/Building/edit_building/bldgloc_landref.dart b/lib/screens/passo/Building/edit_building/bldgloc_landref.dart index 0a891fb..24ed3cd 100644 --- a/lib/screens/passo/Building/edit_building/bldgloc_landref.dart +++ b/lib/screens/passo/Building/edit_building/bldgloc_landref.dart @@ -35,388 +35,395 @@ class _BldgLocLandRefEdit extends State { Set seenCityCodes = Set(); @override Widget build(BuildContext context) { - return ProgressHUD( - padding: const EdgeInsets.all(24), - backgroundColor: Colors.black87, - indicatorWidget: const SpinKitFadingCircle(color: Colors.white), - child: BlocConsumer( - listener: (context, state) { - if (state is LocationLoading) { - 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(); - } - }, - builder: (context, state) { - if (state is LocationLoaded) { - final bldgloc = state.bldgloc; - return BlocConsumer( - listener: (context, state) { - if (state is LandrefLoading) { - 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(); - } - }, - builder: (context, state) { - if (state is LandrefLoaded) { - final landRef = state.landRef; - return BlocConsumer( - listener: (context, state) { - if (state is MunicipalityLoading) { - 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(); - } - }, builder: (context, state) { - if (state is MunicipalityLoaded) { - final cityList = state.municipality; - Set uniqueItems = {}; - - // Iterate through the dropdownItems list to filter out duplicates - for (var item in cityList) { - uniqueItems.add(item); + 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 LocationLoading) { + 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(); + } + }, + builder: (context, state) { + if (state is LocationLoaded) { + final bldgloc = state.bldgloc; + return BlocConsumer( + listener: (context, state) { + if (state is LandrefLoading) { + 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(); + } + }, + builder: (context, state) { + if (state is LandrefLoaded) { + final landRef = state.landRef; + return BlocConsumer( + listener: (context, state) { + if (state is MunicipalityLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); } - return BlocConsumer( - listener: (context, state) { - if (state is BarangayLoading) { - 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(); + } + }, builder: (context, state) { + if (state is MunicipalityLoaded) { + final cityList = state.municipality; + Set uniqueItems = {}; + + // Iterate through the dropdownItems list to filter out duplicates + for (var item in cityList) { + uniqueItems.add(item); } - if (state is BarangayLoaded) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - } - if (state is BarangayErrorState) { - final progress = ProgressHUD.of(context); - progress?.dismiss(); - } - }, builder: (context, state) { - if (state is BarangayLoaded) { - List brgyList = state.brgy; - List brgyNAmes = brgyList - .map((brgy) => brgy.barangayDescription) - .toList() - .cast(); - return FormBuilder( - key: keys, - initialValue: { - 'street': bldgloc.street ?? "", - 'province': bldgloc.province ?? "", - 'l_owner': landRef.owner, - 'oct_tct_cloa': landRef.cloaNo ?? "", - 'survey_no': landRef.surveyNo ?? "", - 'lot_no': landRef.lotNo ?? "", - 'blk_no': landRef.blkNo ?? "", - 'l_td_arp': landRef.tdn ?? "", - 'area': landRef.area ?? "" - }, - enabled: true, - onChanged: () { - keys.currentState!.save(); - debugPrint(keys.currentState!.value.toString()); - }, - autovalidateMode: AutovalidateMode.disabled, - skipDisabled: true, - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(20.0), - child: ListView( - shrinkWrap: true, - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, - top: 20, - right: 0, - bottom: 10), - child: const Text('BUILDING LOCATION', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18), - textAlign: TextAlign.left), - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: FormBuilderDropdown( - name: 'municipality', - autofocus: false, - decoration: normalTextFieldStyle( - bldgloc.municipality ?? - "Municipality", - "", + return BlocConsumer( + listener: (context, state) { + if (state is BarangayLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is BarangayLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is BarangayErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, builder: (context, state) { + if (state is BarangayLoaded) { + List brgyList = state.brgy; + List brgyNAmes = brgyList + .map((brgy) => brgy.barangayDescription) + .toList() + .cast(); + return FormBuilder( + key: keys, + initialValue: { + 'street': bldgloc.street ?? "", + 'province': bldgloc.province ?? "", + 'l_owner': landRef.owner, + 'oct_tct_cloa': landRef.cloaNo ?? "", + 'survey_no': landRef.surveyNo ?? "", + 'lot_no': landRef.lotNo ?? "", + 'blk_no': landRef.blkNo ?? "", + 'l_td_arp': landRef.tdn ?? "", + 'area': landRef.area ?? "" + }, + enabled: true, + onChanged: () { + keys.currentState!.save(); + debugPrint(keys.currentState!.value.toString()); + }, + autovalidateMode: AutovalidateMode.disabled, + skipDisabled: true, + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: ListView( + shrinkWrap: true, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 10), + child: const Text('BUILDING LOCATION', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: FormBuilderDropdown( + name: 'municipality', + autofocus: false, + decoration: + normalTextFieldStyle( + bldgloc.municipality ?? + "Municipality", + "", + ), + items: uniqueItems + .map( + (city) => + DropdownMenuItem< + City>( + value: city, + child: Text( + city.cityDescription ?? + ''), + ), + ) + .toList(), + onChanged: (selectedCityCode) { + // Find the corresponding City object using selectedCityCode + final selectedCity = cityList + .firstWhere((city) => + city.cityCode == + selectedCityCode); + + final barangayBloc = context + .read(); + barangayBloc.add(LoadBarangay( + id: selectedCityCode! + .cityCode!)); + }, ), - items: uniqueItems - .map( - (city) => - DropdownMenuItem( - value: city, - child: Text( - city.cityDescription ?? - ''), - ), - ) - .toList(), - onChanged: (selectedCityCode) { - // Find the corresponding City object using selectedCityCode - final selectedCity = cityList - .firstWhere((city) => - city.cityCode == - selectedCityCode); - - final barangayBloc = context - .read(); - barangayBloc.add(LoadBarangay( - id: selectedCityCode! - .cityCode!)); - }, ), - ), - const SizedBox(width: 10.0), - Expanded( - // optional flex property if flex is 1 because the default flex is 1 + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Province / City", + "", + 'province')) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( flex: 1, child: customTextField( - "Province / City", + "No. / Street", "", 'street'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customDropDownField( + bldgloc.barangay ?? "", + "Barangay", + 'brgy', + brgyNAmes)) + ]), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 10), + child: const Text('LAND REFERENCE', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + customTextField( + "Land Owner", "", 'l_owner'), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "OCT/TCT/CLOA No.", "", - 'province')) - ]), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField( - "No. / Street", "", 'street'), - ), - const SizedBox(width: 10.0), - Expanded( - // optional flex property if flex is 1 because the default flex is 1 - flex: 1, - child: customDropDownField( - bldgloc.barangay ?? "", - "Barangay", - 'brgy', - brgyNAmes)) - ]), - Container( - margin: const EdgeInsets.only( - left: 0, - top: 20, - right: 0, - bottom: 10), - child: const Text('LAND REFERENCE', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18), - textAlign: TextAlign.left), - ), - customTextField( - "Land Owner", "", 'l_owner'), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField( - "OCT/TCT/CLOA No.", - "", - 'oct_tct_cloa'), - ), - const SizedBox(width: 10.0), - Expanded( - // optional flex property if flex is 1 because the default flex is 1 + 'oct_tct_cloa'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Survey No.", + "", + 'survey_no')) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( flex: 1, child: customTextField( - "Survey No.", + "Lot No.", "", 'lot_no'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Blk No.", "", 'blk_no')) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "TD / ARP No.", "", - 'survey_no')) - ]), - Row( + 'l_td_arp'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Area", "", 'area')) + ]), + SizedBox( + height: 50, + ), + Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField( - "Lot No.", "", 'lot_no'), + children: [ + CustomButton( + icon: const Icon( + Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, ), - const SizedBox(width: 10.0), - Expanded( - // optional flex property if flex is 1 because the default flex is 1 - flex: 1, - child: customTextField( - "Blk No.", "", 'blk_no')) - ]), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField( - "TD / ARP No.", "", 'l_td_arp'), - ), - const SizedBox(width: 10.0), - Expanded( - // optional flex property if flex is 1 because the default flex is 1 - flex: 1, - child: customTextField( - "Area", "", 'area')) - ]), - SizedBox( - height: 50, - ), - 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: () { - { - var bldgLocData = BldgLoc( - id: widget.tempId, - street: keys.currentState - ?.value['street'], - barangay: keys.currentState - ?.value['brgy'], - municipality: keys - .currentState - ?.value['municipality'] - ?.cityDescription ?? - bldgloc.municipality, - province: keys.currentState - ?.value['province'], - ); - var landRefData = LandRef( - id: widget.tempId, - owner: keys.currentState - ?.value['l_owner'], - cloaNo: keys.currentState - ?.value['oct_tct_cloa'], - lotNo: keys.currentState - ?.value['lot_no'], - tdn: keys.currentState - ?.value['l_td_arp'], - area: keys.currentState - ?.value['area'], - surveyNo: keys.currentState - ?.value['survey_no'], - blkNo: keys.currentState - ?.value['blk_no'], - ); - context.read() - ..add(UpdateBldgLoc( - bldg_loc: bldgLocData)) - ..add(UpdateLandRef( - land_ref: landRefData)); + CustomButton( + icon: const Icon( + Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + var bldgLocData = BldgLoc( + id: widget.tempId, + street: keys.currentState + ?.value['street'], + barangay: keys.currentState + ?.value['brgy'], + municipality: keys + .currentState + ?.value[ + 'municipality'] + ?.cityDescription ?? + bldgloc.municipality, + province: keys.currentState + ?.value['province'], + ); + var landRefData = LandRef( + id: widget.tempId, + owner: keys.currentState + ?.value['l_owner'], + cloaNo: keys.currentState + ?.value['oct_tct_cloa'], + lotNo: keys.currentState + ?.value['lot_no'], + tdn: keys.currentState + ?.value['l_td_arp'], + area: keys.currentState + ?.value['area'], + surveyNo: keys.currentState + ?.value['survey_no'], + blkNo: keys.currentState + ?.value['blk_no'], + ); + context.read() + ..add(UpdateBldgLoc( + bldg_loc: bldgLocData)) + ..add(UpdateLandRef( + land_ref: landRefData)); - widget.NextBtn(); - } - ; - }, - ) - ], - ) - ], + widget.NextBtn(); + } + ; + }, + ) + ], + ) + ], + ), ), ), - ), - ); - } - if (state is BarangayErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context - .read() - .add(LoadBarangay(id: '01')); - }, - ); - } - return Container(); - }); - } - if (state is MunicipalityErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context - .read() - .add(LoadMunicipality()); - }, - ); - } - return Container(); - }); - } - if (state is LandrefErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context.read().add( - LoadLandref(id: widget.tempId, landRef: LandRef())); - }, - ); - } - return Container(); - }, - ); - } + ); + } + if (state is BarangayErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadBarangay(id: '01')); + }, + ); + } + return Container(); + }); + } + if (state is MunicipalityErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadMunicipality()); + }, + ); + } + return Container(); + }); + } + if (state is LandrefErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add( + LoadLandref(id: widget.tempId, landRef: LandRef())); + }, + ); + } + return Container(); + }, + ); + } - if (state is LocationErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context - .read() - .add(LoadLocation(id: widget.tempId, bldgloc: BldgLoc())); - }, - ); - } - return Container(); - }, + if (state is LocationErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadLocation(id: widget.tempId, bldgloc: BldgLoc())); + }, + ); + } + return Container(); + }, + ), ), ); } diff --git a/lib/screens/passo/Building/edit_building/general_description.dart b/lib/screens/passo/Building/edit_building/general_description.dart index 201d6b7..eb75f7b 100644 --- a/lib/screens/passo/Building/edit_building/general_description.dart +++ b/lib/screens/passo/Building/edit_building/general_description.dart @@ -39,267 +39,315 @@ class _GeneralDescriptionEdit extends State { @override Widget build(BuildContext context) { - return Expanded( - child: 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 GenDescLoaded) { - return FormBuilder( - key: keys, - initialValue: { - 'bldg_permit': state.gendesc.bldgPermit, - 'date_issued': state.gendesc.dateIssued.toString(), - 'cct': state.gendesc.cct.toString(), - 'coc_issued': state.gendesc.certCompletionIssued.toString(), - 'coo_issued': state.gendesc.certOccupancyIssued.toString(), - 'date_cnstructed': state.gendesc.dateIssued.toString(), - 'date_occupied': state.gendesc.dateOccupied.toString(), - 'bldg_age': state.gendesc.bldgAge.toString(), - 'no_of_storeys': state.gendesc.noStoreys.toString(), - 'area_of_1stFl': state.gendesc.area1Stfloor, - 'area_of_2ndFl': state.gendesc.area2Ndfloor, - 'area_of_3rdFl': state.gendesc.area3Rdfloor, - 'area_of_4thFl': state.gendesc.area4Thfloor, - 'total_area': state.gendesc.totalFloorArea.toString(), - 'actual_use': state.gendesc.actualUse + return Scaffold( + body: Column( + children: [ + Expanded( + child: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: + 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(); + } }, - enabled: true, - onChanged: () { - keys.currentState!.save(); - debugPrint(keys.currentState!.value.toString()); - }, - autovalidateMode: AutovalidateMode.disabled, - skipDisabled: true, - child: Expanded( - child: SingleChildScrollView( - scrollDirection: Axis.vertical, - child: Padding( - padding: const EdgeInsets.all(20.0), - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 10), - child: const Text('GENERAL DESCRIPTION', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Container( - margin: const EdgeInsets.only( - left: 0, top: 10, right: 0, bottom: 0), - child: FormBuilderDropdown( - name: 'bldg_type', - autofocus: false, - decoration: normalTextFieldStyle( - state.gendesc.bldgKind ?? "Kind of Building", - "Kind of Building"), - items: widget.unit - .map((e) => DropdownMenuItem( - value: e, - child: - Text(e.bldgType + '-' + e.building), - )) - .toList(), + builder: (context, state) { + if (state is GenDescLoaded) { + return FormBuilder( + key: keys, + initialValue: { + 'bldg_permit': state.gendesc.bldgPermit, + 'date_issued': state.gendesc.dateIssued.toString(), + 'cct': state.gendesc.cct.toString(), + 'coc_issued': + state.gendesc.certCompletionIssued.toString(), + 'coo_issued': + state.gendesc.certOccupancyIssued.toString(), + 'date_cnstructed': state.gendesc.dateIssued.toString(), + 'date_occupied': state.gendesc.dateOccupied.toString(), + 'bldg_age': state.gendesc.bldgAge.toString(), + 'no_of_storeys': state.gendesc.noStoreys.toString(), + 'area_of_1stFl': state.gendesc.area1Stfloor, + 'area_of_2ndFl': state.gendesc.area2Ndfloor, + 'area_of_3rdFl': state.gendesc.area3Rdfloor, + 'area_of_4thFl': state.gendesc.area4Thfloor, + 'total_area': state.gendesc.totalFloorArea.toString(), + 'actual_use': state.gendesc.actualUse + }, + enabled: true, + onChanged: () { + keys.currentState!.save(); + debugPrint(keys.currentState!.value.toString()); + }, + autovalidateMode: AutovalidateMode.disabled, + skipDisabled: true, + child: Expanded( + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('GENERAL DESCRIPTION', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + Container( + margin: const EdgeInsets.only( + left: 0, top: 10, right: 0, bottom: 0), + child: FormBuilderDropdown( + name: 'bldg_type', + autofocus: false, + decoration: normalTextFieldStyle( + state.gendesc.bldgKind ?? + "Kind of Building", + "Kind of Building"), + items: widget.unit + .map((e) => DropdownMenuItem( + value: e, + child: Text(e.bldgType + + '-' + + e.building), + )) + .toList(), + ), + ), + customDropDownField( + "Actual Use", "", 'actual_use', actual_use), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Bldg. Permit No.", + "", + 'bldg_permit'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customDatTimePicker( + "Certificate of Occupancy Issued ON", + "", + 'date_issued')) + ]), + customTextField( + "Condominium Certificate of Title (CCT)", + "", + 'cct'), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customDatTimePicker( + "Certificate of Completion Issued ON", + "", + 'coc_issued'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customDatTimePicker( + "Certificate of Occupancy Issued ON", + "", + 'coo_issued')) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customDatTimePicker( + "Date Constructed /Completed", + "", + 'date_cnstructed'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customDatTimePicker( + "Date Occupied", + "", + 'date_occupied')) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Bldg. Age", "", 'bldg_age'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "No. of storeys", + "", + 'no_of_storeys')) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Area of 1st Floor", + "", + 'area_of_1stFl'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Area of 2nd Floor", + "", + 'area_of_2ndFl')) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Area of 3rd Floor", + "", + 'area_of_3rdFl')), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "Area of 4th Floor", + "", + 'area_of_4thFl')) + ]), + customTextField("Total Area", "", 'total_area'), + SizedBox( + height: 50, + ), + 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: () { + { + keys.currentState!.save(); + var genDescData = GeneralDesc( + id: widget.tempId, + bldgKind: keys + .currentState + ?.value['bldg_type'] + ?.building ?? + state.gendesc.bldgKind, + strucType: keys + .currentState + ?.value['bldg_type'] + ?.bldgType ?? + state.gendesc.strucType, + bldgPermit: keys.currentState + ?.value['bldg_permit'], + dateIssued: keys.currentState + ?.value['coc_issued'], + cct: keys + .currentState?.value['cct'], + certCompletionIssued: keys + .currentState + ?.value['coc_issued'], + certOccupancyIssued: keys + .currentState + ?.value['coo_issued'], + dateCompleted: + keys.currentState?.value['date_cnstructed'], + dateOccupied: keys.currentState?.value['date_occupied'], + bldgAge: int.tryParse(keys.currentState?.value['bldg_age']), + noStoreys: int.tryParse(keys.currentState?.value['no_of_storeys']), + area1Stfloor: keys.currentState?.value['area_of_1stFl'], + area2Ndfloor: keys.currentState?.value['area_of_2ndFl'], + area3Rdfloor: keys.currentState?.value['area_of_3rdFl'], + area4Thfloor: keys.currentState?.value['area_of_4thFl'], + totalFloorArea: keys.currentState?.value['total_area'], + floorSketch: null, + actualUse: keys.currentState?.value['actual_use']); + + context.read() + ..add(UpdateGeneralDesc( + gen_desc: genDescData)); + + widget.NextBtn(); + } + ; + }, + ) + ], + ) + ], ), ), - customDropDownField( - "Actual Use", "", 'actual_use', actual_use), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField( - "Bldg. Permit No.", "", 'bldg_permit'), - ), - const SizedBox(width: 10.0), - Expanded( - // optional flex property if flex is 1 because the default flex is 1 - flex: 1, - child: customDatTimePicker( - "Certificate of Occupancy Issued ON", - "", - 'date_issued')) - ]), - customTextField( - "Condominium Certificate of Title (CCT)", - "", - 'cct'), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customDatTimePicker( - "Certificate of Completion Issued ON", - "", - 'coc_issued'), - ), - const SizedBox(width: 10.0), - Expanded( - // optional flex property if flex is 1 because the default flex is 1 - flex: 1, - child: customDatTimePicker( - "Certificate of Occupancy Issued ON", - "", - 'coo_issued')) - ]), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customDatTimePicker( - "Date Constructed /Completed", - "", - 'date_cnstructed'), - ), - const SizedBox(width: 10.0), - Expanded( - // optional flex property if flex is 1 because the default flex is 1 - flex: 1, - child: customDatTimePicker( - "Date Occupied", "", 'date_occupied')) - ]), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField( - "Bldg. Age", "", 'bldg_age'), - ), - const SizedBox(width: 10.0), - Expanded( - // optional flex property if flex is 1 because the default flex is 1 - flex: 1, - child: customTextField( - "No. of storeys", "", 'no_of_storeys')) - ]), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField( - "Area of 1st Floor", "", 'area_of_1stFl'), - ), - const SizedBox(width: 10.0), - Expanded( - // optional flex property if flex is 1 because the default flex is 1 - flex: 1, - child: customTextField("Area of 2nd Floor", - "", 'area_of_2ndFl')) - ]), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField("Area of 3rd Floor", - "", 'area_of_3rdFl')), - const SizedBox(width: 10.0), - Expanded( - // optional flex property if flex is 1 because the default flex is 1 - flex: 1, - child: customTextField("Area of 4th Floor", - "", 'area_of_4thFl')) - ]), - customTextField("Total Area", "", 'total_area'), - SizedBox( - height: 50, - ), - 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: () { - { - keys.currentState!.save(); - var genDescData = GeneralDesc( - id: widget.tempId, - bldgKind: keys - .currentState - ?.value['bldg_type'] - ?.building ?? - state.gendesc.bldgKind, - strucType: keys - .currentState - ?.value['bldg_type'] - ?.bldgType ?? - state.gendesc.strucType, - bldgPermit: keys - .currentState?.value['bldg_permit'], - dateIssued: keys - .currentState?.value['coc_issued'], - cct: keys.currentState?.value['cct'], - certCompletionIssued: keys - .currentState?.value['coc_issued'], - certOccupancyIssued: keys - .currentState?.value['coo_issued'], - dateCompleted: keys.currentState - ?.value['date_cnstructed'], - dateOccupied: keys.currentState - ?.value['date_occupied'], - bldgAge: int.tryParse(keys.currentState?.value['bldg_age']), - noStoreys: int.tryParse(keys.currentState?.value['no_of_storeys']), - area1Stfloor: keys.currentState?.value['area_of_1stFl'], - area2Ndfloor: keys.currentState?.value['area_of_2ndFl'], - area3Rdfloor: keys.currentState?.value['area_of_3rdFl'], - area4Thfloor: keys.currentState?.value['area_of_4thFl'], - totalFloorArea: keys.currentState?.value['total_area'], - floorSketch: null, - actualUse: keys.currentState?.value['actual_use']); - - context.read() - ..add(UpdateGeneralDesc( - gen_desc: genDescData)); - - widget.NextBtn(); - } - ; - }, - ) - ], - ) - ], + ), ), - ), - ), - ), - ); - } - if (state is GenDescErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context.read().add( - LoadGenDesc(id: widget.tempId, gendesc: GeneralDesc())); + ); + } + if (state is GenDescErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadGenDesc( + id: widget.tempId, gendesc: GeneralDesc())); + }, + ); + } + return Container(); }, - ); - } - return Container(); - }, - ), + ), + ), + ), + ], ), ); } diff --git a/lib/screens/passo/Building/edit_building/property_appraisal.dart b/lib/screens/passo/Building/edit_building/property_appraisal.dart index 535eb1f..de28b54 100644 --- a/lib/screens/passo/Building/edit_building/property_appraisal.dart +++ b/lib/screens/passo/Building/edit_building/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'; @@ -498,638 +500,678 @@ class _PropertyAppraisalEditPage extends State { @override Widget build(BuildContext context) { - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, - builder: (context, state) { - if (state is PropertyAppraisalEditLoaded) { - final appraisal = state.appraisalEdit; - return BlocConsumer(listener: (context, state) { - // TODO: implement listener - }, builder: (context, state) { - if (state is AdditionalItemsEditLoaded) { - final item = state.items; - return BlocConsumer(listener: (context, state) { - // TODO: implement listener - }, builder: (context, state) { - if (state is GenDescLoaded) { - double totalArea = double.tryParse( - state.gendesc.totalFloorArea ?? - appraisal.totalArea.toString()) ?? - 0.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 PropertyAppraisalEditLoading) { + 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(); + } + }, + builder: (context, state) { + if (state is PropertyAppraisalEditLoaded) { + final appraisal = state.appraisalEdit; + return BlocConsumer(listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is AdditionalItemsEditLoaded) { + final item = state.items; + return BlocConsumer(listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is GenDescLoaded) { + double totalArea = double.tryParse( + state.gendesc.totalFloorArea ?? + appraisal.totalArea.toString()) ?? + 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( - 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", + 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( + 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: 13), - textAlign: TextAlign.left, + 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, + 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, + ), ), - ) - ], - ), - 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( - '', - textAlign: TextAlign.right, + 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, + ), ), - ) - ], - ), - 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( + '', + 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( - bldgUnitValue.toString(), - textAlign: TextAlign.right, + 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, + ), ), - ) - ], - ), - 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( + 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, + ), ), - ), - Container( - child: Text( - '', - textAlign: TextAlign.right, + 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( - "Sub-total", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 13), - textAlign: TextAlign.left, + ], + ), + 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( - appraisal.addItemsSubtotal!, - textAlign: TextAlign.right, + 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, + ), ), - ) - ], - ), - 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( + '${(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( - 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( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Container( - 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, - ), - ), - 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( - 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: 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)), - ), - 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( - (totalArea * bldgUnitValue), - item, - double.parse(keys.currentState?.value['depRate'] ?? appraisal.depreciationRate)) - .toString(), - state.gendesc.actualUse) + - '%', - 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: 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: TextStyle( - fontWeight: - FontWeight - .bold, - fontSize: 13, - ), - textAlign: - TextAlign - .center, - ), - ), - const SizedBox( - height: 80, - ), - ], - ), - ) - ]), + 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( + 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, + ), + ), + 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( + 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: + 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)), + ), + 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((totalArea * bldgUnitValue), item, double.parse(keys.currentState?.value['depRate'] ?? appraisal.depreciationRate)) + .toString(), + state + .gendesc + .actualUse) + + '%', + 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: 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: + 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(); + ], + ), + 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)); + 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(); - } - ; - }, - ) - ], - ) - ], + widget.NextBtn(); + } + ; + }, + ) + ], + ) + ], + ), ), ), - ), - ); - } - return Container(); - }); - } - return Container(); - }); - } - if (state is PropertyAppraisalEditErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context - .read() - .add(LoadPropertyAppraisalEdit( - appraisalEdit: PropertyAppraisalEdit(), - id: widget.tempId, - )); - }, - ); - } - return Container(); - }, + ); + } + return Container(); + }); + } + return Container(); + }); + } + if (state is PropertyAppraisalEditErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadPropertyAppraisalEdit( + appraisalEdit: PropertyAppraisalEdit(), + id: widget.tempId, + )); + }, + ); + } + 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 e2b20e3..3439bba 100644 --- a/lib/screens/passo/Building/edit_building/property_assessement_edit.dart +++ b/lib/screens/passo/Building/edit_building/property_assessement_edit.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:searchfield/searchfield.dart'; @@ -457,637 +459,673 @@ class _PropertyAssessmentEditPage extends State { @override Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, state) { - if (state is PropertyAssessmentEditLoaded) { - final assessment = state.assessmentsEdit; - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, - builder: (context, state) { - if (state is SignatoriesLoaded) { - final signatories = state.signatories; + return ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: + BlocConsumer( + listener: (context, state) { + if (state is PropertyAssessmentEditLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is PropertyAssessmentEditLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is PropertyAssessmentEditErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, + builder: (context, state) { + if (state is PropertyAssessmentEditLoaded) { + final assessment = state.assessmentsEdit; + 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 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(), - 'date_of_entry': - assessment.entryDateAssessment.toString(), - 'by': assessment.entryDateBy - }, - enabled: true, - onChanged: () { - keys.currentState!.save(); - debugPrint(keys.currentState!.value.toString()); - }, - autovalidateMode: AutovalidateMode.disabled, - skipDisabled: true, - child: Expanded( - child: Column( - children: [ - 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( - 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', - decoration: - InputDecoration( - labelText: assessment - .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()), - ), - 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', - decoration: - InputDecoration( - labelText: assessment - .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()), - ), - 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, - decoration: - InputDecoration( - labelText: assessment - .approvedbyName!, - labelStyle: - const TextStyle( - color: Colors - .black), - ), - 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: 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', - 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, - ), - SizedBox( - width: - MediaQuery.of(context).size.width, - child: ElevatedButton( - 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, - ), - ), - ), - onPressed: () { - final List - propertyAssessments = []; - - PropertyAssessmentEdit ass = - PropertyAssessmentEdit( - id: 1, - bldgapprDetailsId: 440, - actualUse: assessment.actualUse, - marketValue: '0.0', - assessmentLevel: '0.0', - assessedValue: "1.0", - taxable: isTaxable, - exempt: isExempt, - qtr: int.parse(keys - .currentState! - .value['qtr']), - yr: int.parse(keys - .currentState!.value['yr']), - appraisedbyName: keys - .currentState! - .value['appraised_by'] - .firstname + - ' ' + - keys - .currentState! - .value['appraised_by'] - .middlename + - ' ' + - keys - .currentState! - .value['appraised_by'] - .lastname, - appraisedbyDate: keys - .currentState! - .value['app_date'], - recommendapprName: keys - .currentState! - .value['rec_approval'] - .firstname + - ' ' + - keys - .currentState! - .value['rec_approval'] - .middlename + - ' ' + - keys - .currentState! - .value['rec_approval'] - .lastname, - recommendapprDate: keys - .currentState! - .value['rec_date'], - approvedbyName: keys - .currentState! - .value['apprvd_by'] - .firstname + - ' ' + - keys - .currentState! - .value['apprvd_by'] - .middlename + - ' ' + - keys - .currentState! - .value['apprvd_by'] - .lastname, - memoranda: _memoranda, - swornstatementNo: keys - .currentState! - .value['sworn_statement'], - dateReceived: keys.currentState! - .value['date_received'], - entryDateAssessment: keys - .currentState! - .value['date_of_entry'], - entryDateBy: keys - .currentState!.value['by'], - ); - - propertyAssessments.add(ass); - - context.read< - PropertyAssessmentEditBloc>() - ..add( - UpdatePropertyAssessmentEdit( - assessmentsEdit: - propertyAssessments[ - 0])); - }, - ), - ), - ], + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + 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(), + 'date_of_entry': + assessment.entryDateAssessment.toString(), + 'by': assessment.entryDateBy + }, + enabled: true, + onChanged: () { + keys.currentState!.save(); + debugPrint(keys.currentState!.value.toString()); + }, + autovalidateMode: AutovalidateMode.disabled, + skipDisabled: true, + child: Expanded( + child: Column( + children: [ + 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( + 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', + decoration: + InputDecoration( + labelText: assessment + .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()), + ), + 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', + decoration: + InputDecoration( + labelText: assessment + .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()), + ), + 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, + decoration: + InputDecoration( + labelText: assessment + .approvedbyName!, + labelStyle: + const TextStyle( + color: Colors + .black), + ), + 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: 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', + 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, + ), + SizedBox( + width: MediaQuery.of(context) + .size + .width, + child: ElevatedButton( + 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, + ), + ), + ), + onPressed: () { + final List< + PropertyAssessmentEdit> + propertyAssessments = []; + + PropertyAssessmentEdit ass = + PropertyAssessmentEdit( + id: 1, + bldgapprDetailsId: 440, + actualUse: + assessment.actualUse, + marketValue: '0.0', + assessmentLevel: '0.0', + assessedValue: "1.0", + taxable: isTaxable, + exempt: isExempt, + qtr: int.parse(keys + .currentState! + .value['qtr']), + yr: int.parse(keys + .currentState! + .value['yr']), + appraisedbyName: keys + .currentState! + .value['appraised_by'] + .firstname + + ' ' + + keys + .currentState! + .value['appraised_by'] + .middlename + + ' ' + + keys + .currentState! + .value['appraised_by'] + .lastname, + appraisedbyDate: keys + .currentState! + .value['app_date'], + recommendapprName: keys + .currentState! + .value['rec_approval'] + .firstname + + ' ' + + keys + .currentState! + .value['rec_approval'] + .middlename + + ' ' + + keys + .currentState! + .value['rec_approval'] + .lastname, + recommendapprDate: keys + .currentState! + .value['rec_date'], + approvedbyName: keys + .currentState! + .value['apprvd_by'] + .firstname + + ' ' + + keys + .currentState! + .value['apprvd_by'] + .middlename + + ' ' + + keys + .currentState! + .value['apprvd_by'] + .lastname, + memoranda: _memoranda, + swornstatementNo: keys + .currentState! + .value['sworn_statement'], + dateReceived: keys + .currentState! + .value['date_received'], + entryDateAssessment: keys + .currentState! + .value['date_of_entry'], + entryDateBy: keys + .currentState! + .value['by'], + ); + + propertyAssessments.add(ass); + + context.read< + PropertyAssessmentEditBloc>() + ..add(UpdatePropertyAssessmentEdit( + assessmentsEdit: + propertyAssessments[ + 0])); + }, + ), + ), + ], + ), + )) + ], + ), ), - ), - ); - } - return Container(); - }, - ); - } - return Container(); - }, - ); - } - if (state is PropertyAssessmentEditErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context.read().add( - LoadPropertyAssessmentEdit( - assessmentsEdit: PropertyAssessmentEdit(), - id: widget.tempId)); - }, - ); - } - return Container(); - }, + ); + } + return Container(); + }, + ); + } + return Container(); + }, + ); + } + if (state is PropertyAssessmentEditErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add( + LoadPropertyAssessmentEdit( + assessmentsEdit: PropertyAssessmentEdit(), + id: widget.tempId)); + }, + ); + } + return Container(); + }, + ), ); } } 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 7e81231..f184b9a 100644 --- a/lib/screens/passo/Building/edit_building/property_owner_info.dart +++ b/lib/screens/passo/Building/edit_building/property_owner_info.dart @@ -67,151 +67,168 @@ class _PropertyOwnerInfoEdit extends State { if (state is PropertyInfoLoaded) { return SingleChildScrollView( scrollDirection: Axis.vertical, - child: Expanded( - child: Column( - children: [ - FormBuilder( - key: keys, - initialValue: { - 'transaction_code': widget.faas.transCode, - 'arp_td': widget.faas.tdn, - 'pin': widget.faas.pin, - 'owner': widget.faas.owner, - 'address': widget.faas.address, - 'tel_no': widget.faas.telno, - 'tin': widget.faas.tin, - 'benificiary': widget.faas.adminUser, - 'benificiary_telno': widget.faas.adminTelno, - 'benificiary_address': widget.faas.adminAddress, - 'benificaiary_tin': widget.faas.adminTin, - }, - enabled: true, - onChanged: () { - keys.currentState!.save(); - debugPrint(keys.currentState!.value.toString()); - }, - autovalidateMode: AutovalidateMode.disabled, - skipDisabled: true, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 10), - child: const Text('PROPERTY OWNER INFO', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - const SizedBox(height: 15), - customDropDownField("Transaction Code", "", - "transaction_code", transaction_codes), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - // optional flex property if flex is 1 because the default flex is 1 - flex: 1, - child: customTextField( - "ARP No. / TD No.", "", 'arp_td')), - const SizedBox(width: 10.0), - Expanded( - // optional flex property if flex is 1 because the default flex is 1 - flex: 1, - child: customTextField("Pin", "", 'pin')), - ], - ), - customTextField("Owner", "", 'owner'), - customTextField("Address", "", 'address'), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(15.0), + child: Expanded( + child: Column( + children: [ + FormBuilder( + key: keys, + initialValue: { + 'transaction_code': widget.faas.transCode, + 'arp_td': widget.faas.tdn, + 'pin': widget.faas.pin, + 'owner': widget.faas.owner, + 'address': widget.faas.address, + 'tel_no': widget.faas.telno, + 'tin': widget.faas.tin, + 'benificiary': widget.faas.adminUser, + 'benificiary_telno': widget.faas.adminTelno, + 'benificiary_address': widget.faas.adminAddress, + 'benificaiary_tin': widget.faas.adminTin, + }, + enabled: true, + onChanged: () { + keys.currentState!.save(); + debugPrint(keys.currentState!.value.toString()); + }, + autovalidateMode: AutovalidateMode.disabled, + skipDisabled: true, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Expanded( - flex: 1, - child: - customTextField("Tel No.", "", 'tel_no'), + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('PROPERTY OWNER INFO', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), ), - const SizedBox(width: 10.0), - Expanded( - // optional flex property if flex is 1 because the default flex is 1 - flex: 1, - child: customTextField("TIN", "", 'tin')) - ]), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField( - "Administrator / Benificial User", - "", - 'benificiary'), + const SizedBox(height: 15), + customDropDownField("Transaction Code", "", + "transaction_code", transaction_codes), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "ARP No. / TD No.", "", 'arp_td')), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: + customTextField("Pin", "", 'pin')), + ], ), - const SizedBox(width: 10.0), - Expanded( - // optional flex property if flex is 1 because the default flex is 1 - flex: 1, - child: customTextField( - "TIN", "", 'benificiary_tin')) - ]), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - flex: 1, - child: customTextField( - "Address", "", 'benificiary_address'), - ), - const SizedBox(width: 10.0), - Expanded( - // optional flex property if flex is 1 because the default flex is 1 - flex: 1, - child: customTextField( - "Tel No.", "", 'benificiary_telno')) - ]), - const SizedBox(height: 25), - SizedBox( - width: MediaQuery.of(context).size.width, - child: CustomButton( - icon: const Icon(Icons.chevron_right, - color: Colors.white), - onPressed: () { - var property_info = PropertyInfo( - id: widget.faas.id, - transCode: keys - .currentState!.value['transaction_code'] - .toString(), - tdn: keys.currentState!.value['arp_td'], - pin: keys.currentState!.value['pin'], - owner: keys.currentState!.value['owner'], - address: - keys.currentState!.value['address'], - telno: keys.currentState!.value['tel_no'], - tin: keys.currentState!.value['tin'], - adminUser: - keys.currentState!.value['benificiary'], - adminAddress: keys.currentState! - .value['benificiary_address'], - adminTin: keys - .currentState!.value['benificiary_tin'], - adminTelno: keys.currentState! - .value['benificiary_telno'], - assessedById: '1', - assessedByName: 'Cyril', - dateModified: DateTime.now(), - dateCreated: DateTime.now()); + customTextField("Owner", "", 'owner'), + customTextField("Address", "", 'address'), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Tel No.", "", 'tel_no'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: + customTextField("TIN", "", 'tin')) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField( + "Administrator / Benificial User", + "", + 'benificiary'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField( + "TIN", "", 'benificiary_tin')) + ]), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: customTextField("Address", "", + 'benificiary_address'), + ), + const SizedBox(width: 10.0), + Expanded( + // optional flex property if flex is 1 because the default flex is 1 + flex: 1, + child: customTextField("Tel No.", "", + 'benificiary_telno')) + ]), + const SizedBox(height: 25), + SizedBox( + width: MediaQuery.of(context).size.width, + child: CustomButton( + icon: const Icon(Icons.chevron_right, + color: Colors.white), + onPressed: () { + var property_info = PropertyInfo( + id: widget.faas.id, + transCode: keys.currentState! + .value['transaction_code'] + .toString(), + tdn: keys + .currentState!.value['arp_td'], + pin: keys.currentState!.value['pin'], + owner: + keys.currentState!.value['owner'], + address: keys + .currentState!.value['address'], + telno: keys + .currentState!.value['tel_no'], + tin: keys.currentState!.value['tin'], + adminUser: keys.currentState! + .value['benificiary'], + adminAddress: keys.currentState! + .value['benificiary_address'], + adminTin: keys.currentState! + .value['benificiary_tin'], + adminTelno: keys.currentState! + .value['benificiary_telno'], + assessedById: '1', + assessedByName: 'Cyril', + dateModified: DateTime.now(), + dateCreated: DateTime.now()); - context.read().add( - UpdatPropertyInfo( - property_info: property_info)); + context.read().add( + UpdatPropertyInfo( + property_info: property_info)); - widget.NextBtn(); - }, - ), - ), - ])), - ], - ), + widget.NextBtn(); + }, + ), + ), + ])), + ], + ), + ), + ), + ], ), ); } diff --git a/lib/screens/passo/Building/edit_building/structural_materials.dart b/lib/screens/passo/Building/edit_building/structural_materials.dart index efeacf3..24580b3 100644 --- a/lib/screens/passo/Building/edit_building/structural_materials.dart +++ b/lib/screens/passo/Building/edit_building/structural_materials.dart @@ -56,356 +56,388 @@ class _StructuralMaterialsPageEdit extends State { // TODO: implement listener }, builder: (context, state) { if (state is StructuralMaterialsLoaded) { - return Expanded( - child: SingleChildScrollView( - padding: const EdgeInsets.all(30.0), + return SingleChildScrollView( + scrollDirection: Axis.vertical, child: Column( children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 10), - child: const Text('STRUCTURAL MATERIALS', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - 'FOUNDATION', - textAlign: TextAlign.start, - ), - Row( + Expanded( + child: Column( children: [ - const Text('Others'), - Checkbox( - checkColor: Colors.white, - value: foundationOthers, - onChanged: (bool? value) { - setState(() { - foundationOthers = value!; - }); - }, - ) - ], - ), - ]), - Padding( - padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), - child: Visibility( - visible: foundationOthers, - child: customTextField( - "Enter other foundation", "", "other_foundation"), - replacement: DropDownMultiSelect( - selected_values_style: TextStyle(color: Colors.black), - onChanged: (List x) { - setState(() { - foundation = x; - }); - }, - options: const ['Reinforced Concrete', 'Plain Concrete'], - selectedValues: foundation, - whenEmpty: 'Select Foundations', - ), - ), - ), - Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - 'COLUMNS', - textAlign: TextAlign.start, - ), - Row( - children: [ - const Text('Others'), - Checkbox( - checkColor: Colors.white, - value: columOthers, - onChanged: (bool? value) { - setState(() { - columOthers = value!; - }); - }, - ) - ], - ), - ]), - Padding( - padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), - child: Visibility( - visible: columOthers, - child: customTextField( - "Enter other columns", "", "other_column"), - replacement: DropDownMultiSelect( - selected_values_style: TextStyle(color: Colors.black), - onChanged: (List x) { - setState(() { - column = x; - }); - }, - options: const ['Steel', 'Reinforced Concrete', 'Wood'], - selectedValues: column, - whenEmpty: 'Select Column/s', - ), - ), - ), - Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - 'BEAMS', - textAlign: TextAlign.start, - ), - Row( - children: [ - const Text('Others'), - Checkbox( - checkColor: Colors.white, - value: beamsOthers, - onChanged: (bool? value) { - setState(() { - beamsOthers = value!; - }); - }, - ) - ], - ), - ]), - Padding( - padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), - child: Visibility( - visible: beamsOthers, - child: - customTextField("Enter other beam/s", "", "other_beam"), - replacement: DropDownMultiSelect( - selected_values_style: TextStyle(color: Colors.black), - onChanged: (List x) { - setState(() { - beam = x; - }); - }, - options: const ['Steel', 'Reinforced Concrete', 'Wood'], - selectedValues: beam, - whenEmpty: 'Select Beam/s', - ), - ), - ), - Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - 'TRUSS FRAMING', - textAlign: TextAlign.start, - ), - Row( - children: [ - const Text('Others'), - Checkbox( - checkColor: Colors.white, - value: tfOthers, - onChanged: (bool? value) { - setState(() { - tfOthers = value!; - }); - }, - ) - ], - ), - ]), - Padding( - padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), - child: Visibility( - visible: tfOthers, - child: customTextField( - "Enter other truss framing/s", "", "other_tf"), - replacement: DropDownMultiSelect( - selected_values_style: TextStyle(color: Colors.black), - onChanged: (List x) { - setState(() { - truss_framing = x; - }); - }, - options: const ['Steel', 'Wood'], - selectedValues: truss_framing, - whenEmpty: 'Select Truss Framing/s', - ), - ), - ), - Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - 'ROOF', - textAlign: TextAlign.start, - ), - Row( - children: [ - const Text('Others'), - Checkbox( - checkColor: Colors.white, - value: roofOthers, - onChanged: (bool? value) { - setState(() { - roofOthers = value!; - }); - }, - ) - ], - ), - ]), - Padding( - padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), - child: Visibility( - visible: roofOthers, - child: - customTextField("Enter other roof/s", "", "other_roof"), - replacement: DropDownMultiSelect( - selected_values_style: TextStyle(color: Colors.black), - onChanged: (List x) { - setState(() { - roof = x; - }); - }, - options: const [ - 'Reinforced Concrete', - 'Tiles', - 'G.I Sheet', - 'Aluminum', - 'Asbestos', - 'Long Span', - 'Concrete Desk', - 'Nipa/Anahaw/Cogon' - ], - selectedValues: roof, - whenEmpty: 'Select Roof/s', - ), - ), - ), - Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - 'FLOORING', - textAlign: TextAlign.start, - ), - Row( - children: [ - const Text('Others'), - Checkbox( - checkColor: Colors.white, - value: flooringOthers, - onChanged: (bool? value) { - setState(() { - flooringOthers = value!; - }); - }, - ) - ], - ), - ]), - Padding( - padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), - child: Visibility( - visible: flooringOthers, - child: customTextField( - "Enter other flooring/s", "", "other_flooring"), - replacement: DropDownMultiSelect( - selected_values_style: TextStyle(color: Colors.black), - onChanged: (List x) { - setState(() { - flooring = x; - }); - }, - options: const [ - 'Reinforced Concrete', - 'Plain Cement', - 'Marble', - 'Wood', - 'Tiles' - ], - selectedValues: flooring, - whenEmpty: 'Select Flooring/s', - ), - ), - ), - Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - 'WALLS & PARTITIONS', - textAlign: TextAlign.start, - ), - Row( - children: [ - const Text('Others'), - Checkbox( - checkColor: Colors.white, - value: wpOthers, - onChanged: (bool? value) { - setState(() { - wpOthers = value!; - }); - }, - ) - ], - ), - ]), - Padding( - padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), - child: Visibility( - visible: wpOthers, - child: customTextField( - "Enter other walls & partition/s", "", "other_wp"), - replacement: DropDownMultiSelect( - selected_values_style: TextStyle(color: Colors.black), - onChanged: (List x) { - setState(() { - walls = x; - }); - }, - options: const [ - 'Reinforced Concrete', - 'Plain Concrete', - 'Wood', - 'CHIB', - 'G.I Sheet', - 'Build-a-wall', - 'Sawali', - 'Bamboo' - ], - selectedValues: walls, - whenEmpty: 'Select Walls & Partition/s', - ), - ), - ), - 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: () { - { - var strucMaterials = StructureMaterialsII( - id: widget.tempId, - foundation: foundation, - columns: column, - beams: beam, - trussFraming: truss_framing, - roof: roof, - flooring: flooring, - walls: walls, - others: ["Others"]); - context.read() - ..add(UpdateStrucMaterials(data: strucMaterials)); + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('STRUCTURAL MATERIALS', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'FOUNDATION', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: foundationOthers, + onChanged: (bool? value) { + setState(() { + foundationOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: foundationOthers, + child: customTextField( + "Enter other foundation", "", "other_foundation"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + foundation = x; + }); + }, + options: const [ + 'Reinforced Concrete', + 'Plain Concrete' + ], + selectedValues: foundation, + whenEmpty: 'Select Foundations', + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'COLUMNS', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: columOthers, + onChanged: (bool? value) { + setState(() { + columOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: columOthers, + child: customTextField( + "Enter other columns", "", "other_column"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + column = x; + }); + }, + options: const [ + 'Steel', + 'Reinforced Concrete', + 'Wood' + ], + selectedValues: column, + whenEmpty: 'Select Column/s', + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'BEAMS', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: beamsOthers, + onChanged: (bool? value) { + setState(() { + beamsOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: beamsOthers, + child: customTextField( + "Enter other beam/s", "", "other_beam"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + beam = x; + }); + }, + options: const [ + 'Steel', + 'Reinforced Concrete', + 'Wood' + ], + selectedValues: beam, + whenEmpty: 'Select Beam/s', + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'TRUSS FRAMING', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: tfOthers, + onChanged: (bool? value) { + setState(() { + tfOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: tfOthers, + child: customTextField( + "Enter other truss framing/s", "", "other_tf"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + truss_framing = x; + }); + }, + options: const ['Steel', 'Wood'], + selectedValues: truss_framing, + whenEmpty: 'Select Truss Framing/s', + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'ROOF', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: roofOthers, + onChanged: (bool? value) { + setState(() { + roofOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: roofOthers, + child: customTextField( + "Enter other roof/s", "", "other_roof"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + roof = x; + }); + }, + options: const [ + 'Reinforced Concrete', + 'Tiles', + 'G.I Sheet', + 'Aluminum', + 'Asbestos', + 'Long Span', + 'Concrete Desk', + 'Nipa/Anahaw/Cogon' + ], + selectedValues: roof, + whenEmpty: 'Select Roof/s', + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'FLOORING', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: flooringOthers, + onChanged: (bool? value) { + setState(() { + flooringOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: flooringOthers, + child: customTextField( + "Enter other flooring/s", "", "other_flooring"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + flooring = x; + }); + }, + options: const [ + 'Reinforced Concrete', + 'Plain Cement', + 'Marble', + 'Wood', + 'Tiles' + ], + selectedValues: flooring, + whenEmpty: 'Select Flooring/s', + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'WALLS & PARTITIONS', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: wpOthers, + onChanged: (bool? value) { + setState(() { + wpOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: wpOthers, + child: customTextField( + "Enter other walls & partition/s", "", "other_wp"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + walls = x; + }); + }, + options: const [ + 'Reinforced Concrete', + 'Plain Concrete', + 'Wood', + 'CHIB', + 'G.I Sheet', + 'Build-a-wall', + 'Sawali', + 'Bamboo' + ], + selectedValues: walls, + whenEmpty: 'Select Walls & Partition/s', + ), + ), + ), + 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: () { + { + var strucMaterials = StructureMaterialsII( + id: widget.tempId, + foundation: foundation, + columns: column, + beams: beam, + trussFraming: truss_framing, + roof: roof, + flooring: flooring, + walls: walls, + others: ["Others"]); + context.read() + ..add( + UpdateStrucMaterials(data: strucMaterials)); - widget.NextBtn(); - } - ; - }, - ) - ], - ) + widget.NextBtn(); + } + ; + }, + ) + ], + ) + ], + ), + ), ], ), - )); + ); } if (state is StructuralMaterialsErrorState) { return Text(state.error); diff --git a/lib/screens/passo/Building/edit_building/structural_materials_edit.dart b/lib/screens/passo/Building/edit_building/structural_materials_edit.dart new file mode 100644 index 0000000..57f9d3c --- /dev/null +++ b/lib/screens/passo/Building/edit_building/structural_materials_edit.dart @@ -0,0 +1,481 @@ +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:multiselect/multiselect.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; +import 'package:unit2/bloc/passo/bulding/structural_material/structural_material_bloc.dart'; +import 'package:unit2/model/passo/structural_materials_ii.dart'; +import 'package:unit2/screens/passo/Building/add_building.dart'; +import 'package:unit2/widgets/passo/custom_button.dart'; +import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart'; + +class MaterialOption { + final String id; + final String label; + + MaterialOption(this.id, this.label); +} + +class StructuralMaterialsEditPage extends StatefulWidget { + final int tempId; + final VoidCallback NextBtn; + final VoidCallback PrevBtn; + + StructuralMaterialsEditPage(this.tempId, this.NextBtn, this.PrevBtn); + + @override + _StructuralMaterialsEditPage createState() => _StructuralMaterialsEditPage(); +} + +class _StructuralMaterialsEditPage extends State { + List foundation = []; + List column = []; + List beam = []; + List truss_framing = []; + List roof = []; + List flooring = []; + List walls = []; + bool foundationOthers = false; + bool columOthers = false; + bool beamsOthers = false; + bool tfOthers = false; + bool roofOthers = false; + bool flooringOthers = false; + bool wpOthers = false; + + List columnOptions = [ + MaterialOption('steel', 'Steel'), + MaterialOption('concrete', 'Reinforced Concrete'), + MaterialOption('wood', 'Wood'), + ]; + + List selectedColumnValues = []; + + @override + Widget build(BuildContext context) { + 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 StructuralMaterialsLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + + if (state is StructuralMaterialsLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + setState(() { + foundation = state.structure.foundation!.split(','); + column = state.structure.columns!.split(','); + beam = state.structure.beams!.split(','); + truss_framing = state.structure.trussFraming!.split(','); + roof = state.structure.roof!.split(','); + flooring = state.structure.flooring!.split(','); + walls = state.structure.walls!.split(','); + // Update other local state variables here if needed + }); + } + if (state is StructuralMaterialsErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, builder: (context, state) { + return SingleChildScrollView( + padding: const EdgeInsets.all(30.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('STRUCTURAL MATERIALS', + style: + TextStyle(fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'FOUNDATION', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: foundationOthers, + onChanged: (bool? value) { + setState(() { + foundationOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: foundationOthers, + child: customTextField( + "Enter other foundation", "", "other_foundation"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + foundation = x; + }); + }, + options: const ['Reinforced Concrete', 'Plain Concrete'], + selectedValues: foundation, + whenEmpty: 'Select Foundations', + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'COLUMNS', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: columOthers, + onChanged: (bool? value) { + setState(() { + columOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: columOthers, + child: customTextField( + "Enter other columns", "", "other_column"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + column = x; + }); + }, + options: const ['Steel', 'Reinforced Concrete', 'Wood'], + selectedValues: column, + whenEmpty: 'Select Column/s', + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'BEAMS', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: beamsOthers, + onChanged: (bool? value) { + setState(() { + beamsOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: beamsOthers, + child: + customTextField("Enter other beam/s", "", "other_beam"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + beam = x; + }); + }, + options: const ['Steel', 'Reinforced Concrete', 'Wood'], + selectedValues: beam, + whenEmpty: 'Select Beam/s', + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'TRUSS FRAMING', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: tfOthers, + onChanged: (bool? value) { + setState(() { + tfOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: tfOthers, + child: customTextField( + "Enter other truss framing/s", "", "other_tf"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + truss_framing = x; + }); + }, + options: const ['Steel', 'Wood'], + selectedValues: truss_framing, + whenEmpty: 'Select Truss Framing/s', + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'ROOF', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: roofOthers, + onChanged: (bool? value) { + setState(() { + roofOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: roofOthers, + child: + customTextField("Enter other roof/s", "", "other_roof"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + roof = x; + }); + }, + options: const [ + 'Reinforced Concrete', + 'Tiles', + 'G.I Sheet', + 'Aluminum', + 'Asbestos', + 'Long Span', + 'Concrete Desk', + 'Nipa/Anahaw/Cogon' + ], + selectedValues: roof, + whenEmpty: 'Select Roof/s', + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'FLOORING', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: flooringOthers, + onChanged: (bool? value) { + setState(() { + flooringOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: flooringOthers, + child: customTextField( + "Enter other flooring/s", "", "other_flooring"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + flooring = x; + }); + }, + options: const [ + 'Reinforced Concrete', + 'Plain Cement', + 'Marble', + 'Wood', + 'Tiles' + ], + selectedValues: flooring, + whenEmpty: 'Select Flooring/s', + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'WALLS & PARTITIONS', + textAlign: TextAlign.start, + ), + Row( + children: [ + const Text('Others'), + Checkbox( + checkColor: Colors.white, + value: wpOthers, + onChanged: (bool? value) { + setState(() { + wpOthers = value!; + }); + }, + ) + ], + ), + ]), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), + child: Visibility( + visible: wpOthers, + child: customTextField( + "Enter other walls & partition/s", "", "other_wp"), + replacement: DropDownMultiSelect( + selected_values_style: TextStyle(color: Colors.black), + onChanged: (List x) { + setState(() { + walls = x; + }); + }, + options: const [ + 'Reinforced Concrete', + 'Plain Concrete', + 'Wood', + 'CHIB', + 'G.I Sheet', + 'Build-a-wall', + 'Sawali', + 'Bamboo' + ], + selectedValues: walls, + whenEmpty: 'Select Walls & Partition/s', + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () async { + { + final tempID = await SharedPreferences.getInstance(); + var strucMaterials = StructureMaterialsII( + id: tempID.getInt('tempid')! - 1, + foundation: foundationOthers + ? formKey + .currentState!.value['other_foundation'] + .split(',') + : foundation, + columns: columOthers + ? formKey.currentState!.value['other_column'] + .split(',') + : column, + beams: beamsOthers + ? formKey.currentState!.value['other_beam'] + .split(',') + : beam, + trussFraming: tfOthers + ? formKey.currentState!.value['other_tf'] + .split(',') + : truss_framing, + roof: roofOthers + ? formKey.currentState!.value['other_roof'] + .split(',') + : roof, + flooring: flooringOthers + ? formKey + .currentState!.value['other_flooring'] + .split(',') + : flooring, + walls: wpOthers + ? formKey.currentState!.value['other_wp'] + .split(',') + : walls, + others: ["Others"]); + context.read() + ..add(UpdateStrucMaterials(data: strucMaterials)); + + widget.PrevBtn(); + } + ; + }, + ) + ], + ) + ], + ), + ); + }), + ), + ); + } +} diff --git a/lib/screens/passo/Land/add_land/land_appraisal.dart b/lib/screens/passo/Land/add_land/land_appraisal.dart index fa0ca77..a7fcdc8 100644 --- a/lib/screens/passo/Land/add_land/land_appraisal.dart +++ b/lib/screens/passo/Land/add_land/land_appraisal.dart @@ -5,6 +5,8 @@ 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/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 LandAppraisal extends StatefulWidget { @@ -242,6 +244,14 @@ class _LandAppraisal extends State { ), ); } + if (state is LandAppraisalErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadLandAppraisal()); + }, + ); + } return Container(); }); } diff --git a/lib/screens/passo/building_home.dart b/lib/screens/passo/building_home.dart index 7c428b0..eabc80c 100644 --- a/lib/screens/passo/building_home.dart +++ b/lib/screens/passo/building_home.dart @@ -57,6 +57,7 @@ import 'package:unit2/widgets/error_state.dart'; import 'package:flutter_speed_dial/flutter_speed_dial.dart'; import '../../model/passo/bldg_loc.dart'; +import '../../utils/alerts.dart'; class BuildingHome extends StatelessWidget { const BuildingHome({super.key}); @@ -66,6 +67,11 @@ class BuildingHome extends StatelessWidget { int? profileId; String? token; Profile profile; + + void deleteItem(int itemId) { + context.read().add(DeleteBuildingFaas(id: itemId)); + } + return Scaffold( body: ProgressHUD( backgroundColor: Colors.black87, @@ -102,8 +108,8 @@ class BuildingHome extends StatelessWidget { shrinkWrap: true, itemCount: propertyList.length, itemBuilder: (BuildContext context, int index) { - return _listCard( - propertyList[index], context, index); + return _listCard(propertyList[index], context, + index, deleteItem); }, ), ), @@ -121,6 +127,20 @@ class BuildingHome extends StatelessWidget { }, ); } + if (state is BuildingFaasDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Building FAAS Data has been deleted successfully", + () { + Navigator.of(context).pop(); + context + .read() + .add(const LoadPropertyInfo()); + }); + }); + } + } return Container(); }, ); @@ -269,7 +289,7 @@ class BuildingHome extends StatelessWidget { } } -Card _listCard(PropertyInfo property_info, context, index) { +Card _listCard(PropertyInfo property_info, context, index, deleteItem) { return Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), @@ -400,7 +420,13 @@ Card _listCard(PropertyInfo property_info, context, index) { ], ), ), - IconButton(onPressed: () {}, icon: const Icon(Icons.chevron_right)), + IconButton( + onPressed: () { + deleteItem(property_info.id); + }, + icon: const Icon(Icons.delete_rounded), + color: primary, + ), ], ), ), diff --git a/lib/sevices/passo/building/property_info_services.dart b/lib/sevices/passo/building/property_info_services.dart index ac90a92..a3f7206 100644 --- a/lib/sevices/passo/building/property_info_services.dart +++ b/lib/sevices/passo/building/property_info_services.dart @@ -134,4 +134,29 @@ class PropertyInfoService { } return response; } + + Future remove(id) async { + String path = Url.instance.propertyInfo(); + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientKeySecret + }; + Map params = { + "id": id.toString(), + }; + try { + http.Response response = await Request.instance + .deleteRequest(path: path, headers: headers, body: {}, param: params); + print(id); + if (response.statusCode == 200) { + print(response.body); + return response; + } else { + throw Exception(response.reasonPhrase); + } + } catch (e) { + throw e.toString(); + } + } } diff --git a/lib/utils/request.dart b/lib/utils/request.dart index 970fac6..562a9fb 100644 --- a/lib/utils/request.dart +++ b/lib/utils/request.dart @@ -19,7 +19,7 @@ class Request { Map? param}) async { Response response; try { - response = await get(Uri.https(host, path!, param), headers: headers) + response = await get(Uri.http(host, path!, param), headers: headers) .timeout(Duration(seconds: requestTimeout)); } on TimeoutException catch (_) { // Fluttertoast.showToast( @@ -61,7 +61,7 @@ class Request { Map? param}) async { Response response; try { - response = await post(Uri.https(host, path!, param), + response = await post(Uri.http(host, path!, param), headers: headers, body: jsonEncode(body)) .timeout(Duration(seconds: requestTimeout)); } on TimeoutException catch (_) { @@ -104,7 +104,7 @@ class Request { required Map? param}) async { Response response; try { - response = await put(Uri.https(host, path, param), + response = await put(Uri.http(host, path, param), headers: headers, body: jsonEncode(body)); } on TimeoutException catch (_) { // Fluttertoast.showToast( @@ -188,7 +188,7 @@ class Request { required Map? param}) async { Response response; try { - response = await delete(Uri.https(host, path, param), + response = await delete(Uri.http(host, path, param), headers: headers, body: jsonEncode(body)) .timeout(Duration(seconds: requestTimeout)); } on TimeoutException catch (_) { diff --git a/lib/utils/urls.dart b/lib/utils/urls.dart index 20385fe..3348415 100644 --- a/lib/utils/urls.dart +++ b/lib/utils/urls.dart @@ -5,12 +5,13 @@ class Url { String host() { // return '192.168.10.183:3000'; - return 'agusandelnorte.gov.ph'; + // return 'agusandelnorte.gov.ph'; // return "192.168.10.219:3000"; // return "192.168.10.241"; // return "192.168.10.221:3004"; - // return "playweb.agusandelnorte.gov.ph"; + return "playweb.agusandelnorte.gov.ph"; // return 'devapi.agusandelnorte.gov.ph:3004'; + // return "192.168.10.218:8000"; } String prefixHost() { @@ -26,7 +27,6 @@ class Url { return 'api/jobnet_app/profile/pds/'; } - String latestApk() { return "/api/system_app/apk_version/latest"; }