diff --git a/lib/bloc/passo/bulding/additional_item/additional_item_bloc.dart b/lib/bloc/passo/bulding/additional_item/additional_item_bloc.dart index e7aa87a..762ceb4 100644 --- a/lib/bloc/passo/bulding/additional_item/additional_item_bloc.dart +++ b/lib/bloc/passo/bulding/additional_item/additional_item_bloc.dart @@ -42,7 +42,7 @@ class AdditionalItemBloc emit(AdditionalItemsLoaded(globalAdditionalItems)); } else { - emit(AdditionalItemsErrorState('error')); + emit(const AdditionalItemsErrorState('error')); } } catch (e) { emit(AdditionalItemsErrorState(e.toString())); @@ -56,7 +56,7 @@ class AdditionalItemBloc if (response.statusCode == 200) { globalAdditionalItems .removeWhere(((AdditionalItems element) => element.id == event.id)); - emit(AdditionalItemsDeletedState(success: true)); + emit(const AdditionalItemsDeletedState(success: true)); } }); diff --git a/lib/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart b/lib/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart index 10a5fdc..ef081b9 100644 --- a/lib/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart +++ b/lib/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart @@ -12,14 +12,14 @@ part 'property_appraisal_state.dart'; class PropertyAppraisalBloc extends Bloc { - PropertyAppraisalBloc() : super(PropertyAppraisalInitial()) { + PropertyAppraisalBloc() : super(PropertyAppraisalLoading()) { List globalPropertyAppraisal = []; on((event, emit) async { emit(PropertyAppraisalLoading()); try { - final appraisal = await PropertyAppraisalServices.instance.fetch(); - print(appraisal); - emit(PropertyAppraisalLoaded(appraisal)); + // final appraisal = await PropertyAppraisalServices.instance.fetch(); + // print(appraisal); + emit(PropertyAppraisalLoaded(PropertyAppraisal())); } catch (e) { emit(PropertyAppraisalErrorState(e.toString())); } 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 3ad760d..7d15449 100644 --- a/lib/screens/passo/Building/add_building_components/property_appraisal.dart +++ b/lib/screens/passo/Building/add_building_components/property_appraisal.dart @@ -3,6 +3,7 @@ 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:fluttertoast/fluttertoast.dart'; import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:intl/intl.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -509,578 +510,644 @@ class _PropertyAppraisalPage extends State { padding: const EdgeInsets.all(24), backgroundColor: Colors.black87, indicatorWidget: const SpinKitFadingCircle(color: Colors.white), - child: BlocConsumer( + child: BlocConsumer( listener: (context, state) { - if (state is AdditionalItemsLoading) { + if (state is PropertyAppraisalLoading) { final progress = ProgressHUD.of(context); progress!.showWithText("Please wait..."); + print('app_load'); } - if (state is AdditionalItemsLoaded) { + + if (state is PropertyAppraisalErrorState) { final progress = ProgressHUD.of(context); progress?.dismiss(); } - if (state is AdditionalItemsErrorState) { + if (state is PropertyAppraisalLoaded) { final progress = ProgressHUD.of(context); progress?.dismiss(); } + if (state is ShowPropertyAppraisalSuccessAlertState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + widget.NextBtn(); + } + if (state is ShowPropertyAppraisalErrorAlertState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + Fluttertoast.showToast( + msg: "Slow internet connection, please try again!"); + } }, builder: (context, state) { - if (state is AdditionalItemsLoaded) { - return SingleChildScrollView( - child: Container( - margin: const EdgeInsets.only(left: 20.0, right: 20.0), - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 20), - child: const Text('PROPERTY APPRAISAL', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Unit Construction Cost", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, + if (state is PropertyAppraisalLoaded) { + return BlocConsumer( + listener: (context, state) { + if (state is AdditionalItemsLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is AdditionalItemsLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is AdditionalItemsErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, + builder: (context, state) { + if (state is AdditionalItemsLoaded) { + return SingleChildScrollView( + child: Container( + margin: const EdgeInsets.only(left: 20.0, right: 20.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 20), + child: const Text('PROPERTY APPRAISAL', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), ), - ), - Container( - child: Text( - formKey.currentState!.value['bldg_type'] - .unitValue + - ' sq.m', - textAlign: TextAlign.right, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Unit Construction Cost", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + formKey.currentState!.value['bldg_type'] + .unitValue + + ' sq.m', + textAlign: TextAlign.right, + ), + ) + ], ), - ) - ], - ), - 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, + ), + ) + ], ), - ), - 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( + (double.parse(formKey.currentState! + .value['total_area']) * + double.parse(formKey.currentState! + .value['bldg_type'].unitValue)) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], ), - ) - ], - ), - const SizedBox(height: 40), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Sub-total", - 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( + '', + textAlign: TextAlign.right, + ), + ) + ], ), - ), - Container( - child: Text( - (double.parse(formKey - .currentState!.value['total_area']) * - double.parse(formKey.currentState! - .value['bldg_type'].unitValue)) - .toString(), - textAlign: TextAlign.right, + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Sub-total", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateAdditionalItems(state.items) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], ), - ) - ], - ), - const SizedBox(height: 40), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Cost of Additional Items", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - '', - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Sub-total", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - calculateAdditionalItems(state.items).toString(), - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Total Construction Cost", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - calculateTotalConstructionCost( - (double.parse(formKey.currentState! - .value['total_area']) * - double.parse(formKey.currentState! - .value['bldg_type'].unitValue)), - state.items) - .toString(), - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 40), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Depreciation Rate", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - SizedBox( - width: 90, - height: 25, - child: FormBuilderTextField( - name: 'depRate', - decoration: normalTextFieldStyle("", ""), - 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( - (double.parse(formKey.currentState! - .value['total_area']) * - double.parse(formKey.currentState! - .value['bldg_type'].unitValue)), - state.items, - depRate) - .toString(), - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Total % Depreciation", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - '${(depRate * 100).toStringAsFixed(2)}%', - textAlign: TextAlign.right, - ), - ) - ], - ), - const SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Text( - "Market Value", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 13), - textAlign: TextAlign.left, - ), - ), - Container( - child: Text( - calculateMarketValue( - (double.parse(formKey.currentState! - .value['total_area']) * - double.parse(formKey.currentState! - .value['bldg_type'].unitValue)), - state.items, - depRate) - .toString(), - textAlign: TextAlign.right, - ), - ), - ], - ), - Row( - children: [ - Expanded( - flex: 1, - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Container( - margin: const EdgeInsets.only( - left: 20.0, right: 20.0), - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, - top: 20, - right: 0, - bottom: 20), - child: const Text( - 'PROPERTY ASSESSMENT', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18), - textAlign: TextAlign.left), - ), - Column( - 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: 100, - margin: - const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all( - 5.0), - child: const Text( - 'Market Value', - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, - ), - textAlign: - TextAlign.center, - ), - ), - Container( - width: 100, - margin: - const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all( - 5.0), - child: const Text( - 'Ass. Level', - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, - ), - textAlign: - TextAlign.center, - ), - ), - Container( - width: 100, - margin: - const EdgeInsets.only( - top: 15, left: 15), - padding: - const EdgeInsets.all( - 5.0), - child: const Text( - 'Ass. Value', - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, - ), - textAlign: - TextAlign.center, - ), - ), - ], - ), - SizedBox( - height: 59, - child: Row( - children: [ - Container( - width: 100, - margin: - const EdgeInsets.only( - top: 15, - left: 15), - padding: - const EdgeInsets.all( - 5.0), - child: Text( - formKey.currentState - ?.value[ - 'actual_use']!, - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, - ), - textAlign: - TextAlign.center, - ), - ), - Container( - width: 100, - margin: - const EdgeInsets.only( - top: 15, - left: 15), - padding: - const EdgeInsets.all( - 5.0), - child: Text( - calculateMarketValue( - (double.parse(formKey - .currentState! - .value[ - 'total_area']) * - double.parse(formKey - .currentState! - .value[ - 'bldg_type'] - .unitValue)), - state.items, - depRate) - .toString(), - 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( - (double.parse(formKey.currentState!.value[ - 'total_area']) * - double.parse(formKey - .currentState! - .value[ - 'bldg_type'] - .unitValue)), - state.items, - depRate) - .toString(), - formKey.currentState - ?.value[ - 'actual_use']), - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, - ), - textAlign: - TextAlign.center, - ), - ), - Container( - width: 100, - margin: - const EdgeInsets.only( - top: 15, - left: 15), - padding: - const EdgeInsets.all( - 5.0), - child: Text( - assessmentValue( - calculateMarketValue( - (double.parse(formKey.currentState!.value['total_area']) * - double.parse(formKey - .currentState! - .value[ - 'bldg_type'] - .unitValue)), - state - .items, - depRate) - .toString(), - formKey.currentState - ?.value[ - 'actual_use']) - .toString(), - style: TextStyle( - fontWeight: - FontWeight.bold, - fontSize: 13, - ), - textAlign: - TextAlign.center, - ), - ), - ], - ), - ) - ], - ), - ]))), - ), - ], - ), - SizedBox( - height: 50, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - CustomButton( - icon: const Icon(Icons.chevron_left_rounded, - color: Colors.white), - onPressed: () { - { - widget.PrevBtn(); - } - ; - }, - ), - CustomButton( - icon: const Icon(Icons.chevron_right_rounded, - color: Colors.white), - onPressed: () async { - { - final tempID = - await SharedPreferences.getInstance(); - print(tempID.getInt('tempid')); - var appraisals = PropertyAppraisal( - id: 1, - bldgapprDetailsId: - tempID.getInt('tempid')! - 1, - unitconstructCost: formKey.currentState! - .value['bldg_type'].unitValue, - buildingCore: 'test', - unitconstructSubtotal: - (double.parse(formKey.currentState!.value['total_area']) * + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Total Construction Cost", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateTotalConstructionCost( + (double.parse(formKey.currentState! + .value['total_area']) * double.parse(formKey .currentState! .value['bldg_type'] - .unitValue)) - .toString(), - depreciationRate: depRate.toString(), - depreciationCost: calculateDepCost( - (double.parse(formKey.currentState!.value['total_area']) * - double.parse(formKey.currentState!.value['bldg_type'].unitValue)), + .unitValue)), + state.items) + .toString(), + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 40), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Depreciation Rate", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + SizedBox( + width: 90, + height: 25, + child: FormBuilderTextField( + name: 'depRate', + decoration: normalTextFieldStyle("", ""), + 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( + (double.parse(formKey.currentState! + .value['total_area']) * + double.parse(formKey + .currentState! + .value['bldg_type'] + .unitValue)), state.items, depRate) .toString(), - costAddItems: calculateAdditionalItems(state.items).toString(), - addItemsSubtotal: calculateAdditionalItems(state.items).toString(), - totalpercentDepreciation: (depRate * 100).toStringAsFixed(2), - marketValue: calculateMarketValue((double.parse(formKey.currentState!.value['total_area']) * double.parse(formKey.currentState!.value['bldg_type'].unitValue)), state.items, depRate).toString(), - totalArea: formKey.currentState!.value['total_area'], - actualUse: "Residential"); - context.read() - ..add(AddPropertyAppraisal( - appraisal: appraisals)); - - widget.NextBtn(); - } - ; - }, - ) - ], + 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( + '${(depRate * 100).toStringAsFixed(2)}%', + textAlign: TextAlign.right, + ), + ) + ], + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Text( + "Market Value", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 13), + textAlign: TextAlign.left, + ), + ), + Container( + child: Text( + calculateMarketValue( + (double.parse(formKey.currentState! + .value['total_area']) * + double.parse(formKey + .currentState! + .value['bldg_type'] + .unitValue)), + state.items, + depRate) + .toString(), + textAlign: TextAlign.right, + ), + ), + ], + ), + Row( + children: [ + Expanded( + flex: 1, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Container( + margin: const EdgeInsets.only( + left: 20.0, right: 20.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, + top: 20, + right: 0, + bottom: 20), + child: const Text( + 'PROPERTY ASSESSMENT', + style: TextStyle( + fontWeight: + FontWeight.bold, + fontSize: 18), + textAlign: + TextAlign.left), + ), + Column( + 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: 100, + margin: + const EdgeInsets + .only( + top: 15, + left: 15), + padding: + const EdgeInsets + .all(5.0), + child: const Text( + 'Market Value', + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 13, + ), + textAlign: TextAlign + .center, + ), + ), + Container( + width: 100, + margin: + const EdgeInsets + .only( + top: 15, + left: 15), + padding: + const EdgeInsets + .all(5.0), + child: const Text( + 'Ass. Level', + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 13, + ), + textAlign: TextAlign + .center, + ), + ), + Container( + width: 100, + margin: + const EdgeInsets + .only( + top: 15, + left: 15), + padding: + const EdgeInsets + .all(5.0), + child: const Text( + 'Ass. Value', + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 13, + ), + textAlign: TextAlign + .center, + ), + ), + ], + ), + SizedBox( + height: 59, + child: Row( + children: [ + Container( + width: 100, + margin: + const EdgeInsets + .only( + top: 15, + left: 15), + padding: + const EdgeInsets + .all(5.0), + child: Text( + formKey.currentState + ?.value[ + 'actual_use']!, + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 13, + ), + textAlign: + TextAlign + .center, + ), + ), + Container( + width: 100, + margin: + const EdgeInsets + .only( + top: 15, + left: 15), + padding: + const EdgeInsets + .all(5.0), + child: Text( + calculateMarketValue( + (double.parse(formKey.currentState!.value[ + 'total_area']) * + double.parse(formKey + .currentState! + .value['bldg_type'] + .unitValue)), + state.items, + depRate) + .toString(), + 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( + (double.parse(formKey.currentState!.value['total_area']) * + double.parse(formKey + .currentState! + .value[ + 'bldg_type'] + .unitValue)), + state + .items, + depRate) + .toString(), + formKey.currentState + ?.value[ + 'actual_use']), + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 13, + ), + textAlign: + TextAlign + .center, + ), + ), + Container( + width: 100, + margin: + const EdgeInsets + .only( + top: 15, + left: 15), + padding: + const EdgeInsets + .all(5.0), + child: Text( + assessmentValue( + calculateMarketValue((double.parse(formKey.currentState!.value['total_area']) * double.parse(formKey.currentState!.value['bldg_type'].unitValue)), state.items, depRate) + .toString(), + formKey + .currentState + ?.value['actual_use']) + .toString(), + style: TextStyle( + fontWeight: + FontWeight + .bold, + fontSize: 13, + ), + textAlign: + TextAlign + .center, + ), + ), + ], + ), + ) + ], + ), + ]))), + ), + ], + ), + SizedBox( + height: 50, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () async { + { + final tempID = + await SharedPreferences.getInstance(); + print(tempID.getInt('tempid')); + var appraisals = PropertyAppraisal( + id: 1, + bldgapprDetailsId: + tempID.getInt('tempid')! - 1, + unitconstructCost: formKey + .currentState! + .value['bldg_type'] + .unitValue, + buildingCore: 'test', + unitconstructSubtotal: (double.parse(formKey.currentState!.value['total_area']) * + double.parse(formKey + .currentState! + .value['bldg_type'] + .unitValue)) + .toString(), + depreciationRate: depRate.toString(), + depreciationCost: calculateDepCost( + (double.parse(formKey.currentState!.value['total_area']) * + double.parse(formKey.currentState!.value['bldg_type'].unitValue)), + state.items, + depRate) + .toString(), + costAddItems: calculateAdditionalItems(state.items).toString(), + addItemsSubtotal: calculateAdditionalItems(state.items).toString(), + totalpercentDepreciation: (depRate * 100).toStringAsFixed(2), + marketValue: calculateMarketValue((double.parse(formKey.currentState!.value['total_area']) * double.parse(formKey.currentState!.value['bldg_type'].unitValue)), state.items, depRate).toString(), + totalArea: formKey.currentState!.value['total_area'], + actualUse: "Residential"); + context.read() + ..add(AddPropertyAppraisal( + appraisal: appraisals)); + } + ; + }, + ) + ], + ), + ], + ), ), - ], - ), - ), + ); + } + return Container(); + }, ); } return Container(); diff --git a/lib/screens/passo/Building/add_building_components/property_assessment.dart b/lib/screens/passo/Building/add_building_components/property_assessment.dart index 9220f97..127c9b0 100644 --- a/lib/screens/passo/Building/add_building_components/property_assessment.dart +++ b/lib/screens/passo/Building/add_building_components/property_assessment.dart @@ -580,10 +580,11 @@ class _PropertyAssessmentPage extends State { propertyAssessments.add(ass); - context.read() - ..add(UpdatePropertyAssessment( - assessment: - propertyAssessments[0])); + context + .read() + .add(UpdatePropertyAssessment( + assessment: + propertyAssessments[0])); widget.function(); }, style: ElevatedButton.styleFrom( 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 dd4dea0..97bb863 100644 --- a/lib/screens/passo/Building/edit_building/property_assessement_edit.dart +++ b/lib/screens/passo/Building/edit_building/property_assessement_edit.dart @@ -1129,10 +1129,30 @@ class _PropertyAssessmentEditPage extends State { ), ); } + if (state is MemorandaErrorState) { + return SomethingWentWrong( + message: state.error, + onpressed: () { + context + .read() + .add(const LoadMemoranda()); + }, + ); + } return Container(); }, ); } + if (state is SignatoriesErrorState) { + return SomethingWentWrong( + message: state.error, + onpressed: () { + context + .read() + .add(const LoadSignatories()); + }, + ); + } return Container(); }, ); diff --git a/lib/screens/passo/Land/add_land/AddLandValueAdjustmentModal.dart b/lib/screens/passo/Land/add_land/AddLandValueAdjustmentModal.dart index 7041356..09ecc48 100644 --- a/lib/screens/passo/Land/add_land/AddLandValueAdjustmentModal.dart +++ b/lib/screens/passo/Land/add_land/AddLandValueAdjustmentModal.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:intl/intl.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:unit2/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart'; @@ -105,394 +107,421 @@ class _AddLandValueAdjustmentModal extends State { @override Widget build(BuildContext context) { - return BlocBuilder( - buildWhen: (previous, current) { - return false; - }, builder: (context, state) { - if (state is ShowAddLandValueAdjustmentsScreen) { - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocBuilder( + buildWhen: (previous, current) { + return false; }, builder: (context, state) { - if (state is LandAppraisalLoaded) { - final land_appr = state.land_appr; - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, - builder: (context, state) { - if (state is TypeOfRoadLoaded) { - final roadType = state.road_type; - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, - builder: (context, state) { - if (state is TypeOfLocationLoaded) { - return FormBuilder( - key: otherImpKey, - onChanged: () { - otherImpKey.currentState?.save(); - }, - autovalidateMode: AutovalidateMode.disabled, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: SingleChildScrollView( + if (state is ShowAddLandValueAdjustmentsScreen) { + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, builder: (context, state) { + if (state is LandAppraisalLoaded) { + final land_appr = state.land_appr; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is TypeOfRoadLoaded) { + final roadType = state.road_type; + return BlocConsumer( + listener: (context, state) { + // TODO: implement listener + }, + builder: (context, state) { + if (state is TypeOfLocationLoaded) { + return FormBuilder( + key: otherImpKey, + onChanged: () { + otherImpKey.currentState?.save(); + }, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( padding: const EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, - top: 10, - right: 0, - bottom: 0), - child: Expanded( - flex: 1, - child: - FormBuilderDropdown( - name: 'land_appr_item', - autofocus: false, - decoration: normalTextFieldStyle( - "Land Appraisal Items", ""), - items: land_appr - .map((land_appr) => - DropdownMenuItem< - LandAppr?>( - value: land_appr, - child: Text((land_appr - .subClass ?? - "")), - )) - .toList(), - onChanged: (selectedLandAppr) { - if (selectedLandAppr != null) { - setState(() { - _unitValue = double.parse( - selectedLandAppr - .baseMarketval!); - }); - } - }, - )), - ), - SizedBox( - height: 10, - ), - Text("Adjustment Factors"), - Container( - margin: const EdgeInsets.only( - left: 0, - top: 10, - right: 0, - bottom: 0), - child: Expanded( - flex: 1, - child: FormBuilderDropdown< - TypeOfRoad?>( - name: 'road_type', - autofocus: false, - decoration: normalTextFieldStyle( - "Type of Road", ""), - items: roadType - .map((roadType) => - DropdownMenuItem< - TypeOfRoad?>( - value: roadType, - child: Text((roadType - .roadType ?? - "")), - )) - .toList(), - onChanged: (selectedRoad) { - if (selectedRoad != null) { - setState(() { - _roadTypeDeduction = - double.parse( - selectedRoad - .deduction!); - _roadType = - selectedRoad.roadType!; - }); - } - }, - )), - ), - SizedBox( - height: 10, - ), - Text("Type of Location"), - Container( - margin: const EdgeInsets.only( - left: 0, - top: 10, - right: 0, - bottom: 0), - child: Expanded( - flex: 1, - child: FormBuilderDropdown< - TypeOfLocation?>( - name: 'loc_type_road', - autofocus: false, - decoration: normalTextFieldStyle( - "Distance to Road", ""), - items: state.loc_type - .map((locTypeRoad) => - DropdownMenuItem< - TypeOfLocation?>( - value: locTypeRoad, - child: Text((locTypeRoad - .distanceKm ?? - "")), - )) - .toList(), - onChanged: (selectedLoadRoad) { - if (selectedLoadRoad != null) { - setState(() { - _locTypeRoad = double.parse( - selectedLoadRoad - .allRoadTypes!); - _locRdDistance = - selectedLoadRoad - .distanceKm!; - }); - } - }, - )), - ), - Container( - margin: const EdgeInsets.only( - left: 0, - top: 10, - right: 0, - bottom: 0), - child: Expanded( - flex: 1, - child: FormBuilderDropdown< - TypeOfLocation?>( - name: 'loc_type_pob', - autofocus: false, - decoration: normalTextFieldStyle( - "Distance to Poblacion", ""), - items: state.loc_type - .map((locTypePob) => - DropdownMenuItem< - TypeOfLocation?>( - value: locTypePob, - child: Text((locTypePob - .distanceKm ?? - "")), - )) - .toList(), - onChanged: (selectedLocPob) { - if (selectedLocPob != null) { - setState(() { - _locTypePob = double.parse( - selectedLocPob - .localTradingCenter!); - - _locPobDistance = - selectedLocPob - .distanceKm!; - }); - } - }, - )), - ), - const SizedBox(height: 10), - 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( - (calculateAdjustment() * 100) - .toString() + - '%'), - ), - ), - const SizedBox(height: 10), - Container( - height: 45.0, - width: double.infinity, - decoration: BoxDecoration( - color: Colors.white, - border: Border.all( - color: Colors.grey, - width: 1.0, - ), - borderRadius: - BorderRadius.circular(5.0), - ), - child: Align( - alignment: Alignment.center, - child: Text(NumberFormat.currency( - locale: 'en-PH', - symbol: "₱", - ).format(calculateValueAdjustment())), - ), - ), - const SizedBox(height: 10), - Container( - height: 45.0, - width: double.infinity, - decoration: BoxDecoration( - color: Colors.white, - border: Border.all( - color: Colors.grey, - width: 1.0, - ), - borderRadius: - BorderRadius.circular(5.0), - ), - child: Align( - alignment: Alignment.center, - child: Text(NumberFormat.currency( - locale: 'en-PH', - symbol: "₱", - ).format(calculateMarketValue())), - ), - ), - const SizedBox(height: 10), - Row( - children: [ + child: Container( + child: SingleChildScrollView( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ Container( - width: 120, - height: 60, - padding: const EdgeInsets.all(8.0), - child: ElevatedButton( - onPressed: () async { - final tempID = - await SharedPreferences - .getInstance(); - print(tempID.getInt('landid')); - var adjustments = ValueAdjustments( - landapprDetailsId: tempID - .getInt('landid')! - - 1, - baseMarketval: - _unitValue.toString(), - adjustmentFactors: - _roadType + + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown< + LandAppr?>( + name: 'land_appr_item', + autofocus: false, + decoration: + normalTextFieldStyle( + "Land Appraisal Items", + ""), + items: land_appr + .map((land_appr) => + DropdownMenuItem< + LandAppr?>( + value: land_appr, + child: Text((land_appr + .subClass ?? + "")), + )) + .toList(), + onChanged: + (selectedLandAppr) { + if (selectedLandAppr != + null) { + setState(() { + _unitValue = double.parse( + selectedLandAppr + .baseMarketval!); + }); + } + }, + )), + ), + SizedBox( + height: 10, + ), + Text("Adjustment Factors"), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown< + TypeOfRoad?>( + name: 'road_type', + autofocus: false, + decoration: + normalTextFieldStyle( + "Type of Road", ""), + items: roadType + .map((roadType) => + DropdownMenuItem< + TypeOfRoad?>( + value: roadType, + child: Text((roadType + .roadType ?? + "")), + )) + .toList(), + onChanged: (selectedRoad) { + if (selectedRoad != null) { + setState(() { + _roadTypeDeduction = + double.parse( + selectedRoad + .deduction!); + _roadType = selectedRoad + .roadType!; + }); + } + }, + )), + ), + SizedBox( + height: 10, + ), + Text("Type of Location"), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown< + TypeOfLocation?>( + name: 'loc_type_road', + autofocus: false, + decoration: + normalTextFieldStyle( + "Distance to Road", + ""), + items: state.loc_type + .map((locTypeRoad) => + DropdownMenuItem< + TypeOfLocation?>( + value: locTypeRoad, + child: Text((locTypeRoad + .distanceKm ?? + "")), + )) + .toList(), + onChanged: + (selectedLoadRoad) { + if (selectedLoadRoad != + null) { + setState(() { + _locTypeRoad = double + .parse(selectedLoadRoad + .allRoadTypes!); + _locRdDistance = + selectedLoadRoad + .distanceKm!; + }); + } + }, + )), + ), + Container( + margin: const EdgeInsets.only( + left: 0, + top: 10, + right: 0, + bottom: 0), + child: Expanded( + flex: 1, + child: FormBuilderDropdown< + TypeOfLocation?>( + name: 'loc_type_pob', + autofocus: false, + decoration: + normalTextFieldStyle( + "Distance to Poblacion", + ""), + items: state.loc_type + .map((locTypePob) => + DropdownMenuItem< + TypeOfLocation?>( + value: locTypePob, + child: Text((locTypePob + .distanceKm ?? + "")), + )) + .toList(), + onChanged: (selectedLocPob) { + if (selectedLocPob != + null) { + setState(() { + _locTypePob = double + .parse(selectedLocPob + .localTradingCenter!); + + _locPobDistance = + selectedLocPob + .distanceKm!; + }); + } + }, + )), + ), + const SizedBox(height: 10), + 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( + (calculateAdjustment() * 100) + .toString() + + '%'), + ), + ), + const SizedBox(height: 10), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: + BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format( + calculateValueAdjustment())), + ), + ), + const SizedBox(height: 10), + Container( + height: 45.0, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + borderRadius: + BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text(NumberFormat.currency( + locale: 'en-PH', + symbol: "₱", + ).format(calculateMarketValue())), + ), + ), + const SizedBox(height: 10), + Row( + children: [ + Container( + width: 120, + height: 60, + padding: + const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences + .getInstance(); + print(tempID + .getInt('landid')); + var adjustments = ValueAdjustments( + landapprDetailsId: + tempID.getInt( + 'landid')! - + 1, + baseMarketval: + _unitValue + .toString(), + adjustmentFactors: _roadType + ' , ' + _locPobDistance + ' km from road , ' + _locPobDistance + ' km from poblacion', - adjustment: - calculateAdjustment() - .toString(), - valueAdjustment: - calculateValueAdjustment() - .toString(), - marketValue: - calculateMarketValue() - .toString()); + adjustment: + calculateAdjustment() + .toString(), + valueAdjustment: + calculateValueAdjustment() + .toString(), + marketValue: + calculateMarketValue() + .toString()); - context - .read< - LandValueAdjustmentsBloc>() - .add( - AddLandValueAdjustments( + context + .read< + LandValueAdjustmentsBloc>() + .add(AddLandValueAdjustments( val_adj: adjustments)); - }, - style: ElevatedButton.styleFrom( - primary: Colors.black, + }, + style: + ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Submit"), + ), ), - child: const Text("Submit"), - ), - ), - const SizedBox( - width: - 5), // Use SizedBox for horizontal spacing in a Row - Container( - width: 120, - height: 60, - padding: const EdgeInsets.all(8.0), - child: ElevatedButton( - onPressed: () { - context - .read< - LandValueAdjustmentsBloc>() - .add( - const LoadLandValueAdjustments()); - }, - style: ElevatedButton.styleFrom( - primary: Colors.black, + const SizedBox( + width: + 5), // Use SizedBox for horizontal spacing in a Row + Container( + width: 120, + height: 60, + padding: + const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () { + context + .read< + LandValueAdjustmentsBloc>() + .add( + const LoadLandValueAdjustments()); + }, + style: + ElevatedButton.styleFrom( + primary: Colors.black, + ), + child: const Text("Cancel"), + ), ), - child: const Text("Cancel"), - ), - ), + ], + ) ], - ) - ], + ), + ), ), - ), - ), - )); - } - if (state is TypeOfLocationErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context - .read() - .add(LoadTypeOfLocation()); - }, - ); - } - return Container(); - }, - ); - } - if (state is LandAppraisalErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context - .read() - .add(LoadLandAppraisal()); - }, - ); - } - return Container(); - }, - ); + )); + } + if (state is TypeOfLocationErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadTypeOfLocation()); + }, + ); + } + return Container(); + }, + ); + } + if (state is LandAppraisalErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadLandAppraisal()); + }, + ); + } + return Container(); + }, + ); + } + if (state is LandValueAdjustmentsErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadLandValueAdjustments()); + }, + ); + } + return Container(); + }); } if (state is LandValueAdjustmentsErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context - .read() - .add(LoadLandValueAdjustments()); - }, - ); + return Text(state.error); } - return Container(); - }); - } - if (state is LandValueAdjustmentsErrorState) { - return Text(state.error); - } - return Container( - child: Text("Land Value Adjustment"), - ); - }); + return Container( + child: Text("Land Value Adjustment"), + ); + }), + ), + ); } } diff --git a/lib/screens/passo/Land/add_land/AddPropertyAssessmentModal.dart b/lib/screens/passo/Land/add_land/AddPropertyAssessmentModal.dart index 8752a6f..248d9cd 100644 --- a/lib/screens/passo/Land/add_land/AddPropertyAssessmentModal.dart +++ b/lib/screens/passo/Land/add_land/AddPropertyAssessmentModal.dart @@ -68,23 +68,17 @@ class _AddPropertyAssessmentModal extends State { calculateAssessmentValue() { switch (_actualUse) { case "Residential": - return _unitValue * 0.20; - break; + return (_unitValue * 0.20).ceil(); case "Agricultural": - return _unitValue * 0.40; - break; + return (_unitValue * 0.40).ceil(); case "Commercial": - return _unitValue * 0.50; - break; + return (_unitValue * 0.50).ceil(); case "Industrial": - return _unitValue * 0.50; - break; + return (_unitValue * 0.50).ceil(); case "Mineral": - return _unitValue * 0.50; - break; + return (_unitValue * 0.50).ceil(); case "Timberland": - return _unitValue * 0.20; - break; + return (_unitValue * 0.20).ceil(); default: } } @@ -335,7 +329,7 @@ class _AddPropertyAssessmentModal extends State { onpressed: () { context .read() - .add(LoadLandValueAdjustments()); + .add(const LoadLandValueAdjustments()); }, ); } @@ -348,7 +342,7 @@ class _AddPropertyAssessmentModal extends State { onpressed: () { context .read() - .add(LoadLandPropertyAssessment()); + .add(const LoadLandPropertyAssessment()); }, ); } diff --git a/lib/screens/passo/Land/add_land/value_adjustments.dart b/lib/screens/passo/Land/add_land/value_adjustments.dart index 6ab27ed..b4e3321 100644 --- a/lib/screens/passo/Land/add_land/value_adjustments.dart +++ b/lib/screens/passo/Land/add_land/value_adjustments.dart @@ -16,14 +16,6 @@ class ValueAdjustmentPage extends StatefulWidget { } class _ValueAdjustmentPage extends State { - // double _totalMarketValue(items) { - // double total = 0; - // items.forEach((row) { - // total += double.parse(row); - // }); - // return total; - // } - void deleteItem(int itemId) { context .read() diff --git a/lib/screens/passo/Land/edit_land/AddPropertyAssessmentEditModal.dart b/lib/screens/passo/Land/edit_land/AddPropertyAssessmentEditModal.dart index b96977d..dfe078d 100644 --- a/lib/screens/passo/Land/edit_land/AddPropertyAssessmentEditModal.dart +++ b/lib/screens/passo/Land/edit_land/AddPropertyAssessmentEditModal.dart @@ -70,22 +70,22 @@ class _AddPropertyAssessmentEditModal calculateAssessmentValue() { switch (_actualUse) { case "Residential": - return _unitValue * 0.20; + return (_unitValue * 0.20).ceil(); break; case "Agricultural": - return _unitValue * 0.40; + return (_unitValue * 0.40).ceil(); break; case "Commercial": - return _unitValue * 0.50; + return (_unitValue * 0.50).ceil(); break; case "Industrial": - return _unitValue * 0.50; + return (_unitValue * 0.50).ceil(); break; case "Mineral": - return _unitValue * 0.50; + return (_unitValue * 0.50).ceil(); break; case "Timberland": - return _unitValue * 0.20; + return (_unitValue * 0.20).ceil(); break; default: } @@ -278,7 +278,7 @@ class _AddPropertyAssessmentEditModal child: ElevatedButton( onPressed: () async { var assessment = LandPropertyAssessment( - landapprDetailsId: widget.tempId, + landapprDetailsId: 35, actualUse: _actualUse, marketval: _unitValue.toString(), assessmentLevel: _assessmentLevel, @@ -287,7 +287,7 @@ class _AddPropertyAssessmentEditModal .toString(), totalMarketval: '0', totalAssessedval: '0'); - + print(assessment.toJson()); context .read() .add(AddLandPropertyAssessment( diff --git a/lib/screens/passo/Land/edit_land/land_appraisal.dart b/lib/screens/passo/Land/edit_land/land_appraisal.dart index 7cb966e..47bb838 100644 --- a/lib/screens/passo/Land/edit_land/land_appraisal.dart +++ b/lib/screens/passo/Land/edit_land/land_appraisal.dart @@ -266,10 +266,8 @@ class _LandAppraisalEdit extends State { alignment: Alignment.topCenter, child: Container( child: ConstrainedBox( - constraints: BoxConstraints(maxHeight: 500), - child: Container( - child: AddLandAppraisalEditModal(widget.faasId), - ), + constraints: const BoxConstraints(maxHeight: 500), + child: AddLandAppraisalEditModal(widget.faasId), ), ), ), @@ -283,7 +281,7 @@ class _LandAppraisalEdit extends State { message: onError, onpressed: () { context.read().add(LoadLandAppraisalEdit( - land_appr: [], id: widget.faasId!)); + land_appr: const [], id: widget.faasId!)); }, ); } diff --git a/lib/screens/passo/building_home.dart b/lib/screens/passo/building_home.dart index a477e5c..e31c053 100644 --- a/lib/screens/passo/building_home.dart +++ b/lib/screens/passo/building_home.dart @@ -53,6 +53,7 @@ import 'package:unit2/screens/passo/Test%20Envi/speed_dial.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/utils/global_context.dart'; import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/empty_data.dart'; import 'package:unit2/widgets/error_state.dart'; import 'package:flutter_speed_dial/flutter_speed_dial.dart'; @@ -106,24 +107,30 @@ class BuildingHome extends StatelessWidget { }, builder: (context, state) { if (state is PropertyInfoLoaded) { - List propertyList = state.property_info; - return Container( - padding: const EdgeInsets.symmetric(horizontal: 12), - child: Column( - children: [ - Expanded( - child: ListView.builder( - shrinkWrap: true, - itemCount: propertyList.length, - itemBuilder: (BuildContext context, int index) { - return _listCard(propertyList[index], context, - index, deleteItem); - }, + if (state.property_info.isNotEmpty) { + List propertyList = state.property_info; + return Container( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: Column( + children: [ + Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: propertyList.length, + itemBuilder: (BuildContext context, int index) { + return _listCard(propertyList[index], context, + index, deleteItem); + }, + ), ), - ), - ], - ), - ); + ], + ), + ); + } else { + return const EmptyData( + message: + "You don't have any building faas added. Please click + to add"); + } } if (state is PropertyInfoErrorState) { return SomethingWentWrong( diff --git a/lib/screens/passo/land_home .dart b/lib/screens/passo/land_home .dart index bec0acf..8a5d6e5 100644 --- a/lib/screens/passo/land_home .dart +++ b/lib/screens/passo/land_home .dart @@ -47,6 +47,7 @@ import 'package:unit2/screens/passo/Land/edit_land.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/utils/alerts.dart'; import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/empty_data.dart'; import 'package:unit2/widgets/error_state.dart'; import 'package:flutter_speed_dial/flutter_speed_dial.dart'; @@ -94,24 +95,30 @@ class LandHome extends StatelessWidget { }, builder: (context, state) { if (state is LandLoaded) { - List propertyList = state.land; - return Container( - padding: const EdgeInsets.symmetric(horizontal: 12), - child: Column( - children: [ - Expanded( - child: ListView.builder( - shrinkWrap: true, - itemCount: propertyList.length, - itemBuilder: (BuildContext context, int index) { - return _listCard(propertyList[index], context, - index, deleteItem); - }, + if (state.land.isNotEmpty) { + List propertyList = state.land; + return Container( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: Column( + children: [ + Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: propertyList.length, + itemBuilder: (BuildContext context, int index) { + return _listCard(propertyList[index], context, + index, deleteItem); + }, + ), ), - ), - ], - ), - ); + ], + ), + ); + } else { + return const EmptyData( + message: + "You don't have any land faas added. Please click + to add"); + } } if (state is LandErrorState) { return SomethingWentWrong( diff --git a/pubspec.yaml b/pubspec.yaml index dedf640..e19d2bf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -99,6 +99,7 @@ dependencies: share_plus: ^7.1.0 animated_splash_screen: ^1.3.0 sqflite: ^2.3.0 + dependency_overrides: intl: ^0.18.0