From 75cfe68bd156dc0a557ed3708cad29be6aa1bc5f Mon Sep 17 00:00:00 2001 From: cyzoox Date: Mon, 25 Sep 2023 14:39:55 +0800 Subject: [PATCH 1/4] Added delete on Land Faas;Added auto-refresh/auto-reload on adding new faas --- .../passo/land/land_ext/land_ext_bloc.dart | 3 +- .../land_property_owner_info_bloc.dart | 20 + .../land_property_owner_info_event.dart | 9 + .../land_property_owner_info_state.dart | 15 + lib/screens/passo/Building/add_building.dart | 5 +- .../property_assessment.dart | 20 +- lib/screens/passo/Land/add_land.dart | 6 +- .../add_land/AddLandValueAdjustmentModal.dart | 33 +- .../passo/Land/add_land/land_appraisal.dart | 454 ++++---- .../Land/add_land/other_improvements.dart | 466 +++++---- .../Land/add_land/property_assessment.dart | 424 ++++---- .../add_land/property_assessment_cont.dart | 969 ++++++++++-------- .../Land/add_land/value_adjustments.dart | 432 ++++---- lib/screens/passo/building_home.dart | 7 +- lib/screens/passo/land_home .dart | 60 +- .../passo/land/land_property_owner.dart | 25 + lib/utils/urls.dart | 9 +- 17 files changed, 1627 insertions(+), 1330 deletions(-) diff --git a/lib/bloc/passo/land/land_ext/land_ext_bloc.dart b/lib/bloc/passo/land/land_ext/land_ext_bloc.dart index 7fa7292..1043c2d 100644 --- a/lib/bloc/passo/land/land_ext/land_ext_bloc.dart +++ b/lib/bloc/passo/land/land_ext/land_ext_bloc.dart @@ -42,7 +42,8 @@ class LandExtBloc extends Bloc { }); on((event, emit) async { final tempID = await SharedPreferences.getInstance(); - final tempID2 = tempID.getInt('tempid')! - 1; + final tempID2 = tempID.getInt('landid')! - 1; + http.Response response = (await LandExtServices.instance.update(event.landext, tempID2))!; print('landext'); diff --git a/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart b/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart index 9f9ec3f..0fa5c99 100644 --- a/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart +++ b/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart @@ -59,6 +59,11 @@ class LandPropertyOwnerInfoBloc print(event.land_loc.id!); print('Land LOc'); print(response.statusCode); + if (response.statusCode == 200) { + emit(ShowLandLocSuccessAlertState()); + } else { + emit(ShowLandLocErrorAlertState()); + } }); on((event, emit) async { @@ -67,6 +72,21 @@ class LandPropertyOwnerInfoBloc .update(event.land_boundaries, event.land_boundaries.id))!; print('Land Boundaries'); print(response.body); + if (response.statusCode == 200) { + emit(ShowLandBoundariesSuccessState()); + } else { + emit(ShowLandBoundariesErrorAlertState()); + } + }); + + on((event, emit) async { + print(event.id); + emit(LandLoading()); + http.Response response = (await LandServices.instance.remove(event.id)); + print(response.statusCode); + if (response.statusCode == 200) { + emit(LandFaasDeletedState(success: true)); + } }); } } diff --git a/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_event.dart b/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_event.dart index 58820b6..267c75a 100644 --- a/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_event.dart +++ b/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_event.dart @@ -58,3 +58,12 @@ class UpdateLandBoundaries extends LandPropertyOwnerInfoEvent { @override List get props => [land_boundaries]; } + +class DeleteLandFaas extends LandPropertyOwnerInfoEvent { + final int id; + + const DeleteLandFaas({required this.id}); + + @override + List get props => [id]; +} diff --git a/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_state.dart b/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_state.dart index a519420..360e5bb 100644 --- a/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_state.dart +++ b/lib/bloc/passo/land/land_property_owner_info/land_property_owner_info_state.dart @@ -24,3 +24,18 @@ class LandErrorState extends LandPropertyOwnerInfoState { @override List get props => [error]; } + +class LandFaasDeletedState extends LandPropertyOwnerInfoState { + final bool success; + const LandFaasDeletedState({required this.success}); + @override + List get props => [success]; +} + +class ShowLandLocErrorAlertState extends LandPropertyOwnerInfoState {} + +class ShowLandBoundariesErrorAlertState extends LandPropertyOwnerInfoState {} + +class ShowLandLocSuccessAlertState extends LandPropertyOwnerInfoState {} + +class ShowLandBoundariesSuccessState extends LandPropertyOwnerInfoState {} diff --git a/lib/screens/passo/Building/add_building.dart b/lib/screens/passo/Building/add_building.dart index e87d3e9..fc000c8 100644 --- a/lib/screens/passo/Building/add_building.dart +++ b/lib/screens/passo/Building/add_building.dart @@ -31,6 +31,8 @@ import 'package:unit2/widgets/error_state.dart'; GlobalKey formKey = GlobalKey(); class AddBuilding extends StatefulWidget { + Function triggerBlocEvent; + AddBuilding(this.triggerBlocEvent); @override _AddBuilding createState() => _AddBuilding(); } @@ -293,6 +295,7 @@ class _AddBuilding extends State { } void onSAveAll() { - return Navigator.of(context).pop(); + Navigator.of(context).pop(); + widget.triggerBlocEvent(); } } 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 386df67..9220f97 100644 --- a/lib/screens/passo/Building/add_building_components/property_assessment.dart +++ b/lib/screens/passo/Building/add_building_components/property_assessment.dart @@ -589,7 +589,7 @@ class _PropertyAssessmentPage extends State { style: ElevatedButton.styleFrom( backgroundColor: primary, foregroundColor: Colors.red), - child: SizedBox( + child: const SizedBox( width: 200, height: 50, child: Align( @@ -604,7 +604,7 @@ class _PropertyAssessmentPage extends State { ), ), ), - SizedBox( + const SizedBox( height: 30, ), ]), @@ -613,10 +613,26 @@ class _PropertyAssessmentPage extends State { ], ); } + if (state is MemorandaErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadMemoranda()); + }, + ); + } return Container(); }, ); } + if (state is SignatoriesErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadSignatories()); + }, + ); + } return Container(); }, ))); diff --git a/lib/screens/passo/Land/add_land.dart b/lib/screens/passo/Land/add_land.dart index 4b7e3aa..da0c906 100644 --- a/lib/screens/passo/Land/add_land.dart +++ b/lib/screens/passo/Land/add_land.dart @@ -48,16 +48,16 @@ class _AddLand extends State { appBar: AppBar( centerTitle: true, backgroundColor: primary, - title: Text('Land FAAS'), + title: const Text('Land FAAS'), ), body: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ NumberStepper( - numbers: [1, 2, 3, 4, 5, 6, 7], + numbers: const [1, 2, 3, 4, 5, 6, 7], activeStepColor: primary, - numberStyle: TextStyle(color: Colors.white), + numberStyle: const TextStyle(color: Colors.white), lineColor: primary, // activeStep property set to activeStep variable defined above. activeStep: activeStep, diff --git a/lib/screens/passo/Land/add_land/AddLandValueAdjustmentModal.dart b/lib/screens/passo/Land/add_land/AddLandValueAdjustmentModal.dart index 64a53b6..7041356 100644 --- a/lib/screens/passo/Land/add_land/AddLandValueAdjustmentModal.dart +++ b/lib/screens/passo/Land/add_land/AddLandValueAdjustmentModal.dart @@ -12,6 +12,8 @@ import 'package:unit2/model/passo/land_value_adjustment.dart'; import 'package:unit2/model/passo/type_of_location.dart'; import 'package:unit2/model/passo/type_of_road.dart'; import 'package:unit2/theme-data.dart/form-style.dart'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; class AddLandValueAdjustmentModal extends StatefulWidget { // final List unit; @@ -444,15 +446,44 @@ class _AddLandValueAdjustmentModal extends State { ), )); } + 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(); }); } diff --git a/lib/screens/passo/Land/add_land/land_appraisal.dart b/lib/screens/passo/Land/add_land/land_appraisal.dart index e881636..fd8e5e3 100644 --- a/lib/screens/passo/Land/add_land/land_appraisal.dart +++ b/lib/screens/passo/Land/add_land/land_appraisal.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/land/land_appraisal/land_appraisal_bloc.dart'; import 'package:unit2/model/passo/land_appr.dart'; @@ -32,229 +34,249 @@ class _LandAppraisal extends State { @override Widget build(BuildContext context) { - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, builder: (context, state) { - final state = context.watch().state; - if (state is LandAppraisalLoaded) { - return Column( - children: [ - Expanded( - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 10), - child: const Text('LAND APPRAISAL', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Align( - alignment: Alignment.topRight, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red, + 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 LandAppraisalLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is LandAppraisalLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is LandAppraisalErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, builder: (context, state) { + final state = context.watch().state; + if (state is LandAppraisalLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('LAND APPRAISAL', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), ), - onPressed: () { - context - .read() - .add(ShowLandAppraisal()); - }, - 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(ShowLandAppraisal()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('ADD ITEM'), // <-- Text + const SizedBox( + width: 5, + ), + const Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], ), - ], + ), ), - ), - ), - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: DataTable( - // ignore: prefer_const_literals_to_create_immutables - columns: [ - const DataColumn( - label: Text('Classification'), - ), - const DataColumn( - label: Text('Sub-Classification'), - ), - const DataColumn( - label: Text('Area'), - ), - const DataColumn( - label: Text('Unit Value'), - ), - const DataColumn( - label: Text('Base MArket Value'), - ), - const DataColumn( - label: Text('Action'), - ) - ], - rows: state.land_appr.map((dataRow) { - return DataRow( - cells: [ - DataCell(Text(dataRow.classification!)), - DataCell(Text(dataRow.subClass!)), - DataCell(Text(dataRow.area!)), - DataCell(Text( - ((double.parse(dataRow.unitValue!))) - .toString())), - DataCell(Text( - ((double.parse(dataRow.baseMarketval!))) - .toString())), - DataCell(Row( - children: [ - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.delete, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () { - deleteItem(dataRow.id!); - }, - ), - SizedBox( - width: 10, - ), - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.edit, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () {}, - ), - ], - )) + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Classification'), + ), + const DataColumn( + label: Text('Sub-Classification'), + ), + const DataColumn( + label: Text('Area'), + ), + const DataColumn( + label: Text('Unit Value'), + ), + const DataColumn( + label: Text('Base MArket Value'), + ), + const DataColumn( + label: Text('Action'), + ) ], - ); - }).toList())) + rows: state.land_appr.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.classification!)), + DataCell(Text(dataRow.subClass!)), + DataCell(Text(dataRow.area!)), + DataCell(Text( + ((double.parse(dataRow.unitValue!))) + .toString())), + DataCell(Text(((double.parse( + dataRow.baseMarketval!))) + .toString())), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + deleteItem(dataRow.id!); + }, + ), + SizedBox( + width: 10, + ), + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.edit, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () {}, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is LandAppraisalDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context + .read() + .add(const LoadLandAppraisal()); + }); + }); + } + } + if (state is ShowAddLandAppraisalScreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: Text( + 'ADD LAND APPRAISAL', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(child: AddLandAppraisalModal()), ], ), ), - )), - // Padding( - // padding: const EdgeInsets.only(left: 20.0, right: 20.0), - // child: Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // Text( - // 'Total', - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ), - // Text( - // NumberFormat.currency(locale: 'en-PH', symbol: "₱") - // .format('1.0'), - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ) - // ], - // ), - // ), - Padding( - padding: const EdgeInsets.all(15.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - CustomButton( - icon: const Icon(Icons.chevron_left_rounded, - color: Colors.white), - onPressed: () { - { - widget.PrevBtn(); - } - ; - }, - ), - CustomButton( - icon: const Icon(Icons.chevron_right_rounded, - color: Colors.white), - onPressed: () { - { - widget.NextBtn(); - } - ; - }, - ) - ], - ), - ), - ], - ); - } - if (state is LandAppraisalDeletedState) { - if (state.success) { - WidgetsBinding.instance.addPostFrameCallback((_) { - successAlert(context, "Deletion Successful", - "Extra item has been deleted successfully", () { - Navigator.of(context).pop(); - context.read().add(const LoadLandAppraisal()); - }); - }); - } - } - if (state is ShowAddLandAppraisalScreen) { - return ConstrainedBox( - constraints: BoxConstraints(maxHeight: 1000.0), - child: AlertDialog( - insetPadding: EdgeInsets.symmetric( - horizontal: 20.0, - vertical: 10.0, - ), - title: Text( - 'ADD LAND APPRAISAL', - textAlign: TextAlign.center, - ), - content: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded(child: AddLandAppraisalModal()), - ], - ), - ), - ); - } - if (state is LandAppraisalErrorState) { - return SomethingWentWrong( - message: onError, - onpressed: () { - context.read().add(LoadLandAppraisal()); - }, - ); - } - return Container(); - }); + ); + } + if (state is LandAppraisalErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadLandAppraisal()); + }, + ); + } + return Container(); + }), + ), + ); } } diff --git a/lib/screens/passo/Land/add_land/other_improvements.dart b/lib/screens/passo/Land/add_land/other_improvements.dart index 295e1b7..45b99aa 100644 --- a/lib/screens/passo/Land/add_land/other_improvements.dart +++ b/lib/screens/passo/Land/add_land/other_improvements.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:unit2/bloc/passo/land/other_improvements/other_improvements_bloc.dart'; import 'package:unit2/screens/passo/Land/add_land/AddOtherImprovementModal.dart'; import 'package:unit2/utils/alerts.dart'; @@ -30,234 +32,254 @@ class _OtherImprovementPage extends State { @override Widget build(BuildContext context) { - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, builder: (context, state) { - final state = context.watch().state; - if (state is OtherImprovementLoaded) { - return Column( - children: [ - Expanded( - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 10), - child: const Text('OTHER IMPROVEMENTS', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Align( - alignment: Alignment.topRight, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red, + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + listener: (context, state) { + if (state is OtherImprovementLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is OtherImprovementLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is OtherImprovementErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, builder: (context, state) { + final state = context.watch().state; + if (state is OtherImprovementLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('OTHER IMPROVEMENTS', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), ), - onPressed: () { - context - .read() - .add(ShowOtherImprovement()); - }, - 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(ShowOtherImprovement()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('ADD ITEM'), // <-- Text + const SizedBox( + width: 5, + ), + const Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], ), - ], + ), ), - ), - ), - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: DataTable( - // ignore: prefer_const_literals_to_create_immutables - columns: [ - const DataColumn( - label: Text('Kinds of Tress'), - ), - const DataColumn( - label: Text('Sub-Class / Age'), - ), - const DataColumn( - label: Text('Type of Tree'), - ), - const DataColumn( - label: Text('No.'), - ), - const DataColumn( - label: Text('No. of Productive'), - ), - const DataColumn( - label: Text('No. of Non-Productive'), - ), - const DataColumn( - label: Text('Unit Value'), - ), - const DataColumn( - label: Text('Base Market Value'), - ), - const DataColumn( - label: Text('Action'), - ) - ], - rows: state.other_imp.map((dataRow) { - return DataRow( - cells: [ - DataCell(Text(dataRow.kindsOfTrees!)), - DataCell(Text(dataRow.subclassAge!)), - DataCell(Text(dataRow.fruitBearing! - ? "Fruit Bearing" - : "Non-Fruit Bearing")), - DataCell(Text(dataRow.quantity.toString()!)), - DataCell( - Text(dataRow.noOfProductive.toString()!)), - DataCell(Text( - dataRow.noOfNonproductive.toString()!)), - DataCell(Text(dataRow.unitValue.toString()!)), - DataCell( - Text(dataRow.baseMarketval.toString()!)), - DataCell(Row( - children: [ - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.delete, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () { - deleteItem(dataRow.id!); - }, - ), - SizedBox( - width: 10, - ), - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.edit, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () {}, - ), - ], - )) + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Kinds of Tress'), + ), + const DataColumn( + label: Text('Sub-Class / Age'), + ), + const DataColumn( + label: Text('Type of Tree'), + ), + const DataColumn( + label: Text('No.'), + ), + const DataColumn( + label: Text('No. of Productive'), + ), + const DataColumn( + label: Text('No. of Non-Productive'), + ), + const DataColumn( + label: Text('Unit Value'), + ), + const DataColumn( + label: Text('Base Market Value'), + ), + const DataColumn( + label: Text('Action'), + ) ], - ); - }).toList())) - ], + rows: state.other_imp.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.kindsOfTrees!)), + DataCell(Text(dataRow.subclassAge!)), + DataCell(Text(dataRow.fruitBearing! + ? "Fruit Bearing" + : "Non-Fruit Bearing")), + DataCell( + Text(dataRow.quantity.toString()!)), + DataCell(Text( + dataRow.noOfProductive.toString()!)), + DataCell(Text(dataRow.noOfNonproductive + .toString()!)), + DataCell( + Text(dataRow.unitValue.toString()!)), + DataCell(Text( + dataRow.baseMarketval.toString()!)), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + deleteItem(dataRow.id!); + }, + ), + SizedBox( + width: 10, + ), + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.edit, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () {}, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is OtherImprovementDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context + .read() + .add(const LoadOtherImprovement()); + }); + }); + } + } + if (state is ShowAddOtherImprovementScreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: Text( + 'ADD OTHER IMPROVEMENTS', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [Expanded(child: AddOtherImprovementModal())], ), ), - )), - // Padding( - // padding: const EdgeInsets.only(left: 20.0, right: 20.0), - // child: Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // Text( - // 'Total', - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ), - // Text( - // NumberFormat.currency(locale: 'en-PH', symbol: "₱") - // .format('1.0'), - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ) - // ], - // ), - // ), - Padding( - padding: const EdgeInsets.all(15.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - CustomButton( - icon: const Icon(Icons.chevron_left_rounded, - color: Colors.white), - onPressed: () { - { - widget.PrevBtn(); - } - ; - }, - ), - CustomButton( - icon: const Icon(Icons.chevron_right_rounded, - color: Colors.white), - onPressed: () { - { - widget.NextBtn(); - } - ; - }, - ) - ], - ), - ), - ], - ); - } - if (state is OtherImprovementDeletedState) { - if (state.success) { - WidgetsBinding.instance.addPostFrameCallback((_) { - successAlert(context, "Deletion Successful", - "Extra item has been deleted successfully", () { - Navigator.of(context).pop(); - context - .read() - .add(const LoadOtherImprovement()); - }); - }); - } - } - if (state is ShowAddOtherImprovementScreen) { - return ConstrainedBox( - constraints: BoxConstraints(maxHeight: 1000.0), - child: AlertDialog( - insetPadding: EdgeInsets.symmetric( - horizontal: 20.0, - vertical: 10.0, - ), - title: Text( - 'ADD OTHER IMPROVEMENTS', - textAlign: TextAlign.center, - ), - content: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [Expanded(child: AddOtherImprovementModal())], - ), - ), - ); - } - return Container(); - }); + ); + } + return Container(); + }), + ), + ); } } diff --git a/lib/screens/passo/Land/add_land/property_assessment.dart b/lib/screens/passo/Land/add_land/property_assessment.dart index 19f43bf..69f5a08 100644 --- a/lib/screens/passo/Land/add_land/property_assessment.dart +++ b/lib/screens/passo/Land/add_land/property_assessment.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:unit2/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart'; import 'package:unit2/screens/passo/Land/add_land/AddPropertyAssessmentModal.dart'; import 'package:unit2/utils/alerts.dart'; @@ -30,214 +32,232 @@ class _LandPropertyAssessmentPage 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 LandPropertyAssessmentLoaded) { - return Column( - children: [ - Expanded( - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 10), - child: const Text('PROPERTY ASSESSMENT', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Align( - alignment: Alignment.topRight, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red, + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer(listener: (context, state) { + if (state is LandPropertyAssessmentLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is LandPropertyAssessmentLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is LandPropertyAssessmentErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, builder: (context, state) { + final state = context.watch().state; + if (state is LandPropertyAssessmentLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('PROPERTY ASSESSMENT', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), ), - onPressed: () { - context - .read() - .add(ShowLandPropertyAssessment()); - }, - 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(ShowLandPropertyAssessment()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('ADD ITEM'), // <-- Text + const SizedBox( + width: 5, + ), + const Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], ), - ], + ), ), - ), - ), - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: DataTable( - // ignore: prefer_const_literals_to_create_immutables - columns: [ - const DataColumn( - label: Text('Actual Use'), - ), - const DataColumn( - label: Text('Market Value'), - ), - const DataColumn( - label: Text('Assessment Level'), - ), - const DataColumn( - label: Text('Assessed Value'), - ), - const DataColumn( - label: Text('Action'), - ) - ], - rows: state.assessment.map((dataRow) { - return DataRow( - cells: [ - DataCell(Text(dataRow.actualUse!)), - DataCell(Text(dataRow.marketval!)), - DataCell( - Text(dataRow.assessmentLevel! + '%')), - DataCell(Text(dataRow.assessedValue!)), - DataCell(Row( - children: [ - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.delete, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () { - deleteItem(dataRow.id!); - }, - ), - SizedBox( - width: 10, - ), - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.edit, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () {}, - ), - ], - )) + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Actual Use'), + ), + const DataColumn( + label: Text('Market Value'), + ), + const DataColumn( + label: Text('Assessment Level'), + ), + const DataColumn( + label: Text('Assessed Value'), + ), + const DataColumn( + label: Text('Action'), + ) ], - ); - }).toList())) - ], + rows: state.assessment.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.actualUse!)), + DataCell(Text(dataRow.marketval!)), + DataCell( + Text(dataRow.assessmentLevel! + '%')), + DataCell(Text(dataRow.assessedValue!)), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + deleteItem(dataRow.id!); + }, + ), + SizedBox( + width: 10, + ), + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.edit, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () {}, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is LandPropertyAssessmentDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context + .read() + .add(const LoadLandPropertyAssessment()); + }); + }); + } + } + if (state is ShowAddLandPropertyAssessmentScreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: Text( + 'ADD PROPERTY ASSESSMENT', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [Expanded(child: AddPropertyAssessmentModal())], ), ), - )), - // Padding( - // padding: const EdgeInsets.only(left: 20.0, right: 20.0), - // child: Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // Text( - // 'Total', - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ), - // Text( - // NumberFormat.currency(locale: 'en-PH', symbol: "₱") - // .format('1.0'), - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ) - // ], - // ), - // ), - Padding( - padding: const EdgeInsets.all(15.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - CustomButton( - icon: const Icon(Icons.chevron_left_rounded, - color: Colors.white), - onPressed: () { - { - widget.PrevBtn(); - } - ; - }, - ), - CustomButton( - icon: const Icon(Icons.chevron_right_rounded, - color: Colors.white), - onPressed: () { - { - widget.NextBtn(); - } - ; - }, - ) - ], - ), - ), - ], - ); - } - if (state is LandPropertyAssessmentDeletedState) { - if (state.success) { - WidgetsBinding.instance.addPostFrameCallback((_) { - successAlert(context, "Deletion Successful", - "Extra item has been deleted successfully", () { - Navigator.of(context).pop(); - context - .read() - .add(const LoadLandPropertyAssessment()); - }); - }); - } - } - if (state is ShowAddLandPropertyAssessmentScreen) { - return ConstrainedBox( - constraints: BoxConstraints(maxHeight: 1000.0), - child: AlertDialog( - insetPadding: EdgeInsets.symmetric( - horizontal: 20.0, - vertical: 10.0, - ), - title: Text( - 'ADD PROPERTY ASSESSMENT', - textAlign: TextAlign.center, - ), - content: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [Expanded(child: AddPropertyAssessmentModal())], - ), - ), - ); - } - return Container(); - }); + ); + } + return Container(); + }), + ), + ); } } diff --git a/lib/screens/passo/Land/add_land/property_assessment_cont.dart b/lib/screens/passo/Land/add_land/property_assessment_cont.dart index ad1f710..cf2f93f 100644 --- a/lib/screens/passo/Land/add_land/property_assessment_cont.dart +++ b/lib/screens/passo/Land/add_land/property_assessment_cont.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:searchfield/searchfield.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -12,6 +14,8 @@ import 'package:unit2/model/passo/memoranda.dart'; import 'package:unit2/model/passo/signatories.dart'; import 'package:unit2/screens/passo/Land/add_land.dart'; import 'package:unit2/theme-data.dart/colors.dart'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; class LandSignatories extends StatefulWidget { Function onSAve; @@ -28,162 +32,412 @@ class _LandSignatories extends State { String _memoranda = ""; @override Widget build(BuildContext context) { - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, - builder: (context, state) { - if (state is LandExtLoaded) { - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, - builder: (context, state) { - if (state is SignatoriesLoaded) { - final signatories = state.signatories; - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, - builder: (context, state) { - if (state is MemorandaLoaded) { - return SingleChildScrollView( - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 10), - child: const Text('PROPERTY ASSESSMENT cont..', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + 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 LandExtLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + + if (state is LandExtErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, + builder: (context, state) { + if (state is LandExtLoaded) { + return BlocConsumer( + listener: (context, state) { + if (state is SignatoriesLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + + if (state is SignatoriesErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, + builder: (context, state) { + if (state is SignatoriesLoaded) { + final signatories = state.signatories; + return BlocConsumer( + listener: (context, state) { + if (state is MemorandaLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is MemorandaLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is MemorandaErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, + builder: (context, state) { + if (state is MemorandaLoaded) { + return SingleChildScrollView( + child: Column( 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, + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('PROPERTY ASSESSMENT cont..', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - const Text('Qtr.'), - SizedBox( - width: 70, - height: 25, - child: FormBuilderTextField( - name: 'land_qtr', - validator: - FormBuilderValidators.compose([]), - ), + 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( - width: 20, + height: 20, ), - const Text('Yr.'), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + const Text('Qtr.'), + SizedBox( + width: 70, + height: 25, + child: FormBuilderTextField( + name: 'land_qtr', + validator: + FormBuilderValidators.compose([]), + ), + ), + const SizedBox( + width: 20, + ), + const Text('Yr.'), + SizedBox( + width: 70, + height: 25, + child: FormBuilderTextField( + name: 'land_yr', + validator: + FormBuilderValidators.compose([]), + ), + ), + ], + ), + ], + ), + Container( + margin: const EdgeInsets.only( + left: 0, top: 40, right: 0, bottom: 10), + child: const Text('SIGNATORIES', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18), + textAlign: TextAlign.left), + ), + const SizedBox( + height: 30, + ), + Align( + alignment: Alignment.centerLeft, + child: Text( + 'APPRAISED/ASSESSED BY:', + style: TextStyle(fontWeight: FontWeight.bold), + textAlign: TextAlign.start, + ), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDropdown( + name: 'appraised_by_land', + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'app_date_land', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'RECOMMENDING APPROVAL:', + style: + TextStyle(fontWeight: FontWeight.bold), + )), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDropdown( + name: 'rec_approval_land', + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'rec_date_land', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 30, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'APPROVED BY:', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + )), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Column( + children: [ + SizedBox( + width: 200, + child: FormBuilderDropdown( + name: 'apprvd_by_land', + autofocus: false, + items: signatories + .map((signatories) => + DropdownMenuItem( + value: signatories, + child: Text( + '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), + )) + .toList()), + ), + Text('Name'), + ], + ), + const SizedBox( + width: 15, + ), + Column( + children: [ + SizedBox( + width: 100, + child: FormBuilderDateTimePicker( + name: 'apprvd_by_date_land', + initialEntryMode: + DatePickerEntryMode.calendarOnly, + initialValue: DateTime.now(), + inputType: InputType.date, + + initialTime: const TimeOfDay( + hour: 8, minute: 0), + // locale: const Locale.fromSubtags(languageCode: 'fr'), + ), + ), + Text('Date'), + ], + ), + ], + ), + const SizedBox( + height: 50, + ), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'MEMORANDA: ', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + )), + SizedBox( + height: 50, + ), + SizedBox( + width: 500, + height: 100, + child: SearchField( + suggestions: state.memorada + .map((Memoranda memoranda) => + SearchFieldListItem( + '${memoranda.memoranda}', + item: + memoranda, // Change: Use individual Memoranda object + child: ListTile( + title: Text( + '${memoranda.memoranda}', + overflow: + TextOverflow.ellipsis, + ), + ), + )) + .toList(), + validator: FormBuilderValidators.required( + errorText: "This field is required"), + // searchInputDecoration: + // normalTextFieldStyle( + // "Memoranda", "") + // .copyWith( + // suffixIcon: const Icon( + // Icons.arrow_drop_down), + // ), + // focusNode: focus, + suggestionState: Suggestion.expand, + onSuggestionTap: (memoranda) { + setState(() { + _memoranda = memoranda.item!.memoranda!; + }); + focus.unfocus(); + }, + )), + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text('Sworn Statement No. :'), SizedBox( - width: 70, - height: 25, + width: 150, + height: 20, child: FormBuilderTextField( - name: 'land_yr', + name: 'sworn_statement_land', + decoration: InputDecoration(), validator: FormBuilderValidators.compose([]), ), ), ], ), - ], - ), - Container( - margin: const EdgeInsets.only( - left: 0, top: 40, right: 0, bottom: 10), - child: const Text('SIGNATORIES', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - const SizedBox( - height: 30, - ), - Align( - alignment: Alignment.centerLeft, - child: Text( - 'APPRAISED/ASSESSED BY:', - style: TextStyle(fontWeight: FontWeight.bold), - textAlign: TextAlign.start, - ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( - children: [ - SizedBox( - width: 200, - child: FormBuilderDropdown( - name: 'appraised_by_land', - autofocus: false, - items: signatories - .map((signatories) => - DropdownMenuItem( - value: signatories, - child: Text( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), - )) - .toList()), - ), - Text('Name'), - ], + SizedBox( + height: 30, ), - const SizedBox( - width: 15, - ), - Column( + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ + Text('Date Received:'), SizedBox( - width: 100, + width: 150, + height: 20, child: FormBuilderDateTimePicker( - name: 'app_date_land', + name: 'date_received_land', initialEntryMode: DatePickerEntryMode.calendarOnly, initialValue: DateTime.now(), @@ -194,51 +448,21 @@ class _LandSignatories extends State { // locale: const Locale.fromSubtags(languageCode: 'fr'), ), ), - Text('Date'), ], ), - ], - ), - const SizedBox( - height: 30, - ), - const Align( - alignment: Alignment.centerLeft, - child: Text( - 'RECOMMENDING APPROVAL:', - style: TextStyle(fontWeight: FontWeight.bold), - )), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( - children: [ - SizedBox( - width: 200, - child: FormBuilderDropdown( - name: 'rec_approval_land', - autofocus: false, - items: signatories - .map((signatories) => - DropdownMenuItem( - value: signatories, - child: Text( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), - )) - .toList()), - ), - Text('Name'), - ], + SizedBox( + height: 30, ), - const SizedBox( - width: 15, - ), - Column( + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ + Text('Date of Entry in the Rec. of Ass. :'), SizedBox( width: 100, + height: 20, child: FormBuilderDateTimePicker( - name: 'rec_date_land', + name: 'date_of_entry_land', initialEntryMode: DatePickerEntryMode.calendarOnly, initialValue: DateTime.now(), @@ -249,293 +473,144 @@ class _LandSignatories extends State { // locale: const Locale.fromSubtags(languageCode: 'fr'), ), ), - Text('Date'), ], ), - ], - ), - const SizedBox( - height: 30, - ), - const Align( - alignment: Alignment.centerLeft, - child: Text( - 'APPROVED BY:', - style: TextStyle( - fontWeight: FontWeight.bold, - ), - )), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Column( - children: [ - SizedBox( - width: 200, - child: FormBuilderDropdown( - name: 'apprvd_by_land', - autofocus: false, - items: signatories - .map((signatories) => - DropdownMenuItem( - value: signatories, - child: Text( - '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), - )) - .toList()), - ), - Text('Name'), - ], + SizedBox( + height: 30, ), - const SizedBox( - width: 15, - ), - Column( + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ + Text('By:'), SizedBox( - width: 100, - child: FormBuilderDateTimePicker( - name: 'apprvd_by_date_land', - initialEntryMode: - DatePickerEntryMode.calendarOnly, - initialValue: DateTime.now(), - inputType: InputType.date, - - initialTime: - const TimeOfDay(hour: 8, minute: 0), - // locale: const Locale.fromSubtags(languageCode: 'fr'), + width: 150, + height: 20, + child: FormBuilderTextField( + name: 'by_land', + decoration: InputDecoration(), + validator: + FormBuilderValidators.compose([]), ), ), - Text('Date'), ], ), - ], - ), - const SizedBox( - height: 50, - ), - const Align( - alignment: Alignment.centerLeft, - child: Text( - 'MEMORANDA: ', - style: TextStyle( - fontWeight: FontWeight.bold, - ), - )), - SizedBox( - height: 50, - ), - SizedBox( - width: 500, - height: 100, - child: SearchField( - suggestions: state.memorada - .map((Memoranda memoranda) => - SearchFieldListItem( - '${memoranda.memoranda}', - item: - memoranda, // Change: Use individual Memoranda object - child: ListTile( - title: Text( - '${memoranda.memoranda}', - overflow: TextOverflow.ellipsis, - ), - ), - )) - .toList(), - validator: FormBuilderValidators.required( - errorText: "This field is required"), - // searchInputDecoration: - // normalTextFieldStyle( - // "Memoranda", "") - // .copyWith( - // suffixIcon: const Icon( - // Icons.arrow_drop_down), - // ), - // focusNode: focus, - suggestionState: Suggestion.expand, - onSuggestionTap: (memoranda) { - setState(() { - _memoranda = memoranda.item!.memoranda!; - }); - focus.unfocus(); + SizedBox( + height: 30, + ), + ElevatedButton( + onPressed: () async { + final tempID = + await SharedPreferences.getInstance(); + var ext = LandExt( + landapprDetailsId: + tempID.getInt('landid')! - 1, + taxable: isTaxable, + exempt: isExempt, + qtr: int.parse(landKey + .currentState!.value['land_qtr']), + yr: int.parse(landKey + .currentState!.value['land_yr']), + appraisedbyName: landKey + .currentState! + .value['appraised_by_land'] + .firstname + + ' ' + + landKey + .currentState! + .value['appraised_by_land'] + .middlename + + ' ' + + landKey + .currentState! + .value['appraised_by_land'] + .lastname, + appraisedbyDate: landKey + .currentState!.value['app_date_land'], + recommendapprName: landKey + .currentState! + .value['rec_approval_land'] + .firstname + + ' ' + + landKey.currentState!.value['rec_approval_land'].middlename + + ' ' + + landKey.currentState!.value['rec_approval_land'].lastname, + recommendapprDate: landKey.currentState!.value['rec_date_land'], + approvedbyName: landKey.currentState!.value['apprvd_by_land'].firstname + ' ' + landKey.currentState!.value['apprvd_by_land'].middlename + ' ' + landKey.currentState!.value['apprvd_by_land'].lastname, + approvedbyDate: landKey.currentState!.value['apprvd_by_date_land'], + memoranda: _memoranda, + swornstatementNo: landKey.currentState!.value['sworn_statement_land'], + dateReceived: landKey.currentState!.value['date_received_land'], + entryDateAssessment: landKey.currentState!.value['date_of_entry_land'], + entryDateBy: landKey.currentState!.value['by_land']); + + print(ext.toJson()); + context.read() + ..add(UpdateLandExt(landext: ext)); + // widget.onSAve(); }, - )), - SizedBox( - height: 30, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('Sworn Statement No. :'), - SizedBox( - width: 150, - height: 20, - child: FormBuilderTextField( - name: 'sworn_statement_land', - decoration: InputDecoration(), - validator: FormBuilderValidators.compose([]), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('Date Received:'), - SizedBox( - width: 150, - height: 20, - child: FormBuilderDateTimePicker( - name: 'date_received_land', - initialEntryMode: - DatePickerEntryMode.calendarOnly, - initialValue: DateTime.now(), - inputType: InputType.date, - - initialTime: - const TimeOfDay(hour: 8, minute: 0), - // locale: const Locale.fromSubtags(languageCode: 'fr'), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('Date of Entry in the Rec. of Ass. :'), - SizedBox( - width: 100, - height: 20, - child: FormBuilderDateTimePicker( - name: 'date_of_entry_land', - initialEntryMode: - DatePickerEntryMode.calendarOnly, - initialValue: DateTime.now(), - inputType: InputType.date, - - initialTime: - const TimeOfDay(hour: 8, minute: 0), - // locale: const Locale.fromSubtags(languageCode: 'fr'), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('By:'), - SizedBox( - width: 150, - height: 20, - child: FormBuilderTextField( - name: 'by_land', - decoration: InputDecoration(), - validator: FormBuilderValidators.compose([]), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - ElevatedButton( - onPressed: () async { - final tempID = - await SharedPreferences.getInstance(); - var ext = LandExt( - landapprDetailsId: - tempID.getInt('landid')! - 1, - taxable: isTaxable, - exempt: isExempt, - qtr: int.parse( - landKey.currentState!.value['land_qtr']), - yr: int.parse( - landKey.currentState!.value['land_yr']), - appraisedbyName: landKey.currentState!.value['appraised_by_land'].firstname + - ' ' + - landKey - .currentState! - .value['appraised_by_land'] - .middlename + - ' ' + - landKey.currentState! - .value['appraised_by_land'].lastname, - appraisedbyDate: landKey - .currentState!.value['app_date_land'], - recommendapprName: landKey - .currentState! - .value['rec_approval_land'] - .firstname + - ' ' + - landKey - .currentState! - .value['rec_approval_land'] - .middlename + - ' ' + - landKey.currentState! - .value['rec_approval_land'].lastname, - recommendapprDate: landKey - .currentState!.value['rec_date_land'], - approvedbyName: landKey.currentState!.value['apprvd_by_land'].firstname + - ' ' + - landKey.currentState!.value['apprvd_by_land'].middlename + - ' ' + - landKey.currentState!.value['apprvd_by_land'].lastname, - approvedbyDate: landKey.currentState!.value['apprvd_by_date_land'], - memoranda: _memoranda, - swornstatementNo: landKey.currentState!.value['sworn_statement_land'], - dateReceived: landKey.currentState!.value['date_received_land'], - entryDateAssessment: landKey.currentState!.value['date_of_entry_land'], - entryDateBy: landKey.currentState!.value['by_land']); - - context.read() - ..add(UpdateLandExt(landext: ext)); - widget.onSAve(); - }, - style: ElevatedButton.styleFrom( - backgroundColor: primary, - foregroundColor: Colors.red), - child: SizedBox( - width: 250, - height: 50, - child: Align( - alignment: Alignment.center, - child: Text( - 'Save', - style: TextStyle( - color: Colors.white, + style: ElevatedButton.styleFrom( + backgroundColor: primary, + foregroundColor: Colors.red), + child: SizedBox( + width: 250, + height: 50, + child: Align( + alignment: Alignment.center, + child: Text( + 'Save', + style: TextStyle( + color: Colors.white, + ), + textAlign: TextAlign.center, + ), ), - textAlign: TextAlign.center, ), ), - ), - ), - SizedBox( - height: 30, - ), - ], - )); - } - return Container(); - }, - ); - } - return Container(); - }, - ); - } - return Container(); - }, + SizedBox( + height: 30, + ), + ], + )); + } + if (state is MemorandaErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context + .read() + .add(LoadMemoranda()); + }, + ); + } + return Container(); + }, + ); + } + if (state is SignatoriesErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadSignatories()); + }, + ); + } + return Container(); + }, + ); + } + if (state is LandExtErrorState) { + return SomethingWentWrong( + message: onError, + onpressed: () { + context.read().add(LoadLandExt()); + }, + ); + } + return Container(); + }, + ), + ), ); } } diff --git a/lib/screens/passo/Land/add_land/value_adjustments.dart b/lib/screens/passo/Land/add_land/value_adjustments.dart index 35dbaf2..6ab27ed 100644 --- a/lib/screens/passo/Land/add_land/value_adjustments.dart +++ b/lib/screens/passo/Land/add_land/value_adjustments.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:unit2/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart'; import 'package:unit2/screens/passo/Land/add_land/AddLandValueAdjustmentModal.dart'; import 'package:unit2/utils/alerts.dart'; @@ -30,217 +32,237 @@ class _ValueAdjustmentPage extends State { @override Widget build(BuildContext context) { - return BlocConsumer( - listener: (context, state) { - // TODO: implement listener - }, builder: (context, state) { - final state = context.watch().state; - if (state is LandValueAdjustmentsLoaded) { - return Column( - children: [ - Expanded( - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 0, top: 20, right: 0, bottom: 10), - child: const Text('VALUE ADJUSTMENTS', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18), - textAlign: TextAlign.left), - ), - Align( - alignment: Alignment.topRight, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red, + return Scaffold( + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: + BlocConsumer( + listener: (context, state) { + if (state is LandValueAdjustmentsLoading) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is LandValueAdjustmentsLoaded) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + if (state is LandValueAdjustmentsErrorState) { + final progress = ProgressHUD.of(context); + progress?.dismiss(); + } + }, builder: (context, state) { + final state = context.watch().state; + if (state is LandValueAdjustmentsLoaded) { + return Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only( + left: 0, top: 20, right: 0, bottom: 10), + child: const Text('VALUE ADJUSTMENTS', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18), + textAlign: TextAlign.left), ), - onPressed: () { - context - .read() - .add(ShowLandValueAdjustments()); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - const Text('ADD ITEM'), // <-- Text - const SizedBox( - width: 5, + Align( + alignment: Alignment.topRight, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, ), - const Icon( - // <-- Icon - Icons.add, - size: 24.0, + onPressed: () { + context + .read() + .add(ShowLandValueAdjustments()); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('ADD ITEM'), // <-- Text + const SizedBox( + width: 5, + ), + const Icon( + // <-- Icon + Icons.add, + size: 24.0, + ), + ], ), - ], + ), ), - ), - ), - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: DataTable( - // ignore: prefer_const_literals_to_create_immutables - columns: [ - const DataColumn( - label: Text('Base Market Value'), - ), - const DataColumn( - label: Text('Adjustment Factors'), - ), - const DataColumn( - label: Text('% Adjustment'), - ), - const DataColumn( - label: Text('Value Adjustment'), - ), - const DataColumn( - label: Text('Market Value'), - ), - const DataColumn( - label: Text('Action'), - ) - ], - rows: state.val_adj.map((dataRow) { - return DataRow( - cells: [ - DataCell(Text(dataRow.baseMarketval!)), - DataCell(Text(dataRow.adjustmentFactors!)), - DataCell(Text(dataRow.adjustment!)), - DataCell(Text(dataRow.valueAdjustment!)), - DataCell(Text(dataRow.marketValue!)), - DataCell(Row( - children: [ - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.delete, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () { - deleteItem(dataRow.id!); - }, - ), - SizedBox( - width: 10, - ), - InkWell( - child: Container( - height: 30, - width: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.edit, - color: Colors.white, - size: 20.0, - ), - ), - onTap: () {}, - ), - ], - )) + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + // ignore: prefer_const_literals_to_create_immutables + columns: [ + const DataColumn( + label: Text('Base Market Value'), + ), + const DataColumn( + label: Text('Adjustment Factors'), + ), + const DataColumn( + label: Text('% Adjustment'), + ), + const DataColumn( + label: Text('Value Adjustment'), + ), + const DataColumn( + label: Text('Market Value'), + ), + const DataColumn( + label: Text('Action'), + ) ], - ); - }).toList())) - ], + rows: state.val_adj.map((dataRow) { + return DataRow( + cells: [ + DataCell(Text(dataRow.baseMarketval!)), + DataCell( + Text(dataRow.adjustmentFactors!)), + DataCell(Text(dataRow.adjustment!)), + DataCell(Text(dataRow.valueAdjustment!)), + DataCell(Text(dataRow.marketValue!)), + DataCell(Row( + children: [ + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.delete, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () { + deleteItem(dataRow.id!); + }, + ), + SizedBox( + width: 10, + ), + InkWell( + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.edit, + color: Colors.white, + size: 20.0, + ), + ), + onTap: () {}, + ), + ], + )) + ], + ); + }).toList())) + ], + ), + ), + )), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Total', + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ), + // Text( + // NumberFormat.currency(locale: 'en-PH', symbol: "₱") + // .format('1.0'), + // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + // ) + // ], + // ), + // ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + CustomButton( + icon: const Icon(Icons.chevron_left_rounded, + color: Colors.white), + onPressed: () { + { + widget.PrevBtn(); + } + ; + }, + ), + CustomButton( + icon: const Icon(Icons.chevron_right_rounded, + color: Colors.white), + onPressed: () { + { + widget.NextBtn(); + } + ; + }, + ) + ], + ), + ), + ], + ); + } + if (state is LandValueAdjustmentsDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Extra item has been deleted successfully", () { + Navigator.of(context).pop(); + context + .read() + .add(const LoadLandValueAdjustments()); + }); + }); + } + } + if (state is ShowAddLandValueAdjustmentsScreen) { + return ConstrainedBox( + constraints: BoxConstraints(maxHeight: 1000.0), + child: AlertDialog( + insetPadding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 10.0, + ), + title: Text( + 'ADD VALUE ADJUSTMENTS', + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [Expanded(child: AddLandValueAdjustmentModal())], ), ), - )), - // Padding( - // padding: const EdgeInsets.only(left: 20.0, right: 20.0), - // child: Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // Text( - // 'Total', - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ), - // Text( - // NumberFormat.currency(locale: 'en-PH', symbol: "₱") - // .format('1.0'), - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - // ) - // ], - // ), - // ), - Padding( - padding: const EdgeInsets.all(15.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - CustomButton( - icon: const Icon(Icons.chevron_left_rounded, - color: Colors.white), - onPressed: () { - { - widget.PrevBtn(); - } - ; - }, - ), - CustomButton( - icon: const Icon(Icons.chevron_right_rounded, - color: Colors.white), - onPressed: () { - { - widget.NextBtn(); - } - ; - }, - ) - ], - ), - ), - ], - ); - } - if (state is LandValueAdjustmentsDeletedState) { - if (state.success) { - WidgetsBinding.instance.addPostFrameCallback((_) { - successAlert(context, "Deletion Successful", - "Extra item has been deleted successfully", () { - Navigator.of(context).pop(); - context - .read() - .add(const LoadLandValueAdjustments()); - }); - }); - } - } - if (state is ShowAddLandValueAdjustmentsScreen) { - return ConstrainedBox( - constraints: BoxConstraints(maxHeight: 1000.0), - child: AlertDialog( - insetPadding: EdgeInsets.symmetric( - horizontal: 20.0, - vertical: 10.0, - ), - title: Text( - 'ADD VALUE ADJUSTMENTS', - textAlign: TextAlign.center, - ), - content: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [Expanded(child: AddLandValueAdjustmentModal())], - ), - ), - ); - } - return Container(); - }); + ); + } + return Container(); + }), + ), + ); } } diff --git a/lib/screens/passo/building_home.dart b/lib/screens/passo/building_home.dart index 08d7cbd..a477e5c 100644 --- a/lib/screens/passo/building_home.dart +++ b/lib/screens/passo/building_home.dart @@ -72,6 +72,11 @@ class BuildingHome extends StatelessWidget { context.read().add(DeleteBuildingFaas(id: itemId)); } + void triggerBlocEvent() { + final myBloc = BlocProvider.of(context); + myBloc.add(LoadPropertyInfo()); + } + return Scaffold( body: ProgressHUD( backgroundColor: Colors.black87, @@ -206,7 +211,7 @@ class BuildingHome extends StatelessWidget { BlocProvider( create: (context) => MemorandaBloc()..add(LoadMemoranda())), - ], child: AddBuilding()); + ], child: AddBuilding(triggerBlocEvent)); })); }), SpeedDialChild( diff --git a/lib/screens/passo/land_home .dart b/lib/screens/passo/land_home .dart index a101d7e..bec0acf 100644 --- a/lib/screens/passo/land_home .dart +++ b/lib/screens/passo/land_home .dart @@ -5,17 +5,10 @@ import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:unit2/bloc/passo/barangay/barangay_bloc.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'; import 'package:unit2/bloc/passo/bulding/class_components/class_components_bloc.dart'; -import 'package:unit2/bloc/passo/bulding/general_description/general_description_bloc.dart'; -import 'package:unit2/bloc/passo/bulding/landref/landref_bloc.dart'; -import 'package:unit2/bloc/passo/bulding/location/location_bloc.dart'; import 'package:unit2/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart'; -import 'package:unit2/bloc/passo/bulding/property_appraisal_edit/property_appraisal_edit_bloc.dart'; import 'package:unit2/bloc/passo/bulding/property_assessment/property_assessment_bloc.dart'; -import 'package:unit2/bloc/passo/bulding/property_assessment_edit/property_assessment_edit_bloc.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/bloc/passo/bulding/unit_construct/unit_construct_bloc.dart'; import 'package:unit2/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart'; import 'package:unit2/bloc/passo/land/land_boundaries_edit/land_boundaries_edit_bloc.dart'; @@ -38,42 +31,39 @@ import 'package:unit2/bloc/passo/municipality/municipality_bloc.dart'; import 'package:unit2/bloc/passo/signatories/signatories_bloc.dart'; import 'package:unit2/bloc/user/user_bloc.dart'; -import 'package:unit2/model/passo/additional_items.dart'; -import 'package:unit2/model/passo/general_description.dart'; import 'package:unit2/model/passo/land_appr.dart'; import 'package:unit2/model/passo/land_ext.dart'; import 'package:unit2/model/passo/land_property_assessment.dart'; import 'package:unit2/model/passo/land_property_boundaries.dart'; import 'package:unit2/model/passo/land_property_loc.dart'; import 'package:unit2/model/passo/land_property_owner.dart'; -import 'package:unit2/model/passo/land_ref.dart'; import 'package:unit2/model/passo/land_value_adjustment.dart'; import 'package:unit2/model/passo/other_improvements.dart'; import 'package:unit2/model/passo/property_appraisal.dart'; -import 'package:unit2/model/passo/property_appraisal_edit.dart'; -import 'package:unit2/model/passo/property_assessment_edit.dart'; -import 'package:unit2/model/passo/property_info.dart'; -import 'package:unit2/model/passo/structural_materials_ii.dart'; -import 'package:unit2/model/passo/structureMaterial.dart'; import 'package:unit2/model/profile/basic_information/primary-information.dart'; import 'package:unit2/screens/passo/Building/add_building.dart'; -import 'package:unit2/screens/passo/Building/edit_building.dart'; import 'package:unit2/screens/passo/Land/add_land.dart'; import 'package:unit2/screens/passo/Land/edit_land.dart'; -import 'package:unit2/screens/passo/Test%20Envi/multi_dropdown.dart'; -import 'package:unit2/screens/passo/Test%20Envi/speed_dial.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/error_state.dart'; import 'package:flutter_speed_dial/flutter_speed_dial.dart'; -import '../../model/passo/bldg_loc.dart'; - class LandHome extends StatelessWidget { const LandHome({super.key}); @override Widget build(BuildContext context) { + void deleteItem(int itemId) { + context.read().add(DeleteLandFaas(id: itemId)); + } + + void triggerBlocEvent() { + final myBloc = BlocProvider.of(context); + myBloc.add(LoadPropertyInfo()); + } + int? profileId; String? token; Profile profile; @@ -114,8 +104,8 @@ class LandHome 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); }, ), ), @@ -133,6 +123,20 @@ class LandHome extends StatelessWidget { }, ); } + + if (state is LandFaasDeletedState) { + if (state.success) { + WidgetsBinding.instance.addPostFrameCallback((_) { + successAlert(context, "Deletion Successful", + "Land FAAS Data has been deleted successfully", () { + Navigator.of(context).pop(); + context + .read() + .add(const LoadLand()); + }); + }); + } + } return Container(); }, ); @@ -195,7 +199,7 @@ class LandHome extends StatelessWidget { BlocProvider( create: (context) => MemorandaBloc()..add(LoadMemoranda())), - ], child: AddBuilding()); + ], child: AddBuilding(triggerBlocEvent)); })); }), SpeedDialChild( @@ -281,7 +285,7 @@ class LandHome extends StatelessWidget { } } -Card _listCard(LandPropertyOwner property_info, context, index) { +Card _listCard(LandPropertyOwner property_info, context, index, deleteItem) { return Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), @@ -417,7 +421,13 @@ Card _listCard(LandPropertyOwner 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/land/land_property_owner.dart b/lib/sevices/passo/land/land_property_owner.dart index 2f788aa..8c14a3e 100644 --- a/lib/sevices/passo/land/land_property_owner.dart +++ b/lib/sevices/passo/land/land_property_owner.dart @@ -72,4 +72,29 @@ class LandServices { } return response; } + + Future remove(id) async { + String path = Url.instance.getLandOwnerInfo(); + 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/urls.dart b/lib/utils/urls.dart index 544a406..4816b5a 100644 --- a/lib/utils/urls.dart +++ b/lib/utils/urls.dart @@ -5,17 +5,17 @@ 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() { - return "https"; + return "https"; // return "http"; } @@ -344,7 +344,8 @@ class Url { String getBarangays() { return "/api/web_app/location/barangay/"; } - String getPurok(){ + + String getPurok() { return "/api/web_app/location/purok/"; } From 337fb64bdf6c71d19ba49a4afe3e15d5a6dc1db7 Mon Sep 17 00:00:00 2001 From: cyzoox Date: Tue, 3 Oct 2023 09:13:50 +0800 Subject: [PATCH 2/4] Added sqlflite pub --- .../passo/offline/building/property_info.dart | 26 +++++++++ pubspec.lock | 56 +++++++++++-------- pubspec.yaml | 1 + 3 files changed, 59 insertions(+), 24 deletions(-) create mode 100644 lib/sevices/passo/offline/building/property_info.dart diff --git a/lib/sevices/passo/offline/building/property_info.dart b/lib/sevices/passo/offline/building/property_info.dart new file mode 100644 index 0000000..56a1799 --- /dev/null +++ b/lib/sevices/passo/offline/building/property_info.dart @@ -0,0 +1,26 @@ +import 'package:sqflite/sqflite.dart' as sql; + +class SQLHeper { + static Future createTables(sql.Database database) async { + await database.execute("""CREATE TABLE property_info ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + assessed_by_id TEXT, + assessed_by_name TEXT, + date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + date_modified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + trans_code TEXT, + tdn TEXT, + pin TEXT, + owner TEXT, + address TEXT, + telno TEXT, + tin TEXT, + admin_user TEXT, + admin_address TEXT, + admin_telno TEXT, + admin_tin TEXT, + faas_type TEXT + ) + """); + } +} diff --git a/pubspec.lock b/pubspec.lock index 3d36c10..e336cb5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -77,10 +77,10 @@ packages: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" audioplayers: dependency: "direct main" description: @@ -285,10 +285,10 @@ packages: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" checked_yaml: dependency: transitive description: @@ -317,10 +317,10 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.17.2" convert: dependency: transitive description: @@ -873,26 +873,26 @@ packages: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.5.0" meta: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" mime: dependency: transitive description: @@ -993,10 +993,10 @@ packages: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" path_drawing: dependency: transitive description: @@ -1422,26 +1422,26 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" sqflite: - dependency: transitive + dependency: "direct main" description: name: sqflite - sha256: b4d6710e1200e96845747e37338ea8a819a12b51689a3bcf31eff0003b37a0b9 + sha256: "591f1602816e9c31377d5f008c2d9ef7b8aca8941c3f89cc5fd9d84da0c38a9a" url: "https://pub.dev" source: hosted - version: "2.2.8+4" + version: "2.3.0" sqflite_common: dependency: transitive description: name: sqflite_common - sha256: "8f7603f3f8f126740bc55c4ca2d1027aab4b74a1267a3e31ce51fe40e3b65b8f" + sha256: "1b92f368f44b0dee2425bb861cfa17b6f6cf3961f762ff6f941d20b33355660a" url: "https://pub.dev" source: hosted - version: "2.4.5+1" + version: "2.5.0" stack_trace: dependency: transitive description: @@ -1566,10 +1566,10 @@ packages: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.6.0" timing: dependency: transitive description: @@ -1682,6 +1682,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.2" + web: + dependency: transitive + description: + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.dev" + source: hosted + version: "0.1.4-beta" web_socket_channel: dependency: transitive description: @@ -1723,5 +1731,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">2.19.0 <3.0.0" + dart: ">=3.1.0-185.0.dev <4.0.0" flutter: ">=3.7.0" diff --git a/pubspec.yaml b/pubspec.yaml index 167b593..dedf640 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -98,6 +98,7 @@ dependencies: url_launcher_android: ^6.0.38 share_plus: ^7.1.0 animated_splash_screen: ^1.3.0 + sqflite: ^2.3.0 dependency_overrides: intl: ^0.18.0 From d7324e34f1bcaef66f818557ec0cc35244287ef5 Mon Sep 17 00:00:00 2001 From: cyzoox Date: Tue, 3 Oct 2023 09:16:28 +0800 Subject: [PATCH 3/4] fixed conflict on pubspec.yaml --- .../additional_item/additional_item_bloc.dart | 4 +- .../property_appraisal_bloc.dart | 8 +- .../property_appraisal.dart | 1161 +++++++++-------- .../property_assessment.dart | 9 +- .../property_assessement_edit.dart | 20 + .../add_land/AddLandValueAdjustmentModal.dart | 771 +++++------ .../add_land/AddPropertyAssessmentModal.dart | 22 +- .../Land/add_land/value_adjustments.dart | 8 - .../AddPropertyAssessmentEditModal.dart | 16 +- .../passo/Land/edit_land/land_appraisal.dart | 8 +- lib/screens/passo/building_home.dart | 41 +- lib/screens/passo/land_home .dart | 41 +- pubspec.yaml | 1 + 13 files changed, 1113 insertions(+), 997 deletions(-) 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 From c9372f8e50f7a10d445966ccdc34347b2ecb51c7 Mon Sep 17 00:00:00 2001 From: cyzoox Date: Mon, 9 Oct 2023 08:34:24 +0800 Subject: [PATCH 4/4] Modified additional items --- .../passo/bulding/additional_item/additional_item_bloc.dart | 5 ----- 1 file changed, 5 deletions(-) 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 762ceb4..73c2beb 100644 --- a/lib/bloc/passo/bulding/additional_item/additional_item_bloc.dart +++ b/lib/bloc/passo/bulding/additional_item/additional_item_bloc.dart @@ -16,11 +16,6 @@ class AdditionalItemBloc on((event, emit) async { emit(AdditionalItemsLoading()); try { - // final tempID = await SharedPreferences.getInstance(); - // print(tempID.getInt('tempid')); - // final additionalItem = await GetAdditionalItems.getAdditionalItems( - // tempID.getInt('tempid')); - emit(AdditionalItemsLoaded(globalAdditionalItems)); } catch (e) { emit(AdditionalItemsErrorState(e.toString()));