From 75cfe68bd156dc0a557ed3708cad29be6aa1bc5f Mon Sep 17 00:00:00 2001 From: cyzoox Date: Mon, 25 Sep 2023 14:39:55 +0800 Subject: [PATCH] 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/"; }