Merge pull request 'feature/passo/PASSO-#42-Bug-fix-on-building-faas-and-add-land-faas-edit' (#44) from feature/passo/PASSO-#42-Bug-fix-on-building-faas-and-add-land-faas-edit into develop

Reviewed-on: http://git.agusandelnorte.gov.ph:3000/SoftwareDevelopmentSection/unit2-null-safety-repository/pulls/44
feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
cyrilaquismundo 2023-09-18 14:35:07 +08:00
commit 874f9653c0
54 changed files with 7365 additions and 3815 deletions

View File

@ -27,18 +27,23 @@ class AdditionalItemBloc
} }
}); });
on<AddAdditionalItems>((event, emit) async { on<AddAdditionalItems>((event, emit) async {
http.Response response = emit(AdditionalItemsLoading());
(await AdditionalItemsServices.instance.add(event.items))!; try {
print(response.body); http.Response response =
(await AdditionalItemsServices.instance.add(event.items))!;
print(response.body);
if (response.statusCode == 201) { if (response.statusCode == 201) {
var jsonResponse = jsonDecode(response.body); var jsonResponse = jsonDecode(response.body);
AdditionalItems newAdditional = AdditionalItems newAdditional =
AdditionalItems.fromJson(jsonResponse['data']); AdditionalItems.fromJson(jsonResponse['data']);
print(jsonResponse['data']); print(jsonResponse['data']);
globalAdditionalItems.add(newAdditional); globalAdditionalItems.add(newAdditional);
emit(AdditionalItemsLoaded(globalAdditionalItems)); emit(AdditionalItemsLoaded(globalAdditionalItems));
}
} catch (e) {
emit(AdditionalItemsErrorState(e.toString()));
} }
}); });
on<DeleteAdditionalItems>((event, emit) async { on<DeleteAdditionalItems>((event, emit) async {

View File

@ -26,19 +26,16 @@ class PropertyAppraisalBloc
}); });
on<AddPropertyAppraisal>((event, emit) async { on<AddPropertyAppraisal>((event, emit) async {
final tempID = await SharedPreferences.getInstance(); final tempID = await SharedPreferences.getInstance();
emit(PropertyAppraisalLoading());
try {
http.Response response = (await PropertyAppraisalServices.instance
.update(event.appraisal, tempID.getInt('tempid')! - 1))!;
http.Response response = (await PropertyAppraisalServices.instance if (response.statusCode == 200) {
.update(event.appraisal, tempID.getInt('tempid')! - 1))!; emit(ShowPropertyAppraisalSuccessAlertState());
}
if (response.statusCode == 201) { } catch (e) {
var jsonResponse = jsonDecode(response.body); emit(ShowPropertyAppraisalErrorAlertState());
PropertyAppraisal newAppraisal =
PropertyAppraisal.fromJson(jsonResponse['data']);
print("PA");
print(newAppraisal);
print(response.statusCode);
emit(PropertyAppraisalLoaded(newAppraisal));
} }
}); });
} }

View File

@ -26,3 +26,7 @@ class PropertyAppraisalErrorState extends PropertyAppraisalState {
@override @override
List<Object> get props => [error]; List<Object> get props => [error];
} }
class ShowPropertyAppraisalErrorAlertState extends PropertyAppraisalState {}
class ShowPropertyAppraisalSuccessAlertState extends PropertyAppraisalState {}

View File

@ -48,6 +48,7 @@ class PropertyInfoBloc extends Bloc<PropertyInfoEvent, PropertyInfoState> {
} }
}); });
on<UpdatPropertyInfo>(((event, emit) async { on<UpdatPropertyInfo>(((event, emit) async {
emit(PropertyInfoLoading());
final state = this.state; final state = this.state;
try { try {
http.Response response = (await PropertyInfoService.instance http.Response response = (await PropertyInfoService.instance
@ -60,11 +61,17 @@ class PropertyInfoBloc extends Bloc<PropertyInfoEvent, PropertyInfoState> {
})); }));
on<UpdateBldgLoc>(((event, emit) async { on<UpdateBldgLoc>(((event, emit) async {
final state = this.state; final state = this.state;
try { try {
http.Response response = (await PropertyInfoService.instance http.Response response = (await PropertyInfoService.instance
.updateBldg(event.bldg_loc, event.bldg_loc.id))!; .updateBldg(event.bldg_loc, event.bldg_loc.id))!;
print('bldgLoc'); print('bldgLoc');
print(response.statusCode); print(response.statusCode);
if (response.statusCode == 200) {
emit(ShowBldgLocSuccessAlertState());
} else {
emit(ShowBldgLocErrorAlertState());
}
} catch (e) { } catch (e) {
emit(PropertyInfoErrorState(e.toString())); emit(PropertyInfoErrorState(e.toString()));
} }
@ -72,11 +79,17 @@ class PropertyInfoBloc extends Bloc<PropertyInfoEvent, PropertyInfoState> {
on<UpdateLandRef>( on<UpdateLandRef>(
(event, emit) async { (event, emit) async {
final state = this.state; final state = this.state;
emit(PropertyInfoLoading());
try { try {
http.Response response = (await PropertyInfoService.instance http.Response response = (await PropertyInfoService.instance
.updateLandRef(event.land_ref, event.land_ref.id))!; .updateLandRef(event.land_ref, event.land_ref.id))!;
print('landref'); print('landref');
print(response.body); print(response.body);
if (response.statusCode == 200) {
emit(ShowLandRefSuccessAlertState());
} else {
emit(ShowLandRefErrorAlertState());
}
} catch (e) { } catch (e) {
emit(PropertyInfoErrorState(e.toString())); emit(PropertyInfoErrorState(e.toString()));
} }
@ -85,11 +98,17 @@ class PropertyInfoBloc extends Bloc<PropertyInfoEvent, PropertyInfoState> {
on<UpdateGeneralDesc>((event, emit) async { on<UpdateGeneralDesc>((event, emit) async {
final state = this.state; final state = this.state;
emit(PropertyInfoLoading());
try { try {
http.Response response = (await PropertyInfoService.instance http.Response response = (await PropertyInfoService.instance
.updateGenDesc(event.gen_desc, event.gen_desc.id))!; .updateGenDesc(event.gen_desc, event.gen_desc.id))!;
print('genDesc'); print('genDesc');
print(response.body); print(response.body);
if (response.statusCode == 200) {
emit(ShowGenDescSuccessAlertState());
} else {
emit(ShowGenDescErrorAlertState());
}
} catch (e) { } catch (e) {
emit(PropertyInfoErrorState(e.toString())); emit(PropertyInfoErrorState(e.toString()));
} }
@ -97,6 +116,7 @@ class PropertyInfoBloc extends Bloc<PropertyInfoEvent, PropertyInfoState> {
on<UpdateStrucMaterials>((event, emit) async { on<UpdateStrucMaterials>((event, emit) async {
final state = this.state; final state = this.state;
emit(PropertyInfoLoading());
try { try {
final tempID = await SharedPreferences.getInstance(); final tempID = await SharedPreferences.getInstance();
print(tempID.getInt('tempid')! - 1); print(tempID.getInt('tempid')! - 1);
@ -104,9 +124,25 @@ class PropertyInfoBloc extends Bloc<PropertyInfoEvent, PropertyInfoState> {
.update(event.data, event.data.id))!; .update(event.data, event.data.id))!;
print('struc Material'); print('struc Material');
print(response.body); print(response.body);
if (response.statusCode == 200) {
emit(ShowStrucMatSuccessAlertState());
} else {
emit(ShowStrucMatErrorAlertState());
}
} catch (e) { } catch (e) {
emit(PropertyInfoErrorState(e.toString())); emit(PropertyInfoErrorState(e.toString()));
} }
}); });
on<DeleteBuildingFaas>((event, emit) async {
print(event.id);
emit(PropertyInfoLoading());
http.Response response =
(await PropertyInfoService.instance.remove(event.id));
print(response.statusCode);
if (response.statusCode == 200) {
emit(BuildingFaasDeletedState(success: true));
}
});
} }
} }

View File

@ -73,3 +73,16 @@ class UpdateStrucMaterials extends PropertyInfoEvent {
@override @override
List<Object> get props => [data]; List<Object> get props => [data];
} }
class DeleteBuildingFaas extends PropertyInfoEvent {
final int id;
const DeleteBuildingFaas({required this.id});
@override
List<Object> get props => [id];
}
class ShowBldgLocErrorAlert extends PropertyInfoEvent {}
class ShowLandRefErrorAlert extends PropertyInfoEvent {}

View File

@ -24,3 +24,26 @@ class PropertyInfoErrorState extends PropertyInfoState {
@override @override
List<Object> get props => [error]; List<Object> get props => [error];
} }
class BuildingFaasDeletedState extends PropertyInfoState {
final bool success;
const BuildingFaasDeletedState({required this.success});
@override
List<Object> get props => [success];
}
class ShowBldgLocErrorAlertState extends PropertyInfoState {}
class ShowLandRefErrorAlertState extends PropertyInfoState {}
class ShowGenDescErrorAlertState extends PropertyInfoState {}
class ShowStrucMatErrorAlertState extends PropertyInfoState {}
class ShowStrucMatSuccessAlertState extends PropertyInfoState {}
class ShowBldgLocSuccessAlertState extends PropertyInfoState {}
class ShowLandRefSuccessAlertState extends PropertyInfoState {}
class ShowGenDescSuccessAlertState extends PropertyInfoState {}

View File

@ -18,7 +18,7 @@ class LandAppraisalBloc extends Bloc<LandAppraisalEvent, LandAppraisalState> {
final tempID = await SharedPreferences.getInstance(); final tempID = await SharedPreferences.getInstance();
print(tempID.getInt('landid')); print(tempID.getInt('landid'));
final additionalItems = final additionalItems =
await LandAppraisalServices.instance.fetch(tempID.getInt('tempid')); await LandAppraisalServices.instance.fetch(tempID.getInt('landid'));
globalLandAppraisal globalLandAppraisal
.addAll(additionalItems); // Append all items to the list .addAll(additionalItems); // Append all items to the list

View File

@ -0,0 +1,54 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/model/passo/land_property_boundaries.dart';
import 'package:http/http.dart' as http;
import 'package:unit2/sevices/passo/land/land_boundaries.dart';
part 'land_boundaries_edit_event.dart';
part 'land_boundaries_edit_state.dart';
class LandBoundariesEditBloc
extends Bloc<LandBoundariesEditEvent, LandBoundariesEditState> {
LandBoundariesEditBloc() : super(LandBoundariesEditInitial()) {
on<LoadLandBoundariesEdit>((event, emit) async {
emit(LandBoundariesEditLoading());
try {
final tempID = await SharedPreferences.getInstance();
final assessments =
await LandBoundariesService.instance.fetchEdit(event.id);
emit(LandBoundariesEditLoaded(assessments));
} catch (e) {
emit(LandBoundariesEditErrorState(e.toString()));
}
});
// on<AddLandLocationEdit>((event, emit) async {
// http.Response response = (await LandLocationService.instance
// .addEdit(event.land_loc_edit))!;
// print('Assessment');
// print(response.statusCode);
// print(response.body);
// if (response.statusCode == 201) {
// var jsonResponse = jsonDecode(response.body);
// LandPropertyLoc newAssessment =
// LandPropertyLoc.fromJson(jsonResponse['data']);
// globalLandLocationEdit = newAssessment;
// emit(LandLocationEditLoaded(globalLandBoundariesEdit));
// }
// });
on<UpdateLandBoundariesEdit>((event, emit) async {
http.Response response = (await LandBoundariesService.instance
.updateEdit(event.land_boundaries_edit, event.id))!;
print('landloc edit');
print(response.statusCode);
print(response.body);
// if (response.statusCode == 201) {
// final faas = await PropertyInfoRepository.getUsers();
// emit(FaasLoaded(faas));
// }
});
}
}

View File

@ -0,0 +1,41 @@
part of 'land_boundaries_edit_bloc.dart';
class LandBoundariesEditEvent extends Equatable {
const LandBoundariesEditEvent();
@override
List<Object> get props => [];
}
class LoadLandBoundariesEdit extends LandBoundariesEditEvent {
final LandPropertyBoundaries land_boundaries_edit;
final int? id;
const LoadLandBoundariesEdit(
{required this.land_boundaries_edit, required this.id});
@override
List<Object> get props => [land_boundaries_edit];
}
class AddLandBoundariesEdit extends LandBoundariesEditEvent {
final LandPropertyBoundaries land_boundaries_edit;
const AddLandBoundariesEdit({required this.land_boundaries_edit});
@override
List<Object> get props => [land_boundaries_edit];
}
class UpdateLandBoundariesEdit extends LandBoundariesEditEvent {
// ignore: non_constant_identifier_names
final LandPropertyBoundaries land_boundaries_edit;
final int id;
// ignore: non_constant_identifier_names
const UpdateLandBoundariesEdit(
{required this.land_boundaries_edit, required this.id});
@override
List<Object> get props => [land_boundaries_edit];
}

View File

@ -0,0 +1,28 @@
part of 'land_boundaries_edit_bloc.dart';
class LandBoundariesEditState extends Equatable {
const LandBoundariesEditState();
@override
List<Object> get props => [];
}
class LandBoundariesEditInitial extends LandBoundariesEditState {}
class LandBoundariesEditLoading extends LandBoundariesEditState {}
class LandBoundariesEditLoaded extends LandBoundariesEditState {
LandBoundariesEditLoaded(this.land_boundaries_edit);
final LandPropertyBoundaries land_boundaries_edit;
@override
List<Object> get props => [land_boundaries_edit];
}
class LandBoundariesEditErrorState extends LandBoundariesEditState {
LandBoundariesEditErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -0,0 +1,59 @@
import 'dart:convert';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/model/passo/land_property_loc.dart';
import 'package:http/http.dart' as http;
import 'package:unit2/sevices/passo/land/land_location.dart';
part 'land_location_edit_event.dart';
part 'land_location_edit_state.dart';
class LandLocationEditBloc
extends Bloc<LandLocationEditEvent, LandLocationEditState> {
LandPropertyLoc globalLandLocationEdit;
LandLocationEditBloc()
: globalLandLocationEdit = LandPropertyLoc(),
super(LandLocationEditInitial()) {
on<LoadLandLocationEdit>((event, emit) async {
emit(LandLocationEditLoading());
try {
final tempID = await SharedPreferences.getInstance();
final assessments =
await LandLocationService.instance.fetchEdit(event.id);
emit(LandLocationEditLoaded(assessments));
} catch (e) {
emit(LandLocationEditErrorState(e.toString()));
}
});
// on<AddLandLocationEdit>((event, emit) async {
// http.Response response = (await LandLocationService.instance
// .addEdit(event.land_loc_edit))!;
// print('Assessment');
// print(response.statusCode);
// print(response.body);
// if (response.statusCode == 201) {
// var jsonResponse = jsonDecode(response.body);
// LandPropertyLoc newAssessment =
// LandPropertyLoc.fromJson(jsonResponse['data']);
// globalLandLocationEdit = newAssessment;
// emit(LandLocationEditLoaded(globalLandLocationEdit));
// }
// });
on<UpdateLandLocationEdit>((event, emit) async {
http.Response response = (await LandLocationService.instance
.updateEdit(event.land_loc_edit, event.id))!;
print('landloc edit');
print(response.statusCode);
print(response.body);
// if (response.statusCode == 201) {
// final faas = await PropertyInfoRepository.getUsers();
// emit(FaasLoaded(faas));
// }
});
}
}

View File

@ -0,0 +1,39 @@
part of 'land_location_edit_bloc.dart';
class LandLocationEditEvent extends Equatable {
const LandLocationEditEvent();
@override
List<Object> get props => [];
}
class LoadLandLocationEdit extends LandLocationEditEvent {
final LandPropertyLoc land_loc_edit;
final int? id;
const LoadLandLocationEdit({required this.land_loc_edit, required this.id});
@override
List<Object> get props => [land_loc_edit];
}
class AddLandLocationEdit extends LandLocationEditEvent {
final LandPropertyLoc land_loc_edit;
const AddLandLocationEdit({required this.land_loc_edit});
@override
List<Object> get props => [land_loc_edit];
}
class UpdateLandLocationEdit extends LandLocationEditEvent {
// ignore: non_constant_identifier_names
final LandPropertyLoc land_loc_edit;
final int id;
// ignore: non_constant_identifier_names
const UpdateLandLocationEdit({required this.land_loc_edit, required this.id});
@override
List<Object> get props => [land_loc_edit];
}

View File

@ -0,0 +1,28 @@
part of 'land_location_edit_bloc.dart';
class LandLocationEditState extends Equatable {
const LandLocationEditState();
@override
List<Object> get props => [];
}
class LandLocationEditInitial extends LandLocationEditState {}
class LandLocationEditLoading extends LandLocationEditState {}
class LandLocationEditLoaded extends LandLocationEditState {
LandLocationEditLoaded(this.land_loc_edit);
final LandPropertyLoc land_loc_edit;
@override
List<Object> get props => [land_loc_edit];
}
class LandLocationEditErrorState extends LandLocationEditState {
LandLocationEditErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -10,6 +10,7 @@ import 'package:unit2/sevices/passo/land/land_boundaries.dart';
import 'package:unit2/sevices/passo/land/land_location.dart'; import 'package:unit2/sevices/passo/land/land_location.dart';
import 'package:unit2/sevices/passo/land/land_property_owner.dart'; import 'package:unit2/sevices/passo/land/land_property_owner.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:unit2/utils/text_container.dart';
part 'land_property_owner_info_event.dart'; part 'land_property_owner_info_event.dart';
part 'land_property_owner_info_state.dart'; part 'land_property_owner_info_state.dart';
@ -25,33 +26,39 @@ class LandPropertyOwnerInfoBloc
emit(LandErrorState(e.toString())); emit(LandErrorState(e.toString()));
} }
}); });
on<AddPropertyOwnerLand>((event, emit) async { on<AddPropertyOwnerLand>((event, emit) async {
http.Response response = (await LandServices.instance.add(event.land))!; http.Response response = (await LandServices.instance.add(event.land))!;
if (response.statusCode == 201) { if (response.statusCode == 201) {
var jsonResponse = jsonDecode(response.body); var jsonResponse = jsonDecode(response.body);
var details = jsonResponse['data']['details']; var details = jsonResponse['data'];
print(jsonResponse);
if (details != null) { var id = details['id'];
var id = details['id']; final tempID = await SharedPreferences.getInstance();
final tempID = await SharedPreferences.getInstance(); print(id);
print(id); await tempID.setInt('landid', id + 1);
await tempID.setInt('landid', id + 1); final faas = await LandServices.instance.fetch();
final faas = await LandServices.instance.fetch(); emit(LandLoaded(faas));
emit(LandLoaded(faas));
} else {
print("No 'details' object found in the response.");
// Handle the case when 'details' is missing
}
} }
}); });
on<UpdateLandPropertyOwner>((event, emit) async {
final state = this.state;
http.Response response = (await LandServices.instance
.update(event.land_edit, event.land_edit.id))!;
print('Land LOc');
print(response.body);
});
on<UpdateLandLoc>((event, emit) async { on<UpdateLandLoc>((event, emit) async {
final state = this.state; final state = this.state;
http.Response response = (await LandLocationService.instance http.Response response = (await LandLocationService.instance
.update(event.land_loc, event.land_loc.id))!; .update(event.land_loc, event.land_loc.id))!;
print(event.land_loc.id!);
print('Land LOc'); print('Land LOc');
print(response.body); print(response.statusCode);
}); });
on<UpdateLandBoundaries>((event, emit) async { on<UpdateLandBoundaries>((event, emit) async {

View File

@ -25,6 +25,18 @@ class AddPropertyOwnerLand extends LandPropertyOwnerInfoEvent {
List<Object> get props => [land]; List<Object> get props => [land];
} }
class UpdateLandPropertyOwner extends LandPropertyOwnerInfoEvent {
// ignore: non_constant_identifier_names
final LandPropertyOwner land_edit;
final int id;
// ignore: non_constant_identifier_names
const UpdateLandPropertyOwner({required this.land_edit, required this.id});
@override
List<Object> get props => [land_edit];
}
class UpdateLandLoc extends LandPropertyOwnerInfoEvent { class UpdateLandLoc extends LandPropertyOwnerInfoEvent {
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final LandPropertyLoc land_loc; final LandPropertyLoc land_loc;

View File

@ -17,14 +17,6 @@ class LandLoaded extends LandPropertyOwnerInfoState {
List<Object> get props => [land]; List<Object> get props => [land];
} }
// class PropertyAppraisalLoaded extends AssessorsState {
// PropertyAppraisalLoaded(this.appraisal);
// final List<PropertyAppraisal> appraisal;
// @override
// List<Object> get props => [appraisal];
// }
class LandErrorState extends LandPropertyOwnerInfoState { class LandErrorState extends LandPropertyOwnerInfoState {
const LandErrorState(this.error); const LandErrorState(this.error);
final String error; final String error;

View File

@ -120,17 +120,34 @@ class _AddBuilding extends State<AddBuilding> {
if (state is PropertyInfoErrorState) { if (state is PropertyInfoErrorState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress?.dismiss(); progress?.dismiss();
}
if (state is ShowGenDescErrorAlertState ||
state is ShowLandRefErrorAlertState ||
state is ShowStrucMatErrorAlertState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
Fluttertoast.showToast( Fluttertoast.showToast(
msg: onError, msg: "Slow internet connection, please try again!");
fontSize: 24, }
toastLength: Toast.LENGTH_LONG, if (state is ShowLandRefSuccessAlertState ||
gravity: ToastGravity.CENTER, state is ShowGenDescSuccessAlertState ||
backgroundColor: Colors.black, state is ShowStrucMatSuccessAlertState) {
textColor: Colors.white); final progress = ProgressHUD.of(context);
progress?.dismiss();
NextBtn();
} }
}, builder: (context, state) { }, builder: (context, state) {
if (state is PropertyInfoLoaded || if (state is PropertyInfoLoading ||
state is PropertyInfoErrorState) { state is PropertyInfoLoaded ||
state is PropertyInfoErrorState ||
state is ShowBldgLocErrorAlertState ||
state is ShowGenDescErrorAlertState ||
state is ShowLandRefErrorAlertState ||
state is ShowStrucMatErrorAlertState ||
state is ShowBldgLocSuccessAlertState ||
state is ShowLandRefSuccessAlertState ||
state is ShowGenDescSuccessAlertState ||
state is ShowStrucMatSuccessAlertState) {
return BlocConsumer<UnitConstructBloc, UnitConstructState>( return BlocConsumer<UnitConstructBloc, UnitConstructState>(
listener: ( listener: (
context, context,

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:searchfield/searchfield.dart'; import 'package:searchfield/searchfield.dart';
@ -500,48 +501,56 @@ class _AddExtraItems extends State<AddExtraItems> {
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: ElevatedButton( child: ElevatedButton(
onPressed: () async { onPressed: () async {
final tempID = try {
await SharedPreferences.getInstance(); final tempID =
var itemss = AdditionalItems( await SharedPreferences.getInstance();
id: 1, var itemss = AdditionalItems(
bldgapprDetailsId: id: 1,
tempID.getInt('tempid')! - 1, bldgapprDetailsId:
classId: _classId, tempID.getInt('tempid')! - 1,
className: _className, classId: _classId,
structType: _structureType, className: _className,
unitValue: structType: _structureType,
_withoutBUCC == true ? 0 : _unitValue, unitValue: _withoutBUCC == true
baseUnitValue: _unitBase, ? 0
area: _areaValue, : _unitValue,
marketValue: baseUnitValue: _unitBase,
(_unitValue * _unitBase) * _areaValue, area: _areaValue,
depreciationRate: _depValue, marketValue: (_unitValue * _unitBase) *
adjustedMarketVal: _totalMarketValue( _areaValue,
depreciationRate: _depValue,
adjustedMarketVal: _totalMarketValue(
_unitValue,
_unitBase,
_areaValue,
_depValue,
_withoutBUCC,
_className,
isPainted,
isSecondHand,
_notPaintedUnitVal,
_secondHandUnitVal),
actualUse: 'Test',
amtDepreciation: _amountofDepreciation(
_unitValue, _unitValue,
_unitBase, _unitBase,
_areaValue, _areaValue,
_depValue, _depValue,
_withoutBUCC, ),
_className, painted: true,
isPainted, secondhand: true,
isSecondHand, paintedUnitval: '1',
_notPaintedUnitVal, secondhandUnitval: '1');
_secondHandUnitVal),
actualUse: 'Test',
amtDepreciation: _amountofDepreciation(
_unitValue,
_unitBase,
_areaValue,
_depValue,
),
painted: true,
secondhand: true,
paintedUnitval: '1',
secondhandUnitval: '1');
context context
.read<AdditionalItemBloc>() .read<AdditionalItemBloc>()
.add(AddAdditionalItems(items: itemss)); .add(AddAdditionalItems(items: itemss));
} catch (e) {
Fluttertoast.showToast(
msg:
"Slow internet connection, please try again!",
);
}
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: Colors.black, primary: Colors.black,

View File

@ -1,11 +1,15 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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:intl/intl.dart';
import 'package:unit2/bloc/passo/bulding/additional_item/additional_item_bloc.dart'; import 'package:unit2/bloc/passo/bulding/additional_item/additional_item_bloc.dart';
import 'package:unit2/model/passo/class_components.dart'; import 'package:unit2/model/passo/class_components.dart';
import 'package:unit2/model/passo/unit_construct.dart'; import 'package:unit2/model/passo/unit_construct.dart';
import 'package:unit2/screens/passo/Building/add_building_components/AddExtraItems.dart'; import 'package:unit2/screens/passo/Building/add_building_components/AddExtraItems.dart';
import 'package:unit2/utils/alerts.dart'; import 'package:unit2/utils/alerts.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/error_state.dart';
import 'package:unit2/widgets/passo/custom_button.dart'; import 'package:unit2/widgets/passo/custom_button.dart';
class AdditionalItemPage extends StatefulWidget { class AdditionalItemPage extends StatefulWidget {
@ -37,260 +41,252 @@ class _AdditionalItemPage extends State<AdditionalItemPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocConsumer<AdditionalItemBloc, AdditionalItemState>( return Scaffold(
listener: (context, state) { body: ProgressHUD(
// TODO: implement listener padding: const EdgeInsets.all(24),
}, backgroundColor: Colors.black87,
builder: (context, state) { indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
final state = context.watch<AdditionalItemBloc>().state; child: BlocConsumer<AdditionalItemBloc, AdditionalItemState>(
if (state is AdditionalItemsLoaded) { listener: (context, state) {
return Column( if (state is AdditionalItemsLoading) {
children: [ final progress = ProgressHUD.of(context);
Expanded( progress!.showWithText("Please wait...");
child: SingleChildScrollView( }
child: Padding( if (state is AdditionalItemsLoaded) {
padding: const EdgeInsets.all(15.0), final progress = ProgressHUD.of(context);
child: Column( progress?.dismiss();
children: [ }
Container( if (state is AdditionalItemsErrorState) {
margin: const EdgeInsets.only( final progress = ProgressHUD.of(context);
left: 0, top: 20, right: 0, bottom: 10), progress?.dismiss();
child: const Text('ADDITIONAL ITEMS', }
style: TextStyle( },
fontWeight: FontWeight.bold, fontSize: 18), builder: (context, state) {
textAlign: TextAlign.left), final state = context.watch<AdditionalItemBloc>().state;
), if (state is AdditionalItemsLoaded) {
Align( return Column(
alignment: Alignment.topRight, children: [
child: ElevatedButton( Expanded(
style: ElevatedButton.styleFrom( child: SingleChildScrollView(
backgroundColor: Colors.red, child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
children: [
Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('ADDITIONAL ITEMS',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18),
textAlign: TextAlign.left),
), ),
onPressed: () { Align(
context alignment: Alignment.topRight,
.read<AdditionalItemBloc>() child: ElevatedButton(
.add(ShowAdditionalItems()); style: ElevatedButton.styleFrom(
}, backgroundColor: Colors.red,
child: Row(
mainAxisSize: MainAxisSize.min,
children: const [
Text('ADD ITEM'), // <-- Text
SizedBox(
width: 5,
), ),
Icon( onPressed: () {
// <-- Icon context
Icons.add, .read<AdditionalItemBloc>()
size: 24.0, .add(ShowAdditionalItems());
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: const [
Text('ADD ITEM'), // <-- Text
SizedBox(
width: 5,
),
Icon(
// <-- Icon
Icons.add,
size: 24.0,
),
],
), ),
], ),
), ),
), SingleChildScrollView(
), scrollDirection: Axis.horizontal,
SingleChildScrollView( child: DataTable(
scrollDirection: Axis.horizontal, // ignore: prefer_const_literals_to_create_immutables
child: DataTable( columns: [
// ignore: prefer_const_literals_to_create_immutables const DataColumn(
columns: [ label: Text('Items'),
const DataColumn( ),
label: Text('Items'), const DataColumn(
), label: Text('Unit Value'),
const DataColumn( ),
label: Text('Unit Value'), const DataColumn(
), label: Text('% of BUCC'),
const DataColumn( ),
label: Text('% of BUCC'), const DataColumn(
), label: Text('Market Value'),
const DataColumn( ),
label: Text('Market Value'), const DataColumn(
), label: Text('Action'),
const DataColumn( )
label: Text('Action'),
)
],
rows: state.items.map((dataRow) {
return DataRow(
cells: [
DataCell(Text(dataRow.className)),
DataCell(Text(dataRow.baseUnitValue)),
DataCell(Text(dataRow.unitValue)),
DataCell(Text(((double.parse(
dataRow.adjustedMarketVal)))
.toString())),
DataCell(Row(
children: [
InkWell(
child: Container(
height: 30,
width: 30,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: const Icon(
Icons.delete,
color: Colors.white,
size: 20.0,
),
),
onTap: () {
deleteItem(dataRow.id);
},
),
const SizedBox(
width: 10,
),
InkWell(
child: Container(
height: 30,
width: 30,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: const Icon(
Icons.edit,
color: Colors.white,
size: 20.0,
),
),
onTap: () {},
),
],
))
], ],
); rows: state.items.map((dataRow) {
}).toList(), return DataRow(
), cells: [
DataCell(Text(dataRow.className)),
DataCell(Text(dataRow.baseUnitValue)),
DataCell(Text(dataRow.unitValue)),
DataCell(Text(((double.parse(
dataRow.adjustedMarketVal)))
.toString())),
DataCell(Row(
children: [
InkWell(
child: Container(
height: 30,
width: 30,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: const Icon(
Icons.delete,
color: Colors.white,
size: 20.0,
),
),
onTap: () {
deleteItem(dataRow.id);
},
),
const SizedBox(
width: 10,
),
InkWell(
child: Container(
height: 30,
width: 30,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: const 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: [
const Text(
'Total',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 15),
),
Text(
NumberFormat.currency(locale: 'en-PH', symbol: "")
.format(_totalMarketValue(state.items)),
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 15),
)
], ],
), ),
), ),
), Padding(
), padding: const EdgeInsets.all(15.0),
Padding( child: Row(
padding: const EdgeInsets.only(left: 20.0, right: 20.0), mainAxisAlignment: MainAxisAlignment.spaceEvenly,
child: Row( children: [
mainAxisAlignment: MainAxisAlignment.spaceBetween, CustomButton(
children: [ icon: const Icon(Icons.chevron_left_rounded,
const Text( color: Colors.white),
'Total', onPressed: () {
style: {
TextStyle(fontWeight: FontWeight.bold, fontSize: 15), widget.additionalItemsPrevBtn();
}
;
},
),
CustomButton(
icon: const Icon(Icons.chevron_right_rounded,
color: Colors.white),
onPressed: () {
{
widget.additionalItemsNextBtn();
}
;
},
)
],
), ),
Text( ),
NumberFormat.currency(locale: 'en-PH', symbol: "")
.format(_totalMarketValue(state.items)),
style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
)
],
),
),
Padding(
padding: const EdgeInsets.all(15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
CustomButton(
icon: const Icon(Icons.chevron_left_rounded,
color: Colors.white),
onPressed: () {
{
widget.additionalItemsPrevBtn();
}
;
},
),
CustomButton(
icon: const Icon(Icons.chevron_right_rounded,
color: Colors.white),
onPressed: () {
{
widget.additionalItemsNextBtn();
}
;
},
)
],
),
),
],
);
}
if (state is AdditionalItemsDeletedState) {
if (state.success) {
WidgetsBinding.instance.addPostFrameCallback((_) {
successAlert(context, "Deletion Successful",
"Extra item has been deleted successfully", () {
Navigator.of(context).pop();
context
.read<AdditionalItemBloc>()
.add(const LoadAdditionalItems());
});
});
}
}
if (state is ShowAddItemsScreen) {
return ConstrainedBox(
constraints: BoxConstraints(maxHeight: 1000.0),
child: AlertDialog(
insetPadding: const EdgeInsets.symmetric(
horizontal: 20.0,
vertical: 10.0,
),
title: const Text(
'ADD EXTRA ITEMS',
textAlign: TextAlign.center,
),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: AddExtraItems(widget.unit, widget.options))
], ],
), );
), }
); if (state is AdditionalItemsDeletedState) {
} if (state.success) {
return Container( WidgetsBinding.instance.addPostFrameCallback((_) {
child: Column( successAlert(context, "Deletion Successful",
children: [ "Extra item has been deleted successfully", () {
Container( Navigator.of(context).pop();
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('ADDITIONAL MATERIALS',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
textAlign: TextAlign.left),
),
Align(
alignment: Alignment.topRight,
child: ElevatedButton(
onPressed: () {
context context
.read<AdditionalItemBloc>() .read<AdditionalItemBloc>()
.add(ShowAdditionalItems()); .add(const LoadAdditionalItems());
}, });
child: Row( });
}
}
if (state is ShowAddItemsScreen) {
return ConstrainedBox(
constraints: BoxConstraints(maxHeight: 1000.0),
child: AlertDialog(
insetPadding: const EdgeInsets.symmetric(
horizontal: 20.0,
vertical: 10.0,
),
title: const Text(
'ADD EXTRA ITEMS',
textAlign: TextAlign.center,
),
content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: const [ crossAxisAlignment: CrossAxisAlignment.start,
Text('ADD ITEM'), // <-- Text children: [
SizedBox( Expanded(
width: 5, child: AddExtraItems(widget.unit, widget.options))
),
Icon(
// <-- Icon
Icons.add,
size: 24.0,
),
], ],
), ),
), ),
), );
], }
), if (state is AdditionalItemsErrorState) {
); return SomethingWentWrong(
}, message: onError,
onpressed: () {
context.read<AdditionalItemBloc>().add(LoadAdditionalItems());
},
);
}
return Container();
},
),
),
); );
} }
} }

View File

@ -4,6 +4,7 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/bloc/passo/barangay/barangay_bloc.dart'; import 'package:unit2/bloc/passo/barangay/barangay_bloc.dart';
import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart';
@ -15,7 +16,9 @@ import 'package:unit2/model/passo/bldg_loc.dart';
import 'package:unit2/model/passo/city.dart'; import 'package:unit2/model/passo/city.dart';
import 'package:unit2/model/passo/land_ref.dart'; import 'package:unit2/model/passo/land_ref.dart';
import 'package:unit2/screens/passo/Building/add_building.dart'; import 'package:unit2/screens/passo/Building/add_building.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/theme-data.dart/form-style.dart'; import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/alerts.dart';
import 'package:unit2/utils/text_container.dart'; import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/error_state.dart'; import 'package:unit2/widgets/error_state.dart';
import 'package:unit2/widgets/passo/custom_button.dart'; import 'package:unit2/widgets/passo/custom_button.dart';
@ -95,204 +98,298 @@ class _BldgLocationLandrefPage extends State<BldgLocationLandrefPage> {
.map((brgy) => brgy.barangayDescription) .map((brgy) => brgy.barangayDescription)
.toList() .toList()
.cast<String>(); .cast<String>();
return SingleChildScrollView( return StatefulBuilder(builder: (context, locationState) {
child: Padding( return SingleChildScrollView(
padding: const EdgeInsets.all(20.0), child: Padding(
child: Column( padding: const EdgeInsets.all(20.0),
children: [ child: Column(
Container( children: [
margin: const EdgeInsets.only( Container(
left: 0, top: 20, right: 0, bottom: 10), margin: const EdgeInsets.only(
child: const Text('BUILDING LOCATION', left: 0, top: 20, right: 0, bottom: 10),
style: TextStyle( child: const Text('BUILDING LOCATION',
fontWeight: FontWeight.bold, style: TextStyle(
fontSize: 18), fontWeight: FontWeight.bold,
textAlign: TextAlign.left), fontSize: 18),
), textAlign: TextAlign.left),
Row( ),
mainAxisAlignment: Row(
MainAxisAlignment.spaceEvenly, mainAxisAlignment:
children: <Widget>[ MainAxisAlignment.spaceEvenly,
Expanded( children: <Widget>[
// optional flex property if flex is 1 because the default flex is 1 Expanded(
child: Container(
height: 45.0,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.grey,
width: 1.0,
),
borderRadius:
BorderRadius.circular(5.0),
),
child: Align(
alignment: Alignment.center,
child: Text(
"AGUSAN DEL NORTE",
style: TextStyle(fontSize: 15),
),
),
),
),
const SizedBox(width: 10.0),
Expanded(
flex: 1,
child: FormBuilderDropdown<City>(
name: 'municipality',
autofocus: false,
decoration: normalTextFieldStyle(
"Municipality", ""),
items: cityList
.map((city) =>
DropdownMenuItem<City>(
value: city,
child: Text(city
.cityDescription!), // Use cityDescription instead of cityName
))
.toList(),
onChanged: (selectedCity) {
if (selectedCity != null) {
final selectedCityCode =
selectedCity.cityCode;
final barangayBloc =
context.read<BarangayBloc>();
barangayBloc.add(LoadBarangay(
id: selectedCityCode!)); // Use selectedCityCode directly
}
},
)),
]),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1, flex: 1,
child: customTextField( child: customTextField(
"Province / City", "", 'province')), "No. / Street", "", 'street'),
const SizedBox(width: 10.0), ),
Expanded( const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customDropDownField(
"Brgy. / District",
"",
'brgy',
brgyNAmes))
]),
Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('LAND REFERENCE',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18),
textAlign: TextAlign.left),
),
customTextField("Land Owner", "", 'l_owner'),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1, flex: 1,
child: FormBuilderDropdown<City>( child: customTextField("OCT/TCT/CLOA No.",
name: 'municipality', "", 'oct_tct_cloa'),
autofocus: false, ),
decoration: normalTextFieldStyle( const SizedBox(width: 10.0),
"Municipality", ""), Expanded(
items: cityList // optional flex property if flex is 1 because the default flex is 1
.map((city) => flex: 1,
DropdownMenuItem<City>( child: customTextField(
value: city, "Survey No.", "", 'survey_no'))
child: Text(city ]),
.cityDescription!), // Use cityDescription instead of cityName Row(
)) mainAxisAlignment:
.toList(), MainAxisAlignment.spaceEvenly,
onChanged: (selectedCity) { children: <Widget>[
if (selectedCity != null) { Expanded(
final selectedCityCode =
selectedCity.cityCode;
final barangayBloc =
context.read<BarangayBloc>();
barangayBloc.add(LoadBarangay(
id: selectedCityCode!)); // Use selectedCityCode directly
}
},
)),
]),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"No. / Street", "", 'street'),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customDropDownField(
"Brgy. / District",
"",
'brgy',
brgyNAmes))
]),
Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('LAND REFERENCE',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18),
textAlign: TextAlign.left),
),
customTextField("Land Owner", "", 'l_owner'),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"OCT/TCT/CLOA No.", "", 'oct_tct_cloa'),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1, flex: 1,
child: customTextField( child: customTextField(
"Survey No.", "", 'survey_no')) "Lot No.", "", 'lot_no'),
]), ),
Row( const SizedBox(width: 10.0),
mainAxisAlignment: Expanded(
MainAxisAlignment.spaceEvenly, // optional flex property if flex is 1 because the default flex is 1
children: <Widget>[ flex: 1,
Expanded( child: customTextField(
flex: 1, "Blk No.", "", 'blk_no'))
child: customTextField( ]),
"Lot No.", "", 'lot_no'), Row(
), mainAxisAlignment:
const SizedBox(width: 10.0), MainAxisAlignment.spaceEvenly,
Expanded( children: <Widget>[
// optional flex property if flex is 1 because the default flex is 1 Expanded(
flex: 1, flex: 1,
child: customTextField( child: customTextField(
"Blk No.", "", 'blk_no')) "TD / ARP No.", "", 'l_td_arp'),
]), ),
Row( const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child:
customTextField("Area", "", 'area'))
]),
SizedBox(
height: 50,
),
Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.spaceEvenly, MainAxisAlignment.spaceEvenly,
children: <Widget>[ children: [
Expanded( CustomButton(
flex: 1, icon: const Icon(Icons.chevron_left_rounded,
child: customTextField( color: Colors.white),
"TD / ARP No.", "", 'l_td_arp'), onPressed: () {
{
widget.PrevBtn();
}
;
},
), ),
const SizedBox(width: 10.0), // Builder(builder: (context) {
Expanded( // return CustomButton(
// optional flex property if flex is 1 because the default flex is 1 // icon: const Icon(
flex: 1, // Icons.chevron_right_rounded,
child: // color: Colors.white),
customTextField("Area", "", 'area')) // onPressed: () async {
]), // {
SizedBox( // try {
height: 50, // final progress =
), // ProgressHUD.of(context);
Row( // Future.delayed(Duration(seconds: 3),
mainAxisAlignment: MainAxisAlignment.spaceEvenly, // () {
children: [ // progress?.dismiss();
CustomButton( // });
icon: const Icon(Icons.chevron_left_rounded, // final tempID = await SharedPreferences
color: Colors.white), // .getInstance();
onPressed: () { // var bldgLocData = BldgLoc(
{ // id: tempID.getInt('tempid')! - 1,
widget.PrevBtn(); // street: formKey.currentState
} // ?.value['street'],
; // barangay: formKey
}, // .currentState?.value['brgy'],
), // municipality: formKey
CustomButton( // .currentState
icon: const Icon(Icons.chevron_right_rounded, // ?.value['municipality']
color: Colors.white), // .cityDescription,
onPressed: () async { // province: "Agusan Del Norte");
{ // var landRefData = LandRef(
final tempID = // id: tempID.getInt('tempid')! - 1,
await SharedPreferences.getInstance(); // owner: formKey
var bldgLocData = BldgLoc( // .currentState?.value['l_owner'],
id: tempID.getInt('tempid')! - 1, // cloaNo: formKey.currentState
street: formKey // ?.value['oct_tct_cloa'],
.currentState?.value['street'], // lotNo: formKey
barangay: // .currentState?.value['lot_no'],
formKey.currentState?.value['brgy'], // tdn: formKey.currentState
municipality: formKey // ?.value['l_td_arp'],
.currentState // area: formKey
?.value['municipality'] // .currentState?.value['area'],
.cityDescription, // surveyNo: formKey.currentState
province: formKey // ?.value['survey_no'],
.currentState?.value['province'], // blkNo: formKey
); // .currentState?.value['blk_no'],
var landRefData = LandRef( // );
id: tempID.getInt('tempid')! - 1, // context.read<PropertyInfoBloc>()
owner: formKey // ..add(UpdateBldgLoc(
.currentState?.value['l_owner'], // bldg_loc: bldgLocData))
cloaNo: formKey.currentState // ..add(UpdateLandRef(
?.value['oct_tct_cloa'], // land_ref: landRefData));
lotNo: formKey // } catch (e) {
.currentState?.value['lot_no'], // Fluttertoast.showToast(
tdn: formKey // msg:
.currentState?.value['l_td_arp'], // "Slow internet connection, please try again!");
area: // }
formKey.currentState?.value['area'], // }
surveyNo: formKey // ;
.currentState?.value['survey_no'], // },
blkNo: formKey // );
.currentState?.value['blk_no'], // })
); Builder(builder: (context) {
context.read<PropertyInfoBloc>() return CustomButton(
..add(UpdateBldgLoc( icon: const Icon(
bldg_loc: bldgLocData)) Icons.chevron_right_rounded,
..add(UpdateLandRef( color: Colors.white,
land_ref: landRefData)); ),
onPressed: () async {
try {
// Get the ProgressHUD instance
final progress =
ProgressHUD.of(context);
widget.NextBtn(); // Show the progress indicator
} progress?.show();
;
}, // Dismiss the progress indicator
) progress?.dismiss();
],
) // Rest of your code...
], final tempID = await SharedPreferences
.getInstance();
var bldgLocData = BldgLoc(
id: tempID.getInt('tempid')! - 1,
street: formKey.currentState
?.value['street'],
barangay: formKey
.currentState?.value['brgy'],
municipality: formKey
.currentState
?.value['municipality']
.cityDescription,
province: "Agusan Del Norte");
var landRefData = LandRef(
id: tempID.getInt('tempid')! - 1,
owner: formKey
.currentState?.value['l_owner'],
cloaNo: formKey.currentState
?.value['oct_tct_cloa'],
lotNo: formKey
.currentState?.value['lot_no'],
tdn: formKey.currentState
?.value['l_td_arp'],
area: formKey
.currentState?.value['area'],
surveyNo: formKey.currentState
?.value['survey_no'],
blkNo: formKey
.currentState?.value['blk_no'],
);
context.read<PropertyInfoBloc>()
..add(UpdateBldgLoc(
bldg_loc: bldgLocData))
..add(UpdateLandRef(
land_ref: landRefData));
} catch (e) {
Fluttertoast.showToast(
msg:
"Slow internet connection, please try again!",
);
}
},
);
})
],
)
],
),
), ),
), );
); });
} }
if (state is BarangayErrorState) { if (state is BarangayErrorState) {
return SomethingWentWrong( return SomethingWentWrong(
@ -314,6 +411,22 @@ class _BldgLocationLandrefPage extends State<BldgLocationLandrefPage> {
}, },
); );
} }
if (state is ShowBldgLocErrorAlertState) {
WidgetsBinding.instance.addPostFrameCallback((_) {
errorAlert(
context, "Something went wrong", "Please try again...", () {
Navigator.of(context).pop();
});
});
}
if (state is ShowLandRefErrorAlertState) {
WidgetsBinding.instance.addPostFrameCallback((_) {
errorAlert(
context, "Something went wrong", "Please try again...", () {
Navigator.of(context).pop();
});
});
}
return Container(); return Container();
}, },
), ),
@ -325,12 +438,13 @@ class _BldgLocationLandrefPage extends State<BldgLocationLandrefPage> {
// Wait for the state change indicating completion // Wait for the state change indicating completion
final propertyInfoState = context.read<PropertyInfoBloc>().state; final propertyInfoState = context.read<PropertyInfoBloc>().state;
if (propertyInfoState is PropertyInfoErrorState) { if (propertyInfoState is ShowBldgLocErrorAlertState ||
propertyInfoState is ShowLandRefErrorAlertState) {
// Check if the add operation was successful // Check if the add operation was successful
return true; // You'll need to define this in your state class return false; // You'll need to define this in your state class
} }
// Return false if the state didn't change as expected // Return false if the state didn't change as expected
return false; return true;
} }
} }

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart';
import 'package:unit2/model/passo/general_description.dart'; import 'package:unit2/model/passo/general_description.dart';
@ -177,41 +178,48 @@ class _GeneralDescriptionPage extends State<GeneralDescriptionPage> {
color: Colors.white), color: Colors.white),
onPressed: () async { onPressed: () async {
{ {
final tempID = await SharedPreferences.getInstance(); try {
widget.onPutGeneralDescription(); final tempID = await SharedPreferences.getInstance();
var genDescData = GeneralDesc(
id: tempID.getInt('tempid')! - 1,
bldgKind:
formKey.currentState?.value['bldg_type'].building,
strucType:
formKey.currentState?.value['bldg_type'].bldgType,
bldgPermit:
formKey.currentState?.value['bldg_permit'],
dateIssued: formKey.currentState?.value['coc_issued'],
cct: formKey.currentState?.value['cct'],
certCompletionIssued:
formKey.currentState?.value['coc_issued'],
certOccupancyIssued:
formKey.currentState?.value['coo_issued'],
dateCompleted:
formKey.currentState?.value['date_cnstructed'],
dateOccupied:
formKey.currentState?.value['date_occupied'],
bldgAge: int.tryParse(
formKey.currentState?.value['bldg_age']),
noStoreys: int.tryParse(
formKey.currentState?.value['no_of_storeys']),
area1Stfloor: '0',
area2Ndfloor: '0',
area3Rdfloor: '0',
area4Thfloor: '0',
totalFloorArea:
formKey.currentState?.value['total_area'],
floorSketch: null,
actualUse: formKey.currentState?.value['actual_use']);
context.read<PropertyInfoBloc>() var genDescData = GeneralDesc(
..add(UpdateGeneralDesc(gen_desc: genDescData)); id: tempID.getInt('tempid')! - 1,
bldgKind: formKey
.currentState?.value['bldg_type'].building,
strucType: formKey
.currentState?.value['bldg_type'].bldgType,
bldgPermit:
formKey.currentState?.value['bldg_permit'],
dateIssued:
formKey.currentState?.value['coc_issued'],
cct: formKey.currentState?.value['cct'],
certCompletionIssued:
formKey.currentState?.value['coc_issued'],
certOccupancyIssued:
formKey.currentState?.value['coo_issued'],
dateCompleted:
formKey.currentState?.value['date_cnstructed'],
dateOccupied:
formKey.currentState?.value['date_occupied'],
bldgAge: int.tryParse(
formKey.currentState?.value['bldg_age']),
noStoreys: int.tryParse(
formKey.currentState?.value['no_of_storeys']),
area1Stfloor: '0',
area2Ndfloor: '0',
area3Rdfloor: '0',
area4Thfloor: '0',
totalFloorArea:
formKey.currentState?.value['total_area'],
floorSketch: null,
actualUse:
formKey.currentState?.value['actual_use']);
context.read<PropertyInfoBloc>()
..add(UpdateGeneralDesc(gen_desc: genDescData));
} catch (e) {
Fluttertoast.showToast(
msg: "Slow internet connection, please try again!");
}
} }
; ;
}, },
@ -223,4 +231,17 @@ class _GeneralDescriptionPage extends State<GeneralDescriptionPage> {
), ),
); );
} }
Future<bool> _waitForAddPropertyInfoToComplete() async {
// Wait for the state change indicating completion
final propertyInfoState = context.read<PropertyInfoBloc>().state;
if (propertyInfoState is ShowGenDescErrorAlertState) {
// Check if the add operation was unsuccessful
return true; // You'll need to define this in your state class
}
// Return false if the state didn't change as expected
return false;
}
} }

View File

@ -6,6 +6,7 @@ import 'package:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/bloc/passo/bulding/additional_item/additional_item_bloc.dart'; import 'package:unit2/bloc/passo/bulding/additional_item/additional_item_bloc.dart';
import 'package:unit2/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart'; import 'package:unit2/bloc/passo/bulding/property_appraisal/property_appraisal_bloc.dart';
import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart';
import 'package:unit2/model/passo/additional_items.dart'; import 'package:unit2/model/passo/additional_items.dart';
import 'package:unit2/model/passo/property_appraisal.dart'; import 'package:unit2/model/passo/property_appraisal.dart';
import 'package:unit2/screens/passo/Building/add_building.dart'; import 'package:unit2/screens/passo/Building/add_building.dart';
@ -1029,4 +1030,17 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
}, },
); );
} }
Future<bool> _waitForAddPropertyInfoToComplete() async {
// Wait for the state change indicating completion
final propertyInfoState = context.read<PropertyInfoBloc>().state;
if (propertyInfoState is PropertyInfoErrorState) {
// Check if the add operation was unsuccessful
return true; // You'll need to define this in your state class
}
// Return false if the state didn't change as expected
return false;
}
} }

View File

@ -1002,76 +1002,104 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
bldgapprDetailsId: bldgapprDetailsId:
tempID.getInt('tempid')! - 1, tempID.getInt('tempid')! - 1,
actualUse: formKey.currentState! actualUse: formKey.currentState!
.value['actual_use'], .value['actual_use'] ??
'', // Replace null with an empty string
marketValue: '0.00', marketValue: '0.00',
assessmentLevel: '0.00', assessmentLevel: '0.00',
assessedValue: '0.00', assessedValue: '0.00',
taxable: isTaxable, taxable: isTaxable,
exempt: isExempt, exempt: isExempt,
qtr: int.parse(formKey qtr: int.parse(formKey
.currentState!.value['qtr']), .currentState!
.value['qtr'] ??
'0'), // Replace null with '0'
yr: int.parse(formKey yr: int.parse(formKey
.currentState!.value['yr']),
appraisedbyName: formKey
.currentState! .currentState!
.value['appraised_by'] .value['yr'] ??
.firstname + '0'), // Replace null with '0'
appraisedbyName: (formKey
.currentState!
.value['appraised_by']
?.firstname ??
'') +
' ' + ' ' +
formKey (formKey
.currentState! .currentState!
.value['appraised_by'] .value['appraised_by']
.middlename + ?.middlename ??
'') +
' ' + ' ' +
formKey (formKey
.currentState! .currentState!
.value['appraised_by'] .value['appraised_by']
.lastname, ?.lastname ??
''),
appraisedbyDate: formKey appraisedbyDate: formKey
.currentState! .currentState!
.value['app_date'], .value['app_date']
recommendapprName: formKey as DateTime? ??
.currentState! DateTime
.value['rec_approval'] .now(), // Replace null with current date
.firstname + recommendapprName: (formKey
.currentState!
.value['rec_approval']
?.firstname ??
'') +
' ' + ' ' +
formKey (formKey
.currentState! .currentState!
.value['rec_approval'] .value['rec_approval']
.middlename + ?.middlename ??
'') +
' ' + ' ' +
formKey (formKey
.currentState! .currentState!
.value['rec_approval'] .value['rec_approval']
.lastname, ?.lastname ??
''),
recommendapprDate: formKey recommendapprDate: formKey
.currentState! .currentState!
.value['rec_date'], .value['rec_date']
approvedbyName: formKey as DateTime? ??
.currentState! DateTime
.value['apprvd_by'] .now(), // Replace null with current date
.firstname + approvedbyName: (formKey
.currentState!
.value['apprvd_by']
?.firstname ??
'') +
' ' + ' ' +
formKey (formKey
.currentState! .currentState!
.value['apprvd_by'] .value['apprvd_by']
.middlename + ?.middlename ??
'') +
' ' + ' ' +
formKey (formKey
.currentState! .currentState!
.value['apprvd_by'] .value['apprvd_by']
.lastname, ?.lastname ??
''),
memoranda: _memoranda, memoranda: _memoranda,
swornstatementNo: formKey swornstatementNo: formKey
.currentState! .currentState!.value[
.value['sworn_statement'], 'sworn_statement'] ??
'', // Replace null with an empty string
dateReceived: formKey dateReceived: formKey
.currentState! .currentState!
.value['date_received'], .value['date_received']
as DateTime? ??
DateTime
.now(), // Replace null with current date
entryDateAssessment: formKey entryDateAssessment: formKey
.currentState! .currentState!
.value['date_of_entry'], .value['date_of_entry']
entryDateBy: formKey as DateTime? ??
.currentState!.value['by'], DateTime
.now(), // Replace null with current date
entryDateBy: formKey.currentState!
.value['by'] ??
'', // Replace null with an empty string
); );
propertyAssessments.add(ass); propertyAssessments.add(ass);

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart';
import 'package:unit2/model/passo/property_info.dart'; import 'package:unit2/model/passo/property_info.dart';
import 'package:unit2/screens/passo/Building/add_building.dart'; import 'package:unit2/screens/passo/Building/add_building.dart';
@ -98,42 +99,52 @@ class _PropertyInfoPage extends State<PropertyInfoPage> {
CustomButton( CustomButton(
icon: const Icon(Icons.chevron_right, color: Colors.white), icon: const Icon(Icons.chevron_right, color: Colors.white),
onPressed: () async { onPressed: () async {
var property_info = PropertyInfo( try {
id: 1, var property_info = PropertyInfo(
transCode: formKey.currentState!.value['transaction_code'] id: 1,
.toString(), transCode: formKey
tdn: formKey.currentState!.value['arp_td'], .currentState!.value['transaction_code']
pin: formKey.currentState!.value['pin'], .toString(),
owner: formKey.currentState!.value['owner'], tdn: formKey.currentState!.value['arp_td'],
address: formKey.currentState!.value['address'], pin: formKey.currentState!.value['pin'],
telno: formKey.currentState!.value['tel_no'], owner: formKey.currentState!.value['owner'],
tin: formKey.currentState!.value['tin'], address: formKey.currentState!.value['address'],
adminUser: formKey.currentState!.value['benificiary'], telno: formKey.currentState!.value['tel_no'],
adminAddress: tin: formKey.currentState!.value['tin'],
formKey.currentState!.value['benificiary_address'], adminUser: formKey.currentState!.value['benificiary'],
adminTin: formKey.currentState!.value['benificiary_tin'], adminAddress:
adminTelno: formKey.currentState!.value['benificiary_address'],
formKey.currentState!.value['benificiary_telno'], adminTin:
assessedById: '1', formKey.currentState!.value['benificiary_tin'],
assessedByName: 'Cyril', adminTelno:
faasType: "BUILDING", formKey.currentState!.value['benificiary_telno'],
dateModified: DateTime.now(), assessedById: '1',
dateCreated: DateTime.now()); assessedByName: 'Cyril',
faasType: "BUILDING",
dateModified: DateTime.now(),
dateCreated: DateTime.now());
// Dispatch the event to add the property_info // Dispatch the event to add the property_info
context.read<PropertyInfoBloc>().add( context.read<PropertyInfoBloc>().add(
AddPropertyInfo(property_info: property_info), AddPropertyInfo(property_info: property_info),
); );
widget.handleButtonPress();
} catch (e) {
Fluttertoast.showToast(
msg: "Slow internet connection, please try again!");
}
// Wait for the event to complete and get the result // Wait for the event to complete and get the result
bool success = await _waitForAddPropertyInfoToComplete(); // bool failed = await _waitForAddPropertyInfoToComplete();
if (success) { // if (failed) {
// Proceed to the next step or perform an action // // Proceed to the next step or perform an action
widget.handleButtonPress(); // Fluttertoast.showToast(
} else { // msg: "Slow internet connection, please try again!");
// Stay or show an error message // } else {
} // // Stay or show an error message
// widget.handleButtonPress();
// }
}, },
) )
]), ]),
@ -145,8 +156,8 @@ class _PropertyInfoPage extends State<PropertyInfoPage> {
// Wait for the state change indicating completion // Wait for the state change indicating completion
final propertyInfoState = context.read<PropertyInfoBloc>().state; final propertyInfoState = context.read<PropertyInfoBloc>().state;
if (propertyInfoState is PropertyInfoLoaded) { if (propertyInfoState is PropertyInfoErrorState) {
// Check if the add operation was successful // Check if the add operation was unsuccessful
return true; // You'll need to define this in your state class return true; // You'll need to define this in your state class
} }

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:multiselect/multiselect.dart'; import 'package:multiselect/multiselect.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart';
@ -51,371 +52,380 @@ class _StructuralMaterialsPage extends State<StructuralMaterialsPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SingleChildScrollView( return StatefulBuilder(builder: (context, structuralState) {
padding: const EdgeInsets.all(30.0), return SingleChildScrollView(
child: Column( padding: const EdgeInsets.all(30.0),
children: [ child: Column(
Container( children: [
margin: Container(
const EdgeInsets.only(left: 0, top: 20, right: 0, bottom: 10), margin:
child: const Text('STRUCTURAL MATERIALS', const EdgeInsets.only(left: 0, top: 20, right: 0, bottom: 10),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), child: const Text('STRUCTURAL MATERIALS',
textAlign: TextAlign.left), style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
), textAlign: TextAlign.left),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(
'FOUNDATION',
textAlign: TextAlign.start,
), ),
Row( Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
children: [ Text(
const Text('Others'), 'FOUNDATION',
Checkbox( textAlign: TextAlign.start,
checkColor: Colors.white,
value: foundationOthers,
onChanged: (bool? value) {
setState(() {
foundationOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: foundationOthers,
child: customTextField(
"Enter other foundation", "", "other_foundation"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
setState(() {
foundation = x;
});
},
options: const ['Reinforced Concrete', 'Plain Concrete'],
selectedValues: foundation,
whenEmpty: 'Select Foundations',
), ),
), Row(
), children: [
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Text('Others'),
Text( Checkbox(
'COLUMNS', checkColor: Colors.white,
textAlign: TextAlign.start, value: foundationOthers,
), onChanged: (bool? value) {
Row( structuralState(() {
children: [ foundationOthers = value!;
const Text('Others'), });
Checkbox( },
checkColor: Colors.white, )
value: columOthers,
onChanged: (bool? value) {
setState(() {
columOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: columOthers,
child: customTextField("Enter other columns", "", "other_column"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
setState(() {
column = x;
});
},
options: const ['Steel', 'Reinforced Concrete', 'Wood'],
selectedValues: column,
whenEmpty: 'Select Column/s',
),
),
),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(
'BEAMS',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: beamsOthers,
onChanged: (bool? value) {
setState(() {
beamsOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: beamsOthers,
child: customTextField("Enter other beam/s", "", "other_beam"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
setState(() {
beam = x;
});
},
options: const ['Steel', 'Reinforced Concrete', 'Wood'],
selectedValues: beam,
whenEmpty: 'Select Beam/s',
),
),
),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(
'TRUSS FRAMING',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: tfOthers,
onChanged: (bool? value) {
setState(() {
tfOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: tfOthers,
child: customTextField(
"Enter other truss framing/s", "", "other_tf"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
setState(() {
truss_framing = x;
});
},
options: const ['Steel', 'Wood'],
selectedValues: truss_framing,
whenEmpty: 'Select Truss Framing/s',
),
),
),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(
'ROOF',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: roofOthers,
onChanged: (bool? value) {
setState(() {
roofOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: roofOthers,
child: customTextField("Enter other roof/s", "", "other_roof"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
setState(() {
roof = x;
});
},
options: const [
'Reinforced Concrete',
'Tiles',
'G.I Sheet',
'Aluminum',
'Asbestos',
'Long Span',
'Concrete Desk',
'Nipa/Anahaw/Cogon'
], ],
selectedValues: roof, ),
whenEmpty: 'Select Roof/s', ]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: foundationOthers,
child: customTextField(
"Enter other foundation", "", "other_foundation"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
structuralState(() {
foundation = x;
});
},
options: const ['Reinforced Concrete', 'Plain Concrete'],
selectedValues: foundation,
whenEmpty: 'Select Foundations',
),
), ),
), ),
), Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(
Text( 'COLUMNS',
'FLOORING', textAlign: TextAlign.start,
textAlign: TextAlign.start, ),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: columOthers,
onChanged: (bool? value) {
structuralState(() {
columOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: columOthers,
child:
customTextField("Enter other columns", "", "other_column"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
structuralState(() {
column = x;
});
},
options: const ['Steel', 'Reinforced Concrete', 'Wood'],
selectedValues: column,
whenEmpty: 'Select Column/s',
),
),
),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(
'BEAMS',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: beamsOthers,
onChanged: (bool? value) {
structuralState(() {
beamsOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: beamsOthers,
child: customTextField("Enter other beam/s", "", "other_beam"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
structuralState(() {
beam = x;
});
},
options: const ['Steel', 'Reinforced Concrete', 'Wood'],
selectedValues: beam,
whenEmpty: 'Select Beam/s',
),
),
),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(
'TRUSS FRAMING',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: tfOthers,
onChanged: (bool? value) {
structuralState(() {
tfOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: tfOthers,
child: customTextField(
"Enter other truss framing/s", "", "other_tf"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
structuralState(() {
truss_framing = x;
});
},
options: const ['Steel', 'Wood'],
selectedValues: truss_framing,
whenEmpty: 'Select Truss Framing/s',
),
),
),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(
'ROOF',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: roofOthers,
onChanged: (bool? value) {
structuralState(() {
roofOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: roofOthers,
child: customTextField("Enter other roof/s", "", "other_roof"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
structuralState(() {
roof = x;
});
},
options: const [
'Reinforced Concrete',
'Tiles',
'G.I Sheet',
'Aluminum',
'Asbestos',
'Long Span',
'Concrete Desk',
'Nipa/Anahaw/Cogon'
],
selectedValues: roof,
whenEmpty: 'Select Roof/s',
),
),
),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(
'FLOORING',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: flooringOthers,
onChanged: (bool? value) {
structuralState(() {
flooringOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: flooringOthers,
child: customTextField(
"Enter other flooring/s", "", "other_flooring"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
structuralState(() {
flooring = x;
});
},
options: const [
'Reinforced Concrete',
'Plain Cement',
'Marble',
'Wood',
'Tiles'
],
selectedValues: flooring,
whenEmpty: 'Select Flooring/s',
),
),
),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(
'WALLS & PARTITIONS',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: wpOthers,
onChanged: (bool? value) {
structuralState(() {
wpOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: wpOthers,
child: customTextField(
"Enter other walls & partition/s", "", "other_wp"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
setState(() {
walls = x;
});
},
options: const [
'Reinforced Concrete',
'Plain Concrete',
'Wood',
'CHIB',
'G.I Sheet',
'Build-a-wall',
'Sawali',
'Bamboo'
],
selectedValues: walls,
whenEmpty: 'Select Walls & Partition/s',
),
),
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
const Text('Others'), CustomButton(
Checkbox( icon: const Icon(Icons.chevron_left_rounded,
checkColor: Colors.white, color: Colors.white),
value: flooringOthers, onPressed: () {
onChanged: (bool? value) { {
setState(() { widget.PrevBtn();
flooringOthers = value!; }
}); ;
},
),
CustomButton(
icon: const Icon(Icons.chevron_right_rounded,
color: Colors.white),
onPressed: () async {
{
try {
final tempID = await SharedPreferences.getInstance();
var strucMaterials = StructureMaterialsII(
id: tempID.getInt('tempid')! - 1,
foundation: foundationOthers
? formKey
.currentState!.value['other_foundation']
.split(',')
: foundation,
columns: columOthers
? formKey.currentState!.value['other_column']
.split(',')
: column,
beams: beamsOthers
? formKey.currentState!.value['other_beam']
.split(',')
: beam,
trussFraming: tfOthers
? formKey.currentState!.value['other_tf']
.split(',')
: truss_framing,
roof: roofOthers
? formKey.currentState!.value['other_roof']
.split(',')
: roof,
flooring: flooringOthers
? formKey.currentState!.value['other_flooring']
.split(',')
: flooring,
walls: wpOthers
? formKey.currentState!.value['other_wp']
.split(',')
: walls,
others: ["Others"]);
context.read<PropertyInfoBloc>()
..add(UpdateStrucMaterials(data: strucMaterials));
} catch (e) {
Fluttertoast.showToast(
msg: "Slow internet connection, please try again!");
}
}
;
}, },
) )
], ],
), )
]), ],
Padding( ),
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), );
child: Visibility( });
visible: flooringOthers,
child: customTextField(
"Enter other flooring/s", "", "other_flooring"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
setState(() {
flooring = x;
});
},
options: const [
'Reinforced Concrete',
'Plain Cement',
'Marble',
'Wood',
'Tiles'
],
selectedValues: flooring,
whenEmpty: 'Select Flooring/s',
),
),
),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(
'WALLS & PARTITIONS',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: wpOthers,
onChanged: (bool? value) {
setState(() {
wpOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: wpOthers,
child: customTextField(
"Enter other walls & partition/s", "", "other_wp"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
setState(() {
walls = x;
});
},
options: const [
'Reinforced Concrete',
'Plain Concrete',
'Wood',
'CHIB',
'G.I Sheet',
'Build-a-wall',
'Sawali',
'Bamboo'
],
selectedValues: walls,
whenEmpty: 'Select Walls & Partition/s',
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
CustomButton(
icon:
const Icon(Icons.chevron_left_rounded, color: Colors.white),
onPressed: () {
{
widget.NextBtn();
}
;
},
),
CustomButton(
icon: const Icon(Icons.chevron_right_rounded,
color: Colors.white),
onPressed: () async {
{
final tempID = await SharedPreferences.getInstance();
var strucMaterials = StructureMaterialsII(
id: tempID.getInt('tempid')! - 1,
foundation: foundationOthers
? formKey.currentState!.value['other_foundation']
.split(',')
: foundation,
columns: columOthers
? formKey.currentState!.value['other_column']
.split(',')
: column,
beams: beamsOthers
? formKey.currentState!.value['other_beam']
.split(',')
: beam,
trussFraming: tfOthers
? formKey.currentState!.value['other_tf'].split(',')
: truss_framing,
roof: roofOthers
? formKey.currentState!.value['other_roof']
.split(',')
: roof,
flooring: flooringOthers
? formKey.currentState!.value['other_flooring']
.split(',')
: flooring,
walls: wpOthers
? formKey.currentState!.value['other_wp'].split(',')
: walls,
others: ["Others"]);
context.read<PropertyInfoBloc>()
..add(UpdateStrucMaterials(data: strucMaterials));
widget.PrevBtn();
}
;
},
)
],
)
],
),
);
} }
} }

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
@ -16,6 +17,8 @@ import 'package:unit2/screens/passo/Building/edit_building/property_appraisal.da
import 'package:unit2/screens/passo/Building/edit_building/property_assessement_edit.dart'; import 'package:unit2/screens/passo/Building/edit_building/property_assessement_edit.dart';
import 'package:unit2/screens/passo/Building/edit_building/property_owner_info.dart'; import 'package:unit2/screens/passo/Building/edit_building/property_owner_info.dart';
import 'package:unit2/screens/passo/Building/edit_building/structural_materials.dart'; import 'package:unit2/screens/passo/Building/edit_building/structural_materials.dart';
import 'package:unit2/screens/passo/Building/edit_building/structural_materials_edit.dart';
import 'package:unit2/screens/passo/Land/add_land.dart';
import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/utils/text_container.dart'; import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/error_state.dart'; import 'package:unit2/widgets/error_state.dart';
@ -54,117 +57,121 @@ class _EditBuilding extends State<EditBuilding> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return Scaffold(
debugShowCheckedModeBanner: false, appBar: AppBar(
home: Scaffold( centerTitle: true,
appBar: AppBar( backgroundColor: primary,
centerTitle: true, title: Text('Building FAAS Edit'),
backgroundColor: primary, ),
title: Text('Building FAAS Edit'), body: ProgressHUD(
), padding: const EdgeInsets.all(24),
body: ProgressHUD( backgroundColor: Colors.black87,
padding: const EdgeInsets.all(24), indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
backgroundColor: Colors.black87, child: BlocConsumer<UnitConstructBloc, UnitConstructState>(
indicatorWidget: const SpinKitFadingCircle(color: Colors.white), listener: (context, state) {
child: BlocConsumer<UnitConstructBloc, UnitConstructState>( if (state is UnitConstructLoading) {
listener: (context, state) { final progress = ProgressHUD.of(context);
if (state is UnitConstructLoading) { progress!.showWithText("Please wait...");
final progress = ProgressHUD.of(context); }
progress!.showWithText("Please wait..."); if (state is UnitConstructLoaded) {
} final progress = ProgressHUD.of(context);
if (state is UnitConstructLoaded) { progress?.dismiss();
final progress = ProgressHUD.of(context); }
progress?.dismiss(); if (state is UnitConstructErrorState) {
} final progress = ProgressHUD.of(context);
if (state is UnitConstructErrorState) { progress?.dismiss();
final progress = ProgressHUD.of(context); // Fluttertoast.showToast(
progress?.dismiss(); // msg: onError,
// Fluttertoast.showToast( // fontSize: 24,
// msg: onError, // toastLength: Toast.LENGTH_LONG,
// fontSize: 24, // gravity: ToastGravity.CENTER,
// toastLength: Toast.LENGTH_LONG, // backgroundColor: Colors.black,
// gravity: ToastGravity.CENTER, // textColor: Colors.white);
// backgroundColor: Colors.black, }
// textColor: Colors.white); },
} builder: (context, state) {
}, if (state is UnitConstructLoaded) {
builder: (context, state) { final unit = state.unit;
if (state is UnitConstructLoaded) { return BlocConsumer<ClassComponentsBloc, ClassComponentsState>(
final unit = state.unit; listener: (context, state) {
return BlocConsumer<ClassComponentsBloc, ClassComponentsState>( if (state is ClassComponentLoading) {
listener: (context, state) { final progress = ProgressHUD.of(context);
if (state is ClassComponentLoading) { progress!.showWithText("Please wait...");
final progress = ProgressHUD.of(context); }
progress!.showWithText("Please wait..."); if (state is ClassComponentLoaded) {
} final progress = ProgressHUD.of(context);
if (state is ClassComponentLoaded) { progress?.dismiss();
final progress = ProgressHUD.of(context); }
progress?.dismiss(); if (state is ClassComponentErrorState) {
} final progress = ProgressHUD.of(context);
if (state is ClassComponentErrorState) { progress?.dismiss();
final progress = ProgressHUD.of(context); // Fluttertoast.showToast(
progress?.dismiss(); // msg: onError,
// Fluttertoast.showToast( // fontSize: 24,
// msg: onError, // toastLength: Toast.LENGTH_LONG,
// fontSize: 24, // gravity: ToastGravity.CENTER,
// toastLength: Toast.LENGTH_LONG, // backgroundColor: Colors.black,
// gravity: ToastGravity.CENTER, // textColor: Colors.white);
// backgroundColor: Colors.black, }
// textColor: Colors.white); },
} builder: (context, state) {
}, if (state is ClassComponentLoaded) {
builder: (context, state) { return Column(
if (state is ClassComponentLoaded) { children: [
return Padding( NumberStepper(
padding: const EdgeInsets.all(8.0), numbers: [1, 2, 3, 4, 5, 6, 7],
child: Column( activeStepColor: primary,
children: [ numberStyle: TextStyle(color: Colors.white),
NumberStepper( lineColor: primary,
numbers: [1, 2, 3, 4, 5, 6, 7], // activeStep property set to activeStep variable defined above.
activeStepColor: primary, activeStep: activeStep,
numberStyle: TextStyle(color: Colors.white), activeStepBorderColor: Colors.white,
lineColor: primary, activeStepBorderWidth: 1,
// activeStep property set to activeStep variable defined above. // This ensures step-tapping updates the activeStep.
activeStep: activeStep, onStepReached: (index) {
activeStepBorderColor: Colors.white, setState(() {
activeStepBorderWidth: 1, activeStep = index;
// This ensures step-tapping updates the activeStep. });
onStepReached: (index) { },
setState(() {
activeStep = index;
});
},
),
content(unit, state.classes),
],
), ),
); Expanded(
} child: StatefulBuilder(builder:
if (state is ClassComponentErrorState) { (BuildContext context, StateSetter setState) {
return SomethingWentWrong( return Container(
message: onError, child: content(
onpressed: () { unit,
context state.classes,
.read<ClassComponentsBloc>() ),
.add(LoadClassComponents()); );
}, }),
); ),
} ],
return Container(); );
}, }
); if (state is ClassComponentErrorState) {
} return SomethingWentWrong(
if (state is UnitConstructErrorState) { message: onError,
return SomethingWentWrong( onpressed: () {
message: onError, context
onpressed: () { .read<ClassComponentsBloc>()
context.read<UnitConstructBloc>().add(LoadUnitConstruct()); .add(LoadClassComponents());
}, },
); );
} }
return Container(); return Container();
}, },
), );
}
if (state is UnitConstructErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<UnitConstructBloc>().add(LoadUnitConstruct());
},
);
}
return Container();
},
), ),
), ),
); );
@ -184,7 +191,7 @@ class _EditBuilding extends State<EditBuilding> {
return GeneralDescriptionEdit(unit, widget.faas.id!, NextBtn, PrevBtn); return GeneralDescriptionEdit(unit, widget.faas.id!, NextBtn, PrevBtn);
case 3: case 3:
return StructuralMaterialsPageEdit(widget.faas.id!, NextBtn, PrevBtn); return StructuralMaterialsEditPage(widget.faas.id!, NextBtn, PrevBtn);
case 4: case 4:
return AdditionalItemEditPage( return AdditionalItemEditPage(

View File

@ -1,5 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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:intl/intl.dart';
import 'package:unit2/bloc/passo/bulding/additional_item/additional_item_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/additional_items_edit/additional_items_edit_bloc.dart';
@ -41,265 +43,286 @@ class _AdditionalItemEditPage extends State<AdditionalItemEditPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocConsumer<AdditionalItemsEditBloc, AdditionalItemsEditState>( return Scaffold(
listener: (context, state) { body: ProgressHUD(
// TODO: implement listener padding: const EdgeInsets.all(24),
}, backgroundColor: Colors.black87,
builder: (context, state) { indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
final state = context.watch<AdditionalItemsEditBloc>().state; child: BlocConsumer<AdditionalItemsEditBloc, AdditionalItemsEditState>(
if (state is AdditionalItemsEditLoaded) { listener: (context, state) {
return Column( if (state is AdditionalItemsEditLoading) {
children: [ final progress = ProgressHUD.of(context);
Container( progress!.showWithText("Please wait...");
height: 500, }
child: Expanded( if (state is AdditionalItemsEditLoaded) {
child: SingleChildScrollView( final progress = ProgressHUD.of(context);
child: Padding( progress?.dismiss();
padding: const EdgeInsets.all(15.0), }
child: Column( if (state is AdditionalItemsEditErrorState) {
children: [ final progress = ProgressHUD.of(context);
Container( progress?.dismiss();
margin: const EdgeInsets.only( }
left: 0, top: 20, right: 0, bottom: 10), },
child: const Text('ADDITIONAL ITEMS', builder: (context, state) {
style: TextStyle( final state = context.watch<AdditionalItemsEditBloc>().state;
fontWeight: FontWeight.bold, fontSize: 18), if (state is AdditionalItemsEditLoaded) {
textAlign: TextAlign.left), return Column(
), children: [
Align( Container(
alignment: Alignment.topRight, height: 500,
child: ElevatedButton( child: Expanded(
style: ElevatedButton.styleFrom( child: SingleChildScrollView(
backgroundColor: Colors.red, child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
children: [
Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('ADDITIONAL ITEMS',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18),
textAlign: TextAlign.left),
), ),
onPressed: () { Align(
context alignment: Alignment.topRight,
.read<AdditionalItemsEditBloc>() child: ElevatedButton(
.add(ShowAdditionalItemsEdit()); style: ElevatedButton.styleFrom(
}, backgroundColor: Colors.red,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Text('ADD ITEM'), // <-- Text
const SizedBox(
width: 5,
), ),
const Icon( onPressed: () {
// <-- Icon context
Icons.add, .read<AdditionalItemsEditBloc>()
size: 24.0, .add(ShowAdditionalItemsEdit());
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Text('ADD ITEM'), // <-- Text
const SizedBox(
width: 5,
),
const Icon(
// <-- Icon
Icons.add,
size: 24.0,
),
],
), ),
], ),
), ),
), SingleChildScrollView(
), scrollDirection: Axis.horizontal,
SingleChildScrollView( child: DataTable(
scrollDirection: Axis.horizontal, // ignore: prefer_const_literals_to_create_immutables
child: DataTable( columns: [
// ignore: prefer_const_literals_to_create_immutables const DataColumn(
columns: [ label: Text('Items'),
const DataColumn( ),
label: Text('Items'), const DataColumn(
), label: Text('Unit Value'),
const DataColumn( ),
label: Text('Unit Value'), const DataColumn(
), label: Text('% of BUCC'),
const DataColumn( ),
label: Text('% of BUCC'), const DataColumn(
), label: Text('Market Value'),
const DataColumn( ),
label: Text('Market Value'), const DataColumn(
), label: Text('Action'),
const DataColumn( )
label: Text('Action'),
)
],
rows: state.items.map((dataRow) {
return DataRow(
cells: [
DataCell(Text(dataRow.className)),
DataCell(Text(dataRow.baseUnitValue)),
DataCell(Text(dataRow.unitValue)),
DataCell(Text(((double.parse(
dataRow.adjustedMarketVal)))
.toString())),
DataCell(Row(
children: [
InkWell(
child: Container(
height: 30,
width: 30,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: Icon(
Icons.delete,
color: Colors.white,
size: 20.0,
),
),
onTap: () {
deleteItem(dataRow.id);
},
),
SizedBox(
width: 10,
),
InkWell(
child: Container(
height: 30,
width: 30,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: Icon(
Icons.edit,
color: Colors.white,
size: 20.0,
),
),
onTap: () {},
),
],
))
], ],
); rows: state.items.map((dataRow) {
}).toList(), return DataRow(
), cells: [
DataCell(Text(dataRow.className)),
DataCell(Text(dataRow.baseUnitValue)),
DataCell(Text(dataRow.unitValue)),
DataCell(Text(((double.parse(
dataRow.adjustedMarketVal)))
.toString())),
DataCell(Row(
children: [
InkWell(
child: Container(
height: 30,
width: 30,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: Icon(
Icons.delete,
color: Colors.white,
size: 20.0,
),
),
onTap: () {
deleteItem(dataRow.id);
},
),
SizedBox(
width: 10,
),
InkWell(
child: Container(
height: 30,
width: 30,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: Icon(
Icons.edit,
color: Colors.white,
size: 20.0,
),
),
onTap: () {},
),
],
))
],
);
}).toList(),
),
),
],
),
),
),
),
),
// Padding(
// padding: const EdgeInsets.only(left: 20.0, right: 20.0),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text(
// 'Total',
// style:
// TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
// ),
// Text(
// NumberFormat.currency(locale: 'en-PH', symbol: "")
// .format(_totalMarketValue(state.items)),
// style:
// TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
// )
// ],
// ),
// ),
Padding(
padding: const EdgeInsets.all(15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
CustomButton(
icon: const Icon(Icons.chevron_left_rounded,
color: Colors.white),
onPressed: () {
{
widget.PrevBtn();
}
;
},
),
CustomButton(
icon: const Icon(Icons.chevron_right_rounded,
color: Colors.white),
onPressed: () {
{
widget.NextBtn();
}
;
},
)
],
),
),
],
);
}
if (state is AdditionalItemsEditDeletedState) {
if (state.success) {
WidgetsBinding.instance.addPostFrameCallback((_) {
successAlert(context, "Deletion Successful",
"Extra item has been deleted successfully", () {
Navigator.of(context).pop();
context.read<AdditionalItemsEditBloc>().add(
LoadAdditionalItemsEdit(
items: const <AdditionalItems>[],
id: widget.tempId));
});
});
}
}
if (state is ShowAddItemsScreenEdit) {
return ConstrainedBox(
constraints: BoxConstraints(maxHeight: 1000.0),
child: AlertDialog(
insetPadding: EdgeInsets.symmetric(
horizontal: 20.0,
vertical: 10.0,
),
title: Text(
'ADD EXTRA ITEMS',
textAlign: TextAlign.center,
),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: AddExtraItemsEdit(
widget.unit, widget.options, widget.tempId))
],
),
),
);
}
return Container(
child: Column(
children: [
Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('ADDITIONAL MATERIALS',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
textAlign: TextAlign.left),
),
Align(
alignment: Alignment.topRight,
child: ElevatedButton(
onPressed: () {
context
.read<AdditionalItemBloc>()
.add(ShowAdditionalItems());
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Text('ADD ITEM'), // <-- Text
const SizedBox(
width: 5,
),
const Icon(
// <-- Icon
Icons.add,
size: 24.0,
), ),
], ],
), ),
), ),
), ),
),
),
// Padding(
// padding: const EdgeInsets.only(left: 20.0, right: 20.0),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text(
// 'Total',
// style:
// TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
// ),
// Text(
// NumberFormat.currency(locale: 'en-PH', symbol: "")
// .format(_totalMarketValue(state.items)),
// style:
// TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
// )
// ],
// ),
// ),
Padding(
padding: const EdgeInsets.all(15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
CustomButton(
icon: const Icon(Icons.chevron_left_rounded,
color: Colors.white),
onPressed: () {
{
widget.PrevBtn();
}
;
},
),
CustomButton(
icon: const Icon(Icons.chevron_right_rounded,
color: Colors.white),
onPressed: () {
{
widget.NextBtn();
}
;
},
)
],
),
),
],
);
}
if (state is AdditionalItemsEditDeletedState) {
if (state.success) {
WidgetsBinding.instance.addPostFrameCallback((_) {
successAlert(context, "Deletion Successful",
"Extra item has been deleted successfully", () {
Navigator.of(context).pop();
context.read<AdditionalItemsEditBloc>().add(
LoadAdditionalItemsEdit(
items: const <AdditionalItems>[], id: widget.tempId));
});
});
}
}
if (state is ShowAddItemsScreenEdit) {
return ConstrainedBox(
constraints: BoxConstraints(maxHeight: 1000.0),
child: AlertDialog(
insetPadding: EdgeInsets.symmetric(
horizontal: 20.0,
vertical: 10.0,
),
title: Text(
'ADD EXTRA ITEMS',
textAlign: TextAlign.center,
),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: AddExtraItemsEdit(
widget.unit, widget.options, widget.tempId))
], ],
), ),
), );
); },
} ),
return Container( ),
child: Column(
children: [
Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('ADDITIONAL MATERIALS',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
textAlign: TextAlign.left),
),
Align(
alignment: Alignment.topRight,
child: ElevatedButton(
onPressed: () {
context
.read<AdditionalItemBloc>()
.add(ShowAdditionalItems());
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Text('ADD ITEM'), // <-- Text
const SizedBox(
width: 5,
),
const Icon(
// <-- Icon
Icons.add,
size: 24.0,
),
],
),
),
),
],
),
);
},
); );
} }
} }

View File

@ -35,388 +35,395 @@ class _BldgLocLandRefEdit extends State<BldgLocLandRefEdit> {
Set<String> seenCityCodes = Set<String>(); Set<String> seenCityCodes = Set<String>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ProgressHUD( return Scaffold(
padding: const EdgeInsets.all(24), body: ProgressHUD(
backgroundColor: Colors.black87, padding: const EdgeInsets.all(24),
indicatorWidget: const SpinKitFadingCircle(color: Colors.white), backgroundColor: Colors.black87,
child: BlocConsumer<LocationBloc, LocationState>( indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
listener: (context, state) { child: BlocConsumer<LocationBloc, LocationState>(
if (state is LocationLoading) { listener: (context, state) {
final progress = ProgressHUD.of(context); if (state is LocationLoading) {
progress!.showWithText("Please wait..."); final progress = ProgressHUD.of(context);
} progress!.showWithText("Please wait...");
if (state is LocationLoaded) { }
final progress = ProgressHUD.of(context); if (state is LocationLoaded) {
progress?.dismiss(); final progress = ProgressHUD.of(context);
} progress?.dismiss();
if (state is LocationErrorState) { }
final progress = ProgressHUD.of(context); if (state is LocationErrorState) {
progress?.dismiss(); final progress = ProgressHUD.of(context);
} progress?.dismiss();
}, }
builder: (context, state) { },
if (state is LocationLoaded) { builder: (context, state) {
final bldgloc = state.bldgloc; if (state is LocationLoaded) {
return BlocConsumer<LandrefBloc, LandrefState>( final bldgloc = state.bldgloc;
listener: (context, state) { return BlocConsumer<LandrefBloc, LandrefState>(
if (state is LandrefLoading) { listener: (context, state) {
final progress = ProgressHUD.of(context); if (state is LandrefLoading) {
progress!.showWithText("Please wait..."); final progress = ProgressHUD.of(context);
} progress!.showWithText("Please wait...");
if (state is LandrefLoaded) { }
final progress = ProgressHUD.of(context); if (state is LandrefLoaded) {
progress?.dismiss(); final progress = ProgressHUD.of(context);
} progress?.dismiss();
if (state is LandrefErrorState) { }
final progress = ProgressHUD.of(context); if (state is LandrefErrorState) {
progress?.dismiss(); final progress = ProgressHUD.of(context);
} progress?.dismiss();
}, }
builder: (context, state) { },
if (state is LandrefLoaded) { builder: (context, state) {
final landRef = state.landRef; if (state is LandrefLoaded) {
return BlocConsumer<MunicipalityBloc, MunicipalityState>( final landRef = state.landRef;
listener: (context, state) { return BlocConsumer<MunicipalityBloc, MunicipalityState>(
if (state is MunicipalityLoading) { listener: (context, state) {
final progress = ProgressHUD.of(context); if (state is MunicipalityLoading) {
progress!.showWithText("Please wait..."); final progress = ProgressHUD.of(context);
} progress!.showWithText("Please wait...");
if (state is MunicipalityLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is MunicipalityErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
}, builder: (context, state) {
if (state is MunicipalityLoaded) {
final cityList = state.municipality;
Set<City> uniqueItems = {};
// Iterate through the dropdownItems list to filter out duplicates
for (var item in cityList) {
uniqueItems.add(item);
} }
return BlocConsumer<BarangayBloc, BarangayState>( if (state is MunicipalityLoaded) {
listener: (context, state) { final progress = ProgressHUD.of(context);
if (state is BarangayLoading) { progress?.dismiss();
final progress = ProgressHUD.of(context); }
progress!.showWithText("Please wait..."); if (state is MunicipalityErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
}, builder: (context, state) {
if (state is MunicipalityLoaded) {
final cityList = state.municipality;
Set<City> uniqueItems = {};
// Iterate through the dropdownItems list to filter out duplicates
for (var item in cityList) {
uniqueItems.add(item);
} }
if (state is BarangayLoaded) { return BlocConsumer<BarangayBloc, BarangayState>(
final progress = ProgressHUD.of(context); listener: (context, state) {
progress?.dismiss(); if (state is BarangayLoading) {
} final progress = ProgressHUD.of(context);
if (state is BarangayErrorState) { progress!.showWithText("Please wait...");
final progress = ProgressHUD.of(context); }
progress?.dismiss(); if (state is BarangayLoaded) {
} final progress = ProgressHUD.of(context);
}, builder: (context, state) { progress?.dismiss();
if (state is BarangayLoaded) { }
List<Brgy> brgyList = state.brgy; if (state is BarangayErrorState) {
List<String> brgyNAmes = brgyList final progress = ProgressHUD.of(context);
.map((brgy) => brgy.barangayDescription) progress?.dismiss();
.toList() }
.cast<String>(); }, builder: (context, state) {
return FormBuilder( if (state is BarangayLoaded) {
key: keys, List<Brgy> brgyList = state.brgy;
initialValue: { List<String> brgyNAmes = brgyList
'street': bldgloc.street ?? "", .map((brgy) => brgy.barangayDescription)
'province': bldgloc.province ?? "", .toList()
'l_owner': landRef.owner, .cast<String>();
'oct_tct_cloa': landRef.cloaNo ?? "", return FormBuilder(
'survey_no': landRef.surveyNo ?? "", key: keys,
'lot_no': landRef.lotNo ?? "", initialValue: {
'blk_no': landRef.blkNo ?? "", 'street': bldgloc.street ?? "",
'l_td_arp': landRef.tdn ?? "", 'province': bldgloc.province ?? "",
'area': landRef.area ?? "" 'l_owner': landRef.owner,
}, 'oct_tct_cloa': landRef.cloaNo ?? "",
enabled: true, 'survey_no': landRef.surveyNo ?? "",
onChanged: () { 'lot_no': landRef.lotNo ?? "",
keys.currentState!.save(); 'blk_no': landRef.blkNo ?? "",
debugPrint(keys.currentState!.value.toString()); 'l_td_arp': landRef.tdn ?? "",
}, 'area': landRef.area ?? ""
autovalidateMode: AutovalidateMode.disabled, },
skipDisabled: true, enabled: true,
child: SingleChildScrollView( onChanged: () {
child: Padding( keys.currentState!.save();
padding: const EdgeInsets.all(20.0), debugPrint(keys.currentState!.value.toString());
child: ListView( },
shrinkWrap: true, autovalidateMode: AutovalidateMode.disabled,
children: [ skipDisabled: true,
Container( child: SingleChildScrollView(
margin: const EdgeInsets.only( child: Padding(
left: 0, padding: const EdgeInsets.all(20.0),
top: 20, child: ListView(
right: 0, shrinkWrap: true,
bottom: 10), children: [
child: const Text('BUILDING LOCATION', Container(
style: TextStyle( margin: const EdgeInsets.only(
fontWeight: FontWeight.bold, left: 0,
fontSize: 18), top: 20,
textAlign: TextAlign.left), right: 0,
), bottom: 10),
Row( child: const Text('BUILDING LOCATION',
mainAxisAlignment: style: TextStyle(
MainAxisAlignment.spaceEvenly, fontWeight: FontWeight.bold,
children: <Widget>[ fontSize: 18),
Expanded( textAlign: TextAlign.left),
flex: 1, ),
child: FormBuilderDropdown<City>( Row(
name: 'municipality', mainAxisAlignment:
autofocus: false, MainAxisAlignment.spaceEvenly,
decoration: normalTextFieldStyle( children: <Widget>[
bldgloc.municipality ?? Expanded(
"Municipality", flex: 1,
"", child: FormBuilderDropdown<City>(
name: 'municipality',
autofocus: false,
decoration:
normalTextFieldStyle(
bldgloc.municipality ??
"Municipality",
"",
),
items: uniqueItems
.map(
(city) =>
DropdownMenuItem<
City>(
value: city,
child: Text(
city.cityDescription ??
''),
),
)
.toList(),
onChanged: (selectedCityCode) {
// Find the corresponding City object using selectedCityCode
final selectedCity = cityList
.firstWhere((city) =>
city.cityCode ==
selectedCityCode);
final barangayBloc = context
.read<BarangayBloc>();
barangayBloc.add(LoadBarangay(
id: selectedCityCode!
.cityCode!));
},
), ),
items: uniqueItems
.map(
(city) =>
DropdownMenuItem<City>(
value: city,
child: Text(
city.cityDescription ??
''),
),
)
.toList(),
onChanged: (selectedCityCode) {
// Find the corresponding City object using selectedCityCode
final selectedCity = cityList
.firstWhere((city) =>
city.cityCode ==
selectedCityCode);
final barangayBloc = context
.read<BarangayBloc>();
barangayBloc.add(LoadBarangay(
id: selectedCityCode!
.cityCode!));
},
), ),
), const SizedBox(width: 10.0),
const SizedBox(width: 10.0), Expanded(
Expanded( // optional flex property if flex is 1 because the default flex is 1
// optional flex property if flex is 1 because the default flex is 1 flex: 1,
child: customTextField(
"Province / City",
"",
'province'))
]),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1, flex: 1,
child: customTextField( child: customTextField(
"Province / City", "No. / Street", "", 'street'),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customDropDownField(
bldgloc.barangay ?? "",
"Barangay",
'brgy',
brgyNAmes))
]),
Container(
margin: const EdgeInsets.only(
left: 0,
top: 20,
right: 0,
bottom: 10),
child: const Text('LAND REFERENCE',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18),
textAlign: TextAlign.left),
),
customTextField(
"Land Owner", "", 'l_owner'),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"OCT/TCT/CLOA No.",
"", "",
'province')) 'oct_tct_cloa'),
]), ),
Row( const SizedBox(width: 10.0),
mainAxisAlignment: Expanded(
MainAxisAlignment.spaceEvenly, // optional flex property if flex is 1 because the default flex is 1
children: <Widget>[ flex: 1,
Expanded( child: customTextField(
flex: 1, "Survey No.",
child: customTextField( "",
"No. / Street", "", 'street'), 'survey_no'))
), ]),
const SizedBox(width: 10.0), Row(
Expanded( mainAxisAlignment:
// optional flex property if flex is 1 because the default flex is 1 MainAxisAlignment.spaceEvenly,
flex: 1, children: <Widget>[
child: customDropDownField( Expanded(
bldgloc.barangay ?? "",
"Barangay",
'brgy',
brgyNAmes))
]),
Container(
margin: const EdgeInsets.only(
left: 0,
top: 20,
right: 0,
bottom: 10),
child: const Text('LAND REFERENCE',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18),
textAlign: TextAlign.left),
),
customTextField(
"Land Owner", "", 'l_owner'),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"OCT/TCT/CLOA No.",
"",
'oct_tct_cloa'),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1, flex: 1,
child: customTextField( child: customTextField(
"Survey No.", "Lot No.", "", 'lot_no'),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField(
"Blk No.", "", 'blk_no'))
]),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"TD / ARP No.",
"", "",
'survey_no')) 'l_td_arp'),
]), ),
Row( const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField(
"Area", "", 'area'))
]),
SizedBox(
height: 50,
),
Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.spaceEvenly, MainAxisAlignment.spaceEvenly,
children: <Widget>[ children: [
Expanded( CustomButton(
flex: 1, icon: const Icon(
child: customTextField( Icons.chevron_left_rounded,
"Lot No.", "", 'lot_no'), color: Colors.white),
onPressed: () {
{
widget.PrevBtn();
}
;
},
), ),
const SizedBox(width: 10.0), CustomButton(
Expanded( icon: const Icon(
// optional flex property if flex is 1 because the default flex is 1 Icons.chevron_right_rounded,
flex: 1, color: Colors.white),
child: customTextField( onPressed: () {
"Blk No.", "", 'blk_no')) {
]), var bldgLocData = BldgLoc(
Row( id: widget.tempId,
mainAxisAlignment: street: keys.currentState
MainAxisAlignment.spaceEvenly, ?.value['street'],
children: <Widget>[ barangay: keys.currentState
Expanded( ?.value['brgy'],
flex: 1, municipality: keys
child: customTextField( .currentState
"TD / ARP No.", "", 'l_td_arp'), ?.value[
), 'municipality']
const SizedBox(width: 10.0), ?.cityDescription ??
Expanded( bldgloc.municipality,
// optional flex property if flex is 1 because the default flex is 1 province: keys.currentState
flex: 1, ?.value['province'],
child: customTextField( );
"Area", "", 'area')) var landRefData = LandRef(
]), id: widget.tempId,
SizedBox( owner: keys.currentState
height: 50, ?.value['l_owner'],
), cloaNo: keys.currentState
Row( ?.value['oct_tct_cloa'],
mainAxisAlignment: lotNo: keys.currentState
MainAxisAlignment.spaceEvenly, ?.value['lot_no'],
children: [ tdn: keys.currentState
CustomButton( ?.value['l_td_arp'],
icon: const Icon( area: keys.currentState
Icons.chevron_left_rounded, ?.value['area'],
color: Colors.white), surveyNo: keys.currentState
onPressed: () { ?.value['survey_no'],
{ blkNo: keys.currentState
widget.PrevBtn(); ?.value['blk_no'],
} );
; context.read<PropertyInfoBloc>()
}, ..add(UpdateBldgLoc(
), bldg_loc: bldgLocData))
CustomButton( ..add(UpdateLandRef(
icon: const Icon( land_ref: landRefData));
Icons.chevron_right_rounded,
color: Colors.white),
onPressed: () {
{
var bldgLocData = BldgLoc(
id: widget.tempId,
street: keys.currentState
?.value['street'],
barangay: keys.currentState
?.value['brgy'],
municipality: keys
.currentState
?.value['municipality']
?.cityDescription ??
bldgloc.municipality,
province: keys.currentState
?.value['province'],
);
var landRefData = LandRef(
id: widget.tempId,
owner: keys.currentState
?.value['l_owner'],
cloaNo: keys.currentState
?.value['oct_tct_cloa'],
lotNo: keys.currentState
?.value['lot_no'],
tdn: keys.currentState
?.value['l_td_arp'],
area: keys.currentState
?.value['area'],
surveyNo: keys.currentState
?.value['survey_no'],
blkNo: keys.currentState
?.value['blk_no'],
);
context.read<PropertyInfoBloc>()
..add(UpdateBldgLoc(
bldg_loc: bldgLocData))
..add(UpdateLandRef(
land_ref: landRefData));
widget.NextBtn(); widget.NextBtn();
} }
; ;
}, },
) )
], ],
) )
], ],
),
), ),
), ),
), );
); }
} if (state is BarangayErrorState) {
if (state is BarangayErrorState) { return SomethingWentWrong(
return SomethingWentWrong( message: onError,
message: onError, onpressed: () {
onpressed: () { context
context .read<BarangayBloc>()
.read<BarangayBloc>() .add(LoadBarangay(id: '01'));
.add(LoadBarangay(id: '01')); },
}, );
); }
} return Container();
return Container(); });
}); }
} if (state is MunicipalityErrorState) {
if (state is MunicipalityErrorState) { return SomethingWentWrong(
return SomethingWentWrong( message: onError,
message: onError, onpressed: () {
onpressed: () { context
context .read<MunicipalityBloc>()
.read<MunicipalityBloc>() .add(LoadMunicipality());
.add(LoadMunicipality()); },
}, );
); }
} return Container();
return Container(); });
}); }
} if (state is LandrefErrorState) {
if (state is LandrefErrorState) { return SomethingWentWrong(
return SomethingWentWrong( message: onError,
message: onError, onpressed: () {
onpressed: () { context.read<LandrefBloc>().add(
context.read<LandrefBloc>().add( LoadLandref(id: widget.tempId, landRef: LandRef()));
LoadLandref(id: widget.tempId, landRef: LandRef())); },
}, );
); }
} return Container();
return Container(); },
}, );
); }
}
if (state is LocationErrorState) { if (state is LocationErrorState) {
return SomethingWentWrong( return SomethingWentWrong(
message: onError, message: onError,
onpressed: () { onpressed: () {
context context
.read<LocationBloc>() .read<LocationBloc>()
.add(LoadLocation(id: widget.tempId, bldgloc: BldgLoc())); .add(LoadLocation(id: widget.tempId, bldgloc: BldgLoc()));
}, },
); );
} }
return Container(); return Container();
}, },
),
), ),
); );
} }

View File

@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/bloc/passo/bulding/general_description/general_description_bloc.dart'; import 'package:unit2/bloc/passo/bulding/general_description/general_description_bloc.dart';
import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart'; import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart';
import 'package:unit2/model/passo/general_description.dart'; import 'package:unit2/model/passo/general_description.dart';
@ -39,267 +40,322 @@ class _GeneralDescriptionEdit extends State<GeneralDescriptionEdit> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Expanded( return Scaffold(
child: ProgressHUD( body: Column(
padding: const EdgeInsets.all(24), children: [
backgroundColor: Colors.black87, Expanded(
indicatorWidget: const SpinKitFadingCircle(color: Colors.white), child: ProgressHUD(
child: BlocConsumer<GeneralDescriptionBloc, GeneralDescriptionState>( padding: const EdgeInsets.all(24),
listener: (context, state) { backgroundColor: Colors.black87,
// TODO: implement listener indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
}, child:
builder: (context, state) { BlocConsumer<GeneralDescriptionBloc, GeneralDescriptionState>(
if (state is GenDescLoaded) { listener: (context, state) async {
return FormBuilder( if (state is GenDescLoading) {
key: keys, final progress = ProgressHUD.of(context);
initialValue: { progress!.showWithText("Please wait...");
'bldg_permit': state.gendesc.bldgPermit, }
'date_issued': state.gendesc.dateIssued.toString(), if (state is GenDescLoaded) {
'cct': state.gendesc.cct.toString(), final progress = ProgressHUD.of(context);
'coc_issued': state.gendesc.certCompletionIssued.toString(), progress?.dismiss();
'coo_issued': state.gendesc.certOccupancyIssued.toString(),
'date_cnstructed': state.gendesc.dateIssued.toString(), final tempID = await SharedPreferences.getInstance();
'date_occupied': state.gendesc.dateOccupied.toString(), await tempID.setInt(
'bldg_age': state.gendesc.bldgAge.toString(), 'totalValue', int.parse(state.gendesc.totalFloorArea!));
'no_of_storeys': state.gendesc.noStoreys.toString(), await tempID.setString(
'area_of_1stFl': state.gendesc.area1Stfloor, 'actualUse', state.gendesc.actualUse!);
'area_of_2ndFl': state.gendesc.area2Ndfloor,
'area_of_3rdFl': state.gendesc.area3Rdfloor, }
'area_of_4thFl': state.gendesc.area4Thfloor, if (state is GenDescErrorState) {
'total_area': state.gendesc.totalFloorArea.toString(), final progress = ProgressHUD.of(context);
'actual_use': state.gendesc.actualUse progress?.dismiss();
}
}, },
enabled: true, builder: (context, state) {
onChanged: () { if (state is GenDescLoaded) {
keys.currentState!.save(); return FormBuilder(
debugPrint(keys.currentState!.value.toString()); key: keys,
}, initialValue: {
autovalidateMode: AutovalidateMode.disabled, 'bldg_permit': state.gendesc.bldgPermit,
skipDisabled: true, 'date_issued': state.gendesc.dateIssued.toString(),
child: Expanded( 'cct': state.gendesc.cct.toString(),
child: SingleChildScrollView( 'coc_issued':
scrollDirection: Axis.vertical, state.gendesc.certCompletionIssued.toString(),
child: Padding( 'coo_issued':
padding: const EdgeInsets.all(20.0), state.gendesc.certOccupancyIssued.toString(),
child: Column( 'date_cnstructed': state.gendesc.dateIssued.toString(),
children: [ 'date_occupied': state.gendesc.dateOccupied.toString(),
Container( 'bldg_age': state.gendesc.bldgAge.toString(),
margin: const EdgeInsets.only( 'no_of_storeys': state.gendesc.noStoreys.toString(),
left: 0, top: 20, right: 0, bottom: 10), 'area_of_1stFl': state.gendesc.area1Stfloor,
child: const Text('GENERAL DESCRIPTION', 'area_of_2ndFl': state.gendesc.area2Ndfloor,
style: TextStyle( 'area_of_3rdFl': state.gendesc.area3Rdfloor,
fontWeight: FontWeight.bold, fontSize: 18), 'area_of_4thFl': state.gendesc.area4Thfloor,
textAlign: TextAlign.left), 'total_area': state.gendesc.totalFloorArea.toString(),
), 'actual_use': state.gendesc.actualUse
Container( },
margin: const EdgeInsets.only( enabled: true,
left: 0, top: 10, right: 0, bottom: 0), onChanged: () {
child: FormBuilderDropdown( keys.currentState!.save();
name: 'bldg_type', debugPrint(keys.currentState!.value.toString());
autofocus: false, },
decoration: normalTextFieldStyle( autovalidateMode: AutovalidateMode.disabled,
state.gendesc.bldgKind ?? "Kind of Building", skipDisabled: true,
"Kind of Building"), child: Expanded(
items: widget.unit child: SingleChildScrollView(
.map((e) => DropdownMenuItem( scrollDirection: Axis.vertical,
value: e, child: Padding(
child: padding: const EdgeInsets.all(20.0),
Text(e.bldgType + '-' + e.building), child: Column(
)) children: [
.toList(), Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('GENERAL DESCRIPTION',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18),
textAlign: TextAlign.left),
),
Container(
margin: const EdgeInsets.only(
left: 0, top: 10, right: 0, bottom: 0),
child: FormBuilderDropdown(
name: 'bldg_type',
autofocus: false,
decoration: normalTextFieldStyle(
state.gendesc.bldgKind ??
"Kind of Building",
"Kind of Building"),
items: widget.unit
.map((e) => DropdownMenuItem(
value: e,
child: Text(e.bldgType +
'-' +
e.building),
))
.toList(),
),
),
customDropDownField(
"Actual Use", "", 'actual_use', actual_use),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"Bldg. Permit No.",
"",
'bldg_permit'),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customDatTimePicker(
"Certificate of Occupancy Issued ON",
"",
'date_issued'))
]),
customTextField(
"Condominium Certificate of Title (CCT)",
"",
'cct'),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customDatTimePicker(
"Certificate of Completion Issued ON",
"",
'coc_issued'),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customDatTimePicker(
"Certificate of Occupancy Issued ON",
"",
'coo_issued'))
]),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customDatTimePicker(
"Date Constructed /Completed",
"",
'date_cnstructed'),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customDatTimePicker(
"Date Occupied",
"",
'date_occupied'))
]),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"Bldg. Age", "", 'bldg_age'),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField(
"No. of storeys",
"",
'no_of_storeys'))
]),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"Area of 1st Floor",
"",
'area_of_1stFl'),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField(
"Area of 2nd Floor",
"",
'area_of_2ndFl'))
]),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"Area of 3rd Floor",
"",
'area_of_3rdFl')),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField(
"Area of 4th Floor",
"",
'area_of_4thFl'))
]),
customTextField("Total Area", "", 'total_area'),
SizedBox(
height: 50,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
CustomButton(
icon: const Icon(
Icons.chevron_left_rounded,
color: Colors.white),
onPressed: () {
{
widget.PrevBtn();
}
;
},
),
CustomButton(
icon: const Icon(
Icons.chevron_right_rounded,
color: Colors.white),
onPressed: () {
{
keys.currentState!.save();
var genDescData = GeneralDesc(
id: widget.tempId,
bldgKind: keys
.currentState
?.value['bldg_type']
?.building ??
state.gendesc.bldgKind,
strucType: keys
.currentState
?.value['bldg_type']
?.bldgType ??
state.gendesc.strucType,
bldgPermit: keys.currentState
?.value['bldg_permit'],
dateIssued: keys.currentState
?.value['coc_issued'],
cct: keys
.currentState?.value['cct'],
certCompletionIssued: keys
.currentState
?.value['coc_issued'],
certOccupancyIssued: keys
.currentState
?.value['coo_issued'],
dateCompleted:
keys.currentState?.value['date_cnstructed'],
dateOccupied: keys.currentState?.value['date_occupied'],
bldgAge: int.tryParse(keys.currentState?.value['bldg_age']),
noStoreys: int.tryParse(keys.currentState?.value['no_of_storeys']),
area1Stfloor: keys.currentState?.value['area_of_1stFl'],
area2Ndfloor: keys.currentState?.value['area_of_2ndFl'],
area3Rdfloor: keys.currentState?.value['area_of_3rdFl'],
area4Thfloor: keys.currentState?.value['area_of_4thFl'],
totalFloorArea: keys.currentState?.value['total_area'],
floorSketch: null,
actualUse: keys.currentState?.value['actual_use']);
context.read<PropertyInfoBloc>()
..add(UpdateGeneralDesc(
gen_desc: genDescData));
widget.NextBtn();
}
;
},
)
],
)
],
), ),
), ),
customDropDownField( ),
"Actual Use", "", 'actual_use', actual_use),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"Bldg. Permit No.", "", 'bldg_permit'),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customDatTimePicker(
"Certificate of Occupancy Issued ON",
"",
'date_issued'))
]),
customTextField(
"Condominium Certificate of Title (CCT)",
"",
'cct'),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customDatTimePicker(
"Certificate of Completion Issued ON",
"",
'coc_issued'),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customDatTimePicker(
"Certificate of Occupancy Issued ON",
"",
'coo_issued'))
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customDatTimePicker(
"Date Constructed /Completed",
"",
'date_cnstructed'),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customDatTimePicker(
"Date Occupied", "", 'date_occupied'))
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"Bldg. Age", "", 'bldg_age'),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField(
"No. of storeys", "", 'no_of_storeys'))
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"Area of 1st Floor", "", 'area_of_1stFl'),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField("Area of 2nd Floor",
"", 'area_of_2ndFl'))
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField("Area of 3rd Floor",
"", 'area_of_3rdFl')),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField("Area of 4th Floor",
"", 'area_of_4thFl'))
]),
customTextField("Total Area", "", 'total_area'),
SizedBox(
height: 50,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
CustomButton(
icon: const Icon(Icons.chevron_left_rounded,
color: Colors.white),
onPressed: () {
{
widget.PrevBtn();
}
;
},
),
CustomButton(
icon: const Icon(Icons.chevron_right_rounded,
color: Colors.white),
onPressed: () {
{
keys.currentState!.save();
var genDescData = GeneralDesc(
id: widget.tempId,
bldgKind: keys
.currentState
?.value['bldg_type']
?.building ??
state.gendesc.bldgKind,
strucType: keys
.currentState
?.value['bldg_type']
?.bldgType ??
state.gendesc.strucType,
bldgPermit: keys
.currentState?.value['bldg_permit'],
dateIssued: keys
.currentState?.value['coc_issued'],
cct: keys.currentState?.value['cct'],
certCompletionIssued: keys
.currentState?.value['coc_issued'],
certOccupancyIssued: keys
.currentState?.value['coo_issued'],
dateCompleted: keys.currentState
?.value['date_cnstructed'],
dateOccupied: keys.currentState
?.value['date_occupied'],
bldgAge: int.tryParse(keys.currentState?.value['bldg_age']),
noStoreys: int.tryParse(keys.currentState?.value['no_of_storeys']),
area1Stfloor: keys.currentState?.value['area_of_1stFl'],
area2Ndfloor: keys.currentState?.value['area_of_2ndFl'],
area3Rdfloor: keys.currentState?.value['area_of_3rdFl'],
area4Thfloor: keys.currentState?.value['area_of_4thFl'],
totalFloorArea: keys.currentState?.value['total_area'],
floorSketch: null,
actualUse: keys.currentState?.value['actual_use']);
context.read<PropertyInfoBloc>()
..add(UpdateGeneralDesc(
gen_desc: genDescData));
widget.NextBtn();
}
;
},
)
],
)
],
), ),
), );
), }
), if (state is GenDescErrorState) {
); return SomethingWentWrong(
} message: onError,
if (state is GenDescErrorState) { onpressed: () {
return SomethingWentWrong( context.read<GeneralDescriptionBloc>().add(LoadGenDesc(
message: onError, id: widget.tempId, gendesc: GeneralDesc()));
onpressed: () { },
context.read<GeneralDescriptionBloc>().add( );
LoadGenDesc(id: widget.tempId, gendesc: GeneralDesc())); }
return Container();
}, },
); ),
} ),
return Container(); ),
}, ],
),
), ),
); );
} }

View File

@ -67,151 +67,168 @@ class _PropertyOwnerInfoEdit extends State<PropertyOwnerInfoEdit> {
if (state is PropertyInfoLoaded) { if (state is PropertyInfoLoaded) {
return SingleChildScrollView( return SingleChildScrollView(
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
child: Expanded( child: Column(
child: Column( children: [
children: <Widget>[ Padding(
FormBuilder( padding: const EdgeInsets.all(15.0),
key: keys, child: Expanded(
initialValue: { child: Column(
'transaction_code': widget.faas.transCode, children: <Widget>[
'arp_td': widget.faas.tdn, FormBuilder(
'pin': widget.faas.pin, key: keys,
'owner': widget.faas.owner, initialValue: {
'address': widget.faas.address, 'transaction_code': widget.faas.transCode,
'tel_no': widget.faas.telno, 'arp_td': widget.faas.tdn,
'tin': widget.faas.tin, 'pin': widget.faas.pin,
'benificiary': widget.faas.adminUser, 'owner': widget.faas.owner,
'benificiary_telno': widget.faas.adminTelno, 'address': widget.faas.address,
'benificiary_address': widget.faas.adminAddress, 'tel_no': widget.faas.telno,
'benificaiary_tin': widget.faas.adminTin, 'tin': widget.faas.tin,
}, 'benificiary': widget.faas.adminUser,
enabled: true, 'benificiary_telno': widget.faas.adminTelno,
onChanged: () { 'benificiary_address': widget.faas.adminAddress,
keys.currentState!.save(); 'benificaiary_tin': widget.faas.adminTin,
debugPrint(keys.currentState!.value.toString()); },
}, enabled: true,
autovalidateMode: AutovalidateMode.disabled, onChanged: () {
skipDisabled: true, keys.currentState!.save();
child: Column( debugPrint(keys.currentState!.value.toString());
mainAxisAlignment: MainAxisAlignment.spaceBetween, },
children: <Widget>[ autovalidateMode: AutovalidateMode.disabled,
Container( skipDisabled: true,
margin: const EdgeInsets.only( child: Column(
left: 0, top: 20, right: 0, bottom: 10), mainAxisAlignment: MainAxisAlignment.spaceBetween,
child: const Text('PROPERTY OWNER INFO',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
textAlign: TextAlign.left),
),
const SizedBox(height: 15),
customDropDownField("Transaction Code", "",
"transaction_code", transaction_codes),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField(
"ARP No. / TD No.", "", 'arp_td')),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField("Pin", "", 'pin')),
],
),
customTextField("Owner", "", 'owner'),
customTextField("Address", "", 'address'),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[ children: <Widget>[
Expanded( Container(
flex: 1, margin: const EdgeInsets.only(
child: left: 0, top: 20, right: 0, bottom: 10),
customTextField("Tel No.", "", 'tel_no'), child: const Text('PROPERTY OWNER INFO',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18),
textAlign: TextAlign.left),
), ),
const SizedBox(width: 10.0), const SizedBox(height: 15),
Expanded( customDropDownField("Transaction Code", "",
// optional flex property if flex is 1 because the default flex is 1 "transaction_code", transaction_codes),
flex: 1, Row(
child: customTextField("TIN", "", 'tin')) mainAxisAlignment:
]), MainAxisAlignment.spaceEvenly,
Row( children: <Widget>[
mainAxisAlignment: MainAxisAlignment.spaceEvenly, Expanded(
children: <Widget>[ // optional flex property if flex is 1 because the default flex is 1
Expanded( flex: 1,
flex: 1, child: customTextField(
child: customTextField( "ARP No. / TD No.", "", 'arp_td')),
"Administrator / Benificial User", const SizedBox(width: 10.0),
"", Expanded(
'benificiary'), // optional flex property if flex is 1 because the default flex is 1
flex: 1,
child:
customTextField("Pin", "", 'pin')),
],
), ),
const SizedBox(width: 10.0), customTextField("Owner", "", 'owner'),
Expanded( customTextField("Address", "", 'address'),
// optional flex property if flex is 1 because the default flex is 1 Row(
flex: 1, mainAxisAlignment:
child: customTextField( MainAxisAlignment.spaceEvenly,
"TIN", "", 'benificiary_tin')) children: <Widget>[
]), Expanded(
Row( flex: 1,
mainAxisAlignment: MainAxisAlignment.spaceEvenly, child: customTextField(
children: <Widget>[ "Tel No.", "", 'tel_no'),
Expanded( ),
flex: 1, const SizedBox(width: 10.0),
child: customTextField( Expanded(
"Address", "", 'benificiary_address'), // optional flex property if flex is 1 because the default flex is 1
), flex: 1,
const SizedBox(width: 10.0), child:
Expanded( customTextField("TIN", "", 'tin'))
// optional flex property if flex is 1 because the default flex is 1 ]),
flex: 1, Row(
child: customTextField( mainAxisAlignment:
"Tel No.", "", 'benificiary_telno')) MainAxisAlignment.spaceEvenly,
]), children: <Widget>[
const SizedBox(height: 25), Expanded(
SizedBox( flex: 1,
width: MediaQuery.of(context).size.width, child: customTextField(
child: CustomButton( "Administrator / Benificial User",
icon: const Icon(Icons.chevron_right, "",
color: Colors.white), 'benificiary'),
onPressed: () { ),
var property_info = PropertyInfo( const SizedBox(width: 10.0),
id: widget.faas.id, Expanded(
transCode: keys // optional flex property if flex is 1 because the default flex is 1
.currentState!.value['transaction_code'] flex: 1,
.toString(), child: customTextField(
tdn: keys.currentState!.value['arp_td'], "TIN", "", 'benificiary_tin'))
pin: keys.currentState!.value['pin'], ]),
owner: keys.currentState!.value['owner'], Row(
address: mainAxisAlignment:
keys.currentState!.value['address'], MainAxisAlignment.spaceEvenly,
telno: keys.currentState!.value['tel_no'], children: <Widget>[
tin: keys.currentState!.value['tin'], Expanded(
adminUser: flex: 1,
keys.currentState!.value['benificiary'], child: customTextField("Address", "",
adminAddress: keys.currentState! 'benificiary_address'),
.value['benificiary_address'], ),
adminTin: keys const SizedBox(width: 10.0),
.currentState!.value['benificiary_tin'], Expanded(
adminTelno: keys.currentState! // optional flex property if flex is 1 because the default flex is 1
.value['benificiary_telno'], flex: 1,
assessedById: '1', child: customTextField("Tel No.", "",
assessedByName: 'Cyril', 'benificiary_telno'))
dateModified: DateTime.now(), ]),
dateCreated: DateTime.now()); const SizedBox(height: 25),
SizedBox(
width: MediaQuery.of(context).size.width,
child: CustomButton(
icon: const Icon(Icons.chevron_right,
color: Colors.white),
onPressed: () {
var property_info = PropertyInfo(
id: widget.faas.id,
transCode: keys.currentState!
.value['transaction_code']
.toString(),
tdn: keys
.currentState!.value['arp_td'],
pin: keys.currentState!.value['pin'],
owner:
keys.currentState!.value['owner'],
address: keys
.currentState!.value['address'],
telno: keys
.currentState!.value['tel_no'],
tin: keys.currentState!.value['tin'],
adminUser: keys.currentState!
.value['benificiary'],
adminAddress: keys.currentState!
.value['benificiary_address'],
adminTin: keys.currentState!
.value['benificiary_tin'],
adminTelno: keys.currentState!
.value['benificiary_telno'],
assessedById: '1',
assessedByName: 'Cyril',
dateModified: DateTime.now(),
dateCreated: DateTime.now());
context.read<PropertyInfoBloc>().add( context.read<PropertyInfoBloc>().add(
UpdatPropertyInfo( UpdatPropertyInfo(
property_info: property_info)); property_info: property_info));
widget.NextBtn(); widget.NextBtn();
}, },
), ),
), ),
])), ])),
], ],
), ),
),
),
],
), ),
); );
} }

View File

@ -56,356 +56,388 @@ class _StructuralMaterialsPageEdit extends State<StructuralMaterialsPageEdit> {
// TODO: implement listener // TODO: implement listener
}, builder: (context, state) { }, builder: (context, state) {
if (state is StructuralMaterialsLoaded) { if (state is StructuralMaterialsLoaded) {
return Expanded( return SingleChildScrollView(
child: SingleChildScrollView( scrollDirection: Axis.vertical,
padding: const EdgeInsets.all(30.0),
child: Column( child: Column(
children: [ children: [
Container( Expanded(
margin: const EdgeInsets.only( child: Column(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('STRUCTURAL MATERIALS',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
textAlign: TextAlign.left),
),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(
'FOUNDATION',
textAlign: TextAlign.start,
),
Row(
children: [ children: [
const Text('Others'), Container(
Checkbox( margin: const EdgeInsets.only(
checkColor: Colors.white, left: 0, top: 20, right: 0, bottom: 10),
value: foundationOthers, child: const Text('STRUCTURAL MATERIALS',
onChanged: (bool? value) { style: TextStyle(
setState(() { fontWeight: FontWeight.bold, fontSize: 18),
foundationOthers = value!; textAlign: TextAlign.left),
}); ),
}, Row(
) mainAxisAlignment: MainAxisAlignment.spaceBetween,
], children: [
), Text(
]), 'FOUNDATION',
Padding( textAlign: TextAlign.start,
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), ),
child: Visibility( Row(
visible: foundationOthers, children: [
child: customTextField( const Text('Others'),
"Enter other foundation", "", "other_foundation"), Checkbox(
replacement: DropDownMultiSelect( checkColor: Colors.white,
selected_values_style: TextStyle(color: Colors.black), value: foundationOthers,
onChanged: (List<String> x) { onChanged: (bool? value) {
setState(() { setState(() {
foundation = x; foundationOthers = value!;
}); });
}, },
options: const ['Reinforced Concrete', 'Plain Concrete'], )
selectedValues: foundation, ],
whenEmpty: 'Select Foundations', ),
), ]),
), Padding(
), padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ child: Visibility(
Text( visible: foundationOthers,
'COLUMNS', child: customTextField(
textAlign: TextAlign.start, "Enter other foundation", "", "other_foundation"),
), replacement: DropDownMultiSelect(
Row( selected_values_style: TextStyle(color: Colors.black),
children: [ onChanged: (List<String> x) {
const Text('Others'), setState(() {
Checkbox( foundation = x;
checkColor: Colors.white, });
value: columOthers, },
onChanged: (bool? value) { options: const [
setState(() { 'Reinforced Concrete',
columOthers = value!; 'Plain Concrete'
}); ],
}, selectedValues: foundation,
) whenEmpty: 'Select Foundations',
], ),
), ),
]), ),
Padding( Row(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), mainAxisAlignment: MainAxisAlignment.spaceBetween,
child: Visibility( children: [
visible: columOthers, Text(
child: customTextField( 'COLUMNS',
"Enter other columns", "", "other_column"), textAlign: TextAlign.start,
replacement: DropDownMultiSelect( ),
selected_values_style: TextStyle(color: Colors.black), Row(
onChanged: (List<String> x) { children: [
setState(() { const Text('Others'),
column = x; Checkbox(
}); checkColor: Colors.white,
}, value: columOthers,
options: const ['Steel', 'Reinforced Concrete', 'Wood'], onChanged: (bool? value) {
selectedValues: column, setState(() {
whenEmpty: 'Select Column/s', columOthers = value!;
), });
), },
), )
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ ],
Text( ),
'BEAMS', ]),
textAlign: TextAlign.start, Padding(
), padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
Row( child: Visibility(
children: [ visible: columOthers,
const Text('Others'), child: customTextField(
Checkbox( "Enter other columns", "", "other_column"),
checkColor: Colors.white, replacement: DropDownMultiSelect(
value: beamsOthers, selected_values_style: TextStyle(color: Colors.black),
onChanged: (bool? value) { onChanged: (List<String> x) {
setState(() { setState(() {
beamsOthers = value!; column = x;
}); });
}, },
) options: const [
], 'Steel',
), 'Reinforced Concrete',
]), 'Wood'
Padding( ],
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), selectedValues: column,
child: Visibility( whenEmpty: 'Select Column/s',
visible: beamsOthers, ),
child: ),
customTextField("Enter other beam/s", "", "other_beam"), ),
replacement: DropDownMultiSelect( Row(
selected_values_style: TextStyle(color: Colors.black), mainAxisAlignment: MainAxisAlignment.spaceBetween,
onChanged: (List<String> x) { children: [
setState(() { Text(
beam = x; 'BEAMS',
}); textAlign: TextAlign.start,
}, ),
options: const ['Steel', 'Reinforced Concrete', 'Wood'], Row(
selectedValues: beam, children: [
whenEmpty: 'Select Beam/s', const Text('Others'),
), Checkbox(
), checkColor: Colors.white,
), value: beamsOthers,
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ onChanged: (bool? value) {
Text( setState(() {
'TRUSS FRAMING', beamsOthers = value!;
textAlign: TextAlign.start, });
), },
Row( )
children: [ ],
const Text('Others'), ),
Checkbox( ]),
checkColor: Colors.white, Padding(
value: tfOthers, padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
onChanged: (bool? value) { child: Visibility(
setState(() { visible: beamsOthers,
tfOthers = value!; child: customTextField(
}); "Enter other beam/s", "", "other_beam"),
}, replacement: DropDownMultiSelect(
) selected_values_style: TextStyle(color: Colors.black),
], onChanged: (List<String> x) {
), setState(() {
]), beam = x;
Padding( });
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), },
child: Visibility( options: const [
visible: tfOthers, 'Steel',
child: customTextField( 'Reinforced Concrete',
"Enter other truss framing/s", "", "other_tf"), 'Wood'
replacement: DropDownMultiSelect( ],
selected_values_style: TextStyle(color: Colors.black), selectedValues: beam,
onChanged: (List<String> x) { whenEmpty: 'Select Beam/s',
setState(() { ),
truss_framing = x; ),
}); ),
}, Row(
options: const ['Steel', 'Wood'], mainAxisAlignment: MainAxisAlignment.spaceBetween,
selectedValues: truss_framing, children: [
whenEmpty: 'Select Truss Framing/s', Text(
), 'TRUSS FRAMING',
), textAlign: TextAlign.start,
), ),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row(
Text( children: [
'ROOF', const Text('Others'),
textAlign: TextAlign.start, Checkbox(
), checkColor: Colors.white,
Row( value: tfOthers,
children: [ onChanged: (bool? value) {
const Text('Others'), setState(() {
Checkbox( tfOthers = value!;
checkColor: Colors.white, });
value: roofOthers, },
onChanged: (bool? value) { )
setState(() { ],
roofOthers = value!; ),
}); ]),
}, Padding(
) padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
], child: Visibility(
), visible: tfOthers,
]), child: customTextField(
Padding( "Enter other truss framing/s", "", "other_tf"),
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), replacement: DropDownMultiSelect(
child: Visibility( selected_values_style: TextStyle(color: Colors.black),
visible: roofOthers, onChanged: (List<String> x) {
child: setState(() {
customTextField("Enter other roof/s", "", "other_roof"), truss_framing = x;
replacement: DropDownMultiSelect( });
selected_values_style: TextStyle(color: Colors.black), },
onChanged: (List<String> x) { options: const ['Steel', 'Wood'],
setState(() { selectedValues: truss_framing,
roof = x; whenEmpty: 'Select Truss Framing/s',
}); ),
}, ),
options: const [ ),
'Reinforced Concrete', Row(
'Tiles', mainAxisAlignment: MainAxisAlignment.spaceBetween,
'G.I Sheet', children: [
'Aluminum', Text(
'Asbestos', 'ROOF',
'Long Span', textAlign: TextAlign.start,
'Concrete Desk', ),
'Nipa/Anahaw/Cogon' Row(
], children: [
selectedValues: roof, const Text('Others'),
whenEmpty: 'Select Roof/s', Checkbox(
), checkColor: Colors.white,
), value: roofOthers,
), onChanged: (bool? value) {
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ setState(() {
Text( roofOthers = value!;
'FLOORING', });
textAlign: TextAlign.start, },
), )
Row( ],
children: [ ),
const Text('Others'), ]),
Checkbox( Padding(
checkColor: Colors.white, padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
value: flooringOthers, child: Visibility(
onChanged: (bool? value) { visible: roofOthers,
setState(() { child: customTextField(
flooringOthers = value!; "Enter other roof/s", "", "other_roof"),
}); replacement: DropDownMultiSelect(
}, selected_values_style: TextStyle(color: Colors.black),
) onChanged: (List<String> x) {
], setState(() {
), roof = x;
]), });
Padding( },
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), options: const [
child: Visibility( 'Reinforced Concrete',
visible: flooringOthers, 'Tiles',
child: customTextField( 'G.I Sheet',
"Enter other flooring/s", "", "other_flooring"), 'Aluminum',
replacement: DropDownMultiSelect( 'Asbestos',
selected_values_style: TextStyle(color: Colors.black), 'Long Span',
onChanged: (List<String> x) { 'Concrete Desk',
setState(() { 'Nipa/Anahaw/Cogon'
flooring = x; ],
}); selectedValues: roof,
}, whenEmpty: 'Select Roof/s',
options: const [ ),
'Reinforced Concrete', ),
'Plain Cement', ),
'Marble', Row(
'Wood', mainAxisAlignment: MainAxisAlignment.spaceBetween,
'Tiles' children: [
], Text(
selectedValues: flooring, 'FLOORING',
whenEmpty: 'Select Flooring/s', textAlign: TextAlign.start,
), ),
), Row(
), children: [
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Text('Others'),
Text( Checkbox(
'WALLS & PARTITIONS', checkColor: Colors.white,
textAlign: TextAlign.start, value: flooringOthers,
), onChanged: (bool? value) {
Row( setState(() {
children: [ flooringOthers = value!;
const Text('Others'), });
Checkbox( },
checkColor: Colors.white, )
value: wpOthers, ],
onChanged: (bool? value) { ),
setState(() { ]),
wpOthers = value!; Padding(
}); padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
}, child: Visibility(
) visible: flooringOthers,
], child: customTextField(
), "Enter other flooring/s", "", "other_flooring"),
]), replacement: DropDownMultiSelect(
Padding( selected_values_style: TextStyle(color: Colors.black),
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), onChanged: (List<String> x) {
child: Visibility( setState(() {
visible: wpOthers, flooring = x;
child: customTextField( });
"Enter other walls & partition/s", "", "other_wp"), },
replacement: DropDownMultiSelect( options: const [
selected_values_style: TextStyle(color: Colors.black), 'Reinforced Concrete',
onChanged: (List<String> x) { 'Plain Cement',
setState(() { 'Marble',
walls = x; 'Wood',
}); 'Tiles'
}, ],
options: const [ selectedValues: flooring,
'Reinforced Concrete', whenEmpty: 'Select Flooring/s',
'Plain Concrete', ),
'Wood', ),
'CHIB', ),
'G.I Sheet', Row(
'Build-a-wall', mainAxisAlignment: MainAxisAlignment.spaceBetween,
'Sawali', children: [
'Bamboo' Text(
], 'WALLS & PARTITIONS',
selectedValues: walls, textAlign: TextAlign.start,
whenEmpty: 'Select Walls & Partition/s', ),
), Row(
), children: [
), const Text('Others'),
Row( Checkbox(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, checkColor: Colors.white,
children: [ value: wpOthers,
CustomButton( onChanged: (bool? value) {
icon: const Icon(Icons.chevron_left_rounded, setState(() {
color: Colors.white), wpOthers = value!;
onPressed: () { });
{ },
widget.PrevBtn(); )
} ],
; ),
}, ]),
), Padding(
CustomButton( padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
icon: const Icon(Icons.chevron_right_rounded, child: Visibility(
color: Colors.white), visible: wpOthers,
onPressed: () { child: customTextField(
{ "Enter other walls & partition/s", "", "other_wp"),
var strucMaterials = StructureMaterialsII( replacement: DropDownMultiSelect(
id: widget.tempId, selected_values_style: TextStyle(color: Colors.black),
foundation: foundation, onChanged: (List<String> x) {
columns: column, setState(() {
beams: beam, walls = x;
trussFraming: truss_framing, });
roof: roof, },
flooring: flooring, options: const [
walls: walls, 'Reinforced Concrete',
others: ["Others"]); 'Plain Concrete',
context.read<PropertyInfoBloc>() 'Wood',
..add(UpdateStrucMaterials(data: strucMaterials)); 'CHIB',
'G.I Sheet',
'Build-a-wall',
'Sawali',
'Bamboo'
],
selectedValues: walls,
whenEmpty: 'Select Walls & Partition/s',
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
CustomButton(
icon: const Icon(Icons.chevron_left_rounded,
color: Colors.white),
onPressed: () {
{
widget.PrevBtn();
}
;
},
),
CustomButton(
icon: const Icon(Icons.chevron_right_rounded,
color: Colors.white),
onPressed: () {
{
var strucMaterials = StructureMaterialsII(
id: widget.tempId,
foundation: foundation,
columns: column,
beams: beam,
trussFraming: truss_framing,
roof: roof,
flooring: flooring,
walls: walls,
others: ["Others"]);
context.read<PropertyInfoBloc>()
..add(
UpdateStrucMaterials(data: strucMaterials));
widget.NextBtn(); widget.NextBtn();
} }
; ;
}, },
) )
], ],
) )
],
),
),
], ],
), ),
)); );
} }
if (state is StructuralMaterialsErrorState) { if (state is StructuralMaterialsErrorState) {
return Text(state.error); return Text(state.error);

View File

@ -0,0 +1,481 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:multiselect/multiselect.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart';
import 'package:unit2/bloc/passo/bulding/structural_material/structural_material_bloc.dart';
import 'package:unit2/model/passo/structural_materials_ii.dart';
import 'package:unit2/screens/passo/Building/add_building.dart';
import 'package:unit2/widgets/passo/custom_button.dart';
import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart';
class MaterialOption {
final String id;
final String label;
MaterialOption(this.id, this.label);
}
class StructuralMaterialsEditPage extends StatefulWidget {
final int tempId;
final VoidCallback NextBtn;
final VoidCallback PrevBtn;
StructuralMaterialsEditPage(this.tempId, this.NextBtn, this.PrevBtn);
@override
_StructuralMaterialsEditPage createState() => _StructuralMaterialsEditPage();
}
class _StructuralMaterialsEditPage extends State<StructuralMaterialsEditPage> {
List<String> foundation = [];
List<String> column = [];
List<String> beam = [];
List<String> truss_framing = [];
List<String> roof = [];
List<String> flooring = [];
List<String> walls = [];
bool foundationOthers = false;
bool columOthers = false;
bool beamsOthers = false;
bool tfOthers = false;
bool roofOthers = false;
bool flooringOthers = false;
bool wpOthers = false;
List<MaterialOption> columnOptions = [
MaterialOption('steel', 'Steel'),
MaterialOption('concrete', 'Reinforced Concrete'),
MaterialOption('wood', 'Wood'),
];
List<String> selectedColumnValues = [];
@override
Widget build(BuildContext context) {
return Scaffold(
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<StructuralMaterialBloc, StructuralMaterialState>(
listener: (context, state) {
if (state is StructuralMaterialsLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is StructuralMaterialsLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
setState(() {
foundation = state.structure.foundation!.split(',');
column = state.structure.columns!.split(',');
beam = state.structure.beams!.split(',');
truss_framing = state.structure.trussFraming!.split(',');
roof = state.structure.roof!.split(',');
flooring = state.structure.flooring!.split(',');
walls = state.structure.walls!.split(',');
// Update other local state variables here if needed
});
}
if (state is StructuralMaterialsErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
}, builder: (context, state) {
return SingleChildScrollView(
padding: const EdgeInsets.all(30.0),
child: Column(
children: [
Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('STRUCTURAL MATERIALS',
style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
textAlign: TextAlign.left),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'FOUNDATION',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: foundationOthers,
onChanged: (bool? value) {
setState(() {
foundationOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: foundationOthers,
child: customTextField(
"Enter other foundation", "", "other_foundation"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
setState(() {
foundation = x;
});
},
options: const ['Reinforced Concrete', 'Plain Concrete'],
selectedValues: foundation,
whenEmpty: 'Select Foundations',
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'COLUMNS',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: columOthers,
onChanged: (bool? value) {
setState(() {
columOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: columOthers,
child: customTextField(
"Enter other columns", "", "other_column"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
setState(() {
column = x;
});
},
options: const ['Steel', 'Reinforced Concrete', 'Wood'],
selectedValues: column,
whenEmpty: 'Select Column/s',
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'BEAMS',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: beamsOthers,
onChanged: (bool? value) {
setState(() {
beamsOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: beamsOthers,
child:
customTextField("Enter other beam/s", "", "other_beam"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
setState(() {
beam = x;
});
},
options: const ['Steel', 'Reinforced Concrete', 'Wood'],
selectedValues: beam,
whenEmpty: 'Select Beam/s',
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'TRUSS FRAMING',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: tfOthers,
onChanged: (bool? value) {
setState(() {
tfOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: tfOthers,
child: customTextField(
"Enter other truss framing/s", "", "other_tf"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
setState(() {
truss_framing = x;
});
},
options: const ['Steel', 'Wood'],
selectedValues: truss_framing,
whenEmpty: 'Select Truss Framing/s',
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'ROOF',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: roofOthers,
onChanged: (bool? value) {
setState(() {
roofOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: roofOthers,
child:
customTextField("Enter other roof/s", "", "other_roof"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
setState(() {
roof = x;
});
},
options: const [
'Reinforced Concrete',
'Tiles',
'G.I Sheet',
'Aluminum',
'Asbestos',
'Long Span',
'Concrete Desk',
'Nipa/Anahaw/Cogon'
],
selectedValues: roof,
whenEmpty: 'Select Roof/s',
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'FLOORING',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: flooringOthers,
onChanged: (bool? value) {
setState(() {
flooringOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: flooringOthers,
child: customTextField(
"Enter other flooring/s", "", "other_flooring"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
setState(() {
flooring = x;
});
},
options: const [
'Reinforced Concrete',
'Plain Cement',
'Marble',
'Wood',
'Tiles'
],
selectedValues: flooring,
whenEmpty: 'Select Flooring/s',
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'WALLS & PARTITIONS',
textAlign: TextAlign.start,
),
Row(
children: [
const Text('Others'),
Checkbox(
checkColor: Colors.white,
value: wpOthers,
onChanged: (bool? value) {
setState(() {
wpOthers = value!;
});
},
)
],
),
]),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Visibility(
visible: wpOthers,
child: customTextField(
"Enter other walls & partition/s", "", "other_wp"),
replacement: DropDownMultiSelect(
selected_values_style: TextStyle(color: Colors.black),
onChanged: (List<String> x) {
setState(() {
walls = x;
});
},
options: const [
'Reinforced Concrete',
'Plain Concrete',
'Wood',
'CHIB',
'G.I Sheet',
'Build-a-wall',
'Sawali',
'Bamboo'
],
selectedValues: walls,
whenEmpty: 'Select Walls & Partition/s',
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
CustomButton(
icon: const Icon(Icons.chevron_left_rounded,
color: Colors.white),
onPressed: () {
{
widget.NextBtn();
}
;
},
),
CustomButton(
icon: const Icon(Icons.chevron_right_rounded,
color: Colors.white),
onPressed: () async {
{
final tempID = await SharedPreferences.getInstance();
var strucMaterials = StructureMaterialsII(
id: tempID.getInt('tempid')! - 1,
foundation: foundationOthers
? formKey
.currentState!.value['other_foundation']
.split(',')
: foundation,
columns: columOthers
? formKey.currentState!.value['other_column']
.split(',')
: column,
beams: beamsOthers
? formKey.currentState!.value['other_beam']
.split(',')
: beam,
trussFraming: tfOthers
? formKey.currentState!.value['other_tf']
.split(',')
: truss_framing,
roof: roofOthers
? formKey.currentState!.value['other_roof']
.split(',')
: roof,
flooring: flooringOthers
? formKey
.currentState!.value['other_flooring']
.split(',')
: flooring,
walls: wpOthers
? formKey.currentState!.value['other_wp']
.split(',')
: walls,
others: ["Others"]);
context.read<PropertyInfoBloc>()
..add(UpdateStrucMaterials(data: strucMaterials));
widget.PrevBtn();
}
;
},
)
],
)
],
),
);
}),
),
);
}
}

View File

@ -107,7 +107,6 @@ class _AddLandAppraisalModal extends State<AddLandAppraisalModal> {
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Container( child: Container(
height: 800,
child: SingleChildScrollView( child: SingleChildScrollView(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Column( child: Column(
@ -387,7 +386,7 @@ class _AddLandAppraisalModal extends State<AddLandAppraisalModal> {
), ),
), ),
], ],
) ),
], ],
), ),
), ),

View File

@ -5,6 +5,8 @@ import 'package:unit2/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart';
import 'package:unit2/model/passo/land_appr.dart'; import 'package:unit2/model/passo/land_appr.dart';
import 'package:unit2/screens/passo/Land/add_land/AddLandAppraisal.dart'; import 'package:unit2/screens/passo/Land/add_land/AddLandAppraisal.dart';
import 'package:unit2/utils/alerts.dart'; import 'package:unit2/utils/alerts.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/error_state.dart';
import 'package:unit2/widgets/passo/custom_button.dart'; import 'package:unit2/widgets/passo/custom_button.dart';
class LandAppraisal extends StatefulWidget { class LandAppraisal extends StatefulWidget {
@ -237,11 +239,21 @@ class _LandAppraisal extends State<LandAppraisal> {
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [Expanded(child: AddLandAppraisalModal())], children: [
Expanded(child: AddLandAppraisalModal()),
],
), ),
), ),
); );
} }
if (state is LandAppraisalErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<LandAppraisalBloc>().add(LoadLandAppraisal());
},
);
}
return Container(); return Container();
}); });
} }

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart'; import 'package:unit2/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart';
import 'package:unit2/model/passo/land_property_boundaries.dart'; import 'package:unit2/model/passo/land_property_boundaries.dart';
import 'package:unit2/model/passo/land_property_loc.dart'; import 'package:unit2/model/passo/land_property_loc.dart';
@ -107,16 +108,18 @@ class _LandLocationAndBoundaries extends State<LandLocationAndBoundaries> {
CustomButton( CustomButton(
icon: icon:
const Icon(Icons.chevron_right, color: Colors.white), const Icon(Icons.chevron_right, color: Colors.white),
onPressed: () { onPressed: () async {
final tempID = await SharedPreferences.getInstance();
print(tempID.getInt('landid'));
var boundaries = LandPropertyBoundaries( var boundaries = LandPropertyBoundaries(
id: 3, id: tempID.getInt('landid')! - 1,
north: landKey.currentState?.value['north'], north: landKey.currentState?.value['north'],
east: landKey.currentState?.value['east'], east: landKey.currentState?.value['east'],
west: landKey.currentState?.value['west'], west: landKey.currentState?.value['west'],
south: landKey.currentState?.value['south'], south: landKey.currentState?.value['south'],
); );
var location = LandPropertyLoc( var location = LandPropertyLoc(
id: 3, id: tempID.getInt('landid')! - 1,
street: landKey.currentState?.value['street'], street: landKey.currentState?.value['street'],
barangay: landKey.currentState?.value['brgy'], barangay: landKey.currentState?.value['brgy'],
municipality: municipality:

View File

@ -76,7 +76,6 @@ class _LandPropertyOwnerInfo extends State<LandPropertyOwnerInfo> {
flex: 1, flex: 1,
child: customTextField("Blk", "", "blk")), child: customTextField("Blk", "", "blk")),
]), ]),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[ children: <Widget>[
@ -117,45 +116,6 @@ class _LandPropertyOwnerInfo extends State<LandPropertyOwnerInfo> {
flex: 1, flex: 1,
child: customTextField("Tel No.", "", "admin_telno")) child: customTextField("Tel No.", "", "admin_telno"))
]), ]),
// SizedBox(
// width: double.infinity,
// height: 50,
// child: ElevatedButton(
// style: secondaryBtnStyle(const Color(0xffd92828),
// Color.fromARGB(0, 253, 252, 252), Colors.white54),
// child: const Text(
// "SUBMIT & PROCEED",
// style: TextStyle(
// color: Color.fromARGB(239, 255, 255, 255),
// fontWeight: FontWeight.w700),
// ),
// onPressed: () {
// // formKey.currentState?.save();
// // // var faas = PropertyInfo(
// // // id: 1,
// // // transCode: formKey
// // // .currentState!.value['transaction_code']
// // // .toString(),
// // // tdn: formKey.currentState!.value['arp_td'],
// // // pin: formKey.currentState!.value['pin'],
// // // owner: formKey.currentState!.value['owner'],
// // // address: formKey.currentState!.value['address'],
// // // telno: formKey.currentState!.value['tel_no'],
// // // tin: formKey.currentState!.value['tin'],
// // // adminUser: formKey.currentState!.value['benificiary'],
// // // adminAddress: formKey
// // // .currentState!.value['benificiary_address'],
// // // adminTin:
// // // formKey.currentState!.value['benificiary_tin'],
// // // adminTelno:
// // // formKey.currentState!.value['benificiary_telno']);
// // // context.read<AssessorsBloc>().add(AddFaas(faas: faas));
// // // _loadTempId();
// // _pageController.nextPage(
// // duration: _kDuration, curve: _kCurve);
// }),
// ),
SizedBox( SizedBox(
height: 30, height: 30,
), ),

View File

@ -0,0 +1,128 @@
import 'package:flutter/material.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:im_stepper/stepper.dart';
import 'package:unit2/model/passo/land_property_owner.dart';
import 'package:unit2/screens/passo/Land/edit_land/land_appraisal.dart';
import 'package:unit2/screens/passo/Land/edit_land/location_and_boundaries_edit.dart';
import 'package:unit2/screens/passo/Land/edit_land/other_improvements_edit.dart';
import 'package:unit2/screens/passo/Land/edit_land/property_assessment_cont_edit.dart';
import 'package:unit2/screens/passo/Land/edit_land/property_assessment_edit.dart';
import 'package:unit2/screens/passo/Land/edit_land/property_owner_info_edit.dart';
import 'package:unit2/screens/passo/Land/edit_land/value_adjustments_edit.dart';
import 'package:unit2/theme-data.dart/colors.dart';
GlobalKey<FormBuilderState> landKey = GlobalKey<FormBuilderState>();
class EditLand extends StatefulWidget {
final int index;
final LandPropertyOwner faas;
final String title;
const EditLand(
{super.key,
required this.title,
required this.index,
required this.faas});
@override
_EditLand createState() => _EditLand();
}
class _EditLand extends State<EditLand> {
// THE FOLLOWING TWO VARIABLES ARE REQUIRED TO CONTROL THE STEPPER.
int activeStep = 0; // Initial step set to 5.
int upperBound = 6; // upperBound MUST BE total number of icons minus 1.
void PrevBtn() {
setState(() {
activeStep--;
});
}
void NextBtn() {
setState(() {
activeStep++;
});
}
void onSAveAll() {
return Navigator.of(context).pop();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: primary,
title: Text('Land FAAS'),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
NumberStepper(
numbers: [1, 2, 3, 4, 5, 6, 7],
activeStepColor: primary,
numberStyle: TextStyle(color: Colors.white),
lineColor: primary,
// activeStep property set to activeStep variable defined above.
activeStep: activeStep,
activeStepBorderColor: Colors.white,
activeStepBorderWidth: 1,
// This ensures step-tapping updates the activeStep.
onStepReached: (index) {
setState(() {
activeStep = index;
});
},
),
Expanded(
child: FormBuilder(
key: landKey,
// enabled: false,
onChanged: () {
landKey.currentState?.save();
print(landKey.currentState?.value.toString());
},
autovalidateMode: AutovalidateMode.disabled,
skipDisabled: true,
child: Container(
child: content(PrevBtn, NextBtn, onSAveAll),
),
),
),
],
),
),
);
}
/// Returns the next button.
// Returns the content widget based on the activeStep.
Widget content(PrevBtn, NextBtn, onSAveAll) {
switch (activeStep) {
case 0:
return LandPropertyOwnerInfoEdit(NextBtn, widget.faas!);
case 1:
return LandLocationAndBoundariesEdit(PrevBtn, NextBtn, widget.faas!);
case 2:
return LandAppraisalEdit(PrevBtn, NextBtn);
case 3:
return OtherImprovementEditPage(PrevBtn, NextBtn);
case 4:
return ValueAdjustmentEditPage(PrevBtn, NextBtn);
case 5:
return LandPropertyAssessmentEditPage(PrevBtn, NextBtn);
case 6:
return LandSignatoriesEdit(onSAveAll);
default:
return LandPropertyOwnerInfoEdit(NextBtn, widget.faas!);
}
}
}

View File

@ -0,0 +1,262 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:intl/intl.dart';
import 'package:unit2/bloc/passo/land/land_appraisal/land_appraisal_bloc.dart';
import 'package:unit2/model/passo/land_appr.dart';
import 'package:unit2/screens/passo/Land/add_land/AddLandAppraisal.dart';
import 'package:unit2/utils/alerts.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/error_state.dart';
import 'package:unit2/widgets/passo/custom_button.dart';
class LandAppraisalEdit extends StatefulWidget {
Function PrevBtn;
Function NextBtn;
LandAppraisalEdit(this.PrevBtn, this.NextBtn);
@override
_LandAppraisalEdit createState() => _LandAppraisalEdit();
}
class _LandAppraisalEdit extends State<LandAppraisalEdit> {
// double _totalMarketValue(items) {
// double total = 0;
// items.forEach((row) {
// total += double.parse(row);
// });
// return total;
// }
void deleteItem(int itemId) {
context.read<LandAppraisalBloc>().add(DeleteLandAppraisal(id: itemId));
}
@override
Widget build(BuildContext context) {
return BlocConsumer<LandAppraisalBloc, LandAppraisalState>(
listener: (context, state) {
// TODO: implement listener
}, builder: (context, state) {
final state = context.watch<LandAppraisalBloc>().state;
if (state is LandAppraisalLoaded) {
return Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
children: [
Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('LAND APPRAISAL',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
textAlign: TextAlign.left),
),
Align(
alignment: Alignment.topRight,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
),
onPressed: () {
context
.read<LandAppraisalBloc>()
.add(ShowLandAppraisal());
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Text('ADD ITEM'), // <-- Text
const SizedBox(
width: 5,
),
const Icon(
// <-- Icon
Icons.add,
size: 24.0,
),
],
),
),
),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: DataTable(
// ignore: prefer_const_literals_to_create_immutables
columns: [
const DataColumn(
label: Text('Classification'),
),
const DataColumn(
label: Text('Sub-Classification'),
),
const DataColumn(
label: Text('Area'),
),
const DataColumn(
label: Text('Unit Value'),
),
const DataColumn(
label: Text('Base MArket Value'),
),
const DataColumn(
label: Text('Action'),
)
],
rows: state.land_appr.map((dataRow) {
return DataRow(
cells: [
DataCell(Text(dataRow.classification!)),
DataCell(Text(dataRow.subClass!)),
DataCell(Text(dataRow.area!)),
DataCell(Text(
((double.parse(dataRow.unitValue!)))
.toString())),
DataCell(Text(
((double.parse(dataRow.baseMarketval!)))
.toString())),
DataCell(Row(
children: [
InkWell(
child: Container(
height: 30,
width: 30,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: Icon(
Icons.delete,
color: Colors.white,
size: 20.0,
),
),
onTap: () {
deleteItem(dataRow.id!);
},
),
SizedBox(
width: 10,
),
InkWell(
child: Container(
height: 30,
width: 30,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: Icon(
Icons.edit,
color: Colors.white,
size: 20.0,
),
),
onTap: () {},
),
],
))
],
);
}).toList()))
],
),
),
)),
// Padding(
// padding: const EdgeInsets.only(left: 20.0, right: 20.0),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text(
// 'Total',
// style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
// ),
// Text(
// NumberFormat.currency(locale: 'en-PH', symbol: "")
// .format('1.0'),
// style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
// )
// ],
// ),
// ),
Padding(
padding: const EdgeInsets.all(15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
CustomButton(
icon: const Icon(Icons.chevron_left_rounded,
color: Colors.white),
onPressed: () {
{
widget.PrevBtn();
}
;
},
),
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<LandAppraisalBloc>().add(const LoadLandAppraisal());
});
});
}
}
if (state is ShowAddLandAppraisalScreen) {
return ConstrainedBox(
constraints: BoxConstraints(
maxHeight: 700.0,
),
child: AlertDialog(
insetPadding: EdgeInsets.symmetric(
horizontal: 20.0,
vertical: 10.0,
),
title: Text(
'ADD LAND APPRAISAL',
textAlign: TextAlign.center,
),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(child: AddLandAppraisalModal()),
],
),
),
);
}
if (state is LandAppraisalErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<LandAppraisalBloc>().add(LoadLandAppraisal());
},
);
}
return Container();
});
}
}

View File

@ -0,0 +1,266 @@
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:unit2/bloc/passo/land/land_boundaries_edit/land_boundaries_edit_bloc.dart';
import 'package:unit2/bloc/passo/land/land_location_edit/land_location_edit_bloc.dart';
import 'package:unit2/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart';
import 'package:unit2/model/passo/land_property_boundaries.dart';
import 'package:unit2/model/passo/land_property_loc.dart';
import 'package:unit2/model/passo/land_property_owner.dart';
import 'package:unit2/screens/passo/Land/add_land.dart';
import 'package:unit2/screens/passo/Land/edit_land/property_owner_info_edit.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/error_state.dart';
import 'package:unit2/widgets/passo/custom_button.dart';
import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart';
class LandLocationAndBoundariesEdit extends StatefulWidget {
Function PrevBtn;
Function NextBtn;
LandPropertyOwner land;
LandLocationAndBoundariesEdit(this.PrevBtn, this.NextBtn, this.land);
@override
_LandLocationAndBoundariesEdit createState() =>
_LandLocationAndBoundariesEdit();
}
class _LandLocationAndBoundariesEdit
extends State<LandLocationAndBoundariesEdit> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<LandLocationEditBloc, LandLocationEditState>(
listener: (context, state) {
if (state is LandLocationEditLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is LandLocationEditErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
},
builder: (context, state) {
if (state is LandLocationEditLoaded) {
final landLoc = state.land_loc_edit;
return BlocConsumer<LandBoundariesEditBloc,
LandBoundariesEditState>(
listener: (context, state) {
if (state is LandLocationEditLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is LandBoundariesEditErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
},
builder: (context, state) {
if (state is LandBoundariesEditLoaded) {
return FormBuilder(
key: landEditKey,
initialValue: {
'street': landLoc.street,
'brgy': landLoc.barangay,
'municipality': landLoc.municipality,
'province': landLoc.province
},
enabled: true,
onChanged: () {
landEditKey.currentState!.save();
debugPrint(landEditKey.currentState!.value.toString());
},
autovalidateMode: AutovalidateMode.disabled,
skipDisabled: true,
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('PROPERTY LOCATION',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18),
textAlign: TextAlign.left),
),
const SizedBox(height: 15),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField(
"No. / Street", "", "street")),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField(
"Brgy./District", "", "brgy")),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"Municipality", "", "municipality"),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField(
"Province/City", "", "province"))
]),
Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('PROPERTY BOUNDARIES',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18),
textAlign: TextAlign.left),
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"North", "", "north"),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField(
"East", "", "east"))
]),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"South", "", "south"),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField(
"West", "", "west"))
]),
SizedBox(
height: 50,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
CustomButton(
icon: const Icon(Icons.chevron_left,
color: Colors.white),
onPressed: () {
widget.PrevBtn();
}),
CustomButton(
icon: const Icon(Icons.chevron_right,
color: Colors.white),
onPressed: () {
print(widget.land.id);
var boundaries =
LandPropertyBoundaries(
id: widget.land.id,
north: landEditKey
.currentState?.value['north'],
east: landEditKey
.currentState?.value['east'],
west: landEditKey
.currentState?.value['west'],
south: landEditKey
.currentState?.value['south'],
);
var location = LandPropertyLoc(
id: widget.land.id,
street: landEditKey
.currentState?.value['street'],
barangay: landEditKey
.currentState?.value['brgy'],
municipality: landEditKey
.currentState
?.value['municipality'],
province: landEditKey.currentState
?.value['province'],
);
context.read<LandLocationEditBloc>()
..add(UpdateLandLocationEdit(
land_loc_edit: location,
id: widget.land.id!));
context.read<LandBoundariesEditBloc>()
..add(UpdateLandBoundariesEdit(
land_boundaries_edit:
boundaries,
id: widget.land.id!));
widget.NextBtn();
})
],
)
]),
),
),
);
}
if (state is LandBoundariesEditErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<LandBoundariesEditBloc>().add(
LoadLandBoundariesEdit(
land_boundaries_edit: LandPropertyBoundaries(),
id: widget.land.id!));
},
);
}
return Container();
},
);
}
;
if (state is LandLocationEditErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<LandLocationEditBloc>().add(LoadLandLocationEdit(
land_loc_edit: LandPropertyLoc(), id: widget.land.id!));
},
);
}
return Container();
},
),
),
);
}
}

View File

@ -0,0 +1,263 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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';
import 'package:unit2/widgets/passo/custom_button.dart';
class OtherImprovementEditPage extends StatefulWidget {
Function PrevBtn;
Function NextBtn;
OtherImprovementEditPage(this.PrevBtn, this.NextBtn);
@override
_OtherImprovementEditPage createState() => _OtherImprovementEditPage();
}
class _OtherImprovementEditPage extends State<OtherImprovementEditPage> {
// double _totalMarketValue(items) {
// double total = 0;
// items.forEach((row) {
// total += double.parse(row);
// });
// return total;
// }
void deleteItem(int itemId) {
context
.read<OtherImprovementsBloc>()
.add(DeleteOtherImprovement(id: itemId));
}
@override
Widget build(BuildContext context) {
return BlocConsumer<OtherImprovementsBloc, OtherImprovementsState>(
listener: (context, state) {
// TODO: implement listener
}, builder: (context, state) {
final state = context.watch<OtherImprovementsBloc>().state;
if (state is OtherImprovementLoaded) {
return Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
children: [
Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('OTHER IMPROVEMENTS',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
textAlign: TextAlign.left),
),
Align(
alignment: Alignment.topRight,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
),
onPressed: () {
context
.read<OtherImprovementsBloc>()
.add(ShowOtherImprovement());
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Text('ADD ITEM'), // <-- Text
const SizedBox(
width: 5,
),
const Icon(
// <-- Icon
Icons.add,
size: 24.0,
),
],
),
),
),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: DataTable(
// ignore: prefer_const_literals_to_create_immutables
columns: [
const DataColumn(
label: Text('Kinds of Tress'),
),
const DataColumn(
label: Text('Sub-Class / Age'),
),
const DataColumn(
label: Text('Type of Tree'),
),
const DataColumn(
label: Text('No.'),
),
const DataColumn(
label: Text('No. of Productive'),
),
const DataColumn(
label: Text('No. of Non-Productive'),
),
const DataColumn(
label: Text('Unit Value'),
),
const DataColumn(
label: Text('Base Market Value'),
),
const DataColumn(
label: Text('Action'),
)
],
rows: state.other_imp.map((dataRow) {
return DataRow(
cells: [
DataCell(Text(dataRow.kindsOfTrees!)),
DataCell(Text(dataRow.subclassAge!)),
DataCell(Text(dataRow.fruitBearing!
? "Fruit Bearing"
: "Non-Fruit Bearing")),
DataCell(Text(dataRow.quantity.toString()!)),
DataCell(
Text(dataRow.noOfProductive.toString()!)),
DataCell(Text(
dataRow.noOfNonproductive.toString()!)),
DataCell(Text(dataRow.unitValue.toString()!)),
DataCell(
Text(dataRow.baseMarketval.toString()!)),
DataCell(Row(
children: [
InkWell(
child: Container(
height: 30,
width: 30,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: Icon(
Icons.delete,
color: Colors.white,
size: 20.0,
),
),
onTap: () {
deleteItem(dataRow.id!);
},
),
SizedBox(
width: 10,
),
InkWell(
child: Container(
height: 30,
width: 30,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: Icon(
Icons.edit,
color: Colors.white,
size: 20.0,
),
),
onTap: () {},
),
],
))
],
);
}).toList()))
],
),
),
)),
// Padding(
// padding: const EdgeInsets.only(left: 20.0, right: 20.0),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text(
// 'Total',
// style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
// ),
// Text(
// NumberFormat.currency(locale: 'en-PH', symbol: "")
// .format('1.0'),
// style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
// )
// ],
// ),
// ),
Padding(
padding: const EdgeInsets.all(15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
CustomButton(
icon: const Icon(Icons.chevron_left_rounded,
color: Colors.white),
onPressed: () {
{
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<OtherImprovementsBloc>()
.add(const LoadOtherImprovement());
});
});
}
}
if (state is ShowAddOtherImprovementScreen) {
return ConstrainedBox(
constraints: BoxConstraints(maxHeight: 1000.0),
child: AlertDialog(
insetPadding: EdgeInsets.symmetric(
horizontal: 20.0,
vertical: 10.0,
),
title: Text(
'ADD OTHER IMPROVEMENTS',
textAlign: TextAlign.center,
),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [Container(child: AddOtherImprovementModal())],
),
),
);
}
return Container();
});
}
}

View File

@ -0,0 +1,541 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:searchfield/searchfield.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/bloc/passo/land/land_ext/land_ext_bloc.dart';
import 'package:unit2/bloc/passo/memoranda/memoranda_bloc.dart';
import 'package:unit2/bloc/passo/signatories/signatories_bloc.dart';
import 'package:unit2/model/passo/land_ext.dart';
import 'package:unit2/model/passo/memoranda.dart';
import 'package:unit2/model/passo/signatories.dart';
import 'package:unit2/screens/passo/Land/add_land.dart';
import 'package:unit2/theme-data.dart/colors.dart';
class LandSignatoriesEdit extends StatefulWidget {
Function onSAve;
LandSignatoriesEdit(this.onSAve);
@override
_LandSignatoriesEdit createState() => _LandSignatoriesEdit();
}
class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
bool isTaxable = false;
bool isExempt = false;
final focus = FocusNode();
String _memoranda = "";
@override
Widget build(BuildContext context) {
return BlocConsumer<LandExtBloc, LandExtState>(
listener: (context, state) {
// TODO: implement listener
},
builder: (context, state) {
if (state is LandExtLoaded) {
return BlocConsumer<SignatoriesBloc, SignatoriesState>(
listener: (context, state) {
// TODO: implement listener
},
builder: (context, state) {
if (state is SignatoriesLoaded) {
final signatories = state.signatories;
return BlocConsumer<MemorandaBloc, MemorandaState>(
listener: (context, state) {
// TODO: implement listener
},
builder: (context, state) {
if (state is MemorandaLoaded) {
return SingleChildScrollView(
child: Column(
children: [
Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('PROPERTY ASSESSMENT cont..',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
textAlign: TextAlign.left),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Row(
children: [
const Text('Taxable'),
Checkbox(
checkColor: Colors.white,
value: isTaxable,
onChanged: (bool? value) {
setState(() {
isTaxable = value!;
});
},
)
],
),
Row(
children: [
const Text('Exempt'),
Checkbox(
checkColor: Colors.white,
value: isExempt,
onChanged: (bool? value) {
setState(() {
isExempt = value!;
});
},
)
],
),
],
),
Column(
children: [
const SizedBox(
height: 20,
),
const Text(
'EFFECTIVITY OF ASSESSMENT / REASSESSMENT :',
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
const Text('Qtr.'),
SizedBox(
width: 70,
height: 25,
child: FormBuilderTextField(
name: 'land_qtr',
validator:
FormBuilderValidators.compose([]),
),
),
const SizedBox(
width: 20,
),
const Text('Yr.'),
SizedBox(
width: 70,
height: 25,
child: FormBuilderTextField(
name: 'land_yr',
validator:
FormBuilderValidators.compose([]),
),
),
],
),
],
),
Container(
margin: const EdgeInsets.only(
left: 0, top: 40, right: 0, bottom: 10),
child: const Text('SIGNATORIES',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
textAlign: TextAlign.left),
),
const SizedBox(
height: 30,
),
Align(
alignment: Alignment.centerLeft,
child: Text(
'APPRAISED/ASSESSED BY:',
style: TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.start,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
children: [
SizedBox(
width: 200,
child: FormBuilderDropdown<Signatories>(
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<Signatories>(
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<Signatories>(
name: 'apprvd_by_land',
autofocus: false,
items: signatories
.map((signatories) =>
DropdownMenuItem(
value: signatories,
child: Text(
'${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'),
))
.toList()),
),
Text('Name'),
],
),
const SizedBox(
width: 15,
),
Column(
children: [
SizedBox(
width: 100,
child: FormBuilderDateTimePicker(
name: 'apprvd_by_date_land',
initialEntryMode:
DatePickerEntryMode.calendarOnly,
initialValue: DateTime.now(),
inputType: InputType.date,
initialTime:
const TimeOfDay(hour: 8, minute: 0),
// locale: const Locale.fromSubtags(languageCode: 'fr'),
),
),
Text('Date'),
],
),
],
),
const SizedBox(
height: 50,
),
const Align(
alignment: Alignment.centerLeft,
child: Text(
'MEMORANDA: ',
style: TextStyle(
fontWeight: FontWeight.bold,
),
)),
SizedBox(
height: 50,
),
SizedBox(
width: 500,
height: 100,
child: SearchField(
suggestions: state.memorada
.map((Memoranda memoranda) =>
SearchFieldListItem(
'${memoranda.memoranda}',
item:
memoranda, // Change: Use individual Memoranda object
child: ListTile(
title: Text(
'${memoranda.memoranda}',
overflow: TextOverflow.ellipsis,
),
),
))
.toList(),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
// searchInputDecoration:
// normalTextFieldStyle(
// "Memoranda", "")
// .copyWith(
// suffixIcon: const Icon(
// Icons.arrow_drop_down),
// ),
// focusNode: focus,
suggestionState: Suggestion.expand,
onSuggestionTap: (memoranda) {
setState(() {
_memoranda = memoranda.item!.memoranda!;
});
focus.unfocus();
},
)),
SizedBox(
height: 30,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Sworn Statement No. :'),
SizedBox(
width: 150,
height: 20,
child: FormBuilderTextField(
name: 'sworn_statement_land',
decoration: InputDecoration(),
validator: FormBuilderValidators.compose([]),
),
),
],
),
SizedBox(
height: 30,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Date Received:'),
SizedBox(
width: 150,
height: 20,
child: FormBuilderDateTimePicker(
name: 'date_received_land',
initialEntryMode:
DatePickerEntryMode.calendarOnly,
initialValue: DateTime.now(),
inputType: InputType.date,
initialTime:
const TimeOfDay(hour: 8, minute: 0),
// locale: const Locale.fromSubtags(languageCode: 'fr'),
),
),
],
),
SizedBox(
height: 30,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Date of Entry in the Rec. of Ass. :'),
SizedBox(
width: 100,
height: 20,
child: FormBuilderDateTimePicker(
name: 'date_of_entry_land',
initialEntryMode:
DatePickerEntryMode.calendarOnly,
initialValue: DateTime.now(),
inputType: InputType.date,
initialTime:
const TimeOfDay(hour: 8, minute: 0),
// locale: const Locale.fromSubtags(languageCode: 'fr'),
),
),
],
),
SizedBox(
height: 30,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('By:'),
SizedBox(
width: 150,
height: 20,
child: FormBuilderTextField(
name: 'by_land',
decoration: InputDecoration(),
validator: FormBuilderValidators.compose([]),
),
),
],
),
SizedBox(
height: 30,
),
ElevatedButton(
onPressed: () async {
final tempID =
await SharedPreferences.getInstance();
var ext = LandExt(
landapprDetailsId:
tempID.getInt('landid')! - 1,
taxable: isTaxable,
exempt: isExempt,
qtr: int.parse(
landKey.currentState!.value['land_qtr']),
yr: int.parse(
landKey.currentState!.value['land_yr']),
appraisedbyName: landKey.currentState!.value['appraised_by_land'].firstname +
' ' +
landKey
.currentState!
.value['appraised_by_land']
.middlename +
' ' +
landKey.currentState!
.value['appraised_by_land'].lastname,
appraisedbyDate: landKey
.currentState!.value['app_date_land'],
recommendapprName: landKey
.currentState!
.value['rec_approval_land']
.firstname +
' ' +
landKey
.currentState!
.value['rec_approval_land']
.middlename +
' ' +
landKey.currentState!
.value['rec_approval_land'].lastname,
recommendapprDate: landKey
.currentState!.value['rec_date_land'],
approvedbyName: landKey.currentState!.value['apprvd_by_land'].firstname +
' ' +
landKey.currentState!.value['apprvd_by_land'].middlename +
' ' +
landKey.currentState!.value['apprvd_by_land'].lastname,
approvedbyDate: landKey.currentState!.value['apprvd_by_date_land'],
memoranda: _memoranda,
swornstatementNo: landKey.currentState!.value['sworn_statement_land'],
dateReceived: landKey.currentState!.value['date_received_land'],
entryDateAssessment: landKey.currentState!.value['date_of_entry_land'],
entryDateBy: landKey.currentState!.value['by_land']);
context.read<LandExtBloc>()
..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,
),
textAlign: TextAlign.center,
),
),
),
),
SizedBox(
height: 30,
),
],
));
}
return Container();
},
);
}
return Container();
},
);
}
return Container();
},
);
}
}

View File

@ -0,0 +1,245 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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';
import 'package:unit2/widgets/passo/custom_button.dart';
class LandPropertyAssessmentEditPage extends StatefulWidget {
Function PrevBtn;
Function NextBtn;
LandPropertyAssessmentEditPage(this.PrevBtn, this.NextBtn);
@override
_LandPropertyAssessmentEditPage createState() =>
_LandPropertyAssessmentEditPage();
}
class _LandPropertyAssessmentEditPage
extends State<LandPropertyAssessmentEditPage> {
// double _totalMarketValue(items) {
// double total = 0;
// items.forEach((row) {
// total += double.parse(row);
// });
// return total;
// }
void deleteItem(int itemId) {
context
.read<LandPropertyAssessmentBloc>()
.add(DeleteLandPropertyAssessment(id: itemId));
}
@override
Widget build(BuildContext context) {
return BlocConsumer<LandPropertyAssessmentBloc,
LandPropertyAssessmentState>(listener: (context, state) {
// TODO: implement listener
}, builder: (context, state) {
final state = context.watch<LandPropertyAssessmentBloc>().state;
if (state is LandPropertyAssessmentLoaded) {
return Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
children: [
Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('PROPERTY ASSESSMENT',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
textAlign: TextAlign.left),
),
Align(
alignment: Alignment.topRight,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
),
onPressed: () {
context
.read<LandPropertyAssessmentBloc>()
.add(ShowLandPropertyAssessment());
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Text('ADD ITEM'), // <-- Text
const SizedBox(
width: 5,
),
const Icon(
// <-- Icon
Icons.add,
size: 24.0,
),
],
),
),
),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: DataTable(
// ignore: prefer_const_literals_to_create_immutables
columns: [
const DataColumn(
label: Text('Actual Use'),
),
const DataColumn(
label: Text('Market Value'),
),
const DataColumn(
label: Text('Assessment Level'),
),
const DataColumn(
label: Text('Assessed Value'),
),
const DataColumn(
label: Text('Action'),
)
],
rows: state.assessment.map((dataRow) {
return DataRow(
cells: [
DataCell(Text(dataRow.actualUse!)),
DataCell(Text(dataRow.marketval!)),
DataCell(
Text(dataRow.assessmentLevel! + '%')),
DataCell(Text(dataRow.assessedValue!)),
DataCell(Row(
children: [
InkWell(
child: Container(
height: 30,
width: 30,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: Icon(
Icons.delete,
color: Colors.white,
size: 20.0,
),
),
onTap: () {
deleteItem(dataRow.id!);
},
),
SizedBox(
width: 10,
),
InkWell(
child: Container(
height: 30,
width: 30,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: Icon(
Icons.edit,
color: Colors.white,
size: 20.0,
),
),
onTap: () {},
),
],
))
],
);
}).toList()))
],
),
),
)),
// Padding(
// padding: const EdgeInsets.only(left: 20.0, right: 20.0),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text(
// 'Total',
// style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
// ),
// Text(
// NumberFormat.currency(locale: 'en-PH', symbol: "")
// .format('1.0'),
// style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
// )
// ],
// ),
// ),
Padding(
padding: const EdgeInsets.all(15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
CustomButton(
icon: const Icon(Icons.chevron_left_rounded,
color: Colors.white),
onPressed: () {
{
widget.PrevBtn();
}
;
},
),
CustomButton(
icon: const Icon(Icons.chevron_right_rounded,
color: Colors.white),
onPressed: () {
{
widget.NextBtn();
}
;
},
)
],
),
),
],
);
}
if (state is LandPropertyAssessmentDeletedState) {
if (state.success) {
WidgetsBinding.instance.addPostFrameCallback((_) {
successAlert(context, "Deletion Successful",
"Extra item has been deleted successfully", () {
Navigator.of(context).pop();
context
.read<LandPropertyAssessmentBloc>()
.add(const LoadLandPropertyAssessment());
});
});
}
}
if (state is ShowAddLandPropertyAssessmentScreen) {
return ConstrainedBox(
constraints: BoxConstraints(maxHeight: 1000.0),
child: AlertDialog(
insetPadding: EdgeInsets.symmetric(
horizontal: 20.0,
vertical: 10.0,
),
title: Text(
'ADD PROPERTY ASSESSMENT',
textAlign: TextAlign.center,
),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [Container(child: AddPropertyAssessmentModal())],
),
),
);
}
return Container();
});
}
}

View File

@ -0,0 +1,223 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:unit2/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart';
import 'package:unit2/model/passo/land_property_owner.dart';
import 'package:unit2/screens/passo/Land/add_land.dart';
import 'package:unit2/widgets/passo/custom_button.dart';
import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart';
GlobalKey<FormBuilderState> landEditKey = GlobalKey<FormBuilderState>();
class LandPropertyOwnerInfoEdit extends StatefulWidget {
Function NextBtn;
LandPropertyOwner land;
LandPropertyOwnerInfoEdit(this.NextBtn, this.land);
@override
_LandPropertyOwnerInfoEdit createState() => _LandPropertyOwnerInfoEdit();
}
class _LandPropertyOwnerInfoEdit extends State<LandPropertyOwnerInfoEdit> {
final transaction_codes = ['New', 'Revision'];
@override
Widget build(BuildContext context) {
return BlocConsumer<LandPropertyOwnerInfoBloc, LandPropertyOwnerInfoState>(
listener: (context, state) {
// TODO: implement listener
},
builder: (context, state) {
return FormBuilder(
key: landEditKey,
initialValue: {
'transaction_code': widget.land.transCode ?? '',
'td_no': widget.land.tdn ?? '',
'owner': widget.land.owner ?? '',
'pin': widget.land.pin ?? '',
'tin': widget.land.tin ?? '',
'cloa_no': widget.land.cloaNo ?? '',
'dated': widget.land.dated ?? '',
'survey_no': widget.land.surveyNo ?? '',
'lot_no': widget.land.lotNo ?? '',
'blk': widget.land.blkNo ?? '',
'address': widget.land.address ?? '',
'tel_no': widget.land.telno ?? '',
'admin': widget.land.adminUser ?? '',
'admin_tin': widget.land.adminTin ?? '',
'admin_address': widget.land.adminAddress ?? '',
'admin_telno': widget.land.adminTelno ?? '',
},
enabled: true,
onChanged: () {
landEditKey.currentState!.save();
debugPrint(landEditKey.currentState!.value.toString());
},
autovalidateMode: AutovalidateMode.disabled,
skipDisabled: true,
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('PROPERTY OWNER INFO',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
textAlign: TextAlign.left),
),
const SizedBox(height: 15),
customDropDownField("Transaction Code", "",
"transaction_code", transaction_codes),
customTextField("ARP No./ TD No.", "", "td_no"),
customTextField("Owner", "", "owner"),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1, child: customTextField("PIN", "", "pin")),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField("TIN", "", "tin"))
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"OCT/TCT CLOA No.", "", "cloa_no"),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customDatTimePicker("Dated", "", "dated"))
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField("Survey No.", "", "survey_no"),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField("Lot No.", "", "lot_no")),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField("Blk", "", "blk")),
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField("Address", "", "address"),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField("Tel No.", "", "tel_no"))
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child: customTextField(
"Administrator/Beneficial User", "", "admin"),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customTextField("TIN", "", "admin_tin"))
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
flex: 1,
child:
customTextField("Address", "", "admin_address"),
),
const SizedBox(width: 10.0),
Expanded(
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child:
customTextField("Tel No.", "", "admin_telno"))
]),
SizedBox(
height: 30,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CustomButton(
icon: const Icon(Icons.chevron_right,
color: Colors.white),
onPressed: () {
var land = LandPropertyOwner(
id: widget.land.id,
transCode: landEditKey
.currentState!.value['transaction_code']
.toString(),
tdn: landEditKey.currentState!.value['td_no'],
cloaNo:
landEditKey.currentState!.value['cloa_no'],
dated: landEditKey.currentState!.value['dated'],
assessedById: "1",
assessedByName: "cyril",
dateCreated:
landEditKey.currentState!.value['dated'],
dateModified:
landEditKey.currentState!.value['dated'],
pin: landEditKey.currentState!.value['pin'],
surveyNo:
landEditKey.currentState!.value['survey_no'],
lotNo: landEditKey.currentState!.value['lot_no'],
blkNo: landEditKey.currentState!.value['blk'],
owner: landEditKey.currentState!.value['owner'],
address:
landEditKey.currentState!.value['address'],
telno: landEditKey.currentState!.value['tel_no'],
tin: landEditKey.currentState!.value['tin'],
adminUser:
landEditKey.currentState!.value['admin'],
adminAddress: landEditKey
.currentState!.value['admin_address'],
adminTin:
landEditKey.currentState!.value['admin_tin'],
// faasType: "LAND",
adminTelno: landEditKey
.currentState!.value['admin_telno']);
context.read<LandPropertyOwnerInfoBloc>().add(
UpdateLandPropertyOwner(
land_edit: land, id: widget.land.id!));
widget.NextBtn();
},
)
],
),
const SizedBox(
height: 20,
),
]),
)),
);
},
);
}
}

View File

@ -0,0 +1,246 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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';
import 'package:unit2/widgets/passo/custom_button.dart';
class ValueAdjustmentEditPage extends StatefulWidget {
Function PrevBtn;
Function NextBtn;
ValueAdjustmentEditPage(this.PrevBtn, this.NextBtn);
@override
_ValueAdjustmentEditPage createState() => _ValueAdjustmentEditPage();
}
class _ValueAdjustmentEditPage extends State<ValueAdjustmentEditPage> {
// double _totalMarketValue(items) {
// double total = 0;
// items.forEach((row) {
// total += double.parse(row);
// });
// return total;
// }
void deleteItem(int itemId) {
context
.read<LandValueAdjustmentsBloc>()
.add(DeleteLandValueAdjustments(id: itemId));
}
@override
Widget build(BuildContext context) {
return BlocConsumer<LandValueAdjustmentsBloc, LandValueAdjustmentsState>(
listener: (context, state) {
// TODO: implement listener
}, builder: (context, state) {
final state = context.watch<LandValueAdjustmentsBloc>().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,
),
onPressed: () {
context
.read<LandValueAdjustmentsBloc>()
.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: () {},
),
],
))
],
);
}).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<LandValueAdjustmentsBloc>()
.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();
});
}
}

View File

@ -57,6 +57,7 @@ import 'package:unit2/widgets/error_state.dart';
import 'package:flutter_speed_dial/flutter_speed_dial.dart'; import 'package:flutter_speed_dial/flutter_speed_dial.dart';
import '../../model/passo/bldg_loc.dart'; import '../../model/passo/bldg_loc.dart';
import '../../utils/alerts.dart';
class BuildingHome extends StatelessWidget { class BuildingHome extends StatelessWidget {
const BuildingHome({super.key}); const BuildingHome({super.key});
@ -66,6 +67,11 @@ class BuildingHome extends StatelessWidget {
int? profileId; int? profileId;
String? token; String? token;
Profile profile; Profile profile;
void deleteItem(int itemId) {
context.read<PropertyInfoBloc>().add(DeleteBuildingFaas(id: itemId));
}
return Scaffold( return Scaffold(
body: ProgressHUD( body: ProgressHUD(
backgroundColor: Colors.black87, backgroundColor: Colors.black87,
@ -102,8 +108,8 @@ class BuildingHome extends StatelessWidget {
shrinkWrap: true, shrinkWrap: true,
itemCount: propertyList.length, itemCount: propertyList.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return _listCard( return _listCard(propertyList[index], context,
propertyList[index], context, index); index, deleteItem);
}, },
), ),
), ),
@ -121,6 +127,20 @@ class BuildingHome extends StatelessWidget {
}, },
); );
} }
if (state is BuildingFaasDeletedState) {
if (state.success) {
WidgetsBinding.instance.addPostFrameCallback((_) {
successAlert(context, "Deletion Successful",
"Building FAAS Data has been deleted successfully",
() {
Navigator.of(context).pop();
context
.read<PropertyInfoBloc>()
.add(const LoadPropertyInfo());
});
});
}
}
return Container(); return Container();
}, },
); );
@ -269,7 +289,7 @@ class BuildingHome extends StatelessWidget {
} }
} }
Card _listCard(PropertyInfo property_info, context, index) { Card _listCard(PropertyInfo property_info, context, index, deleteItem) {
return Card( return Card(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
@ -400,7 +420,13 @@ Card _listCard(PropertyInfo property_info, context, index) {
], ],
), ),
), ),
IconButton(onPressed: () {}, icon: const Icon(Icons.chevron_right)), IconButton(
onPressed: () {
deleteItem(property_info.id);
},
icon: const Icon(Icons.delete_rounded),
color: primary,
),
], ],
), ),
), ),

View File

@ -18,8 +18,10 @@ 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/structural_material/structural_material_bloc.dart';
import 'package:unit2/bloc/passo/bulding/unit_construct/unit_construct_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_appraisal/land_appraisal_bloc.dart';
import 'package:unit2/bloc/passo/land/land_boundaries_edit/land_boundaries_edit_bloc.dart';
import 'package:unit2/bloc/passo/land/land_classification/land_classification_bloc.dart'; import 'package:unit2/bloc/passo/land/land_classification/land_classification_bloc.dart';
import 'package:unit2/bloc/passo/land/land_ext/land_ext_bloc.dart'; import 'package:unit2/bloc/passo/land/land_ext/land_ext_bloc.dart';
import 'package:unit2/bloc/passo/land/land_location_edit/land_location_edit_bloc.dart';
import 'package:unit2/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart'; import 'package:unit2/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart';
import 'package:unit2/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart'; import 'package:unit2/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart';
import 'package:unit2/bloc/passo/land/land_subclassification/land_subclassification_bloc.dart'; import 'package:unit2/bloc/passo/land/land_subclassification/land_subclassification_bloc.dart';
@ -37,6 +39,8 @@ import 'package:unit2/bloc/passo/signatories/signatories_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart'; import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/passo/additional_items.dart'; import 'package:unit2/model/passo/additional_items.dart';
import 'package:unit2/model/passo/general_description.dart'; import 'package:unit2/model/passo/general_description.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_property_owner.dart';
import 'package:unit2/model/passo/land_ref.dart'; import 'package:unit2/model/passo/land_ref.dart';
import 'package:unit2/model/passo/property_appraisal.dart'; import 'package:unit2/model/passo/property_appraisal.dart';
@ -49,6 +53,7 @@ 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/add_building.dart';
import 'package:unit2/screens/passo/Building/edit_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/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/multi_dropdown.dart';
import 'package:unit2/screens/passo/Test%20Envi/speed_dial.dart'; import 'package:unit2/screens/passo/Test%20Envi/speed_dial.dart';
import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/colors.dart';
@ -283,79 +288,72 @@ Card _listCard(LandPropertyOwner property_info, context, index) {
padding: const EdgeInsets.all(15.0), padding: const EdgeInsets.all(15.0),
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
// Navigator.push(context, Navigator.push(context,
// MaterialPageRoute(builder: (BuildContext context) { MaterialPageRoute(builder: (BuildContext context) {
// return MultiBlocProvider( return MultiBlocProvider(
// providers: [ providers: [
// BlocProvider( BlocProvider(
// create: (context) => create: (context) =>
// PropertyInfoBloc()..add(LoadPropertyInfo()), LandPropertyOwnerInfoBloc()..add(LoadLand())),
// ), BlocProvider(
// BlocProvider( create: (context) => LandLocationEditBloc()
// create: (context) => ..add(LoadLandLocationEdit(
// UnitConstructBloc()..add(LoadUnitConstruct()), land_loc_edit: LandPropertyLoc(),
// ), id: property_info.id))),
// BlocProvider( BlocProvider(
// create: (context) => create: (context) => LandBoundariesEditBloc()
// ClassComponentsBloc()..add(LoadClassComponents()), ..add(LoadLandBoundariesEdit(
// ), land_boundaries_edit: LandPropertyBoundaries(),
// BlocProvider( id: property_info.id))),
// create: (context) => BlocProvider(
// SignatoriesBloc()..add(LoadSignatories())), create: (context) =>
// BlocProvider( LandAppraisalBloc()..add(LoadLandAppraisal())),
// create: (context) => LocationBloc() BlocProvider(
// ..add( create: (context) => LandClassificationBloc()
// LoadLocation(bldgloc: BldgLoc(), id: property_info.id)), ..add(LoadLandClassification())),
// ), BlocProvider(
// BlocProvider( create: (context) => LandSubClassificationBloc()
// create: (context) => LandrefBloc() ..add(LoadLandSubClassification(
// ..add( cityCode: "1", classCode: 1))),
// LoadLandref(landRef: LandRef(), id: property_info.id)), BlocProvider(
// ), create: (context) =>
// BlocProvider( OtherImprovementsBloc()..add(LoadOtherImprovement())),
// create: (context) => GeneralDescriptionBloc() BlocProvider(
// ..add(LoadGenDesc( create: (context) =>
// gendesc: GeneralDesc(), id: property_info.id)), TypeOfLocationBloc()..add(LoadTypeOfLocation())),
// ), BlocProvider(
// BlocProvider( create: (context) =>
// create: (context) => AdditionalItemsEditBloc() TypeOfRoadBloc()..add(LoadTypeOfRoad())),
// ..add(LoadAdditionalItemsEdit( BlocProvider(
// items: const <AdditionalItems>[], create: (context) => LandPropertyAssessmentBloc()
// id: property_info.id)), ..add(LoadLandPropertyAssessment())),
// ), BlocProvider(
// BlocProvider( create: (context) => LandTreesImprovementsBloc()
// create: (context) => PropertyAssessmentEditBloc() ..add(LoadLandTreesImprovements())),
// ..add(LoadPropertyAssessmentEdit( BlocProvider(
// assessmentsEdit: PropertyAssessmentEdit(), create: (context) => LandExtBloc()..add(LoadLandExt())),
// id: property_info.id)), BlocProvider(
// ), create: (context) => LandValueAdjustmentsBloc()
// BlocProvider( ..add(LoadLandValueAdjustments())),
// create: (context) => PropertyAppraisalEditBloc() BlocProvider(
// ..add(LoadPropertyAppraisalEdit( create: (context) =>
// appraisalEdit: PropertyAppraisalEdit(), SignatoriesBloc()..add(LoadSignatories())),
// id: property_info.id)), BlocProvider(
// ), create: (context) =>
// BlocProvider( MunicipalityBloc()..add(LoadMunicipality())),
// create: (context) => BlocProvider(
// MunicipalityBloc()..add(LoadMunicipality())), create: (context) =>
// BlocProvider( BarangayBloc()..add(LoadBarangay(id: '01'))),
// create: (context) => BlocProvider(
// BarangayBloc()..add(LoadBarangay(id: '01'))), create: (context) => MemorandaBloc()..add(LoadMemoranda())),
// BlocProvider( ],
// create: (context) => MemorandaBloc()..add(LoadMemoranda())), child: EditLand(
// BlocProvider( index: index,
// create: (context) => StructuralMaterialBloc() faas: property_info,
// ..add(LoadStructuralMaterial( title: 'Bldg & Structure Edit',
// structure: StructureMaterials(), ),
// id: property_info.id))), );
// ], }));
// child: EditBuilding(
// index: index,
// faas: property_info,
// title: 'Bldg & Structure Edit',
// ),
// );
// }));
}, },
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,

View File

@ -134,4 +134,29 @@ class PropertyInfoService {
} }
return response; return response;
} }
Future<http.Response> remove(id) async {
String path = Url.instance.propertyInfo();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map<String, String> 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();
}
}
} }

View File

@ -56,4 +56,57 @@ class LandBoundariesService {
} }
return response; return response;
} }
Future<http.Response?> updateEdit(LandPropertyBoundaries data, id) async {
String path = Url.instance.getLandPropertyBoundaries();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map<String, String> params = {
"landappr_details_id": id.toString(),
};
http.Response? response;
try {
response = await Request.instance.putRequest(
path: path, body: data.toJson(), headers: headers, param: params);
} catch (e) {
log(e.toString());
}
return response;
}
Future<LandPropertyBoundaries> fetchEdit(tempID) async {
String path = Url.instance.getLandPropertyBoundaries();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map<String, String> params = {
"landappr_details_id": tempID.toString(),
};
try {
http.Response response = await Request.instance
.getRequest(param: params, path: path, headers: headers);
print('LandBoundEdit');
print(response.body);
if (response.statusCode == 200) {
final jsonData = jsonDecode(response.body);
final dataList = jsonData['data'] as List<dynamic>;
final result = LandPropertyBoundaries.fromJson(
dataList[0] as Map<String, dynamic>);
return result;
} else {
print(response.reasonPhrase);
throw Exception(response.reasonPhrase);
}
} catch (e) {
throw e.toString();
}
}
} }

View File

@ -55,4 +55,57 @@ class LandLocationService {
} }
return response; return response;
} }
Future<http.Response?> updateEdit(LandPropertyLoc data, id) async {
String path = Url.instance.getLandPropertyLoc();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map<String, String> params = {
"landappr_details_id": id.toString(),
};
http.Response? response;
try {
response = await Request.instance.putRequest(
path: path, body: data.toJson(), headers: headers, param: params);
} catch (e) {
log(e.toString());
}
return response;
}
Future<LandPropertyLoc> fetchEdit(tempID) async {
String path = Url.instance.getLandPropertyLoc();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map<String, String> params = {
"landappr_details_id": tempID.toString(),
};
try {
http.Response response = await Request.instance
.getRequest(param: params, path: path, headers: headers);
print('LandLocEdit');
print(response.body);
if (response.statusCode == 200) {
final jsonData = jsonDecode(response.body);
final dataList = jsonData['data'] as List<dynamic>;
final result =
LandPropertyLoc.fromJson(dataList[0] as Map<String, dynamic>);
return result;
} else {
print(response.reasonPhrase);
throw Exception(response.reasonPhrase);
}
} catch (e) {
throw e.toString();
}
}
} }

View File

@ -52,4 +52,24 @@ class LandServices {
} }
return response; return response;
} }
Future<http.Response?> update(LandPropertyOwner data, id) async {
String path = Url.instance.getLandOwnerInfo();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map<String, String> params = {
"id": id.toString(),
};
http.Response? response;
try {
response = await Request.instance.putRequest(
path: path, body: data.toJson(), headers: headers, param: params);
} catch (e) {
log(e.toString());
}
return response;
}
} }

View File

@ -19,7 +19,7 @@ class Request {
Map<String, String>? param}) async { Map<String, String>? param}) async {
Response response; Response response;
try { try {
response = await get(Uri.https(host, path!, param), headers: headers) response = await get(Uri.http(host, path!, param), headers: headers)
.timeout(Duration(seconds: requestTimeout)); .timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {
// Fluttertoast.showToast( // Fluttertoast.showToast(
@ -61,7 +61,7 @@ class Request {
Map<String, String>? param}) async { Map<String, String>? param}) async {
Response response; Response response;
try { try {
response = await post(Uri.https(host, path!, param), response = await post(Uri.http(host, path!, param),
headers: headers, body: jsonEncode(body)) headers: headers, body: jsonEncode(body))
.timeout(Duration(seconds: requestTimeout)); .timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {
@ -104,7 +104,7 @@ class Request {
required Map<String, dynamic>? param}) async { required Map<String, dynamic>? param}) async {
Response response; Response response;
try { try {
response = await put(Uri.https(host, path, param), response = await put(Uri.http(host, path, param),
headers: headers, body: jsonEncode(body)); headers: headers, body: jsonEncode(body));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {
// Fluttertoast.showToast( // Fluttertoast.showToast(
@ -188,7 +188,7 @@ class Request {
required Map<String, dynamic>? param}) async { required Map<String, dynamic>? param}) async {
Response response; Response response;
try { try {
response = await delete(Uri.https(host, path, param), response = await delete(Uri.http(host, path, param),
headers: headers, body: jsonEncode(body)) headers: headers, body: jsonEncode(body))
.timeout(Duration(seconds: requestTimeout)); .timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {

View File

@ -5,12 +5,13 @@ class Url {
String host() { String host() {
// return '192.168.10.183:3000'; // return '192.168.10.183:3000';
return 'agusandelnorte.gov.ph'; // return 'agusandelnorte.gov.ph';
// return "192.168.10.219:3000"; // return "192.168.10.219:3000";
// return "192.168.10.241"; // return "192.168.10.241";
// return "192.168.10.221:3004"; // return "192.168.10.221:3004";
// return "playweb.agusandelnorte.gov.ph"; return "playweb.agusandelnorte.gov.ph";
// return 'devapi.agusandelnorte.gov.ph:3004'; // return 'devapi.agusandelnorte.gov.ph:3004';
// return "192.168.10.218:8000";
} }
String prefixHost() { String prefixHost() {
@ -26,7 +27,6 @@ class Url {
return 'api/jobnet_app/profile/pds/'; return 'api/jobnet_app/profile/pds/';
} }
String latestApk() { String latestApk() {
return "/api/system_app/apk_version/latest"; return "/api/system_app/apk_version/latest";
} }