Compare commits

...

21 Commits

Author SHA1 Message Date
superadmin 4647e2885f Merge pull request 'release/v1/beta/v1.0.3-beta' (#58) from release/v1/beta/v1.0.3-beta into master
Reviewed-on: http://git.agusandelnorte.gov.ph:3000/SoftwareDevelopmentSection/unit2-null-safety-repository/pulls/58
2023-09-25 11:55:49 +08:00
superadmin 73993f7371 Merge pull request 'feature/unit2/UNIT2-#56Built_in_downloader_for_updating_unit2_app' (#57) from feature/unit2/UNIT2-#56Built_in_downloader_for_updating_unit2_app into develop
Reviewed-on: http://git.agusandelnorte.gov.ph:3000/SoftwareDevelopmentSection/unit2-null-safety-repository/pulls/57
2023-09-25 11:42:21 +08:00
PGAN-MIS dcfb1ca1a3 add built in downloader 2023-09-25 11:38:00 +08:00
PGAN-MIS fdd2354320 commit before upgrade 2023-09-25 09:43:03 +08:00
cyrilaquismundo f6d7760ef9 Merge pull request 'release/v1/beta/v1.0.2-beta' (#54) from release/v1/beta/v1.0.2-beta into master
Reviewed-on: http://git.agusandelnorte.gov.ph:3000/SoftwareDevelopmentSection/unit2-null-safety-repository/pulls/54
2023-09-22 16:33:03 +08:00
cyrilaquismundo a27f402dd8 Merge branch 'master' into release/v1/beta/v1.0.2-beta 2023-09-22 16:32:32 +08:00
rodolfobacuinjr b560340ebc Merge pull request 'consol/feature/unit2/UNIT2-#41Fix_small_bugs_and_implement_assign_role_area__develop' (#53) from consol/feature/unit2/UNIT2-#41Fix_small_bugs_and_implement_assign_role_area__develop into develop
Reviewed-on: http://git.agusandelnorte.gov.ph:3000/SoftwareDevelopmentSection/unit2-null-safety-repository/pulls/53
2023-09-22 16:24:44 +08:00
PGAN-MIS 4cfa75e8b8 fixed conflicts 2023-09-22 16:16:33 +08:00
PGAN-MIS 106cc71362 fixed bugs for assigned area 2023-09-22 16:07:13 +08:00
superadmin 06f68f0734 Merge pull request 'Fixed minor bugs on adding land faas and editing land faas' (#49) from feature/passo/PASSO-#43-Offline-capability-using-sqlflite into develop
Reviewed-on: http://git.agusandelnorte.gov.ph:3000/SoftwareDevelopmentSection/unit2-null-safety-repository/pulls/49
2023-09-22 16:05:59 +08:00
cyzoox 9fe152b793 Fixed minor bugs on adding land faas and editing land faas 2023-09-22 16:00:14 +08:00
PGAN-MIS b46022c167 role area assignment done. just need testing 2023-09-20 14:10:44 +08:00
PGAN-MIS 6a42e52d87 assign area barangay area type add response with bloc 2023-09-20 09:35:34 +08:00
PGAN-MIS 6dd9216af7 assign area using purok 2023-09-19 11:35:31 +08:00
PGAN-MIS f73f8a03e1 role area assignment done but need ui enhancement and refactoring 2023-09-15 08:03:54 +08:00
PGAN-MIS 8fea765258 agency areaType selection 2023-09-13 10:45:03 +08:00
PGAN-MIS 749bd30fab flutter upgrade to latest version 2023-09-11 11:34:42 +08:00
PGAN-MIS 01d454dcce fixed retain username and password in error login state 2023-09-07 13:54:47 +08:00
rodolfobacuinjr 4f48b9cba1 Merge pull request 'release/v1/beta/v1.0.1-beta' (#40) from release/v1/beta/v1.0.1-beta into master
Reviewed-on: http://git.agusandelnorte.gov.ph:3000/SoftwareDevelopmentSection/unit2-null-safety-repository/pulls/40
2023-09-06 09:44:39 +08:00
cyrilaquismundo 8e52b7dcea Merge pull request 'consol/feature/passo/PASSO-#18-Merge-PASSO-App-into-UniT-App__develop-2' (#37) from develop into consol/feature/passo/PASSO-#18-Merge-PASSO-App-into-UniT-App__develop-2
Reviewed-on: http://git.agusandelnorte.gov.ph:3000/SoftwareDevelopmentSection/unit2-null-safety-repository/pulls/37
2023-09-06 09:20:45 +08:00
rodolfobacuinjr 7ed707b529 Merge pull request 'release/v1/beta/v1.0.0-beta' (#35) from release/v1/beta/v1.0.0-beta into master
Reviewed-on: http://git.agusandelnorte.gov.ph:3000/SoftwareDevelopmentSection/unit2-null-safety-repository/pulls/35
2023-09-01 14:09:39 +08:00
104 changed files with 8110 additions and 4658 deletions

View File

@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app') project.evaluationDependsOn(':app')
} }
task clean(type: Delete) { tasks.register("clean", Delete) {
delete rootProject.buildDir delete rootProject.buildDir
} }

View File

@ -41,6 +41,8 @@ class AdditionalItemBloc
globalAdditionalItems.add(newAdditional); globalAdditionalItems.add(newAdditional);
emit(AdditionalItemsLoaded(globalAdditionalItems)); emit(AdditionalItemsLoaded(globalAdditionalItems));
} else {
emit(AdditionalItemsErrorState('error'));
} }
} catch (e) { } catch (e) {
emit(AdditionalItemsErrorState(e.toString())); emit(AdditionalItemsErrorState(e.toString()));

View File

@ -18,7 +18,7 @@ class PropertyAppraisalBloc
emit(PropertyAppraisalLoading()); emit(PropertyAppraisalLoading());
try { try {
final appraisal = await PropertyAppraisalServices.instance.fetch(); final appraisal = await PropertyAppraisalServices.instance.fetch();
print(appraisal);
emit(PropertyAppraisalLoaded(appraisal)); emit(PropertyAppraisalLoaded(appraisal));
} catch (e) { } catch (e) {
emit(PropertyAppraisalErrorState(e.toString())); emit(PropertyAppraisalErrorState(e.toString()));
@ -30,11 +30,16 @@ class PropertyAppraisalBloc
try { try {
http.Response response = (await PropertyAppraisalServices.instance http.Response response = (await PropertyAppraisalServices.instance
.update(event.appraisal, tempID.getInt('tempid')! - 1))!; .update(event.appraisal, tempID.getInt('tempid')! - 1))!;
print('Appraisal');
print(tempID.getInt('tempid')! - 1);
print(event.appraisal.toJson());
print(response.body);
if (response.statusCode == 200) { if (response.statusCode == 200) {
emit(ShowPropertyAppraisalSuccessAlertState()); emit(ShowPropertyAppraisalSuccessAlertState());
} }
} catch (e) { } catch (e) {
print('app error');
print(e.toString());
emit(ShowPropertyAppraisalErrorAlertState()); emit(ShowPropertyAppraisalErrorAlertState());
} }
}); });

View File

@ -18,10 +18,11 @@ class PropertyAssessmentBloc
emit(PropertyAssessmentLoading()); emit(PropertyAssessmentLoading());
try { try {
final tempID = await SharedPreferences.getInstance(); final tempID = await SharedPreferences.getInstance();
print(tempID.getInt('tempid')! - 1);
final assessments = await PropertyAssessmentServices.instance final assessments = await PropertyAssessmentServices.instance
.fetch(tempID.getInt('tempid')! + 1); .fetch(tempID.getInt('tempid')! - 1);
print(assessments);
emit(PropertyAssessmentLoaded(assessments)); emit(PropertyAssessmentLoaded(assessments));
} catch (e) { } catch (e) {
emit(PropertyAssessmentErrorState(e.toString())); emit(PropertyAssessmentErrorState(e.toString()));

View File

@ -18,8 +18,6 @@ class PropertyAssessmentEditBloc
on<LoadPropertyAssessmentEdit>((event, emit) async { on<LoadPropertyAssessmentEdit>((event, emit) async {
emit(PropertyAssessmentEditLoading()); emit(PropertyAssessmentEditLoading());
try { try {
final tempID = await SharedPreferences.getInstance();
final assessments = final assessments =
await PropertyAssessmentServices.instance.fetchEdit(event.id); await PropertyAssessmentServices.instance.fetchEdit(event.id);

View File

@ -27,6 +27,19 @@ class LandAppraisalBloc extends Bloc<LandAppraisalEvent, LandAppraisalState> {
emit(LandAppraisalErrorState(e.toString())); emit(LandAppraisalErrorState(e.toString()));
} }
}); });
on<LoadLandAppraisalEdit>((event, emit) async {
emit(LandAppraisalLoading());
try {
final additionalItems =
await LandAppraisalServices.instance.fetch(event.id);
globalLandAppraisal.clear();
globalLandAppraisal
.addAll(additionalItems); // Append all items to the list
emit(LandAppraisalLoaded(globalLandAppraisal));
} catch (e) {
emit(LandAppraisalErrorState(e.toString()));
}
});
on<AddLandAppraisal>((event, emit) async { on<AddLandAppraisal>((event, emit) async {
http.Response response = http.Response response =
(await LandAppraisalServices.instance.add(event.land_appr))!; (await LandAppraisalServices.instance.add(event.land_appr))!;

View File

@ -16,6 +16,16 @@ class LoadLandAppraisal extends LandAppraisalEvent {
List<Object> get props => [land_appr]; List<Object> get props => [land_appr];
} }
class LoadLandAppraisalEdit extends LandAppraisalEvent {
final List<LandAppr> land_appr;
final int id;
const LoadLandAppraisalEdit({required this.land_appr, required this.id});
@override
List<Object> get props => [land_appr];
}
class AddLandAppraisal extends LandAppraisalEvent { class AddLandAppraisal extends LandAppraisalEvent {
final LandAppr land_appr; final LandAppr land_appr;

View File

@ -0,0 +1,53 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/model/passo/land_ext.dart';
import 'package:unit2/sevices/passo/land/land_ext.dart';
import 'package:http/http.dart' as http;
part 'land_ext_edit_event.dart';
part 'land_ext_edit_state.dart';
class LandExtEditBloc extends Bloc<LandExtEditEvent, LandExtEditState> {
LandExtEditBloc() : super(LandExtEditInitial()) {
on<LoadLandExtEdit>((event, emit) async {
emit(LandExtEditLoading());
try {
final tempID = await SharedPreferences.getInstance();
final assessments = await LandExtServices.instance.fetchEdit(event.id);
emit(LandExtEditLoaded(assessments));
} catch (e) {
print(e.toString());
emit(LandExtEditErrorState(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<UpdateLandExtEdit>((event, emit) async {
http.Response response = (await LandExtServices.instance
.updateEdit(event.land_ext_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_ext_edit_bloc.dart';
class LandExtEditEvent extends Equatable {
const LandExtEditEvent();
@override
List<Object> get props => [];
}
class LoadLandExtEdit extends LandExtEditEvent {
final LandExt land_ext_edit;
final int? id;
const LoadLandExtEdit({required this.land_ext_edit, required this.id});
@override
List<Object> get props => [land_ext_edit];
}
class AddLandExtEdit extends LandExtEditEvent {
final LandExt land_ext_edit;
const AddLandExtEdit({required this.land_ext_edit});
@override
List<Object> get props => [land_ext_edit];
}
class UpdateLandExtEdit extends LandExtEditEvent {
// ignore: non_constant_identifier_names
final LandExt land_ext_edit;
final int id;
// ignore: non_constant_identifier_names
const UpdateLandExtEdit({required this.land_ext_edit, required this.id});
@override
List<Object> get props => [land_ext_edit];
}

View File

@ -0,0 +1,28 @@
part of 'land_ext_edit_bloc.dart';
class LandExtEditState extends Equatable {
const LandExtEditState();
@override
List<Object> get props => [];
}
class LandExtEditInitial extends LandExtEditState {}
class LandExtEditLoading extends LandExtEditState {}
class LandExtEditLoaded extends LandExtEditState {
LandExtEditLoaded(this.land_ext_edit);
final LandExt land_ext_edit;
@override
List<Object> get props => [land_ext_edit];
}
class LandExtEditErrorState extends LandExtEditState {
LandExtEditErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -29,6 +29,19 @@ class LandPropertyAssessmentBloc
emit(LandPropertyAssessmentErrorState(e.toString())); emit(LandPropertyAssessmentErrorState(e.toString()));
} }
}); });
on<LoadLandPropertyAssessmentEdit>((event, emit) async {
emit(LandPropertyAssessmentLoading());
try {
final additionalItems =
await LandPropertyAssessmentServices.instance.fetch(event.id);
globalLandPropertyAssessment.clear();
globalLandPropertyAssessment
.addAll(additionalItems); // Append all items to the list
emit(LandPropertyAssessmentLoaded(globalLandPropertyAssessment));
} catch (e) {
emit(LandPropertyAssessmentErrorState(e.toString()));
}
});
on<AddLandPropertyAssessment>((event, emit) async { on<AddLandPropertyAssessment>((event, emit) async {
http.Response response = (await LandPropertyAssessmentServices.instance http.Response response = (await LandPropertyAssessmentServices.instance
.add(event.assessment))!; .add(event.assessment))!;

View File

@ -17,6 +17,17 @@ class LoadLandPropertyAssessment extends LandPropertyAssessmentEvent {
List<Object> get props => [assessment]; List<Object> get props => [assessment];
} }
class LoadLandPropertyAssessmentEdit extends LandPropertyAssessmentEvent {
final List<LandPropertyAssessment> assessment;
final int id;
const LoadLandPropertyAssessmentEdit(
{required this.assessment, required this.id});
@override
List<Object> get props => [assessment];
}
class AddLandPropertyAssessment extends LandPropertyAssessmentEvent { class AddLandPropertyAssessment extends LandPropertyAssessmentEvent {
final LandPropertyAssessment assessment; final LandPropertyAssessment assessment;

View File

@ -25,6 +25,19 @@ class LandValueAdjustmentsBloc
emit(LandValueAdjustmentsErrorState(e.toString())); emit(LandValueAdjustmentsErrorState(e.toString()));
} }
}); });
on<LoadLandValueAdjustmentsEdit>((event, emit) async {
emit(LandValueAdjustmentsLoading());
try {
final additionalItems =
await ValueAdjustmentsServices.instance.fetch(event.id);
globalLandValueAdjustments.clear();
globalLandValueAdjustments
.addAll(additionalItems); // Append all items to the list
emit(LandValueAdjustmentsLoaded(globalLandValueAdjustments));
} catch (e) {
emit(LandValueAdjustmentsErrorState(e.toString()));
}
});
on<AddLandValueAdjustments>((event, emit) async { on<AddLandValueAdjustments>((event, emit) async {
http.Response response = http.Response response =
(await ValueAdjustmentsServices.instance.add(event.val_adj))!; (await ValueAdjustmentsServices.instance.add(event.val_adj))!;

View File

@ -16,6 +16,16 @@ class LoadLandValueAdjustments extends LandValueAdjustmentsEvent {
List<Object> get props => [val_adj]; List<Object> get props => [val_adj];
} }
class LoadLandValueAdjustmentsEdit extends LandValueAdjustmentsEvent {
final List<ValueAdjustments> val_adj;
final int id;
const LoadLandValueAdjustmentsEdit({required this.val_adj, required this.id});
@override
List<Object> get props => [val_adj];
}
class AddLandValueAdjustments extends LandValueAdjustmentsEvent { class AddLandValueAdjustments extends LandValueAdjustmentsEvent {
final ValueAdjustments val_adj; final ValueAdjustments val_adj;

View File

@ -25,6 +25,21 @@ class OtherImprovementsBloc
emit(OtherImprovementErrorState(e.toString())); emit(OtherImprovementErrorState(e.toString()));
} }
}); });
on<LoadOtherImprovementEdit>((event, emit) async {
emit(OtherImprovementLoading());
try {
final additionalItems =
await OtherImprovementServices.instance.fetch(event.ids);
print(additionalItems);
globalOtherImprovement.clear();
globalOtherImprovement
.addAll(additionalItems); // Append all items to the list
emit(OtherImprovementLoaded(globalOtherImprovement));
} catch (e) {
print(e.toString());
emit(OtherImprovementErrorState(e.toString()));
}
});
on<AddOtherImprovement>((event, emit) async { on<AddOtherImprovement>((event, emit) async {
http.Response response = http.Response response =
(await OtherImprovementServices.instance.add(event.other_imp))!; (await OtherImprovementServices.instance.add(event.other_imp))!;

View File

@ -16,6 +16,16 @@ class LoadOtherImprovement extends OtherImprovementsEvent {
List<Object> get props => [other_imp]; List<Object> get props => [other_imp];
} }
class LoadOtherImprovementEdit extends OtherImprovementsEvent {
final List<OtherImprovements> other_imps;
final int ids;
const LoadOtherImprovementEdit({required this.other_imps, required this.ids});
@override
List<Object> get props => [other_imps];
}
class AddOtherImprovement extends OtherImprovementsEvent { class AddOtherImprovement extends OtherImprovementsEvent {
final OtherImprovements other_imp; final OtherImprovements other_imp;

View File

@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/memoranda.dart'; import 'package:unit2/model/passo/memoranda.dart';
@ -7,12 +9,22 @@ part 'memoranda_event.dart';
part 'memoranda_state.dart'; part 'memoranda_state.dart';
class MemorandaBloc extends Bloc<MemorandaEvent, MemorandaState> { class MemorandaBloc extends Bloc<MemorandaEvent, MemorandaState> {
MemorandaBloc() : super(MemorandaInitial()) { MemorandaBloc() : super(MemorandaLoading()) {
on<LoadMemoranda>((event, emit) async { on<LoadMemoranda>((event, emit) async {
emit(MemorandaLoading()); emit(MemorandaLoading());
try { try {
final municipality = await MemorandaServices.instance.fetch(); final response = await MemorandaServices.instance.fetch();
emit(MemorandaLoaded(municipality)); print('Memoranda bloc');
print(response.statusCode);
print(response.body);
if (response.statusCode == 200) {
final List result = jsonDecode(response.body)['data'];
emit(MemorandaLoaded(
result.map(((e) => Memoranda.fromJson(e))).toList()));
} else {
emit(MemorandaErrorState(response.reasonPhrase!));
}
} catch (e) { } catch (e) {
emit(MemorandaErrorState(e.toString())); emit(MemorandaErrorState(e.toString()));
} }

View File

@ -12,15 +12,14 @@ class MemorandaInitial extends MemorandaState {}
class MemorandaLoading extends MemorandaState {} class MemorandaLoading extends MemorandaState {}
class MemorandaLoaded extends MemorandaState { class MemorandaLoaded extends MemorandaState {
MemorandaLoaded(this.memorada);
final List<Memoranda> memorada; final List<Memoranda> memorada;
const MemorandaLoaded(this.memorada);
@override @override
List<Object> get props => [memorada]; List<Object> get props => [memorada];
} }
class MemorandaErrorState extends MemorandaState { class MemorandaErrorState extends MemorandaState {
MemorandaErrorState(this.error); const MemorandaErrorState(this.error);
final String error; final String error;
@override @override

View File

@ -6,6 +6,7 @@ import 'package:unit2/sevices/profile/profile_service.dart';
import '../../model/profile/basic_information/primary-information.dart'; import '../../model/profile/basic_information/primary-information.dart';
import '../../screens/profile/components/basic_information/profile_other_info.dart'; import '../../screens/profile/components/basic_information/profile_other_info.dart';
import '../../utils/global.dart';
part 'profile_event.dart'; part 'profile_event.dart';
part 'profile_state.dart'; part 'profile_state.dart';
@ -52,20 +53,24 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
.getProfile(event.token, event.userID); .getProfile(event.token, event.userID);
globalProfileInformation = profileInformation; globalProfileInformation = profileInformation;
} }
emit(ProfileLoaded(profileInformation: globalProfileInformation!)); emit(ProfileLoaded(profileInformation: globalProfileInformation!));
} catch (e) { } catch (e) {
emit(ProfileErrorState(mesage: e.toString())); emit(ProfileErrorState(mesage: e.toString()));
} }
}); });
on<GetPrimaryBasicInfo>((event, emit) { on<GetPrimaryBasicInfo>((event, emit) {
if (globalCurrentProfile != null) {
emit(BasicInformationProfileLoaded(
primaryBasicInformation: globalCurrentProfile!));
} else {
currentProfileInformation = event.primaryBasicInformation; currentProfileInformation = event.primaryBasicInformation;
emit(BasicInformationProfileLoaded( emit(BasicInformationProfileLoaded(
primaryBasicInformation: event.primaryBasicInformation)); primaryBasicInformation: currentProfileInformation!));
}
}); });
on<LoadBasicPrimaryInfo>((event, emit) { on<LoadBasicPrimaryInfo>((event, emit) {
emit(BasicInformationProfileLoaded( emit(BasicInformationProfileLoaded(
primaryBasicInformation: currentProfileInformation!)); primaryBasicInformation: globalCurrentProfile!));
}); });
on<ShowPrimaryInfoEditForm>((event, emit) async { on<ShowPrimaryInfoEditForm>((event, emit) async {
try { try {
@ -132,6 +137,12 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
if (status['success']) { if (status['success']) {
Profile profile = Profile.fromJson(status['data']); Profile profile = Profile.fromJson(status['data']);
currentProfileInformation = profile; currentProfileInformation = profile;
globalCurrentProfile = profile;
globalFistname = profile.firstName;
globalLastname = profile.lastName;
globalBday = profile.birthdate;
globalSex = profile.sex;
emit(BasicProfileInfoEditedState(response: status)); emit(BasicProfileInfoEditedState(response: status));
} }
emit(BasicProfileInfoEditedState(response: status)); emit(BasicProfileInfoEditedState(response: status));

View File

@ -0,0 +1,275 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/bloc/role_assignment/role_assignment_bloc.dart';
import 'package:unit2/model/location/purok2.dart';
import 'package:unit2/model/rbac/assigned_role.dart';
import 'package:unit2/model/rbac/rbac.dart';
import 'package:unit2/model/rbac/rbac_station.dart';
import 'package:unit2/model/roles/pass_check/assign_role_area_type.dart';
import 'package:unit2/model/utils/agency.dart';
import 'package:unit2/sevices/roles/rbac_operations/assigned_area_services.dart';
import '../../../../model/location/barangay2.dart';
import '../../../../model/profile/assigned_area.dart';
import '../../../../model/profile/basic_information/primary-information.dart';
import '../../../../sevices/roles/rbac_operations/role_assignment_services.dart';
part 'assign_area_event.dart';
part 'assign_area_state.dart';
class AssignAreaBloc extends Bloc<AssignAreaEvent, AssignAreaState> {
AssignAreaBloc() : super(AssignAreaInitial()) {
String? fname;
String? lname;
String? fullname;
Profile? profile;
int id;
List<UserAssignedArea> userAssignedAreas = [];
List<AssignedRole> assignedRoles = [];
List<RBAC> roles = [];
on<GetAssignArea>((event, emit) async {
emit(AssignAreaLoadingState());
try {
profile = await RbacRoleAssignmentServices.instance.searchUser(
page: 1, name: event.firstname, lastname: event.lastname);
if (profile != null && profile!.id != null) {
fname = profile!.firstName;
lname = profile!.lastName;
fullname = profile!.lastName;
fullname = "${fname!} ${lname!}";
id = profile!.webuserId!;
userAssignedAreas = await RbacAssignedAreaServices.instance
.getAssignedArea(id: profile!.webuserId!);
assignedRoles = await RbacRoleAssignmentServices.instance
.getAssignedRoles(
firstname: event.firstname, lastname: event.lastname);
for (var role in assignedRoles) {
roles.add(role.role!);
}
emit(AssignedAreaLoadedState(
userAssignedAreas: userAssignedAreas,
fullname: fullname!,
roles: roles,
userId: id));
} else {
id = 0;
emit(UserNotExistError());
}
} catch (e) {
emit(AssignAreaErorState(message: e.toString()));
}
});
on<AddAssignArea>((event, emit) async {
// try {
emit(AssignAreaLoadingState());
Map<dynamic, dynamic> response = await RbacAssignedAreaServices.instance
.add(
userId: event.userId,
roleId: event.roleId,
areaTypeId: event.areaTypeId,
areaId: event.areaId);
if (response["success"]) {
UserAssignedArea? newAssignArea;
for (var userArea in userAssignedAreas) {
if (userArea.assignedRole?.role?.id == event.roleId &&
userArea.assignedRole?.user?.id == event.userId) {
newAssignArea = userArea;
break;
}
}
// newAssignArea = userAssignedAreas.firstWhere((var element) {
// return element.assignedRole?.role?.id == event.roleId &&
// element.assignedRole?.user?.id == event.userId;
// });
if (newAssignArea?.assignedArea != null) {
userAssignedAreas.removeWhere((element) =>
element.assignedRole!.role!.id == event.roleId &&
element.assignedRole!.user!.id == event.userId);
}
AssignedRole newAssignedRole =
AssignedRole.fromJson(response['data'][0]['assigned_role']);
AssignRoleAreaType newAssignRoleType = AssignRoleAreaType.fromJson(
response['data'][0]['assigned_role_area_type']);
UserAssignedArea temp = UserAssignedArea(
assignedRole: newAssignedRole,
assignedRoleAreaType: newAssignRoleType,
assignedArea: []);
newAssignArea = temp;
////barangay
if (event.areaTypeId == 1) {
List<dynamic> newAreas = [];
for (var area in response['data']) {
for (var assignedArea in area['assigned_area']) {
var newArea = {};
newArea.addAll({"id": assignedArea['id']});
newArea.addAll({'isactive': assignedArea['isactive']});
Barangay2 newBarangay = Barangay2.fromJson(assignedArea['area']);
newArea.addAll({
'area': {
"brgycode": newBarangay.brgycode,
"brgydesc": newBarangay.brgydesc,
"citymuncode": newBarangay.citymuncode
}
});
newAreas.add(newArea);
}
}
newAssignArea?.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea!);
//// purok
}
if (event.areaTypeId == 2) {
List<dynamic> newAreas = [];
for (var area in response['data']) {
for (var assignedArea in area['assigned_area']) {
var newArea = {};
newArea.addAll({"id": assignedArea['id']});
newArea.addAll({'isactive': assignedArea['isactive']});
Purok2 newPurok = Purok2.fromJson(assignedArea['area']);
newArea.addAll({
'area': {
"purokid": newPurok.purokid,
"purokdesc": newPurok.purokdesc,
"brgy": {
"brgycode": newPurok.brgy?.brgycode,
"brgydesc": newPurok.brgy?.brgydesc,
"citymuncode": newPurok.brgy?.citymuncode,
},
"purok_leader": newPurok.purokLeader,
"writelock": newPurok.writelock,
"recordsignature": newPurok.recordsignature
}
});
newAreas.add(newArea);
}
}
newAssignArea?.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea!);
}
////statiom
if (event.areaTypeId == 4) {
List<dynamic> newAreas = [];
for (var area in response['data']) {
for (var assignedArea in area['assigned_area']) {
var newArea = {};
newArea.addAll({"id": assignedArea['id']});
newArea.addAll({'isactive': assignedArea['isactive']});
RbacStation newStation =
RbacStation.fromJson(assignedArea['area']);
newArea.addAll({
"area": {
"id": newStation.id,
"station_name": newStation.stationName,
"station_type": {
"id": newStation.stationType?.id,
"type_name": newStation.stationType?.typeName,
"color": newStation.stationType?.color,
"order": newStation.stationType?.order,
"is_active": newStation.stationType?.isActive,
"group": null
},
"hierarchy_order_no": newStation.hierarchyOrderNo,
"head_position": newStation.headPosition,
"government_agency": {
"agencyid": newStation.governmentAgency?.agencycatid,
"agencyname": newStation.governmentAgency?.agencyname,
"agencycatid": newStation.governmentAgency?.agencycatid,
"private_entity":
newStation.governmentAgency?.privateEntity,
"contactinfoid": newStation.governmentAgency?.contactinfoid
},
"acronym": newStation.acronym,
"parent_station": newStation.parentStation,
"code": newStation.code,
"fullcode": newStation.fullcode,
"child_station_info": newStation.childStationInfo,
"islocation_under_parent": newStation.islocationUnderParent,
"main_parent_station": newStation.mainParentStation,
"description": newStation.description,
"ishospital": newStation.ishospital,
"isactive": newStation.isactive,
"selling_station": newStation.sellingStation
}
});
newAreas.add(newArea);
}
}
newAssignArea?.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea!);
}
////agency
if (event.areaTypeId == 3) {
List<dynamic> newAreas = [];
for (var area in response['data']) {
for (var assignedArea in area['assigned_area']) {
var newArea = {};
newArea.addAll({"id": assignedArea['id']});
newArea.addAll({'isactive': assignedArea['isactive']});
Agency newAgency = Agency.fromJson(assignedArea['area']);
newArea.addAll({
"area": {
"id": newAgency.id,
"name": newAgency.name,
"category": {
"id": newAgency.category?.id,
"industry_class": {
"id": newAgency.category?.industryClass?.id,
"name": newAgency.category?.industryClass?.name,
"description":
newAgency.category?.industryClass?.description
}
},
"private_entity": newAgency.privateEntity,
}
});
newAreas.add(newArea);
}
}
newAssignArea?.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea!);
}
emit(AssignAreaAddedState(response: response));
} else {
emit(AssignAreaAddedState(response: response));
}
// } catch (e) {
// emit(AssignAreaErorState(message: e.toString()));
// }
});
on<LoadAssignedAreas>((event, emit) async {
emit(AssignedAreaLoadedState(
userAssignedAreas: userAssignedAreas,
fullname: fullname!,
roles: roles,
userId: event.userId));
});
on<DeleteAssignedArea>((event, emit) async {
emit(AssignAreaLoadingState());
try {
bool success = await RbacAssignedAreaServices.instance
.deleteAssignedArea(areaId: event.areaId);
if (success) {
for (var area in userAssignedAreas) {
area.assignedArea.removeWhere((var a) {
return a['id'] == event.areaId;
});
}
emit(AssignedAreaDeletedState(success: success));
} else {
emit(AssignedAreaDeletedState(success: success));
}
} catch (e) {
emit(AssignAreaErorState(message: e.toString()));
}
});
on<CallErrorState>((event, emit) {
emit(AssignAreaErorState(message: event.message));
});
}
}

View File

@ -0,0 +1,52 @@
part of 'assign_area_bloc.dart';
class AssignAreaEvent extends Equatable {
const AssignAreaEvent();
@override
List<Object> get props => [];
}
class GetAssignArea extends AssignAreaEvent {
final String firstname;
final String lastname;
const GetAssignArea({required this.firstname, required this.lastname});
@override
List<Object> get props => [firstname, lastname];
}
class DeleteAssignedArea extends AssignAreaEvent {
final int areaId;
const DeleteAssignedArea({required this.areaId});
@override
List<Object> get props => [areaId];
}
class LoadAssignedAreas extends AssignAreaEvent {
final int userId;
const LoadAssignedAreas({required this.userId});
@override
List<Object> get props => [userId];
}
class CallErrorState extends AssignAreaEvent {
final String message;
const CallErrorState({required this.message});
@override
List<Object> get props => [message];
}
class AddAssignArea extends AssignAreaEvent {
final int userId;
final int roleId;
final int areaTypeId;
final String areaId;
const AddAssignArea(
{required this.areaId,
required this.areaTypeId,
required this.roleId,
required this.userId});
@override
List<Object> get props => [userId, roleId, areaTypeId, areaId];
}

View File

@ -0,0 +1,44 @@
part of 'assign_area_bloc.dart';
class AssignAreaState extends Equatable {
const AssignAreaState();
@override
List<Object> get props => [];
}
class AssignedAreaLoadedState extends AssignAreaState{
final List<UserAssignedArea> userAssignedAreas;
final List<RBAC> roles;
final String fullname;
final int userId;
const AssignedAreaLoadedState({required this.userAssignedAreas, required this.fullname, required this.roles, required this.userId});
@override
List<Object> get props => [userAssignedAreas,fullname,roles];
}
class AssignAreaErorState extends AssignAreaState {
final String message;
const AssignAreaErorState({required this.message});
@override
List<Object> get props => [message];
}
class AssignAreaLoadingState extends AssignAreaState{
}
class UserNotExistError extends AssignAreaState{
}
class AssignAreaInitial extends AssignAreaState {}
class AssignedAreaDeletedState extends AssignAreaState{
final bool success;
const AssignedAreaDeletedState({required this.success});
@override
List<Object> get props => [success];
}
class AssignAreaAddedState extends AssignAreaState {
final Map<dynamic,dynamic> response;
const AssignAreaAddedState({required this.response});
@override
List<Object> get props => [response];
}

View File

@ -65,6 +65,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
otherInputs: otherInputs!, otherInputs: otherInputs!,
passerId: uuid!, passerId: uuid!,
roleId: roleIdRoleName!.roleId, roleId: roleIdRoleName!.roleId,
roleName: roleIdRoleName!.roleName,
stationId: stationId, stationId: stationId,
temp: event.temp)); temp: event.temp));
}); });
@ -78,6 +79,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
otherInputs: otherInputs!, otherInputs: otherInputs!,
passerId: uuid!, passerId: uuid!,
roleId: roleIdRoleName!.roleId, roleId: roleIdRoleName!.roleId,
roleName: roleIdRoleName!.roleName,
stationId: stationId, stationId: stationId,
temp: null)); temp: null));
}); });
@ -123,6 +125,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
otherInputs: otherInputs!, otherInputs: otherInputs!,
passerId: uuid!, passerId: uuid!,
roleId: roleIdRoleName!.roleId, roleId: roleIdRoleName!.roleId,
roleName: roleIdRoleName!.roleName,
stationId: stationId, stationId: stationId,
temp: null)); temp: null));
} }
@ -152,7 +155,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
stationId: event.stationId, stationId: event.stationId,
cpId: event.cpId, cpId: event.cpId,
otherInputs: event.otherInputs, otherInputs: event.otherInputs,
roleid: event.roleId); roleIdRoleName: roleIdRoleName!);
if (success) { if (success) {
Fluttertoast.showToast( Fluttertoast.showToast(
msg: "SUCCESSFULLY SAVED", msg: "SUCCESSFULLY SAVED",

View File

@ -44,6 +44,7 @@ class PerformPostLogs extends PassCheckEvent {
final int? stationId; final int? stationId;
final String? destination; final String? destination;
final double? temp; final double? temp;
final String roleName;
final int roleId; final int roleId;
const PerformPostLogs( const PerformPostLogs(
{required this.checkerId, {required this.checkerId,
@ -52,6 +53,7 @@ class PerformPostLogs extends PassCheckEvent {
required this.io, required this.io,
required this.otherInputs, required this.otherInputs,
required this.passerId, required this.passerId,
required this.roleName,
required this.roleId, required this.roleId,
required this.stationId, required this.stationId,
required this.temp}); required this.temp});

View File

@ -1,5 +1,6 @@
import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:unit2/utils/text_container.dart';
import '../../model/profile/basic_information/primary-information.dart'; import '../../model/profile/basic_information/primary-information.dart';
import '../../model/rbac/assigned_role.dart'; import '../../model/rbac/assigned_role.dart';
import '../../model/rbac/rbac.dart'; import '../../model/rbac/rbac.dart';
@ -21,16 +22,15 @@ class RoleAssignmentBloc
List<RBAC> roles = []; List<RBAC> roles = [];
on<GetAssignedRoles>((event, emit) async { on<GetAssignedRoles>((event, emit) async {
emit(RoleAssignmentLoadingState()); emit(RoleAssignmentLoadingState());
fname = event.firstname;
lname = event.lastname;
fullname = "${event.firstname} ${event.lastname}";
try { try {
profile = await RbacRoleAssignmentServices.instance.searchUser( profile = await RbacRoleAssignmentServices.instance.searchUser(
page: 1, name: event.firstname, lastname: event.lastname); page: 1, name: event.firstname, lastname: event.lastname);
if (profile != null && profile?.id != null) { if (profile != null && profile?.id != null) {
fname = profile!.firstName;
lname = profile!.lastName;
fullname = "${fname!} ${lname!}";
assignedRoles = await RbacRoleAssignmentServices.instance assignedRoles = await RbacRoleAssignmentServices.instance
.getAssignedRoles( .getAssignedRoles(firstname: event.firstname, lastname: event.lastname);
firstname: event.firstname, lastname: event.lastname);
if (roles.isEmpty) { if (roles.isEmpty) {
roles = await RbacRoleServices.instance.getRbacRoles(); roles = await RbacRoleServices.instance.getRbacRoles();
@ -40,8 +40,6 @@ class RoleAssignmentBloc
} else { } else {
emit(UserNotExistError()); emit(UserNotExistError());
} }
} catch (e) { } catch (e) {
emit(RoleAssignmentErrorState(message: e.toString())); emit(RoleAssignmentErrorState(message: e.toString()));
} }

View File

@ -15,13 +15,14 @@ import '../../utils/scanner.dart';
import '../../utils/text_container.dart'; import '../../utils/text_container.dart';
part 'user_event.dart'; part 'user_event.dart';
part 'user_state.dart'; part 'user_state.dart';
class UserBloc extends Bloc<UserEvent, UserState> { class UserBloc extends Bloc<UserEvent, UserState> {
UserData? _userData; UserData? _userData;
VersionInfo? _versionInfo; VersionInfo? _versionInfo;
String? _apkVersion; String? _apkVersion;
bool save = false; bool save = false;
String? uuid; String? uuid;
String? username;
String? password;
List<AssignedArea> establishmentPointPersonAssignedAreas = []; List<AssignedArea> establishmentPointPersonAssignedAreas = [];
UserBloc() : super(UserInitial()) { UserBloc() : super(UserInitial()) {
//// this event is called when opening the app to check if //// this event is called when opening the app to check if
@ -37,17 +38,23 @@ class UserBloc extends Bloc<UserEvent, UserState> {
String apkVersion = await getAppVersion(); String apkVersion = await getAppVersion();
_apkVersion = apkVersion; _apkVersion = apkVersion;
final String? saved = CREDENTIALS?.get('saved'); final String? saved = CREDENTIALS?.get('saved');
final String? username = CREDENTIALS?.get('username'); username = CREDENTIALS?.get('username');
final String? password = CREDENTIALS?.get('password'); password = CREDENTIALS?.get('password');
if (saved != null) { if(apkVersion != _versionInfo!.id ){
emit(VersionLoaded(
versionInfo: _versionInfo,
apkVersion: _apkVersion,
username: event.username,
password: event.password));
}else if (saved != null) {
save = true; save = true;
add(UserLogin(username: username, password: password)); add(UserLogin(username: username, password: password));
} else { } else {
emit(VersionLoaded( emit(VersionLoaded(
versionInfo: _versionInfo, versionInfo: _versionInfo,
apkVersion: _apkVersion, apkVersion: _apkVersion,
username: null, username: event.username,
password: null)); password: event.password));
} }
} catch (e) { } catch (e) {
emit(UserError( emit(UserError(
@ -57,14 +64,18 @@ class UserBloc extends Bloc<UserEvent, UserState> {
}); });
////Loading the current version of the app ////Loading the current version of the app
on<LoadVersion>((event, emit) { on<LoadVersion>((event, emit) {
username = event.username;
password = event.password;
emit(VersionLoaded( emit(VersionLoaded(
versionInfo: _versionInfo, versionInfo: _versionInfo,
apkVersion: _apkVersion, apkVersion: _apkVersion,
username: event.username, username: username,
password: event.password)); password: password));
}); });
////userlogin ////userlogin
on<UserLogin>((event, emit) async { on<UserLogin>((event, emit) async {
username = event.username;
password = event.password;
try { try {
Map<dynamic, dynamic> response = await AuthService.instance Map<dynamic, dynamic> response = await AuthService.instance
.webLogin(username: event.username, password: event.password); .webLogin(username: event.username, password: event.password);

View File

@ -6,9 +6,11 @@ abstract class UserEvent extends Equatable {
} }
class GetApkVersion extends UserEvent { class GetApkVersion extends UserEvent {
GetApkVersion(); final String username;
final String password;
GetApkVersion({required this.password, required this.username});
@override @override
List<Object> get props => []; List<Object> get props => [username,password];
} }
class UserLogin extends UserEvent { class UserLogin extends UserEvent {

View File

@ -0,0 +1,41 @@
// To parse this JSON data, do
//
// final barangay = barangayFromJson(jsonString);
import 'package:meta/meta.dart';
import 'dart:convert';
import 'city.dart';
import 'provinces.dart';
Barangay2 barangayFromJson(String str) => Barangay2.fromJson(json.decode(str));
String barangayToJson(Barangay2 data) => json.encode(data.toJson());
class Barangay2 {
Barangay2({
required this.brgycode,
required this.brgydesc,
required this.citymuncode,
});
final String? brgycode;
final String? brgydesc;
final String? citymuncode;
factory Barangay2.fromJson(Map<String, dynamic> json) => Barangay2(
brgycode: json["brgycode"],
brgydesc: json["brgydesc"],
citymuncode: json['citymuncode']
);
Map<String, dynamic> toJson() => {
"brgycode": brgycode,
"brgydesc": brgydesc,
"citymuncode": citymuncode
};
}

View File

@ -0,0 +1,36 @@
// To parse this JSON data, do
//
// final purok = purokFromJson(jsonString);
import 'package:meta/meta.dart';
import 'dart:convert';
import 'package:unit2/model/location/barangay.dart';
Purok purokFromJson(String str) => Purok.fromJson(json.decode(str));
String purokToJson(Purok data) => json.encode(data.toJson());
class Purok {
final String code;
final String description;
final Barangay barangay;
Purok({
required this.code,
required this.description,
required this.barangay,
});
factory Purok.fromJson(Map<String, dynamic> json) => Purok(
code: json["code"],
description: json["description"],
barangay: Barangay.fromJson(json["barangay"]),
);
Map<String, dynamic> toJson() => {
"code": code,
"description": description,
"barangay": barangay.toJson(),
};
}

View File

@ -0,0 +1,39 @@
import 'package:unit2/model/location/barangay2.dart';
class Purok2 {
final String purokid;
final String purokdesc;
final Barangay2? brgy;
final dynamic purokLeader;
final bool writelock;
final dynamic recordsignature;
Purok2({
required this.purokid,
required this.purokdesc,
required this.brgy,
required this.purokLeader,
required this.writelock,
required this.recordsignature,
});
factory Purok2.fromJson(Map<String, dynamic> json) => Purok2(
purokid: json["purokid"],
purokdesc: json["purokdesc"],
brgy: json['brgy'] == null?null: Barangay2.fromJson(json["brgy"]),
purokLeader: json["purok_leader"],
writelock: json["writelock"],
recordsignature: json["recordsignature"],
);
Map<String, dynamic> toJson() => {
"purokid": purokid,
"purokdesc": purokdesc,
"brgy": brgy?.toJson(),
"purok_leader": purokLeader,
"writelock": writelock,
"recordsignature": recordsignature,
};
}

View File

@ -1,6 +1,6 @@
class VersionInfo { class VersionInfo {
VersionInfo({ VersionInfo({
this.version, this.id,
this.versionInfo, this.versionInfo,
this.dateReleased, this.dateReleased,
this.development, this.development,
@ -11,7 +11,7 @@ class VersionInfo {
this.x8664DownloadUrl, this.x8664DownloadUrl,
}); });
String? version; String? id;
String? versionInfo; String? versionInfo;
DateTime? dateReleased; DateTime? dateReleased;
bool? development; bool? development;
@ -22,7 +22,7 @@ class VersionInfo {
String? x8664DownloadUrl; String? x8664DownloadUrl;
factory VersionInfo.fromJson(Map<String, dynamic> json) => VersionInfo( factory VersionInfo.fromJson(Map<String, dynamic> json) => VersionInfo(
version: json["version"], id: json["id"],
versionInfo: json["version_info"], versionInfo: json["version_info"],
dateReleased: DateTime.parse(json["date_released"]), dateReleased: DateTime.parse(json["date_released"]),
development: json["development"], development: json["development"],
@ -34,7 +34,7 @@ class VersionInfo {
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"version": version, "version": id,
"version_info": versionInfo, "version_info": versionInfo,
"date_released": "date_released":
"${dateReleased!.year.toString().padLeft(4, '0')}-${dateReleased!.month.toString().padLeft(2, '0')}-${dateReleased!.day.toString().padLeft(2, '0')}", "${dateReleased!.year.toString().padLeft(4, '0')}-${dateReleased!.month.toString().padLeft(2, '0')}-${dateReleased!.day.toString().padLeft(2, '0')}",

View File

@ -27,6 +27,7 @@ class PropertyAppraisal {
final String? totalpercentDepreciation; final String? totalpercentDepreciation;
final String? marketValue; final String? marketValue;
final String? totalArea; final String? totalArea;
final String? actualUse;
PropertyAppraisal( PropertyAppraisal(
{this.id, {this.id,
@ -44,7 +45,8 @@ class PropertyAppraisal {
this.addItemsSubtotal, this.addItemsSubtotal,
this.totalpercentDepreciation, this.totalpercentDepreciation,
this.marketValue, this.marketValue,
this.totalArea}); this.totalArea,
this.actualUse});
factory PropertyAppraisal.fromJson(Map<String, dynamic> json) => factory PropertyAppraisal.fromJson(Map<String, dynamic> json) =>
PropertyAppraisal( PropertyAppraisal(
@ -68,7 +70,7 @@ class PropertyAppraisal {
totalpercentDepreciation: json["totalpercent_depreciation"], totalpercentDepreciation: json["totalpercent_depreciation"],
marketValue: json["market_value"], marketValue: json["market_value"],
totalArea: json["total_area"], totalArea: json["total_area"],
); actualUse: json["actual_use"]);
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"id": id, "id": id,
@ -86,6 +88,7 @@ class PropertyAppraisal {
"add_items_subtotal": addItemsSubtotal, "add_items_subtotal": addItemsSubtotal,
"totalpercent_depreciation": totalpercentDepreciation, "totalpercent_depreciation": totalpercentDepreciation,
"market_value": marketValue, "market_value": marketValue,
"total_area": totalArea "total_area": totalArea,
"actual_use": actualUse
}; };
} }

View File

@ -0,0 +1,32 @@
import 'package:unit2/model/rbac/assigned_role.dart';
import 'package:unit2/model/rbac/rbac.dart';
import '../roles/pass_check/assign_role_area_type.dart';
class UserAssignedArea {
AssignedRole? assignedRole;
AssignRoleAreaType? assignedRoleAreaType;
dynamic assignedArea;
UserAssignedArea({
required this.assignedRole,
required this.assignedRoleAreaType,
required this.assignedArea,
});
factory UserAssignedArea.fromJson(Map<String, dynamic> json) => UserAssignedArea(
assignedRole: json['assigned_role'] == null? null: AssignedRole.fromJson(json["assigned_role"]),
assignedRoleAreaType: json['assigned_role_area_type'] == null? null : AssignRoleAreaType.fromJson(json["assigned_role_area_type"]),
assignedArea: json["assigned_area"],
);
Map<String, dynamic> toJson() => {
"assigned_role": assignedRole?.toJson(),
"assigned_role_area_type": assignedRoleAreaType?.toJson(),
"assigned_area": assignedArea,
};
}

View File

@ -5,13 +5,15 @@
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'dart:convert'; import 'dart:convert';
import 'package:unit2/model/rbac/rbac.dart';
AssignedRole assignedRoleFromJson(String str) => AssignedRole.fromJson(json.decode(str)); AssignedRole assignedRoleFromJson(String str) => AssignedRole.fromJson(json.decode(str));
String assignedRoleToJson(AssignedRole data) => json.encode(data.toJson()); String assignedRoleToJson(AssignedRole data) => json.encode(data.toJson());
class AssignedRole { class AssignedRole {
final int? id; final int? id;
final Role? role; final RBAC? role;
final CreatedBy? user; final CreatedBy? user;
final DateTime? createdAt; final DateTime? createdAt;
final DateTime? updatedAt; final DateTime? updatedAt;
@ -30,7 +32,7 @@ class AssignedRole {
factory AssignedRole.fromJson(Map<String, dynamic> json) => AssignedRole( factory AssignedRole.fromJson(Map<String, dynamic> json) => AssignedRole(
id: json["id"], id: json["id"],
role: json['role'] == null?null: Role.fromJson(json["role"]), role: json['role'] == null?null: RBAC.fromJson(json["role"]),
user: json['role'] == null?null: CreatedBy.fromJson(json["user"]), user: json['role'] == null?null: CreatedBy.fromJson(json["user"]),
createdAt:json["created_at"] == null?null: DateTime.parse(json["created_at"]), createdAt:json["created_at"] == null?null: DateTime.parse(json["created_at"]),
updatedAt: json["updated_at"] == null?null: DateTime.parse(json["updated_at"]), updatedAt: json["updated_at"] == null?null: DateTime.parse(json["updated_at"]),
@ -84,47 +86,3 @@ class CreatedBy {
"is_active": isActive, "is_active": isActive,
}; };
} }
class Role {
final int id;
final String name;
final String slug;
final String shorthand;
final DateTime createdAt;
final DateTime updatedAt;
final CreatedBy createdBy;
final CreatedBy updatedBy;
Role({
required this.id,
required this.name,
required this.slug,
required this.shorthand,
required this.createdAt,
required this.updatedAt,
required this.createdBy,
required this.updatedBy,
});
factory Role.fromJson(Map<String, dynamic> json) => Role(
id: json["id"],
name: json["name"],
slug: json["slug"],
shorthand: json["shorthand"],
createdAt: DateTime.parse(json["created_at"]),
updatedAt: DateTime.parse(json["updated_at"]),
createdBy: CreatedBy.fromJson(json["created_by"]),
updatedBy: CreatedBy.fromJson(json["updated_by"]),
);
Map<String, dynamic> toJson() => {
"id": id,
"name": name,
"slug": slug,
"shorthand": shorthand,
"created_at": createdAt.toIso8601String(),
"updated_at": updatedAt.toIso8601String(),
"created_by": createdBy.toJson(),
"updated_by": updatedBy.toJson(),
};
}

View File

@ -2,7 +2,7 @@
import 'barangay_assign_area.dart'; import 'barangay_assign_area.dart';
class Purok { class PassCheckPurok {
final String? purokid; final String? purokid;
final String? purokdesc; final String? purokdesc;
final BaragayAssignArea? brgy; final BaragayAssignArea? brgy;
@ -10,7 +10,7 @@ class Purok {
final bool? writelock; final bool? writelock;
final dynamic recordsignature; final dynamic recordsignature;
Purok({ PassCheckPurok({
required this.purokid, required this.purokid,
required this.purokdesc, required this.purokdesc,
required this.brgy, required this.brgy,
@ -19,7 +19,7 @@ class Purok {
required this.recordsignature, required this.recordsignature,
}); });
factory Purok.fromJson(Map<String, dynamic> json) => Purok( factory PassCheckPurok.fromJson(Map<String, dynamic> json) => PassCheckPurok(
purokid: json["purokid"], purokid: json["purokid"],
purokdesc: json["purokdesc"], purokdesc: json["purokdesc"],
brgy: json["brgy"]==null?null:BaragayAssignArea.fromJson(json["brgy"]), brgy: json["brgy"]==null?null:BaragayAssignArea.fromJson(json["brgy"]),

View File

@ -49,20 +49,10 @@ class _BldgLocationLandrefPage extends State<BldgLocationLandrefPage> {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait..."); progress!.showWithText("Please wait...");
} }
if (state is MunicipalityLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is MunicipalityErrorState) { if (state is MunicipalityErrorState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress?.dismiss(); progress?.dismiss();
// Fluttertoast.showToast(
// msg: onError,
// fontSize: 24,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.CENTER,
// backgroundColor: Colors.black,
// textColor: Colors.white);
} }
}, },
builder: (context, state) { builder: (context, state) {
@ -75,6 +65,7 @@ class _BldgLocationLandrefPage extends State<BldgLocationLandrefPage> {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait..."); progress!.showWithText("Please wait...");
} }
if (state is BarangayLoaded) { if (state is BarangayLoaded) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress?.dismiss(); progress?.dismiss();
@ -82,13 +73,6 @@ class _BldgLocationLandrefPage extends State<BldgLocationLandrefPage> {
if (state is BarangayErrorState) { if (state is BarangayErrorState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress?.dismiss(); progress?.dismiss();
// Fluttertoast.showToast(
// msg: onError,
// fontSize: 24,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.CENTER,
// backgroundColor: Colors.black,
// textColor: Colors.white);
} }
}, },
builder: (context, state) { builder: (context, state) {
@ -130,7 +114,7 @@ class _BldgLocationLandrefPage extends State<BldgLocationLandrefPage> {
borderRadius: borderRadius:
BorderRadius.circular(5.0), BorderRadius.circular(5.0),
), ),
child: Align( child: const Align(
alignment: Alignment.center, alignment: Alignment.center,
child: Text( child: Text(
"AGUSAN DEL NORTE", "AGUSAN DEL NORTE",
@ -244,7 +228,7 @@ class _BldgLocationLandrefPage extends State<BldgLocationLandrefPage> {
child: child:
customTextField("Area", "", 'area')) customTextField("Area", "", 'area'))
]), ]),
SizedBox( const SizedBox(
height: 50, height: 50,
), ),
Row( Row(

View File

@ -231,17 +231,4 @@ 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

@ -1,6 +1,8 @@
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:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@ -502,8 +504,26 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocConsumer<AdditionalItemBloc, AdditionalItemState>( return Scaffold(
listener: (context, state) {}, body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<AdditionalItemBloc, AdditionalItemState>(
listener: (context, state) {
if (state is AdditionalItemsLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is AdditionalItemsLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is AdditionalItemsErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
},
builder: (context, state) { builder: (context, state) {
if (state is AdditionalItemsLoaded) { if (state is AdditionalItemsLoaded) {
return SingleChildScrollView( return SingleChildScrollView(
@ -532,7 +552,8 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
), ),
Container( Container(
child: Text( child: Text(
formKey.currentState!.value['bldg_type'].unitValue + formKey.currentState!.value['bldg_type']
.unitValue +
' sq.m', ' sq.m',
textAlign: TextAlign.right, textAlign: TextAlign.right,
), ),
@ -638,8 +659,8 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
Container( Container(
child: Text( child: Text(
calculateTotalConstructionCost( calculateTotalConstructionCost(
(double.parse(formKey (double.parse(formKey.currentState!
.currentState!.value['total_area']) * .value['total_area']) *
double.parse(formKey.currentState! double.parse(formKey.currentState!
.value['bldg_type'].unitValue)), .value['bldg_type'].unitValue)),
state.items) state.items)
@ -692,8 +713,8 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
Container( Container(
child: Text( child: Text(
calculateDepCost( calculateDepCost(
(double.parse(formKey (double.parse(formKey.currentState!
.currentState!.value['total_area']) * .value['total_area']) *
double.parse(formKey.currentState! double.parse(formKey.currentState!
.value['bldg_type'].unitValue)), .value['bldg_type'].unitValue)),
state.items, state.items,
@ -739,8 +760,8 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
Container( Container(
child: Text( child: Text(
calculateMarketValue( calculateMarketValue(
(double.parse(formKey (double.parse(formKey.currentState!
.currentState!.value['total_area']) * .value['total_area']) *
double.parse(formKey.currentState! double.parse(formKey.currentState!
.value['bldg_type'].unitValue)), .value['bldg_type'].unitValue)),
state.items, state.items,
@ -761,7 +782,8 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
margin: const EdgeInsets.only( margin: const EdgeInsets.only(
left: 20.0, right: 20.0), left: 20.0, right: 20.0),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment:
MainAxisAlignment.start,
children: [ children: [
Container( Container(
margin: const EdgeInsets.only( margin: const EdgeInsets.only(
@ -769,7 +791,8 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
top: 20, top: 20,
right: 0, right: 0,
bottom: 20), bottom: 20),
child: const Text('PROPERTY ASSESSMENT', child: const Text(
'PROPERTY ASSESSMENT',
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 18), fontSize: 18),
@ -781,62 +804,78 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
children: [ children: [
Container( Container(
width: 100, width: 100,
margin: const EdgeInsets.only( margin:
const EdgeInsets.only(
top: 15, left: 15), top: 15, left: 15),
padding: padding:
const EdgeInsets.all(5.0), const EdgeInsets.all(
5.0),
child: const Text( child: const Text(
'Actual Use', 'Actual Use',
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight:
FontWeight.bold,
fontSize: 13, fontSize: 13,
), ),
textAlign: TextAlign.center, textAlign:
TextAlign.center,
), ),
), ),
Container( Container(
width: 100, width: 100,
margin: const EdgeInsets.only( margin:
const EdgeInsets.only(
top: 15, left: 15), top: 15, left: 15),
padding: padding:
const EdgeInsets.all(5.0), const EdgeInsets.all(
5.0),
child: const Text( child: const Text(
'Market Value', 'Market Value',
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight:
FontWeight.bold,
fontSize: 13, fontSize: 13,
), ),
textAlign: TextAlign.center, textAlign:
TextAlign.center,
), ),
), ),
Container( Container(
width: 100, width: 100,
margin: const EdgeInsets.only( margin:
const EdgeInsets.only(
top: 15, left: 15), top: 15, left: 15),
padding: padding:
const EdgeInsets.all(5.0), const EdgeInsets.all(
5.0),
child: const Text( child: const Text(
'Ass. Level', 'Ass. Level',
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight:
FontWeight.bold,
fontSize: 13, fontSize: 13,
), ),
textAlign: TextAlign.center, textAlign:
TextAlign.center,
), ),
), ),
Container( Container(
width: 100, width: 100,
margin: const EdgeInsets.only( margin:
const EdgeInsets.only(
top: 15, left: 15), top: 15, left: 15),
padding: padding:
const EdgeInsets.all(5.0), const EdgeInsets.all(
5.0),
child: const Text( child: const Text(
'Ass. Value', 'Ass. Value',
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight:
FontWeight.bold,
fontSize: 13, fontSize: 13,
), ),
textAlign: TextAlign.center, textAlign:
TextAlign.center,
), ),
), ),
], ],
@ -847,27 +886,35 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
children: [ children: [
Container( Container(
width: 100, width: 100,
margin: const EdgeInsets.only( margin:
top: 15, left: 15), const EdgeInsets.only(
top: 15,
left: 15),
padding: padding:
const EdgeInsets.all(5.0), const EdgeInsets.all(
5.0),
child: Text( child: Text(
formKey.currentState formKey.currentState
?.value['actual_use']!, ?.value[
'actual_use']!,
style: TextStyle( style: TextStyle(
fontWeight: fontWeight:
FontWeight.bold, FontWeight.bold,
fontSize: 13, fontSize: 13,
), ),
textAlign: TextAlign.center, textAlign:
TextAlign.center,
), ),
), ),
Container( Container(
width: 100, width: 100,
margin: const EdgeInsets.only( margin:
top: 15, left: 15), const EdgeInsets.only(
top: 15,
left: 15),
padding: padding:
const EdgeInsets.all(5.0), const EdgeInsets.all(
5.0),
child: Text( child: Text(
calculateMarketValue( calculateMarketValue(
(double.parse(formKey (double.parse(formKey
@ -887,21 +934,23 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
FontWeight.bold, FontWeight.bold,
fontSize: 13, fontSize: 13,
), ),
textAlign: TextAlign.center, textAlign:
TextAlign.center,
), ),
), ),
Container( Container(
width: 100, width: 100,
margin: const EdgeInsets.only( margin:
top: 15, left: 15), const EdgeInsets.only(
top: 15,
left: 15),
padding: padding:
const EdgeInsets.all(5.0), const EdgeInsets.all(
5.0),
child: Text( child: Text(
assessmentLevel( assessmentLevel(
calculateMarketValue( calculateMarketValue(
(double.parse(formKey (double.parse(formKey.currentState!.value[
.currentState!
.value[
'total_area']) * 'total_area']) *
double.parse(formKey double.parse(formKey
.currentState! .currentState!
@ -919,26 +968,30 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
FontWeight.bold, FontWeight.bold,
fontSize: 13, fontSize: 13,
), ),
textAlign: TextAlign.center, textAlign:
TextAlign.center,
), ),
), ),
Container( Container(
width: 100, width: 100,
margin: const EdgeInsets.only( margin:
top: 15, left: 15), const EdgeInsets.only(
top: 15,
left: 15),
padding: padding:
const EdgeInsets.all(5.0), const EdgeInsets.all(
5.0),
child: Text( child: Text(
assessmentValue( assessmentValue(
calculateMarketValue( calculateMarketValue(
(double.parse(formKey.currentState!.value[ (double.parse(formKey.currentState!.value['total_area']) *
'total_area']) *
double.parse(formKey double.parse(formKey
.currentState! .currentState!
.value[ .value[
'bldg_type'] 'bldg_type']
.unitValue)), .unitValue)),
state.items, state
.items,
depRate) depRate)
.toString(), .toString(),
formKey.currentState formKey.currentState
@ -950,7 +1003,8 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
FontWeight.bold, FontWeight.bold,
fontSize: 13, fontSize: 13,
), ),
textAlign: TextAlign.center, textAlign:
TextAlign.center,
), ),
), ),
], ],
@ -988,20 +1042,22 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
print(tempID.getInt('tempid')); print(tempID.getInt('tempid'));
var appraisals = PropertyAppraisal( var appraisals = PropertyAppraisal(
id: 1, id: 1,
bldgapprDetailsId: tempID.getInt('tempid')!, bldgapprDetailsId:
unitconstructCost: formKey tempID.getInt('tempid')! - 1,
.currentState!.value['bldg_type'].unitValue, unitconstructCost: formKey.currentState!
.value['bldg_type'].unitValue,
buildingCore: 'test', buildingCore: 'test',
unitconstructSubtotal: unitconstructSubtotal:
(double.parse(formKey.currentState!.value['total_area']) * (double.parse(formKey.currentState!.value['total_area']) *
double.parse(formKey.currentState! double.parse(formKey
.value['bldg_type'].unitValue)) .currentState!
.value['bldg_type']
.unitValue))
.toString(), .toString(),
depreciationRate: depRate.toString(), depreciationRate: depRate.toString(),
depreciationCost: calculateDepCost( depreciationCost: calculateDepCost(
(double.parse(formKey.currentState!.value['total_area']) * (double.parse(formKey.currentState!.value['total_area']) *
double.parse( double.parse(formKey.currentState!.value['bldg_type'].unitValue)),
formKey.currentState!.value['bldg_type'].unitValue)),
state.items, state.items,
depRate) depRate)
.toString(), .toString(),
@ -1009,10 +1065,11 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
addItemsSubtotal: calculateAdditionalItems(state.items).toString(), addItemsSubtotal: calculateAdditionalItems(state.items).toString(),
totalpercentDepreciation: (depRate * 100).toStringAsFixed(2), totalpercentDepreciation: (depRate * 100).toStringAsFixed(2),
marketValue: calculateMarketValue((double.parse(formKey.currentState!.value['total_area']) * double.parse(formKey.currentState!.value['bldg_type'].unitValue)), state.items, depRate).toString(), marketValue: calculateMarketValue((double.parse(formKey.currentState!.value['total_area']) * double.parse(formKey.currentState!.value['bldg_type'].unitValue)), state.items, depRate).toString(),
totalArea: formKey.currentState!.value['total_area']); totalArea: formKey.currentState!.value['total_area'],
actualUse: "Residential");
context.read<PropertyAppraisalBloc>() context.read<PropertyAppraisalBloc>()
..add( ..add(AddPropertyAppraisal(
AddPropertyAppraisal(appraisal: appraisals)); appraisal: appraisals));
widget.NextBtn(); widget.NextBtn();
} }
@ -1028,6 +1085,8 @@ class _PropertyAppraisalPage extends State<PropertyAppraisalPage> {
} }
return Container(); return Container();
}, },
),
),
); );
} }

View File

@ -40,424 +40,6 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
String _memoranda = ''; String _memoranda = '';
final focus = FocusNode(); final focus = FocusNode();
String assessmentLevel(marketValues, property_class) {
final marketValue = double.parse(marketValues);
switch (property_class) {
case 'Residential':
if (marketValue < 175000) {
// setState(() {
// assessment_level = 0;
// });
return '0 ';
} else if (marketValue < 300000 && marketValue > 175000) {
// setState(() {
// assessment_level = 0.10;
// });
return '10 ';
} else if (marketValue < 500000 && marketValue > 300000) {
// setState(() {
// assessment_level = 0.20;
// });
return '20 ';
} else if (marketValue < 750000 && marketValue > 500000) {
// setState(() {
// assessment_level = 0.25;
// });
return '25 ';
} else if (marketValue < 1000000 && marketValue > 750000) {
// setState(() {
// assessment_level = 0.30;
// });
return '30 ';
} else if (marketValue < 2000000 && marketValue > 1000000) {
// setState(() {
// assessment_level = 0.35;
// });
return '35 ';
} else if (marketValue < 5000000 && marketValue > 2000000) {
// setState(() {
// assessment_level = 0.40;
// });
return '40 ';
} else if (marketValue < 10000000 && marketValue > 5000000) {
// setState(() {
// assessment_level = 0.50;
// });
return '50 ';
} else if (marketValue > 10000000) {
// setState(() {
// assessment_level = 0.60;
// });
return '60 ';
}
break;
case 'Agricultural':
if (marketValue < 300000) {
// setState(() {
// assessment_level = 0.45;
// });
return '45 ';
} else if (marketValue < 500000 && marketValue > 300000) {
// setState(() {
// assessment_level = 0.50;
// });
return '50 ';
} else if (marketValue < 750000 && marketValue > 5000000) {
// setState(() {
// assessment_level = 0.55;
// });
return '55 ';
} else if (marketValue < 1000000 && marketValue > 750000) {
// setState(() {
// assessment_level = 0.60;
// });
return '60 ';
} else if (marketValue < 2000000 && marketValue > 1000000) {
// setState(() {
// assessment_level = 0.65;
// });
return '65 ';
} else if (marketValue > 2000000) {
// setState(() {
// assessment_level = 0.70;
// });
return '70 ';
}
break;
case 'Commercial':
if (marketValue < 300000) {
// setState(() {
// assessment_level = 0.30;
// });
return '30 ';
} else if (marketValue < 500000 && marketValue > 300000) {
// setState(() {
// assessment_level = 0.35;
// });
return '35 ';
} else if (marketValue < 750000 && marketValue > 500000) {
// setState(() {
// assessment_level = 0.40;
// });
return '40 ';
} else if (marketValue < 1000000 && marketValue > 750000) {
// setState(() {
// assessment_level = 0.50;
// });
return '50 ';
} else if (marketValue < 2000000 && marketValue > 1000000) {
// setState(() {
// assessment_level = 0.60;
// });
return '60 ';
} else if (marketValue < 5000000 && marketValue > 2000000) {
// setState(() {
// assessment_level = 0.70;
// });
return '70 ';
} else if (marketValue < 10000000 && marketValue > 5000000) {
// setState(() {
// assessment_level = 0.75;
// });
return '75 ';
} else if (marketValue > 10000000) {
// setState(() {
// assessment_level = 0.80;
// });
}
break;
case 'Industrial':
if (marketValue < 300000) {
// setState(() {
// assessment_level = 0.30;
// });
return '30 ';
} else if (marketValue < 500000 && marketValue > 300000) {
// setState(() {
// assessment_level = 0.35;
// });
return '35 ';
} else if (marketValue < 750000 && marketValue > 500000) {
// setState(() {
// assessment_level = 0.40;
// });
return '40 ';
} else if (marketValue < 1000000 && marketValue > 750000) {
// setState(() {
// assessment_level = 0.50;
// });
return '50 ';
} else if (marketValue < 2000000 && marketValue > 1000000) {
// setState(() {
// assessment_level = 0.60;
// });
return '60 ';
} else if (marketValue < 5000000 && marketValue > 2000000) {
// setState(() {
// assessment_level = 0.70;
// });
return '70 ';
} else if (marketValue < 10000000 && marketValue > 5000000) {
// setState(() {
// assessment_level = 0.75;
// });
return '75 ';
} else if (marketValue > 10000000) {
// setState(() {
// assessment_level = 0.80;
// });
return '80 ';
}
break;
case 'Mineral':
break;
case 'Timberland':
if (marketValue < 300000) {
// setState(() {
// assessment_level = 0.45;
// });
return '45 ';
} else if (marketValue < 500000 && marketValue > 300000) {
// setState(() {
// assessment_level = 0.50;
// });
return '50 ';
} else if (marketValue < 750000 && marketValue > 500000) {
// setState(() {
// assessment_level = 0.55;
// });
return '55 ';
} else if (marketValue < 1000000 && marketValue > 750000) {
// setState(() {
// assessment_level = 0.60;
// });
return '60 ';
} else if (marketValue < 2000000 && marketValue > 1000000) {
// setState(() {
// assessment_level = 0.65;
// });
return '65 ';
} else if (marketValue < 2000000) {
// setState(() {
// assessment_level = 0.70;
// });
return '70 ';
}
break;
default:
}
return '';
}
double assessmentValue(marketValues, property_class) {
final marketValue = double.parse(marketValues);
switch (property_class) {
case 'Residential':
if (marketValue < 175000) {
// setState(() {
// assessment_level = 0;
// });
return marketValue * 0;
} else if (marketValue < 300000 && marketValue > 175000) {
// setState(() {
// assessment_level = 0.10;
// });
return marketValue * 0.10;
} else if (marketValue < 500000 && marketValue > 300000) {
// setState(() {
// assessment_level = 0.20;
// });
return marketValue * 0.20;
} else if (marketValue < 750000 && marketValue > 500000) {
// setState(() {
// assessment_level = 0.25;
// });
return marketValue * 0.25;
} else if (marketValue < 1000000 && marketValue > 750000) {
// setState(() {
// assessment_level = 0.30;
// });
return marketValue * 0.30;
} else if (marketValue < 2000000 && marketValue > 1000000) {
// setState(() {
// assessment_level = 0.35;
// });
return marketValue * 0.35;
} else if (marketValue < 5000000 && marketValue > 2000000) {
// setState(() {
// assessment_level = 0.40;
// });
return marketValue * 0.40;
} else if (marketValue < 10000000 && marketValue > 5000000) {
// setState(() {
// assessment_level = 0.50;
// });
return marketValue * 0.50;
} else if (marketValue > 10000000) {
// setState(() {
// assessment_level = 0.60;
// });
return marketValue * 0.60;
}
break;
case 'Agricultural':
if (marketValue < 300000) {
// setState(() {
// assessment_level = 0.45;
// });
return marketValue * 0.45;
} else if (marketValue < 500000 && marketValue > 300000) {
// setState(() {
// assessment_level = 0.50;
// });
return marketValue * 0.50;
} else if (marketValue < 750000 && marketValue > 5000000) {
// setState(() {
// assessment_level = 0.55;
// });
return marketValue * 0.55;
} else if (marketValue < 1000000 && marketValue > 750000) {
// setState(() {
// assessment_level = 0.60;
// });
return marketValue * 0.60;
} else if (marketValue < 2000000 && marketValue > 1000000) {
// setState(() {
// assessment_level = 0.65;
// });
return marketValue * 0.65;
} else if (marketValue > 2000000) {
// setState(() {
// assessment_level = 0.70;
// });
return marketValue * 0.70;
}
break;
case 'Commercial':
if (marketValue < 300000) {
// setState(() {
// assessment_level = 0.30;
// });
return marketValue * 0.30;
} else if (marketValue < 500000 && marketValue > 300000) {
// setState(() {
// assessment_level = 0.35;
// });
return marketValue * 0.35;
} else if (marketValue < 750000 && marketValue > 500000) {
// setState(() {
// assessment_level = 0.40;
// });
return marketValue * 0.40;
} else if (marketValue < 1000000 && marketValue > 750000) {
// setState(() {
// assessment_level = 0.50;
// });
return marketValue * 0.50;
} else if (marketValue < 2000000 && marketValue > 1000000) {
// setState(() {
// assessment_level = 0.60;
// });
return marketValue * 0.60;
} else if (marketValue < 5000000 && marketValue > 2000000) {
// setState(() {
// assessment_level = 0.70;
// });
return marketValue * 0.70;
} else if (marketValue < 10000000 && marketValue > 5000000) {
// setState(() {
// assessment_level = 0.75;
// });
return marketValue * 0.75;
} else if (marketValue > 10000000) {
// setState(() {
// assessment_level = 0.80;
// });
}
break;
case 'Industrial':
if (marketValue < 300000) {
// setState(() {
// assessment_level = 0.30;
// });
return marketValue * 0.30;
} else if (marketValue < 500000 && marketValue > 300000) {
// setState(() {
// assessment_level = 0.35;
// });
return marketValue * 0.35;
} else if (marketValue < 750000 && marketValue > 500000) {
// setState(() {
// assessment_level = 0.40;
// });
return marketValue * 0.40;
} else if (marketValue < 1000000 && marketValue > 750000) {
// setState(() {
// assessment_level = 0.50;
// });
return marketValue * 0.50;
} else if (marketValue < 2000000 && marketValue > 1000000) {
// setState(() {
// assessment_level = 0.60;
// });
return marketValue * 0.60;
} else if (marketValue < 5000000 && marketValue > 2000000) {
// setState(() {
// assessment_level = 0.70;
// });
return marketValue * 0.70;
} else if (marketValue < 10000000 && marketValue > 5000000) {
// setState(() {
// assessment_level = 0.75;
// });
return marketValue * 0.75;
} else if (marketValue > 10000000) {
// setState(() {
// assessment_level = 0.80;
// });
return marketValue * 0.80;
}
break;
case 'Mineral':
break;
case 'Timberland':
if (marketValue < 300000) {
// setState(() {
// assessment_level = 0.45;
// });
return marketValue * 0.45;
} else if (marketValue < 500000 && marketValue > 300000) {
// setState(() {
// assessment_level = 0.50;
// });
return marketValue * 0.50;
} else if (marketValue < 750000 && marketValue > 500000) {
// setState(() {
// assessment_level = 0.55;
// });
return marketValue * 0.55;
} else if (marketValue < 1000000 && marketValue > 750000) {
// setState(() {
// assessment_level = 0.60;
// });
return marketValue * 0.60;
} else if (marketValue < 2000000 && marketValue > 1000000) {
// setState(() {
// assessment_level = 0.65;
// });
return marketValue * 0.65;
} else if (marketValue < 2000000) {
// setState(() {
// assessment_level = 0.70;
// });
return marketValue * 0.70;
}
break;
default:
}
return 0;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -466,111 +48,26 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
padding: const EdgeInsets.all(24), padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87, backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white), indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<PropertyAssessmentBloc, PropertyAssessmentState>( child: BlocConsumer<SignatoriesBloc, SignatoriesState>(
listener: (context, state) { listener: (context, state) {
if (state is PropertyAssessmentLoading) { // TODO: implement listener
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is PropertyAssessmentLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is PropertyAssessmentErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
// Fluttertoast.showToast(
// msg: onError,
// fontSize: 24,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.CENTER,
// backgroundColor: Colors.black,
// textColor: Colors.white);
}
},
builder: (context, state) {
if (state is PropertyAssessmentLoaded) {
return BlocConsumer<SignatoriesBloc, SignatoriesState>(
listener: (context, state) {
if (state is SignatoriesLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is SignatoriesLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is SignatoriesErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
// Fluttertoast.showToast(
// msg: onError,
// fontSize: 24,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.CENTER,
// backgroundColor: Colors.black,
// textColor: Colors.white);
}
}, },
builder: (context, state) { builder: (context, state) {
if (state is SignatoriesLoaded) { if (state is SignatoriesLoaded) {
final signatories = state.signatories; final signatories = state.signatories;
return BlocConsumer<MemorandaBloc, MemorandaState>( return BlocConsumer<MemorandaBloc, MemorandaState>(
listener: (context, state) { listener: (context, state) {
if (state is MemorandaLoading) { // TODO: implement listener
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is MemorandaLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is MemorandaErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
// Fluttertoast.showToast(
// msg: onError,
// fontSize: 24,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.CENTER,
// backgroundColor: Colors.black,
// textColor: Colors.white);
}
}, },
builder: (context, state) { builder: (context, state) {
if (state is MemorandaLoaded) { if (state is MemorandaLoaded) {
final memoranda = state.memorada; final memoranda = state.memorada;
return BlocConsumer<PropertyAppraisalBloc,
PropertyAppraisalState>(
listener: (context, state) {
if (state is PropertyAppraisalLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is PropertyAppraisalLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is PropertyAppraisalErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
// Fluttertoast.showToast(
// msg: onError,
// fontSize: 24,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.CENTER,
// backgroundColor: Colors.black,
// textColor: Colors.white);
}
}, builder: (context, state) {
if (state is PropertyAppraisalLoaded) {
return ListView( return ListView(
children: [ children: [
Align( Align(
alignment: Alignment.center, alignment: Alignment.center,
child: Container( child: Container(
margin: const EdgeInsets.fromLTRB( margin: const EdgeInsets.fromLTRB(0, 20, 0, 20),
0, 20, 0, 20),
child: const Text( child: const Text(
'PROPERTY ASSESSMENT cont..', 'PROPERTY ASSESSMENT cont..',
style: TextStyle( style: TextStyle(
@ -584,8 +81,8 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
Expanded( Expanded(
flex: 3, flex: 3,
child: SingleChildScrollView( child: SingleChildScrollView(
padding: EdgeInsets.only( padding:
left: 20.0, right: 20.0), EdgeInsets.only(left: 20.0, right: 20.0),
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
child: Column(children: [ child: Column(children: [
Row( Row(
@ -646,8 +143,8 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
child: FormBuilderTextField( child: FormBuilderTextField(
name: 'qtr', name: 'qtr',
validator: validator:
FormBuilderValidators FormBuilderValidators.compose(
.compose([]), []),
), ),
), ),
const SizedBox( const SizedBox(
@ -660,8 +157,8 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
child: FormBuilderTextField( child: FormBuilderTextField(
name: 'yr', name: 'yr',
validator: validator:
FormBuilderValidators FormBuilderValidators.compose(
.compose([]), []),
), ),
), ),
], ],
@ -695,8 +192,7 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
items: signatories items: signatories
.map((signatories) => .map((signatories) =>
DropdownMenuItem( DropdownMenuItem(
value: value: signatories,
signatories,
child: Text( child: Text(
'${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'),
)) ))
@ -712,18 +208,15 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
children: [ children: [
SizedBox( SizedBox(
width: 100, width: 100,
child: child: FormBuilderDateTimePicker(
FormBuilderDateTimePicker(
name: 'app_date', name: 'app_date',
initialEntryMode: initialEntryMode:
DatePickerEntryMode DatePickerEntryMode
.calendarOnly, .calendarOnly,
initialValue: initialValue: DateTime.now(),
DateTime.now(),
inputType: InputType.date, inputType: InputType.date,
initialTime: initialTime: const TimeOfDay(
const TimeOfDay(
hour: 8, minute: 0), hour: 8, minute: 0),
// locale: const Locale.fromSubtags(languageCode: 'fr'), // locale: const Locale.fromSubtags(languageCode: 'fr'),
), ),
@ -758,8 +251,7 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
items: signatories items: signatories
.map((signatories) => .map((signatories) =>
DropdownMenuItem( DropdownMenuItem(
value: value: signatories,
signatories,
child: Text( child: Text(
'${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'),
)) ))
@ -775,18 +267,15 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
children: [ children: [
SizedBox( SizedBox(
width: 100, width: 100,
child: child: FormBuilderDateTimePicker(
FormBuilderDateTimePicker(
name: 'rec_date', name: 'rec_date',
initialEntryMode: initialEntryMode:
DatePickerEntryMode DatePickerEntryMode
.calendarOnly, .calendarOnly,
initialValue: initialValue: DateTime.now(),
DateTime.now(),
inputType: InputType.date, inputType: InputType.date,
initialTime: initialTime: const TimeOfDay(
const TimeOfDay(
hour: 8, minute: 0), hour: 8, minute: 0),
// locale: const Locale.fromSubtags(languageCode: 'fr'), // locale: const Locale.fromSubtags(languageCode: 'fr'),
), ),
@ -808,8 +297,7 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
), ),
)), )),
Row( Row(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.center,
MainAxisAlignment.center,
children: [ children: [
Column( Column(
children: [ children: [
@ -822,8 +310,7 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
items: signatories items: signatories
.map((signatories) => .map((signatories) =>
DropdownMenuItem( DropdownMenuItem(
value: value: signatories,
signatories,
child: Text( child: Text(
'${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'), '${signatories.firstname} ${signatories.middlename} ${signatories.lastname}'),
)) ))
@ -863,14 +350,13 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
title: Text( title: Text(
'${memoranda.memoranda}', '${memoranda.memoranda}',
overflow: overflow:
TextOverflow TextOverflow.ellipsis,
.ellipsis,
), ),
), ),
)) ))
.toList(), .toList(),
validator: FormBuilderValidators validator:
.required( FormBuilderValidators.required(
errorText: errorText:
"This field is required"), "This field is required"),
// searchInputDecoration: // searchInputDecoration:
@ -881,12 +367,11 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
// Icons.arrow_drop_down), // Icons.arrow_drop_down),
// ), // ),
// focusNode: focus, // focusNode: focus,
suggestionState: suggestionState: Suggestion.expand,
Suggestion.expand,
onSuggestionTap: (memoranda) { onSuggestionTap: (memoranda) {
setState(() { setState(() {
_memoranda = memoranda _memoranda =
.item!.memoranda!; memoranda.item!.memoranda!;
}); });
focus.unfocus(); focus.unfocus();
}, },
@ -905,8 +390,8 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
child: FormBuilderTextField( child: FormBuilderTextField(
name: 'sworn_statement', name: 'sworn_statement',
decoration: InputDecoration(), decoration: InputDecoration(),
validator: FormBuilderValidators validator:
.compose([]), FormBuilderValidators.compose([]),
), ),
), ),
], ],
@ -925,8 +410,7 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
child: FormBuilderDateTimePicker( child: FormBuilderDateTimePicker(
name: 'date_received', name: 'date_received',
initialEntryMode: initialEntryMode:
DatePickerEntryMode DatePickerEntryMode.calendarOnly,
.calendarOnly,
initialValue: DateTime.now(), initialValue: DateTime.now(),
inputType: InputType.date, inputType: InputType.date,
@ -952,8 +436,7 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
child: FormBuilderDateTimePicker( child: FormBuilderDateTimePicker(
name: 'date_of_entry', name: 'date_of_entry',
initialEntryMode: initialEntryMode:
DatePickerEntryMode DatePickerEntryMode.calendarOnly,
.calendarOnly,
initialValue: DateTime.now(), initialValue: DateTime.now(),
inputType: InputType.date, inputType: InputType.date,
@ -978,8 +461,8 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
child: FormBuilderTextField( child: FormBuilderTextField(
name: 'by', name: 'by',
decoration: InputDecoration(), decoration: InputDecoration(),
validator: FormBuilderValidators validator:
.compose([]), FormBuilderValidators.compose([]),
), ),
), ),
], ],
@ -990,8 +473,7 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
ElevatedButton( ElevatedButton(
onPressed: () async { onPressed: () async {
final tempID = final tempID =
await SharedPreferences await SharedPreferences.getInstance();
.getInstance();
print(tempID.getInt('tempid')! - 1); print(tempID.getInt('tempid')! - 1);
final List<PropertyAssessment> final List<PropertyAssessment>
propertyAssessments = []; propertyAssessments = [];
@ -1010,12 +492,10 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
taxable: isTaxable, taxable: isTaxable,
exempt: isExempt, exempt: isExempt,
qtr: int.parse(formKey qtr: int.parse(formKey
.currentState! .currentState!.value['qtr'] ??
.value['qtr'] ??
'0'), // Replace null with '0' '0'), // Replace null with '0'
yr: int.parse(formKey yr: int.parse(
.currentState! formKey.currentState!.value['yr'] ??
.value['yr'] ??
'0'), // Replace null with '0' '0'), // Replace null with '0'
appraisedbyName: (formKey appraisedbyName: (formKey
.currentState! .currentState!
@ -1034,8 +514,7 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
.value['appraised_by'] .value['appraised_by']
?.lastname ?? ?.lastname ??
''), ''),
appraisedbyDate: formKey appraisedbyDate: formKey.currentState!
.currentState!
.value['app_date'] .value['app_date']
as DateTime? ?? as DateTime? ??
DateTime DateTime
@ -1057,8 +536,7 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
.value['rec_approval'] .value['rec_approval']
?.lastname ?? ?.lastname ??
''), ''),
recommendapprDate: formKey recommendapprDate: formKey.currentState!
.currentState!
.value['rec_date'] .value['rec_date']
as DateTime? ?? as DateTime? ??
DateTime DateTime
@ -1081,12 +559,10 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
?.lastname ?? ?.lastname ??
''), ''),
memoranda: _memoranda, memoranda: _memoranda,
swornstatementNo: formKey swornstatementNo: formKey.currentState!
.currentState!.value[ .value['sworn_statement'] ??
'sworn_statement'] ??
'', // Replace null with an empty string '', // Replace null with an empty string
dateReceived: formKey dateReceived: formKey.currentState!
.currentState!
.value['date_received'] .value['date_received']
as DateTime? ?? as DateTime? ??
DateTime DateTime
@ -1097,15 +573,14 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
as DateTime? ?? as DateTime? ??
DateTime DateTime
.now(), // Replace null with current date .now(), // Replace null with current date
entryDateBy: formKey.currentState! entryDateBy: formKey
.value['by'] ?? .currentState!.value['by'] ??
'', // Replace null with an empty string '', // Replace null with an empty string
); );
propertyAssessments.add(ass); propertyAssessments.add(ass);
context context.read<PropertyAssessmentBloc>()
.read<PropertyAssessmentBloc>()
..add(UpdatePropertyAssessment( ..add(UpdatePropertyAssessment(
assessment: assessment:
propertyAssessments[0])); propertyAssessments[0]));
@ -1138,59 +613,12 @@ class _PropertyAssessmentPage extends State<PropertyAssessmentPage> {
], ],
); );
} }
if (state is PropertyAppraisalErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<PropertyAppraisalBloc>().add(
LoadPropertyAppraisal(
appraisal: PropertyAppraisal()));
},
);
}
return Container(); return Container();
});
}
if (state is MemorandaErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context
.read<MemorandaBloc>()
.add(LoadMemoranda());
}, },
); );
} }
return Container(); return Container();
}, },
); )));
}
if (state is SignatoriesErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<SignatoriesBloc>().add(LoadSignatories());
},
);
}
return Container();
},
);
}
if (state is PropertyAssessmentErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context
.read<PropertyAssessmentBloc>()
.add(LoadPropertyAssessment());
},
);
}
return Container();
},
),
),
);
} }
} }

View File

@ -46,10 +46,7 @@ class _BldgLocLandRefEdit extends State<BldgLocLandRefEdit> {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait..."); progress!.showWithText("Please wait...");
} }
if (state is LocationLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is LocationErrorState) { if (state is LocationErrorState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress?.dismiss(); progress?.dismiss();
@ -64,10 +61,6 @@ class _BldgLocLandRefEdit extends State<BldgLocLandRefEdit> {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait..."); progress!.showWithText("Please wait...");
} }
if (state is LandrefLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is LandrefErrorState) { if (state is LandrefErrorState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress?.dismiss(); progress?.dismiss();
@ -82,10 +75,6 @@ class _BldgLocLandRefEdit extends State<BldgLocLandRefEdit> {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait..."); progress!.showWithText("Please wait...");
} }
if (state is MunicipalityLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is MunicipalityErrorState) { if (state is MunicipalityErrorState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress?.dismiss(); progress?.dismiss();

View File

@ -33,24 +33,24 @@ class PropertyAppraisalEditPage extends StatefulWidget {
class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> { class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
double depRate = 0; double depRate = 0;
int totalAreas = 0; // int totalAreas = 0;
String actualUse = ""; // String actualUse = "";
@override // @override
void initState() { // void initState() {
super.initState(); // super.initState();
_loadDataFromSharedPreferences(); // Call the method to load data // _loadDataFromSharedPreferences(); // Call the method to load data
} // }
// Method to load data from SharedPreferences // Method to load data from SharedPreferences
_loadDataFromSharedPreferences() async { // _loadDataFromSharedPreferences() async {
SharedPreferences prefs = await SharedPreferences.getInstance(); // SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() { // setState(() {
actualUse = prefs.getString('actualUse') ?? ''; // actualUse = prefs.getString('actualUse') ?? '';
totalAreas = prefs.getInt('totalArea') ?? // totalAreas = prefs.getInt('totalArea') ??
0; // Provide a default value if the key doesn't exist // 0; // Provide a default value if the key doesn't exist
}); // });
} // }
calculateAdditionalItems(List<AdditionalItems> items) { calculateAdditionalItems(List<AdditionalItems> items) {
double sum = 0; double sum = 0;
@ -529,10 +529,7 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait..."); progress!.showWithText("Please wait...");
} }
if (state is PropertyAppraisalEditLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is PropertyAppraisalEditErrorState) { if (state is PropertyAppraisalEditErrorState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress?.dismiss(); progress?.dismiss();
@ -543,38 +540,78 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
final appraisal = state.appraisalEdit; final appraisal = state.appraisalEdit;
return BlocConsumer<AdditionalItemsEditBloc, return BlocConsumer<AdditionalItemsEditBloc,
AdditionalItemsEditState>(listener: (context, state) { AdditionalItemsEditState>(listener: (context, state) {
// TODO: implement listener if (state is PropertyAppraisalEditLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is AdditionalItemsEditLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is AdditionalItemsEditErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
}, builder: (context, state) { }, builder: (context, state) {
if (state is AdditionalItemsEditLoaded) { if (state is AdditionalItemsEditLoaded) {
final item = state.items; final item = state.items;
double totalArea = double.tryParse(totalAreas.toString() ?? return BlocConsumer<GeneralDescriptionBloc,
appraisal.totalArea.toString()) ?? GeneralDescriptionState>(
listener: (context, state) {
if (state is GenDescLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is GenDescLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is GenDescErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
},
builder: (context, state) {
if (state is GenDescLoaded) {
double totalArea = double.tryParse(
(state.gendesc.totalFloorArea ??
appraisal.totalArea)
?.toString() ??
'0.0') ??
0.0; 0.0;
double bldgUnitValue = double.tryParse( double bldgUnitValue = double.tryParse(keys.currentState
keys.currentState?.value['bldg_type']?.unitValue ?? ?.value['bldg_type']?.unitValue ??
appraisal.unitconstructCost) ?? appraisal.unitconstructCost) ??
0.0; 0.0;
return Expanded( return Column(
children: [
Expanded(
child: SingleChildScrollView( child: SingleChildScrollView(
child: Container( child: Container(
margin: const EdgeInsets.only(left: 20.0, right: 20.0), margin: const EdgeInsets.only(
left: 20.0, right: 20.0),
child: Column( child: Column(
children: [ children: [
Container( Container(
margin: const EdgeInsets.only( margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 20), left: 0,
top: 20,
right: 0,
bottom: 20),
child: const Text('PROPERTY APPRAISAL', child: const Text('PROPERTY APPRAISAL',
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18), fontWeight: FontWeight.bold,
fontSize: 18),
textAlign: TextAlign.left), textAlign: TextAlign.left),
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
Container( Container(
child: Text( child: const Text(
"Unit Construction Cost", "Unit Construction Cost",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -592,10 +629,11 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
), ),
const SizedBox(height: 15), const SizedBox(height: 15),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
Container( Container(
child: Text( child: const Text(
"Building Core", "Building Core",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -604,7 +642,7 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
), ),
), ),
Container( Container(
child: Text( child: const Text(
'', '',
textAlign: TextAlign.right, textAlign: TextAlign.right,
), ),
@ -613,10 +651,11 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
), ),
const SizedBox(height: 40), const SizedBox(height: 40),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
Container( Container(
child: Text( child: const Text(
"Sub-total", "Sub-total",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -634,10 +673,11 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
), ),
const SizedBox(height: 40), const SizedBox(height: 40),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
Container( Container(
child: Text( child: const Text(
"Cost of Additional Items", "Cost of Additional Items",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -646,7 +686,7 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
), ),
), ),
Container( Container(
child: Text( child: const Text(
'', '',
textAlign: TextAlign.right, textAlign: TextAlign.right,
), ),
@ -655,10 +695,11 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
), ),
const SizedBox(height: 15), const SizedBox(height: 15),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
Container( Container(
child: Text( child: const Text(
"Sub-total", "Sub-total",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -668,7 +709,8 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
), ),
Container( Container(
child: Text( child: Text(
appraisal.addItemsSubtotal ?? '0.00', appraisal.addItemsSubtotal ??
'0.00',
textAlign: TextAlign.right, textAlign: TextAlign.right,
), ),
) )
@ -676,10 +718,11 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
), ),
const SizedBox(height: 15), const SizedBox(height: 15),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
Container( Container(
child: Text( child: const Text(
"Total Construction Cost", "Total Construction Cost",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -690,11 +733,11 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
Container( Container(
child: Text( child: Text(
calculateConstructionCost( calculateConstructionCost(
double.parse( double.parse(appraisal
appraisal.unitconstructSubtotal!), .unitconstructSubtotal!),
double.parse( double.parse(appraisal
appraisal.addItemsSubtotal!)) .addItemsSubtotal!))
.toString()!, .toString(),
textAlign: TextAlign.right, textAlign: TextAlign.right,
), ),
) )
@ -702,10 +745,11 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
), ),
const SizedBox(height: 40), const SizedBox(height: 40),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
Container( Container(
child: Text( child: const Text(
"Depreciation Rate", "Depreciation Rate",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -718,8 +762,11 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
height: 25, height: 25,
child: FormBuilderTextField( child: FormBuilderTextField(
name: 'depRate', name: 'depRate',
decoration: normalTextFieldStyle("0.00", ""), decoration: normalTextFieldStyle(
validator: FormBuilderValidators.compose([]), "0.00", ""),
validator:
FormBuilderValidators.compose(
[]),
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
depRate = double.parse(value!); depRate = double.parse(value!);
@ -731,10 +778,11 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
), ),
const SizedBox(height: 15), const SizedBox(height: 15),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
Container( Container(
child: Text( child: const Text(
"Depreciation Cost", "Depreciation Cost",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -747,9 +795,12 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
calculateDepCost( calculateDepCost(
(totalArea * bldgUnitValue), (totalArea * bldgUnitValue),
item, item,
double.parse(keys.currentState double.parse(keys
?.value['depRate'] ?? .currentState
appraisal.depreciationRate)) ?.value[
'depRate'] ??
appraisal
.depreciationRate))
.toString(), .toString(),
textAlign: TextAlign.right, textAlign: TextAlign.right,
), ),
@ -758,10 +809,11 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
), ),
const SizedBox(height: 15), const SizedBox(height: 15),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
Container( Container(
child: Text( child: const Text(
"Total % Depreciation", "Total % Depreciation",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -779,10 +831,11 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
), ),
const SizedBox(height: 15), const SizedBox(height: 15),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
Container( Container(
child: Text( child: const Text(
"Market Value", "Market Value",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -795,9 +848,12 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
calculateMarketValue( calculateMarketValue(
(totalArea * bldgUnitValue), (totalArea * bldgUnitValue),
item, item,
double.parse(keys.currentState double.parse(keys
?.value['depRate'] ?? .currentState
appraisal.depreciationRate)) ?.value[
'depRate'] ??
appraisal
.depreciationRate))
.toString(), .toString(),
textAlign: TextAlign.right, textAlign: TextAlign.right,
), ),
@ -811,19 +867,21 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
child: SingleChildScrollView( child: SingleChildScrollView(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
child: Container( child: Container(
margin: const EdgeInsets.symmetric( margin:
const EdgeInsets.symmetric(
horizontal: 20.0), horizontal: 20.0),
child: Column( child: Column(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.start, MainAxisAlignment.start,
children: [ children: [
Container( Container(
margin: const EdgeInsets.fromLTRB( margin: const EdgeInsets
0, 20, 0, 20), .fromLTRB(0, 20, 0, 20),
child: const Text( child: const Text(
'PROPERTY ASSESSMENT', 'PROPERTY ASSESSMENT',
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight:
FontWeight.bold,
fontSize: 18, fontSize: 18,
), ),
textAlign: TextAlign.left, textAlign: TextAlign.left,
@ -835,73 +893,102 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
children: [ children: [
Container( Container(
width: 100, width: 100,
margin: const EdgeInsets.only( margin:
top: 15, left: 15), const EdgeInsets
.only(
top: 15,
left: 15),
padding: padding:
const EdgeInsets.all(5.0), const EdgeInsets
.all(5.0),
child: const Text( child: const Text(
'Actual Use', 'Actual Use',
style: TextStyle( style: TextStyle(
fontWeight: fontWeight:
FontWeight.bold, FontWeight
.bold,
fontSize: 13, fontSize: 13,
), ),
textAlign: TextAlign.center, textAlign:
TextAlign
.center,
), ),
), ),
Container( Container(
width: 150, width: 150,
margin: const EdgeInsets.only( margin:
top: 15, left: 15), const EdgeInsets
.only(
top: 15,
left: 15),
padding: padding:
const EdgeInsets.all(5.0), const EdgeInsets
.all(5.0),
child: const Text( child: const Text(
'Market Value', 'Market Value',
style: TextStyle( style: TextStyle(
fontWeight: fontWeight:
FontWeight.bold, FontWeight
.bold,
fontSize: 13, fontSize: 13,
), ),
textAlign: TextAlign.center, textAlign:
TextAlign
.center,
), ),
), ),
Container( Container(
width: 100, width: 100,
margin: const EdgeInsets.only( margin:
top: 15, left: 15), const EdgeInsets
.only(
top: 15,
left: 15),
padding: padding:
const EdgeInsets.all(5.0), const EdgeInsets
.all(5.0),
child: const Text( child: const Text(
'Ass. Level', 'Ass. Level',
style: TextStyle( style: TextStyle(
fontWeight: fontWeight:
FontWeight.bold, FontWeight
.bold,
fontSize: 13, fontSize: 13,
), ),
textAlign: TextAlign.center, textAlign:
TextAlign
.center,
), ),
), ),
Container( Container(
width: 150, width: 150,
margin: const EdgeInsets.only( margin:
top: 15, left: 15), const EdgeInsets
.only(
top: 15,
left: 15),
padding: padding:
const EdgeInsets.all(5.0), const EdgeInsets
.all(5.0),
child: const Text( child: const Text(
'Ass. Value', 'Ass. Value',
style: TextStyle( style: TextStyle(
fontWeight: fontWeight:
FontWeight.bold, FontWeight
.bold,
fontSize: 13, fontSize: 13,
), ),
textAlign: TextAlign.center, textAlign:
TextAlign
.center,
), ),
), ),
], ],
), ),
SizedBox( SizedBox(
height: 50, height: 50,
child: SingleChildScrollView( child:
SingleChildScrollView(
scrollDirection: scrollDirection:
Axis.horizontal, Axis.horizontal,
child: Row(children: [ child: Row(children: [
@ -911,125 +998,123 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
children: [ children: [
Container( Container(
width: 100, width: 100,
margin: margin: const EdgeInsets
const EdgeInsets
.only( .only(
top: 15, top: 15,
left: 15), left:
15),
padding: padding:
const EdgeInsets const EdgeInsets.all(
.all(5.0), 5.0),
child: Text( child: Text(
actualUse ?? "", state.gendesc
style: TextStyle( .actualUse ??
"",
style:
const TextStyle(
fontWeight: fontWeight:
FontWeight FontWeight.bold,
.bold, fontSize:
fontSize: 13, 13,
), ),
textAlign: TextAlign textAlign:
TextAlign
.center, .center,
), ),
), ),
Container( Container(
width: 150, width: 150,
margin: margin: const EdgeInsets
const EdgeInsets
.only( .only(
top: 15, top: 15,
left: 15), left:
15),
padding: padding:
const EdgeInsets const EdgeInsets.all(
.all(5.0), 5.0),
child: Text( child: Text(
NumberFormat NumberFormat
.currency( .currency(
locale: 'en-PH', locale:
symbol: "", 'en-PH',
symbol:
"",
).format( ).format(
calculateMarketValue( calculateMarketValue(
(totalArea * (totalArea *
bldgUnitValue), bldgUnitValue),
item, item,
double.parse(keys double.parse(keys.currentState?.value['depRate'] ??
.currentState appraisal.depreciationRate)),
?.value[
'depRate'] ??
appraisal
.depreciationRate)),
), ),
style: TextStyle( style:
const TextStyle(
fontWeight: fontWeight:
FontWeight FontWeight.bold,
.bold, fontSize:
fontSize: 13, 13,
), ),
textAlign: TextAlign textAlign:
TextAlign
.center, .center,
), ),
), ),
Container( Container(
width: 100, width: 100,
margin: margin: const EdgeInsets
const EdgeInsets
.only( .only(
top: 15, top: 15,
left: 15), left:
15),
padding: padding:
const EdgeInsets const EdgeInsets.all(
.all(5.0), 5.0),
child: Text( child: Text(
assessmentLevel( '${assessmentLevel(calculateMarketValue((totalArea * bldgUnitValue), item, double.parse(keys.currentState?.value['depRate'] ?? appraisal.depreciationRate)).toString(), state.gendesc.actualUse)}%',
calculateMarketValue( style:
(totalArea * const TextStyle(
bldgUnitValue),
item,
double.parse(keys.currentState?.value['depRate'] ??
appraisal.depreciationRate))
.toString(),
actualUse) +
'%',
style: TextStyle(
fontWeight: fontWeight:
FontWeight FontWeight.bold,
.bold, fontSize:
fontSize: 13, 13,
), ),
textAlign: TextAlign textAlign:
TextAlign
.center, .center,
), ),
), ),
Container( Container(
width: 150, width: 150,
margin: margin: const EdgeInsets
const EdgeInsets
.only( .only(
top: 15, top: 15,
left: 15), left:
15),
padding: padding:
const EdgeInsets const EdgeInsets.all(
.all(5.0), 5.0),
child: Text( child: Text(
NumberFormat NumberFormat
.currency( .currency(
locale: 'en-PH', locale:
symbol: "", 'en-PH',
symbol:
"",
).format(assessmentValue( ).format(assessmentValue(
calculateMarketValue( calculateMarketValue((totalArea * bldgUnitValue), item, double.parse(keys.currentState?.value['depRate'] ?? appraisal.depreciationRate))
(totalArea *
bldgUnitValue),
item,
double.parse(keys.currentState?.value['depRate'] ??
appraisal.depreciationRate))
.toString(), .toString(),
actualUse)), state
style: TextStyle( .gendesc
.actualUse)),
style:
const TextStyle(
fontWeight: fontWeight:
FontWeight FontWeight.bold,
.bold, fontSize:
fontSize: 13, 13,
), ),
textAlign: TextAlign textAlign:
TextAlign
.center, .center,
), ),
), ),
@ -1052,10 +1137,12 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
], ],
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [ children: [
CustomButton( CustomButton(
icon: const Icon(Icons.chevron_left_rounded, icon: const Icon(
Icons.chevron_left_rounded,
color: Colors.white), color: Colors.white),
onPressed: () { onPressed: () {
{ {
@ -1065,45 +1152,53 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
}, },
), ),
CustomButton( CustomButton(
icon: const Icon(Icons.chevron_right_rounded, icon: const Icon(
Icons.chevron_right_rounded,
color: Colors.white), color: Colors.white),
onPressed: () async { onPressed: () async {
final tempID = final tempID =
await SharedPreferences.getInstance(); await SharedPreferences
.getInstance();
final id = tempID.getInt('tempid')! - 1; final id =
tempID.getInt('tempid')! - 1;
{ {
var appraisals = PropertyAppraisalEdit( var appraisals = PropertyAppraisalEdit(
id: 1, id: 1,
bldgapprDetailsId: id, bldgapprDetailsId: id,
unitconstructCost: bldgUnitValue unitconstructCost:
.toString(), bldgUnitValue.toString(),
buildingCore: 'test', buildingCore: 'test',
unitconstructSubtotal: (totalArea * unitconstructSubtotal:
bldgUnitValue) (totalArea * bldgUnitValue)
.toString(), .toString(),
depreciationRate: depRate.toString(), depreciationRate:
depreciationCost: calculateDepCost( depRate.toString(),
(totalArea * bldgUnitValue), depreciationCost:
item, calculateDepCost((totalArea * bldgUnitValue), item, depRate)
depRate)
.toString(), .toString(),
costAddItems: calculateAdditionalItems(item) costAddItems:
calculateAdditionalItems(item)
.toString(), .toString(),
addItemsSubtotal: addItemsSubtotal:
calculateAdditionalItems(item) calculateAdditionalItems(item)
.toString(), .toString(),
totalpercentDepreciation: totalpercentDepreciation:
(depRate * 100).toStringAsFixed(2), (depRate * 100)
.toStringAsFixed(2),
marketValue: calculateMarketValue( marketValue: calculateMarketValue(
(totalArea * bldgUnitValue), (totalArea * bldgUnitValue),
item, item,
depRate) depRate)
.toString(), .toString(),
totalArea: totalArea.toString()); totalArea: totalArea.toString());
context.read<PropertyAppraisalEditBloc>() context
..add(UpdatePropertyAppraisalEdit( .read<
appraisalEdit: appraisals, PropertyAppraisalEditBloc>()
.add(
UpdatePropertyAppraisalEdit(
appraisalEdit:
appraisals,
id: widget.tempId)); id: widget.tempId));
widget.NextBtn(); widget.NextBtn();
@ -1117,6 +1212,12 @@ class _PropertyAppraisalEditPage extends State<PropertyAppraisalEditPage> {
), ),
), ),
), ),
),
],
);
}
return Container();
},
); );
} }
return Container(); return Container();

View File

@ -484,7 +484,15 @@ class _PropertyAssessmentEditPage extends State<PropertyAssessmentEditPage> {
final assessment = state.assessmentsEdit; final assessment = state.assessmentsEdit;
return BlocConsumer<SignatoriesBloc, SignatoriesState>( return BlocConsumer<SignatoriesBloc, SignatoriesState>(
listener: (context, state) { listener: (context, state) {
// TODO: implement listener if (state is SignatoriesLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is SignatoriesErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
}, },
builder: (context, state) { builder: (context, state) {
if (state is SignatoriesLoaded) { if (state is SignatoriesLoaded) {
@ -492,26 +500,39 @@ class _PropertyAssessmentEditPage extends State<PropertyAssessmentEditPage> {
return BlocConsumer<MemorandaBloc, MemorandaState>( return BlocConsumer<MemorandaBloc, MemorandaState>(
listener: (context, state) { listener: (context, state) {
// TODO: implement listener if (state is MemorandaLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is MemorandaLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is MemorandaErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
}, },
builder: (context, state) { builder: (context, state) {
if (state is MemorandaLoaded) { if (state is MemorandaLoaded) {
return FormBuilder( return FormBuilder(
key: keys, key: keys,
initialValue: { initialValue: {
'qtr': assessment.qtr.toString(), 'qtr': assessment.qtr?.toString() ?? '',
'yr': assessment.qtr.toString(), 'yr': assessment.qtr?.toString() ?? '',
// 'appraised_by': assessment.appraisedbyName, 'app_date':
'app_date': assessment.appraisedbyDate.toString(), assessment.appraisedbyDate?.toString() ?? '',
// 'rec_approval': assessment.recommendapprName, 'rec_date':
'rec_date': assessment.recommendapprDate.toString(), assessment.recommendapprDate?.toString() ?? '',
// 'apprvd_by': assessment.approvedbyName, 'memoranda': assessment.memoranda ?? '',
'memoranda': assessment.memoranda, 'sworn_statement':
'sworn_statement': assessment.swornstatementNo, assessment.swornstatementNo ?? '',
'date_received': assessment.dateReceived.toString(), 'date_received':
assessment.dateReceived?.toString() ?? '',
'date_of_entry': 'date_of_entry':
assessment.entryDateAssessment.toString(), assessment.entryDateAssessment?.toString() ??
'by': assessment.entryDateBy '',
'by': assessment.entryDateBy ?? '',
}, },
enabled: true, enabled: true,
onChanged: () { onChanged: () {
@ -649,7 +670,8 @@ class _PropertyAssessmentEditPage extends State<PropertyAssessmentEditPage> {
decoration: decoration:
InputDecoration( InputDecoration(
labelText: assessment labelText: assessment
.appraisedbyName!, .appraisedbyName ??
"",
labelStyle: labelStyle:
const TextStyle( const TextStyle(
color: Colors color: Colors
@ -723,7 +745,8 @@ class _PropertyAssessmentEditPage extends State<PropertyAssessmentEditPage> {
decoration: decoration:
InputDecoration( InputDecoration(
labelText: assessment labelText: assessment
.recommendapprName!, .recommendapprName ??
"",
labelStyle: labelStyle:
const TextStyle( const TextStyle(
color: Colors color: Colors
@ -798,7 +821,8 @@ class _PropertyAssessmentEditPage extends State<PropertyAssessmentEditPage> {
decoration: decoration:
InputDecoration( InputDecoration(
labelText: assessment labelText: assessment
.approvedbyName!, .approvedbyName ??
"",
labelStyle: labelStyle:
const TextStyle( const TextStyle(
color: Colors color: Colors
@ -1087,9 +1111,10 @@ class _PropertyAssessmentEditPage extends State<PropertyAssessmentEditPage> {
propertyAssessments.add(ass); propertyAssessments.add(ass);
context.read< context
.read<
PropertyAssessmentEditBloc>() PropertyAssessmentEditBloc>()
..add(UpdatePropertyAssessmentEdit( .add(UpdatePropertyAssessmentEdit(
assessmentsEdit: assessmentsEdit:
propertyAssessments[ propertyAssessments[
0])); 0]));
@ -1114,7 +1139,7 @@ class _PropertyAssessmentEditPage extends State<PropertyAssessmentEditPage> {
} }
if (state is PropertyAssessmentEditErrorState) { if (state is PropertyAssessmentEditErrorState) {
return SomethingWentWrong( return SomethingWentWrong(
message: onError, message: state.error,
onpressed: () { onpressed: () {
context.read<PropertyAssessmentEditBloc>().add( context.read<PropertyAssessmentEditBloc>().add(
LoadPropertyAssessmentEdit( LoadPropertyAssessmentEdit(

View File

@ -62,7 +62,19 @@ class _PropertyOwnerInfoEdit extends State<PropertyOwnerInfoEdit> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocConsumer<PropertyInfoBloc, PropertyInfoState>( return BlocConsumer<PropertyInfoBloc, PropertyInfoState>(
listener: (context, state) { listener: (context, state) {
// TODO: implement listener if (state is PropertyInfoLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is PropertyInfoLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is PropertyInfoErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
}, builder: (context, state) { }, builder: (context, state) {
if (state is PropertyInfoLoaded) { if (state is PropertyInfoLoaded) {
return SingleChildScrollView( return SingleChildScrollView(

View File

@ -79,22 +79,10 @@ class _EditLand extends State<EditLand> {
}, },
), ),
Expanded( Expanded(
child: FormBuilder(
key: landKey,
// enabled: false,
onChanged: () {
landKey.currentState?.save();
print(landKey.currentState?.value.toString());
},
autovalidateMode: AutovalidateMode.disabled,
skipDisabled: true,
child: Container( child: Container(
child: content(PrevBtn, NextBtn, onSAveAll), child: content(PrevBtn, NextBtn, onSAveAll),
), ),
), ),
),
], ],
), ),
), ),
@ -111,15 +99,16 @@ class _EditLand extends State<EditLand> {
case 1: case 1:
return LandLocationAndBoundariesEdit(PrevBtn, NextBtn, widget.faas!); return LandLocationAndBoundariesEdit(PrevBtn, NextBtn, widget.faas!);
case 2: case 2:
return LandAppraisalEdit(PrevBtn, NextBtn); return LandAppraisalEdit(PrevBtn, NextBtn, widget.faas.id!);
case 3: case 3:
return OtherImprovementEditPage(PrevBtn, NextBtn); return OtherImprovementEditPage(PrevBtn, NextBtn, widget.faas.id!);
case 4: case 4:
return ValueAdjustmentEditPage(PrevBtn, NextBtn); return ValueAdjustmentEditPage(PrevBtn, NextBtn, widget.faas.id!);
case 5: case 5:
return LandPropertyAssessmentEditPage(PrevBtn, NextBtn); return LandPropertyAssessmentEditPage(
PrevBtn, NextBtn, widget.faas.id!);
case 6: case 6:
return LandSignatoriesEdit(onSAveAll); return LandSignatoriesEdit(onSAveAll, widget.faas.id!);
default: default:
return LandPropertyOwnerInfoEdit(NextBtn, widget.faas!); return LandPropertyOwnerInfoEdit(NextBtn, widget.faas!);

View File

@ -0,0 +1,464 @@
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:form_builder_validators/form_builder_validators.dart';
import 'package:intl/intl.dart';
import 'package:searchfield/searchfield.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/land/land_appraisal/land_appraisal_bloc.dart';
import 'package:unit2/bloc/passo/land/land_classification/land_classification_bloc.dart';
import 'package:unit2/bloc/passo/land/land_subclassification/land_subclassification_bloc.dart';
import 'package:unit2/bloc/passo/municipality/municipality_bloc.dart';
import 'package:unit2/model/passo/additional_items.dart';
import 'package:unit2/model/passo/city.dart';
import 'package:unit2/model/passo/class_components.dart';
import 'package:unit2/model/passo/land_appr.dart';
import 'package:unit2/model/passo/land_classification.dart';
import 'package:unit2/model/passo/land_subclassification.dart';
import 'package:unit2/model/passo/unit_construct.dart';
import 'package:unit2/screens/passo/Land/add_land.dart';
import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/error_state.dart';
import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart';
class AddLandAppraisalEditModal extends StatefulWidget {
// final List<UnitConstruct> unit;
// final List<ClassComponents> options;
final int tempId;
AddLandAppraisalEditModal(this.tempId);
@override
_AddLandAppraisalEditModal createState() => _AddLandAppraisalEditModal();
}
class _AddLandAppraisalEditModal extends State<AddLandAppraisalEditModal> {
final focus = FocusNode();
bool isPainted = false;
bool isSecondHand = false;
TextEditingController textEditingController = TextEditingController();
double _unitBase = 0;
int _areaValue = 0;
final double _depValue = 0;
double _unitValue = 0;
String _subClassDesc = "";
int _classId = 0;
String _structureType = "";
bool _withoutBUCC = false;
int _notPaintedUnitVal = 0;
int _secondHandUnitVal = 0;
String cityCode = '';
String cityDesc = '';
int classCode = 1;
String _classDesc = '';
GlobalKey<FormBuilderState> appraisalLandKey = GlobalKey<FormBuilderState>();
BoxDecoration box1() {
return const BoxDecoration(boxShadow: [
BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5)
], color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(3)));
}
double _amountofDepreciation(unitVal, unitBase, area, depreciation) {
return ((unitVal * unitBase) * area) * depreciation;
}
double _totalMarketValue(unitBase, area) {
return unitBase * area;
}
@override
Widget build(BuildContext context) {
return BlocConsumer<LandAppraisalBloc, LandAppraisalState>(
listener: (context, state) {
if (state is LandAppraisalLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is LandAppraisalLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is LandAppraisalErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
}, buildWhen: (previous, current) {
return false;
}, builder: (context, state) {
if (state is ShowAddLandAppraisalScreen) {
return BlocConsumer<LandClassificationBloc, LandClassificationState>(
listener: (context, state) {
// TODO: implement listener
},
builder: (context, state) {
if (state is LandClassificationLoaded) {
final classification = state.land_classification;
return BlocConsumer<LandSubClassificationBloc,
LandSubClassificationState>(
listener: (context, state) {
// TODO: implement listener
},
builder: (context, state) {
if (state is LandSubClassificationLoaded) {
final subclassification = state.land_subclassification;
return BlocConsumer<MunicipalityBloc, MunicipalityState>(
listener: (context, state) {
// TODO: implement listener
},
builder: (context, state) {
if (state is MunicipalityLoaded) {
return FormBuilder(
key: appraisalLandKey,
onChanged: () {
appraisalLandKey.currentState?.save();
},
autovalidateMode: AutovalidateMode.disabled,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: SingleChildScrollView(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
margin: const EdgeInsets.only(
left: 0,
top: 10,
right: 0,
bottom: 0),
child: Expanded(
flex: 1,
child:
FormBuilderDropdown<City>(
name:
'appraisal_municipality',
autofocus: false,
decoration:
normalTextFieldStyle(
cityDesc ??
"Municipality",
""),
items: state.municipality
.map((municipality) =>
DropdownMenuItem<
City>(
value: municipality,
child: Text(municipality
.cityDescription!), // Use cityDescription instead of cityName
))
.toList(),
onChanged: (selectedCity) {
if (selectedCity != null) {
final selectedCityCode =
selectedCity.cityCode;
setState(() {
cityCode =
selectedCityCode!;
cityDesc = selectedCity
.cityDescription!;
});
final barangayBloc =
context.read<
LandSubClassificationBloc>();
barangayBloc.add(
LoadLandSubClassification(
classCode:
classCode!,
cityCode:
selectedCityCode!)); // Use selectedCityCode directly
}
},
)),
),
Container(
margin: const EdgeInsets.only(
left: 0,
top: 10,
right: 0,
bottom: 0),
child: Expanded(
flex: 1,
child: FormBuilderDropdown<
LandClassification>(
name: 'classification',
autofocus: false,
decoration:
normalTextFieldStyle(
_classDesc
.toString() ??
"Classification",
""),
items: classification
.map((classification) =>
DropdownMenuItem<
LandClassification>(
value:
classification,
child: Text(
classification
.description!), // Use cityDescription instead of cityName
))
.toList(),
onChanged: (selectedClass) {
if (selectedClass != null) {
final selectedClassCode =
selectedClass.id;
setState(() {
classCode =
selectedClassCode!;
_classDesc =
selectedClass
.description!;
});
final barangayBloc =
context.read<
LandSubClassificationBloc>();
barangayBloc.add(
LoadLandSubClassification(
classCode:
selectedClassCode!,
cityCode:
cityCode)); // Use selectedCityCode directly
}
},
)),
),
Container(
margin: const EdgeInsets.only(
left: 0,
top: 10,
right: 0,
bottom: 0),
child: SizedBox(
height: 45,
child: SearchField(
itemHeight: 70,
suggestions: subclassification
.map((LandSubClassification
subclass) =>
SearchFieldListItem(
'${subclass.subclassCode} - ${subclass.subclassDescription}',
item: subclass,
child: ListTile(
title: Text(
'${subclass.subclassCode} - ${subclass.subclassDescription!.toUpperCase()}',
overflow:
TextOverflow
.ellipsis,
),
)))
.toList(),
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
searchInputDecoration:
normalTextFieldStyle(
"Structure Type",
"")
.copyWith(
suffixIcon:
const Icon(Icons
.arrow_drop_down)),
////agency suggestion tap
focusNode: focus,
suggestionState:
Suggestion.expand,
onSuggestionTap: (subclass) {
setState(() {
_unitBase = double.parse(
subclass.item!
.baseUnitMarketval!);
_subClassDesc =
'${subclass.item!.subclassCode} - ${subclass.item!.subclassDescription}';
});
focus.unfocus();
},
),
),
),
const SizedBox(height: 10),
FormBuilderTextField(
name: 'land_appraisal_area',
decoration: normalTextFieldStyle(
"Area", ""),
validator:
FormBuilderValidators.compose(
[]),
onChanged: (value) {
setState(() {
_areaValue = int.parse(value!);
});
},
),
const SizedBox(height: 10),
const Text('Market Value'),
const SizedBox(height: 5),
Container(
height: 45.0,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.grey,
width: 1.0,
),
borderRadius:
BorderRadius.circular(5.0),
),
child: Align(
alignment: Alignment.center,
child: Text(
NumberFormat.currency(
locale: 'en-PH',
symbol: "")
.format(
_totalMarketValue(
_unitBase,
_areaValue)))),
),
const SizedBox(height: 10),
Row(
children: [
Container(
width: 120,
height: 60,
padding:
const EdgeInsets.all(8.0),
child: ElevatedButton(
onPressed: () async {
final tempID =
await SharedPreferences
.getInstance();
print(tempID
.getInt('landid'));
var land_appraisal = LandAppr(
landapprDetailsId:
widget.tempId,
classification:
_classDesc,
subClass: _subClassDesc,
area: _areaValue
.toString(),
unitValue: _unitBase
.toString(),
baseMarketval:
_totalMarketValue(
_unitBase,
_areaValue)
.toString());
context
.read<
LandAppraisalBloc>()
.add(AddLandAppraisal(
land_appr:
land_appraisal));
},
style:
ElevatedButton.styleFrom(
primary: Colors.black,
),
child: const Text("Submit"),
),
),
const SizedBox(
width:
5), // Use SizedBox for horizontal spacing in a Row
Container(
width: 120,
height: 60,
padding:
const EdgeInsets.all(8.0),
child: ElevatedButton(
onPressed: () {
context
.read<
LandAppraisalBloc>()
.add(
LoadLandAppraisalEdit(
land_appr: <
LandAppr>[],
id: widget.tempId,
));
},
style:
ElevatedButton.styleFrom(
primary: Colors.black,
),
child: const Text("Cancel"),
),
),
],
),
],
),
),
)));
}
if (state is MunicipalityErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context
.read<MunicipalityBloc>()
.add(LoadMunicipality());
},
);
}
return Container();
},
);
}
if (state is LandSubClassificationErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<LandSubClassificationBloc>().add(
const LoadLandSubClassification(
cityCode: '1', classCode: 1));
},
);
}
return Container();
},
);
}
if (state is LandClassificationErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context
.read<LandClassificationBloc>()
.add(LoadLandClassification());
},
);
}
return Container();
},
);
}
if (state is LandAppraisalErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<LandAppraisalBloc>().add(LoadLandAppraisal());
},
);
}
return Container();
});
}
}

View File

@ -0,0 +1,357 @@
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:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/bloc/passo/land/land_trees_improvements/land_trees_improvements_bloc.dart';
import 'package:unit2/bloc/passo/land/other_improvements/other_improvements_bloc.dart';
import 'package:unit2/model/passo/other_improvements.dart';
import 'package:unit2/model/passo/trees_improvements.dart';
import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/error_state.dart';
class AddOtherImprovementEditModal extends StatefulWidget {
// final List<UnitConstruct> unit;
// final List<ClassComponents> options;
final int tempId;
AddOtherImprovementEditModal(this.tempId);
@override
_AddOtherImprovementEditModal createState() =>
_AddOtherImprovementEditModal();
}
class _AddOtherImprovementEditModal
extends State<AddOtherImprovementEditModal> {
final focus = FocusNode();
bool isPainted = false;
bool isSecondHand = false;
TextEditingController textEditingController = TextEditingController();
double _unitBase = 0;
int _areaValue = 0;
final double _depValue = 0;
double _unitValue = 0;
String _subClassDesc = "";
int _classId = 0;
String _structureType = "";
int _notPaintedUnitVal = 0;
int _secondHandUnitVal = 0;
String cityCode = '';
String cityDesc = '';
int classCode = 1;
String _classDesc = '';
String _treeType = "";
bool _nonfruitBearing = false;
bool _fruitBearing = false;
int qty = 0;
int pr_qty = 0;
int nonpr_qty = 0;
GlobalKey<FormBuilderState> otherImpKey = GlobalKey<FormBuilderState>();
final typeOfTree = [
"Non-Fruit Bearing",
"Fruit Bearing",
];
_calculateBaseMarketValue() {
double base = 0.00;
if (_fruitBearing) {
base = (pr_qty + nonpr_qty) * _unitValue;
} else {
base = qty * _unitValue;
}
return base;
}
BoxDecoration box1() {
return const BoxDecoration(boxShadow: [
BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5)
], color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(3)));
}
double _amountofDepreciation(unitVal, unitBase, area, depreciation) {
return ((unitVal * unitBase) * area) * depreciation;
}
double _totalMarketValue(unitBase, area) {
return unitBase * area;
}
@override
Widget build(BuildContext context) {
return BlocBuilder<OtherImprovementsBloc, OtherImprovementsState>(
buildWhen: (previous, current) {
return false;
}, builder: (context, state) {
if (state is ShowAddOtherImprovementScreen) {
return BlocConsumer<LandTreesImprovementsBloc,
LandTreesImprovementsState>(listener: (context, state) {
// TODO: implement listener
}, builder: (context, state) {
if (state is LandTreesImprovementsLoaded) {
final trees = state.trees_imp;
return FormBuilder(
key: otherImpKey,
onChanged: () {
otherImpKey.currentState?.save();
},
autovalidateMode: AutovalidateMode.disabled,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: SingleChildScrollView(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
margin: const EdgeInsets.only(
left: 0, top: 10, right: 0, bottom: 0),
child: Expanded(
flex: 1,
child: FormBuilderDropdown<TreesImprovements>(
name: 'kinds_of_trees',
autofocus: false,
decoration: normalTextFieldStyle(
"Kinds of Trees", ""),
items: state.trees_imp
.map((trees) =>
DropdownMenuItem<TreesImprovements>(
value: trees,
child: Text(
(trees.improvement ?? "") +
" " +
(trees.subclassCode ?? ""),
),
))
.toList(),
onChanged: (selectedTree) {
if (selectedTree != null) {
setState(() {
_unitValue = double.parse(
selectedTree.pricePerTree!);
_treeType = selectedTree.improvement!;
});
}
},
)),
),
Container(
child: Row(
children: [
Row(
children: [
Checkbox(
value: _fruitBearing,
onChanged: (bool? value) {
setState(() {
_fruitBearing = value!;
});
},
),
Text('Fruit Bearing ?'),
],
),
],
),
),
Visibility(
visible: !_fruitBearing,
child: Row(
children: [
Expanded(
child: FormBuilderTextField(
name: 'subClass',
decoration: normalTextFieldStyle(
"SubClass/Age", ""),
validator:
FormBuilderValidators.compose([]),
onChanged: (value) {
setState(() {
_subClassDesc = value!;
});
},
),
),
SizedBox(
width: 10,
),
Expanded(
child: FormBuilderTextField(
name: 'qty',
decoration: normalTextFieldStyle("No.", ""),
validator:
FormBuilderValidators.compose([]),
onChanged: (value) {
setState(() {
qty = int.parse(value!);
});
},
),
),
],
),
replacement: Column(
children: [
FormBuilderTextField(
name: 'no_of_productive',
decoration: normalTextFieldStyle(
"No. of Productive", ""),
validator: FormBuilderValidators.compose([]),
onChanged: (value) {
setState(() {
pr_qty = int.parse(value!);
});
},
),
const SizedBox(height: 10),
FormBuilderTextField(
name: 'no_of_nonproductive',
decoration: normalTextFieldStyle(
"No. of Non-Productive", ""),
validator: FormBuilderValidators.compose([]),
onChanged: (value) {
setState(() {
nonpr_qty = int.parse(value!);
});
},
),
],
),
),
const SizedBox(height: 10),
const Text('Market Value'),
const SizedBox(height: 5),
Container(
height: 45.0,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.grey,
width: 1.0,
),
borderRadius: BorderRadius.circular(5.0),
),
child: Align(
alignment: Alignment.center,
child: Text(NumberFormat.currency(
locale: 'en-PH', symbol: "")
.format(_unitValue))),
),
const SizedBox(height: 10),
const Text('Base Market Value'),
const SizedBox(height: 5),
Container(
height: 45.0,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.grey,
width: 1.0,
),
borderRadius: BorderRadius.circular(5.0),
),
child: Align(
alignment: Alignment.center,
child: Text(NumberFormat.currency(
locale: 'en-PH',
symbol: "",
).format(_calculateBaseMarketValue().toString() ==
"0.00"
? "00.0"
: _calculateBaseMarketValue())),
),
),
const SizedBox(height: 10),
Row(
children: [
Container(
width: 120,
height: 60,
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
onPressed: () async {
var improvement = OtherImprovements(
landapprDetailsId: widget.tempId,
kindsOfTrees: _treeType,
subclassAge: _subClassDesc,
quantity: qty,
unitValue: _unitValue.toString(),
baseMarketval:
_calculateBaseMarketValue()
.toString(),
noOfProductive: pr_qty,
noOfNonproductive: nonpr_qty,
fruitBearing: _fruitBearing);
context.read<OtherImprovementsBloc>().add(
AddOtherImprovement(
other_imp: improvement));
},
style: ElevatedButton.styleFrom(
primary: Colors.black,
),
child: const Text("Submit"),
),
),
const SizedBox(
width:
5), // Use SizedBox for horizontal spacing in a Row
Container(
width: 120,
height: 60,
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
onPressed: () {
context.read<OtherImprovementsBloc>().add(
LoadOtherImprovementEdit(
other_imps: <OtherImprovements>[],
ids: widget.tempId));
},
style: ElevatedButton.styleFrom(
primary: Colors.black,
),
child: const Text("Cancel"),
),
),
],
)
],
),
),
),
));
}
if (state is LandTreesImprovementsErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context
.read<LandTreesImprovementsBloc>()
.add(LoadLandTreesImprovements());
},
);
}
return Container();
});
}
if (state is OtherImprovementErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<OtherImprovementsBloc>().add(LoadOtherImprovement());
},
);
}
return Container();
});
}
}

View File

@ -0,0 +1,356 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/bloc/passo/land/land_property_assessment/land_property_assessment_bloc.dart';
import 'package:unit2/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart';
import 'package:unit2/model/passo/land_property_assessment.dart';
import 'package:unit2/model/passo/land_value_adjustment.dart';
import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/error_state.dart';
class AddPropertyAssessmentEditModal extends StatefulWidget {
// final List<UnitConstruct> unit;
// final List<ClassComponents> options;
final int tempId;
AddPropertyAssessmentEditModal(this.tempId);
@override
_AddPropertyAssessmentEditModal createState() =>
_AddPropertyAssessmentEditModal();
}
class _AddPropertyAssessmentEditModal
extends State<AddPropertyAssessmentEditModal> {
final focus = FocusNode();
bool isPainted = false;
bool isSecondHand = false;
TextEditingController textEditingController = TextEditingController();
double _unitBase = 0;
int _areaValue = 0;
final double _depValue = 0;
double _unitValue = 0;
String _subClassDesc = "";
int _classId = 0;
String _structureType = "";
int _notPaintedUnitVal = 0;
int _secondHandUnitVal = 0;
String cityCode = '';
String cityDesc = '';
int classCode = 1;
String _classDesc = '';
String _treeType = "";
bool _nonfruitBearing = false;
bool _fruitBearing = false;
int qty = 0;
int pr_qty = 0;
int nonpr_qty = 0;
String _actualUse = "Residential";
String _assessmentLevel = "";
GlobalKey<FormBuilderState> assessmentKey = GlobalKey<FormBuilderState>();
final typeOfTree = [
"Non-Fruit Bearing",
"Fruit Bearing",
];
final actual_use = [
"Residential",
"Agricultural",
"Commercial",
"Industrial",
"Mineral",
"Timberland",
];
calculateAssessmentValue() {
switch (_actualUse) {
case "Residential":
return _unitValue * 0.20;
break;
case "Agricultural":
return _unitValue * 0.40;
break;
case "Commercial":
return _unitValue * 0.50;
break;
case "Industrial":
return _unitValue * 0.50;
break;
case "Mineral":
return _unitValue * 0.50;
break;
case "Timberland":
return _unitValue * 0.20;
break;
default:
}
}
BoxDecoration box1() {
return const BoxDecoration(boxShadow: [
BoxShadow(color: Colors.black12, spreadRadius: 5, blurRadius: 5)
], color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(3)));
}
double _amountofDepreciation(unitVal, unitBase, area, depreciation) {
return ((unitVal * unitBase) * area) * depreciation;
}
double _totalMarketValue(unitBase, area) {
return unitBase * area;
}
@override
Widget build(BuildContext context) {
return BlocBuilder<LandPropertyAssessmentBloc, LandPropertyAssessmentState>(
buildWhen: (previous, current) {
return false;
}, builder: (context, state) {
if (state is ShowAddLandPropertyAssessmentScreen) {
return BlocConsumer<LandValueAdjustmentsBloc,
LandValueAdjustmentsState>(listener: (context, state) {
// TODO: implement listener
}, builder: (context, state) {
if (state is LandValueAdjustmentsLoaded) {
final assessment = state.val_adj;
return FormBuilder(
key: assessmentKey,
onChanged: () {
assessmentKey.currentState?.save();
},
autovalidateMode: AutovalidateMode.disabled,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: SingleChildScrollView(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
margin: const EdgeInsets.only(
left: 0, top: 10, right: 0, bottom: 0),
child: Expanded(
flex: 1,
child: FormBuilderDropdown<ValueAdjustments>(
name: 'value_adjustments',
autofocus: false,
decoration: normalTextFieldStyle(
"Value Adjustments", ""),
items: state.val_adj
.map((adj) =>
DropdownMenuItem<ValueAdjustments>(
value: adj,
child: Text(
(adj.adjustmentFactors ?? ""),
),
))
.toList(),
onChanged: (selectedAdj) {
if (selectedAdj != null) {
setState(() {
_unitValue = double.parse(
selectedAdj.marketValue!);
});
}
},
)),
),
SizedBox(
height: 10,
),
FormBuilderDropdown<String?>(
name: "land_actual_use",
autofocus: false,
decoration: normalTextFieldStyle("Actual Use", ""),
items: actual_use
.map((item) => DropdownMenuItem(
value: item,
child: Text(item),
))
.toList(),
onChanged: (value) {
setState(() {
_actualUse = value!;
switch (value) {
case "Residential":
setState(() {
_assessmentLevel = '20';
});
break;
case "Agricultural":
setState(() {
_assessmentLevel = '40';
});
break;
case "Commercial":
setState(() {
_assessmentLevel = '50';
});
break;
case "Industrial":
setState(() {
_assessmentLevel = '50';
});
break;
case "Mineral":
setState(() {
_assessmentLevel = '50';
});
break;
case "Timberland":
setState(() {
_assessmentLevel = '20';
});
break;
default:
}
});
},
),
SizedBox(
height: 10,
),
Text('Assessment Level'),
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(_assessmentLevel + '%'),
),
),
SizedBox(
height: 10,
),
Text('Assessment Value'),
Container(
height: 45.0,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.grey,
width: 1.0,
),
borderRadius: BorderRadius.circular(5.0),
),
child: Align(
alignment: Alignment.center,
child: Text(NumberFormat.currency(
locale: 'en-PH',
symbol: "",
).format(calculateAssessmentValue().toString() ==
"0.00"
? "00.0"
: calculateAssessmentValue())),
),
),
const SizedBox(height: 10),
Row(
children: [
Container(
width: 120,
height: 60,
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
onPressed: () async {
var assessment = LandPropertyAssessment(
landapprDetailsId: widget.tempId,
actualUse: _actualUse,
marketval: _unitValue.toString(),
assessmentLevel: _assessmentLevel,
assessedValue:
calculateAssessmentValue()
.toString(),
totalMarketval: '0',
totalAssessedval: '0');
context
.read<LandPropertyAssessmentBloc>()
.add(AddLandPropertyAssessment(
assessment: assessment));
},
style: ElevatedButton.styleFrom(
primary: Colors.black,
),
child: const Text("Submit"),
),
),
const SizedBox(
width:
5), // Use SizedBox for horizontal spacing in a Row
Container(
width: 120,
height: 60,
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
onPressed: () {
context
.read<LandPropertyAssessmentBloc>()
.add(
const LoadLandPropertyAssessment());
},
style: ElevatedButton.styleFrom(
primary: Colors.black,
),
child: const Text("Cancel"),
),
),
],
)
],
),
),
),
));
}
if (state is LandValueAdjustmentsErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context
.read<LandValueAdjustmentsBloc>()
.add(LoadLandValueAdjustments());
},
);
}
return Container();
});
}
if (state is LandPropertyAssessmentErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context
.read<LandPropertyAssessmentBloc>()
.add(LoadLandPropertyAssessment());
},
);
}
return Container();
});
}
}

View File

@ -1,9 +1,12 @@
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/land/land_appraisal/land_appraisal_bloc.dart'; 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/edit_land/AddLandAppraisalEdit.dart';
import 'package:unit2/utils/alerts.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';
@ -12,7 +15,8 @@ import 'package:unit2/widgets/passo/custom_button.dart';
class LandAppraisalEdit extends StatefulWidget { class LandAppraisalEdit extends StatefulWidget {
Function PrevBtn; Function PrevBtn;
Function NextBtn; Function NextBtn;
LandAppraisalEdit(this.PrevBtn, this.NextBtn); final int faasId;
LandAppraisalEdit(this.PrevBtn, this.NextBtn, this.faasId);
@override @override
_LandAppraisalEdit createState() => _LandAppraisalEdit(); _LandAppraisalEdit createState() => _LandAppraisalEdit();
} }
@ -32,9 +36,24 @@ class _LandAppraisalEdit extends State<LandAppraisalEdit> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocConsumer<LandAppraisalBloc, LandAppraisalState>( return ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<LandAppraisalBloc, LandAppraisalState>(
listener: (context, state) { listener: (context, state) {
// TODO: implement listener if (state is LandAppraisalLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is LandAppraisalLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is LandAppraisalErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
}, builder: (context, state) { }, builder: (context, state) {
final state = context.watch<LandAppraisalBloc>().state; final state = context.watch<LandAppraisalBloc>().state;
if (state is LandAppraisalLoaded) { if (state is LandAppraisalLoaded) {
@ -219,22 +238,23 @@ class _LandAppraisalEdit extends State<LandAppraisalEdit> {
successAlert(context, "Deletion Successful", successAlert(context, "Deletion Successful",
"Extra item has been deleted successfully", () { "Extra item has been deleted successfully", () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context.read<LandAppraisalBloc>().add(const LoadLandAppraisal()); context.read<LandAppraisalBloc>().add(LoadLandAppraisalEdit(
land_appr: const <LandAppr>[], id: widget.faasId!));
}); });
}); });
} }
} }
if (state is ShowAddLandAppraisalScreen) { if (state is ShowAddLandAppraisalScreen) {
return ConstrainedBox( return ConstrainedBox(
constraints: BoxConstraints( constraints: const BoxConstraints(
maxHeight: 700.0, maxHeight: 700.0,
), ),
child: AlertDialog( child: AlertDialog(
insetPadding: EdgeInsets.symmetric( insetPadding: const EdgeInsets.symmetric(
horizontal: 20.0, horizontal: 20.0,
vertical: 10.0, vertical: 10.0,
), ),
title: Text( title: const Text(
'ADD LAND APPRAISAL', 'ADD LAND APPRAISAL',
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
@ -242,7 +262,17 @@ class _LandAppraisalEdit extends State<LandAppraisalEdit> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Container(child: AddLandAppraisalModal()), Align(
alignment: Alignment.topCenter,
child: Container(
child: ConstrainedBox(
constraints: BoxConstraints(maxHeight: 500),
child: Container(
child: AddLandAppraisalEditModal(widget.faasId),
),
),
),
),
], ],
), ),
), ),
@ -252,11 +282,13 @@ class _LandAppraisalEdit extends State<LandAppraisalEdit> {
return SomethingWentWrong( return SomethingWentWrong(
message: onError, message: onError,
onpressed: () { onpressed: () {
context.read<LandAppraisalBloc>().add(LoadLandAppraisal()); context.read<LandAppraisalBloc>().add(LoadLandAppraisalEdit(
land_appr: <LandAppr>[], id: widget.faasId!));
}, },
); );
} }
return Container(); return Container();
}); }),
);
} }
} }

View File

@ -5,11 +5,9 @@ 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:unit2/bloc/passo/land/land_boundaries_edit/land_boundaries_edit_bloc.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_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_boundaries.dart';
import 'package:unit2/model/passo/land_property_loc.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/screens/passo/Land/add_land.dart';
import 'package:unit2/screens/passo/Land/edit_land/property_owner_info_edit.dart'; import 'package:unit2/screens/passo/Land/edit_land/property_owner_info_edit.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';
@ -53,7 +51,7 @@ class _LandLocationAndBoundariesEdit
return BlocConsumer<LandBoundariesEditBloc, return BlocConsumer<LandBoundariesEditBloc,
LandBoundariesEditState>( LandBoundariesEditState>(
listener: (context, state) { listener: (context, state) {
if (state is LandLocationEditLoaded) { if (state is LandBoundariesEditLoaded) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress?.dismiss(); progress?.dismiss();
} }
@ -70,7 +68,11 @@ class _LandLocationAndBoundariesEdit
'street': landLoc.street, 'street': landLoc.street,
'brgy': landLoc.barangay, 'brgy': landLoc.barangay,
'municipality': landLoc.municipality, 'municipality': landLoc.municipality,
'province': landLoc.province 'province': landLoc.province,
'north': state.land_boundaries_edit.north,
'south': state.land_boundaries_edit.south,
'east': state.land_boundaries_edit.east,
'west': state.land_boundaries_edit.west
}, },
enabled: true, enabled: true,
onChanged: () { onChanged: () {
@ -169,7 +171,7 @@ class _LandLocationAndBoundariesEdit
child: customTextField( child: customTextField(
"West", "", "west")) "West", "", "west"))
]), ]),
SizedBox( const SizedBox(
height: 50, height: 50,
), ),
Row( Row(
@ -212,13 +214,15 @@ class _LandLocationAndBoundariesEdit
?.value['province'], ?.value['province'],
); );
context.read<LandLocationEditBloc>() context
..add(UpdateLandLocationEdit( .read<LandLocationEditBloc>()
.add(UpdateLandLocationEdit(
land_loc_edit: location, land_loc_edit: location,
id: widget.land.id!)); id: widget.land.id!));
context.read<LandBoundariesEditBloc>() context
..add(UpdateLandBoundariesEdit( .read<LandBoundariesEditBloc>()
.add(UpdateLandBoundariesEdit(
land_boundaries_edit: land_boundaries_edit:
boundaries, boundaries,
id: widget.land.id!)); id: widget.land.id!));

View File

@ -1,14 +1,21 @@
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:unit2/bloc/passo/land/other_improvements/other_improvements_bloc.dart'; import 'package:unit2/bloc/passo/land/other_improvements/other_improvements_bloc.dart';
import 'package:unit2/model/passo/other_improvements.dart';
import 'package:unit2/screens/passo/Land/add_land/AddOtherImprovementModal.dart'; import 'package:unit2/screens/passo/Land/add_land/AddOtherImprovementModal.dart';
import 'package:unit2/screens/passo/Land/edit_land/AddOtherImprovementEditModal.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 OtherImprovementEditPage extends StatefulWidget { class OtherImprovementEditPage extends StatefulWidget {
Function PrevBtn; Function PrevBtn;
Function NextBtn; Function NextBtn;
OtherImprovementEditPage(this.PrevBtn, this.NextBtn); final int faasId;
OtherImprovementEditPage(this.PrevBtn, this.NextBtn, this.faasId);
@override @override
_OtherImprovementEditPage createState() => _OtherImprovementEditPage(); _OtherImprovementEditPage createState() => _OtherImprovementEditPage();
} }
@ -30,9 +37,25 @@ class _OtherImprovementEditPage extends State<OtherImprovementEditPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocConsumer<OtherImprovementsBloc, OtherImprovementsState>( return Scaffold(
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<OtherImprovementsBloc, OtherImprovementsState>(
listener: (context, state) { listener: (context, state) {
// TODO: implement listener if (state is OtherImprovementLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is OtherImprovementLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is OtherImprovementErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
}, builder: (context, state) { }, builder: (context, state) {
final state = context.watch<OtherImprovementsBloc>().state; final state = context.watch<OtherImprovementsBloc>().state;
if (state is OtherImprovementLoaded) { if (state is OtherImprovementLoaded) {
@ -120,14 +143,16 @@ class _OtherImprovementEditPage extends State<OtherImprovementEditPage> {
DataCell(Text(dataRow.fruitBearing! DataCell(Text(dataRow.fruitBearing!
? "Fruit Bearing" ? "Fruit Bearing"
: "Non-Fruit Bearing")), : "Non-Fruit Bearing")),
DataCell(Text(dataRow.quantity.toString()!)),
DataCell( DataCell(
Text(dataRow.noOfProductive.toString()!)), Text(dataRow.quantity.toString()!)),
DataCell(Text( DataCell(Text(
dataRow.noOfNonproductive.toString()!)), dataRow.noOfProductive.toString()!)),
DataCell(Text(dataRow.unitValue.toString()!)), DataCell(Text(dataRow.noOfNonproductive
.toString()!)),
DataCell( DataCell(
Text(dataRow.baseMarketval.toString()!)), Text(dataRow.unitValue.toString()!)),
DataCell(Text(
dataRow.baseMarketval.toString()!)),
DataCell(Row( DataCell(Row(
children: [ children: [
InkWell( InkWell(
@ -252,12 +277,37 @@ class _OtherImprovementEditPage extends State<OtherImprovementEditPage> {
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [Container(child: AddOtherImprovementModal())], children: [
Align(
alignment: Alignment.topCenter,
child: Container(
child: ConstrainedBox(
constraints: BoxConstraints(maxHeight: 500),
child: Container(
child: AddOtherImprovementEditModal(widget.faasId),
),
),
),
),
],
), ),
), ),
); );
} }
if (state is OtherImprovementErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<OtherImprovementsBloc>().add(
LoadOtherImprovementEdit(
other_imps: const <OtherImprovements>[],
ids: widget.faasId));
},
);
}
return Container(); return Container();
}); }),
),
);
} }
} }

View File

@ -1,21 +1,26 @@
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:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:searchfield/searchfield.dart'; import 'package:searchfield/searchfield.dart';
import 'package:shared_preferences/shared_preferences.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/land/land_ext_bloc/land_ext_edit_bloc.dart';
import 'package:unit2/bloc/passo/memoranda/memoranda_bloc.dart'; import 'package:unit2/bloc/passo/memoranda/memoranda_bloc.dart';
import 'package:unit2/bloc/passo/signatories/signatories_bloc.dart'; import 'package:unit2/bloc/passo/signatories/signatories_bloc.dart';
import 'package:unit2/model/passo/land_ext.dart'; import 'package:unit2/model/passo/land_ext.dart';
import 'package:unit2/model/passo/memoranda.dart'; import 'package:unit2/model/passo/memoranda.dart';
import 'package:unit2/model/passo/signatories.dart'; import 'package:unit2/model/passo/signatories.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/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/error_state.dart';
class LandSignatoriesEdit extends StatefulWidget { class LandSignatoriesEdit extends StatefulWidget {
Function onSAve; Function onSAve;
LandSignatoriesEdit(this.onSAve); final int faasId;
LandSignatoriesEdit(this.onSAve, this.faasId);
@override @override
_LandSignatoriesEdit createState() => _LandSignatoriesEdit(); _LandSignatoriesEdit createState() => _LandSignatoriesEdit();
@ -28,38 +33,86 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
String _memoranda = ""; String _memoranda = "";
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocConsumer<LandExtBloc, LandExtState>( return Scaffold(
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<LandExtEditBloc, LandExtEditState>(
listener: (context, state) { listener: (context, state) {
// TODO: implement listener if (state is LandExtEditLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is LandExtEditErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
}, },
builder: (context, state) { builder: (context, state) {
if (state is LandExtLoaded) { if (state is LandExtEditLoaded) {
final landext = state.land_ext_edit;
return BlocConsumer<SignatoriesBloc, SignatoriesState>( return BlocConsumer<SignatoriesBloc, SignatoriesState>(
listener: (context, state) { listener: (context, state) {
// TODO: implement listener if (state is SignatoriesErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
}, },
builder: (context, state) { builder: (context, state) {
if (state is SignatoriesLoaded) { if (state is SignatoriesLoaded) {
final signatories = state.signatories; final signatories = state.signatories;
return BlocConsumer<MemorandaBloc, MemorandaState>( return BlocConsumer<MemorandaBloc, MemorandaState>(
listener: (context, state) { listener: (context, state) {
// TODO: implement listener if (state is MemorandaLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is MemorandaErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
}, },
builder: (context, state) { builder: (context, state) {
if (state is MemorandaLoaded) { if (state is MemorandaLoaded) {
return SingleChildScrollView( return FormBuilder(
key: landEditKey,
initialValue: {
'land_qtr': landext.qtr.toString(),
'land_yr': landext.yr.toString(),
'app_date_land': landext.appraisedbyDate,
'rec_date_land': landext.recommendapprDate,
'apprvd_by_date_land': landext.approvedbyDate,
'sworn_statement_land': landext.swornstatementNo,
'date_received_land': landext.dateReceived,
'date_of_entry_land': landext.entryDateAssessment,
'by_land': landext.entryDateBy
},
enabled: true,
onChanged: () {
landEditKey.currentState!.save();
debugPrint(
landEditKey.currentState!.value.toString());
},
autovalidateMode: AutovalidateMode.disabled,
skipDisabled: true,
child: SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
Container( Container(
margin: const EdgeInsets.only( margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10), left: 0, top: 20, right: 0, bottom: 10),
child: const Text('PROPERTY ASSESSMENT cont..', child: const Text(
'PROPERTY ASSESSMENT cont..',
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18), fontWeight: FontWeight.bold,
fontSize: 18),
textAlign: TextAlign.left), textAlign: TextAlign.left),
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [ children: [
Row( Row(
children: [ children: [
@ -98,7 +151,8 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
), ),
const Text( const Text(
'EFFECTIVITY OF ASSESSMENT / REASSESSMENT :', 'EFFECTIVITY OF ASSESSMENT / REASSESSMENT :',
style: TextStyle(fontWeight: FontWeight.bold), style: TextStyle(
fontWeight: FontWeight.bold),
), ),
const SizedBox( const SizedBox(
height: 20, height: 20,
@ -114,7 +168,8 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
child: FormBuilderTextField( child: FormBuilderTextField(
name: 'land_qtr', name: 'land_qtr',
validator: validator:
FormBuilderValidators.compose([]), FormBuilderValidators.compose(
[]),
), ),
), ),
const SizedBox( const SizedBox(
@ -127,7 +182,8 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
child: FormBuilderTextField( child: FormBuilderTextField(
name: 'land_yr', name: 'land_yr',
validator: validator:
FormBuilderValidators.compose([]), FormBuilderValidators.compose(
[]),
), ),
), ),
], ],
@ -139,29 +195,39 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
left: 0, top: 40, right: 0, bottom: 10), left: 0, top: 40, right: 0, bottom: 10),
child: const Text('SIGNATORIES', child: const Text('SIGNATORIES',
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18), fontWeight: FontWeight.bold,
fontSize: 18),
textAlign: TextAlign.left), textAlign: TextAlign.left),
), ),
const SizedBox( const SizedBox(
height: 30, height: 30,
), ),
Align( const Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Text( child: Text(
'APPRAISED/ASSESSED BY:', 'APPRAISED/ASSESSED BY:',
style: TextStyle(fontWeight: FontWeight.bold), style:
TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.start, textAlign: TextAlign.start,
), ),
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [ children: [
Column( Column(
children: [ children: [
SizedBox( SizedBox(
width: 200, width: 200,
child: FormBuilderDropdown<Signatories>( child:
FormBuilderDropdown<Signatories>(
name: 'appraised_by_land', name: 'appraised_by_land',
decoration: InputDecoration(
labelText: landext
.appraisedbyName!,
labelStyle: const TextStyle(
color: Colors.black),
),
autofocus: false, autofocus: false,
items: signatories items: signatories
.map((signatories) => .map((signatories) =>
@ -172,7 +238,7 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
)) ))
.toList()), .toList()),
), ),
Text('Name'), const Text('Name'),
], ],
), ),
const SizedBox( const SizedBox(
@ -185,16 +251,17 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
child: FormBuilderDateTimePicker( child: FormBuilderDateTimePicker(
name: 'app_date_land', name: 'app_date_land',
initialEntryMode: initialEntryMode:
DatePickerEntryMode.calendarOnly, DatePickerEntryMode
.calendarOnly,
initialValue: DateTime.now(), initialValue: DateTime.now(),
inputType: InputType.date, inputType: InputType.date,
initialTime: initialTime: const TimeOfDay(
const TimeOfDay(hour: 8, minute: 0), hour: 8, minute: 0),
// locale: const Locale.fromSubtags(languageCode: 'fr'), // locale: const Locale.fromSubtags(languageCode: 'fr'),
), ),
), ),
Text('Date'), const Text('Date'),
], ],
), ),
], ],
@ -206,17 +273,26 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Text( child: Text(
'RECOMMENDING APPROVAL:', 'RECOMMENDING APPROVAL:',
style: TextStyle(fontWeight: FontWeight.bold), style: TextStyle(
fontWeight: FontWeight.bold),
)), )),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [ children: [
Column( Column(
children: [ children: [
SizedBox( SizedBox(
width: 200, width: 200,
child: FormBuilderDropdown<Signatories>( child:
FormBuilderDropdown<Signatories>(
name: 'rec_approval_land', name: 'rec_approval_land',
decoration: InputDecoration(
labelText: landext
.recommendapprName!,
labelStyle: const TextStyle(
color: Colors.black),
),
autofocus: false, autofocus: false,
items: signatories items: signatories
.map((signatories) => .map((signatories) =>
@ -227,7 +303,7 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
)) ))
.toList()), .toList()),
), ),
Text('Name'), const Text('Name'),
], ],
), ),
const SizedBox( const SizedBox(
@ -240,16 +316,17 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
child: FormBuilderDateTimePicker( child: FormBuilderDateTimePicker(
name: 'rec_date_land', name: 'rec_date_land',
initialEntryMode: initialEntryMode:
DatePickerEntryMode.calendarOnly, DatePickerEntryMode
.calendarOnly,
initialValue: DateTime.now(), initialValue: DateTime.now(),
inputType: InputType.date, inputType: InputType.date,
initialTime: initialTime: const TimeOfDay(
const TimeOfDay(hour: 8, minute: 0), hour: 8, minute: 0),
// locale: const Locale.fromSubtags(languageCode: 'fr'), // locale: const Locale.fromSubtags(languageCode: 'fr'),
), ),
), ),
Text('Date'), const Text('Date'),
], ],
), ),
], ],
@ -272,8 +349,15 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
children: [ children: [
SizedBox( SizedBox(
width: 200, width: 200,
child: FormBuilderDropdown<Signatories>( child:
FormBuilderDropdown<Signatories>(
name: 'apprvd_by_land', name: 'apprvd_by_land',
decoration: InputDecoration(
labelText:
landext.approvedbyName!,
labelStyle: const TextStyle(
color: Colors.black),
),
autofocus: false, autofocus: false,
items: signatories items: signatories
.map((signatories) => .map((signatories) =>
@ -284,7 +368,7 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
)) ))
.toList()), .toList()),
), ),
Text('Name'), const Text('Name'),
], ],
), ),
const SizedBox( const SizedBox(
@ -297,12 +381,13 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
child: FormBuilderDateTimePicker( child: FormBuilderDateTimePicker(
name: 'apprvd_by_date_land', name: 'apprvd_by_date_land',
initialEntryMode: initialEntryMode:
DatePickerEntryMode.calendarOnly, DatePickerEntryMode
.calendarOnly,
initialValue: DateTime.now(), initialValue: DateTime.now(),
inputType: InputType.date, inputType: InputType.date,
initialTime: initialTime: const TimeOfDay(
const TimeOfDay(hour: 8, minute: 0), hour: 8, minute: 0),
// locale: const Locale.fromSubtags(languageCode: 'fr'), // locale: const Locale.fromSubtags(languageCode: 'fr'),
), ),
), ),
@ -322,7 +407,7 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
)), )),
SizedBox( const SizedBox(
height: 50, height: 50,
), ),
SizedBox( SizedBox(
@ -338,7 +423,8 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
child: ListTile( child: ListTile(
title: Text( title: Text(
'${memoranda.memoranda}', '${memoranda.memoranda}',
overflow: TextOverflow.ellipsis, overflow:
TextOverflow.ellipsis,
), ),
), ),
)) ))
@ -356,16 +442,18 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
suggestionState: Suggestion.expand, suggestionState: Suggestion.expand,
onSuggestionTap: (memoranda) { onSuggestionTap: (memoranda) {
setState(() { setState(() {
_memoranda = memoranda.item!.memoranda!; _memoranda =
memoranda.item!.memoranda!;
}); });
focus.unfocus(); focus.unfocus();
}, },
)), )),
SizedBox( const SizedBox(
height: 30, height: 30,
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
Text('Sworn Statement No. :'), Text('Sworn Statement No. :'),
SizedBox( SizedBox(
@ -374,16 +462,18 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
child: FormBuilderTextField( child: FormBuilderTextField(
name: 'sworn_statement_land', name: 'sworn_statement_land',
decoration: InputDecoration(), decoration: InputDecoration(),
validator: FormBuilderValidators.compose([]), validator:
FormBuilderValidators.compose([]),
), ),
), ),
], ],
), ),
SizedBox( const SizedBox(
height: 30, height: 30,
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
Text('Date Received:'), Text('Date Received:'),
SizedBox( SizedBox(
@ -403,13 +493,15 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
), ),
], ],
), ),
SizedBox( const SizedBox(
height: 30, height: 30,
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
Text('Date of Entry in the Rec. of Ass. :'), const Text(
'Date of Entry in the Rec. of Ass. :'),
SizedBox( SizedBox(
width: 100, width: 100,
height: 20, height: 20,
@ -427,25 +519,27 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
), ),
], ],
), ),
SizedBox( const SizedBox(
height: 30, height: 30,
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
Text('By:'), const Text('By:'),
SizedBox( SizedBox(
width: 150, width: 150,
height: 20, height: 20,
child: FormBuilderTextField( child: FormBuilderTextField(
name: 'by_land', name: 'by_land',
decoration: InputDecoration(), decoration: const InputDecoration(),
validator: FormBuilderValidators.compose([]), validator:
FormBuilderValidators.compose([]),
), ),
), ),
], ],
), ),
SizedBox( const SizedBox(
height: 30, height: 30,
), ),
ElevatedButton( ElevatedButton(
@ -457,55 +551,48 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
tempID.getInt('landid')! - 1, tempID.getInt('landid')! - 1,
taxable: isTaxable, taxable: isTaxable,
exempt: isExempt, exempt: isExempt,
qtr: int.parse( qtr: int.parse(landEditKey
landKey.currentState!.value['land_qtr']), .currentState!.value['land_qtr']),
yr: int.parse( yr: int.parse(landEditKey
landKey.currentState!.value['land_yr']), .currentState!.value['land_yr']),
appraisedbyName: landKey.currentState!.value['appraised_by_land'].firstname + appraisedbyName: landEditKey.currentState!.value['appraised_by_land'].firstname +
' ' + ' ' +
landKey landEditKey
.currentState! .currentState!
.value['appraised_by_land'] .value['appraised_by_land']
.middlename + .middlename +
' ' + ' ' +
landKey.currentState! landEditKey
.value['appraised_by_land'].lastname,
appraisedbyDate: landKey
.currentState!.value['app_date_land'],
recommendapprName: landKey
.currentState! .currentState!
.value['rec_approval_land'] .value['appraised_by_land']
.firstname + .lastname,
' ' + appraisedbyDate: landEditKey
landKey
.currentState! .currentState!
.value['rec_approval_land'] .value['app_date_land'],
.middlename + recommendapprName: landEditKey.currentState!.value['rec_approval_land'].firstname +
' ' + ' ' +
landKey.currentState! landEditKey.currentState!.value['rec_approval_land'].middlename +
.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 + landEditKey.currentState!.value['rec_approval_land'].lastname,
' ' + recommendapprDate: landEditKey.currentState!.value['rec_date_land'],
landKey.currentState!.value['apprvd_by_land'].lastname, approvedbyName: landEditKey.currentState!.value['apprvd_by_land'].firstname + ' ' + landEditKey.currentState!.value['apprvd_by_land'].middlename + ' ' + landEditKey.currentState!.value['apprvd_by_land'].lastname,
approvedbyDate: landKey.currentState!.value['apprvd_by_date_land'], approvedbyDate: landEditKey.currentState!.value['apprvd_by_date_land'],
memoranda: _memoranda, memoranda: _memoranda,
swornstatementNo: landKey.currentState!.value['sworn_statement_land'], swornstatementNo: landEditKey.currentState!.value['sworn_statement_land'],
dateReceived: landKey.currentState!.value['date_received_land'], dateReceived: landEditKey.currentState!.value['date_received_land'],
entryDateAssessment: landKey.currentState!.value['date_of_entry_land'], entryDateAssessment: landEditKey.currentState!.value['date_of_entry_land'],
entryDateBy: landKey.currentState!.value['by_land']); entryDateBy: landEditKey.currentState!.value['by_land']);
context.read<LandExtBloc>() context.read<LandExtEditBloc>().add(
..add(UpdateLandExt(landext: ext)); UpdateLandExtEdit(
land_ext_edit: ext,
id: widget.faasId));
widget.onSAve(); widget.onSAve();
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: primary, backgroundColor: primary,
foregroundColor: Colors.red), foregroundColor: Colors.red),
child: SizedBox( child: const SizedBox(
width: 250, width: 250,
height: 50, height: 50,
child: Align( child: Align(
@ -520,13 +607,20 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
), ),
), ),
), ),
SizedBox( const SizedBox(
height: 30, height: 30,
), ),
], ],
)); )),
);
} }
return Container(); if (state is MemorandaErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context
.read<MemorandaBloc>()
.add(const LoadMemoranda());
}, },
); );
} }
@ -534,8 +628,33 @@ class _LandSignatoriesEdit extends State<LandSignatoriesEdit> {
}, },
); );
} }
if (state is SignatoriesErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context
.read<SignatoriesBloc>()
.add(const LoadSignatories());
},
);
}
return Container(); return Container();
}, },
); );
} }
if (state is LandExtEditErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<LandExtEditBloc>().add(LoadLandExtEdit(
land_ext_edit: LandExt(), id: widget.faasId));
},
);
}
return Container();
},
),
),
);
}
} }

View File

@ -1,14 +1,22 @@
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:unit2/bloc/passo/bulding/property_assessment_edit/property_assessment_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/model/passo/land_property_assessment.dart';
import 'package:unit2/screens/passo/Land/add_land/AddPropertyAssessmentModal.dart'; import 'package:unit2/screens/passo/Land/add_land/AddPropertyAssessmentModal.dart';
import 'package:unit2/screens/passo/Land/edit_land/AddPropertyAssessmentEditModal.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 LandPropertyAssessmentEditPage extends StatefulWidget { class LandPropertyAssessmentEditPage extends StatefulWidget {
Function PrevBtn; Function PrevBtn;
Function NextBtn; Function NextBtn;
LandPropertyAssessmentEditPage(this.PrevBtn, this.NextBtn); final int faasId;
LandPropertyAssessmentEditPage(this.PrevBtn, this.NextBtn, this.faasId);
@override @override
_LandPropertyAssessmentEditPage createState() => _LandPropertyAssessmentEditPage createState() =>
_LandPropertyAssessmentEditPage(); _LandPropertyAssessmentEditPage();
@ -32,9 +40,25 @@ class _LandPropertyAssessmentEditPage
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocConsumer<LandPropertyAssessmentBloc, return Scaffold(
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<LandPropertyAssessmentBloc,
LandPropertyAssessmentState>(listener: (context, state) { LandPropertyAssessmentState>(listener: (context, state) {
// TODO: implement listener if (state is LandPropertyAssessmentLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is LandPropertyAssessmentLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is LandPropertyAssessmentErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
}, builder: (context, state) { }, builder: (context, state) {
final state = context.watch<LandPropertyAssessmentBloc>().state; final state = context.watch<LandPropertyAssessmentBloc>().state;
if (state is LandPropertyAssessmentLoaded) { if (state is LandPropertyAssessmentLoaded) {
@ -212,9 +236,10 @@ class _LandPropertyAssessmentEditPage
successAlert(context, "Deletion Successful", successAlert(context, "Deletion Successful",
"Extra item has been deleted successfully", () { "Extra item has been deleted successfully", () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context context.read<LandPropertyAssessmentBloc>().add(
.read<LandPropertyAssessmentBloc>() LoadLandPropertyAssessmentEdit(
.add(const LoadLandPropertyAssessment()); assessment: <LandPropertyAssessment>[],
id: widget.faasId));
}); });
}); });
} }
@ -234,12 +259,29 @@ class _LandPropertyAssessmentEditPage
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [Container(child: AddPropertyAssessmentModal())], children: [
Container(
child: AddPropertyAssessmentEditModal(widget.faasId))
],
), ),
), ),
); );
} }
if (state is LandPropertyAssessmentErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<LandPropertyAssessmentBloc>().add(
LoadLandPropertyAssessmentEdit(
assessment: const <LandPropertyAssessment>[],
id: widget.faasId));
},
);
}
return Container(); return Container();
}); }),
),
);
} }
} }

View File

@ -1,14 +1,20 @@
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:unit2/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart'; import 'package:unit2/bloc/passo/land/land_value_adjustments/land_value_adjustments_bloc.dart';
import 'package:unit2/model/passo/land_value_adjustment.dart';
import 'package:unit2/screens/passo/Land/add_land/AddLandValueAdjustmentModal.dart'; import 'package:unit2/screens/passo/Land/add_land/AddLandValueAdjustmentModal.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 ValueAdjustmentEditPage extends StatefulWidget { class ValueAdjustmentEditPage extends StatefulWidget {
Function PrevBtn; Function PrevBtn;
Function NextBtn; Function NextBtn;
ValueAdjustmentEditPage(this.PrevBtn, this.NextBtn); final int faasId;
ValueAdjustmentEditPage(this.PrevBtn, this.NextBtn, this.faasId);
@override @override
_ValueAdjustmentEditPage createState() => _ValueAdjustmentEditPage(); _ValueAdjustmentEditPage createState() => _ValueAdjustmentEditPage();
} }
@ -30,9 +36,26 @@ class _ValueAdjustmentEditPage extends State<ValueAdjustmentEditPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocConsumer<LandValueAdjustmentsBloc, LandValueAdjustmentsState>( return Scaffold(
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child:
BlocConsumer<LandValueAdjustmentsBloc, LandValueAdjustmentsState>(
listener: (context, state) { listener: (context, state) {
// TODO: implement listener if (state is LandValueAdjustmentsLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is LandValueAdjustmentsLoaded) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is LandValueAdjustmentsErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
}, builder: (context, state) { }, builder: (context, state) {
final state = context.watch<LandValueAdjustmentsBloc>().state; final state = context.watch<LandValueAdjustmentsBloc>().state;
if (state is LandValueAdjustmentsLoaded) { if (state is LandValueAdjustmentsLoaded) {
@ -107,7 +130,8 @@ class _ValueAdjustmentEditPage extends State<ValueAdjustmentEditPage> {
return DataRow( return DataRow(
cells: [ cells: [
DataCell(Text(dataRow.baseMarketval!)), DataCell(Text(dataRow.baseMarketval!)),
DataCell(Text(dataRow.adjustmentFactors!)), DataCell(
Text(dataRow.adjustmentFactors!)),
DataCell(Text(dataRow.adjustment!)), DataCell(Text(dataRow.adjustment!)),
DataCell(Text(dataRow.valueAdjustment!)), DataCell(Text(dataRow.valueAdjustment!)),
DataCell(Text(dataRow.marketValue!)), DataCell(Text(dataRow.marketValue!)),
@ -213,9 +237,9 @@ class _ValueAdjustmentEditPage extends State<ValueAdjustmentEditPage> {
successAlert(context, "Deletion Successful", successAlert(context, "Deletion Successful",
"Extra item has been deleted successfully", () { "Extra item has been deleted successfully", () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context context.read<LandValueAdjustmentsBloc>().add(
.read<LandValueAdjustmentsBloc>() LoadLandValueAdjustmentsEdit(
.add(const LoadLandValueAdjustments()); val_adj: <ValueAdjustments>[], id: widget.faasId));
}); });
}); });
} }
@ -240,7 +264,20 @@ class _ValueAdjustmentEditPage extends State<ValueAdjustmentEditPage> {
), ),
); );
} }
if (state is LandValueAdjustmentsErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<LandValueAdjustmentsBloc>().add(
LoadLandValueAdjustmentsEdit(
val_adj: const <ValueAdjustments>[],
id: widget.faasId));
},
);
}
return Container(); return Container();
}); }),
),
);
} }
} }

View File

@ -90,8 +90,11 @@ class BuildingHome extends StatelessWidget {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait..."); progress!.showWithText("Please wait...");
} }
if (state is PropertyInfoLoaded || if (state is PropertyInfoLoaded) {
state is PropertyInfoErrorState) { final progress = ProgressHUD.of(context);
progress?.dismiss();
}
if (state is PropertyInfoErrorState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress?.dismiss(); progress?.dismiss();
} }

View File

@ -21,6 +21,7 @@ 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_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_ext_bloc/land_ext_edit_bloc.dart';
import 'package:unit2/bloc/passo/land/land_location_edit/land_location_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_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';
@ -39,10 +40,15 @@ 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_appr.dart';
import 'package:unit2/model/passo/land_ext.dart';
import 'package:unit2/model/passo/land_property_assessment.dart';
import 'package:unit2/model/passo/land_property_boundaries.dart'; import 'package:unit2/model/passo/land_property_boundaries.dart';
import 'package:unit2/model/passo/land_property_loc.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/land_value_adjustment.dart';
import 'package:unit2/model/passo/other_improvements.dart';
import 'package:unit2/model/passo/property_appraisal.dart'; import 'package:unit2/model/passo/property_appraisal.dart';
import 'package:unit2/model/passo/property_appraisal_edit.dart'; import 'package:unit2/model/passo/property_appraisal_edit.dart';
import 'package:unit2/model/passo/property_assessment_edit.dart'; import 'package:unit2/model/passo/property_assessment_edit.dart';
@ -300,14 +306,20 @@ Card _listCard(LandPropertyOwner property_info, context, index) {
..add(LoadLandLocationEdit( ..add(LoadLandLocationEdit(
land_loc_edit: LandPropertyLoc(), land_loc_edit: LandPropertyLoc(),
id: property_info.id))), id: property_info.id))),
BlocProvider(
create: (context) => LandExtEditBloc()
..add(LoadLandExtEdit(
land_ext_edit: LandExt(), id: property_info.id))),
BlocProvider( BlocProvider(
create: (context) => LandBoundariesEditBloc() create: (context) => LandBoundariesEditBloc()
..add(LoadLandBoundariesEdit( ..add(LoadLandBoundariesEdit(
land_boundaries_edit: LandPropertyBoundaries(), land_boundaries_edit: LandPropertyBoundaries(),
id: property_info.id))), id: property_info.id))),
BlocProvider( BlocProvider(
create: (context) => create: (context) => LandAppraisalBloc()
LandAppraisalBloc()..add(LoadLandAppraisal())), ..add(LoadLandAppraisalEdit(
land_appr: const <LandAppr>[],
id: property_info.id!))),
BlocProvider( BlocProvider(
create: (context) => LandClassificationBloc() create: (context) => LandClassificationBloc()
..add(LoadLandClassification())), ..add(LoadLandClassification())),
@ -316,8 +328,10 @@ Card _listCard(LandPropertyOwner property_info, context, index) {
..add(LoadLandSubClassification( ..add(LoadLandSubClassification(
cityCode: "1", classCode: 1))), cityCode: "1", classCode: 1))),
BlocProvider( BlocProvider(
create: (context) => create: (context) => OtherImprovementsBloc()
OtherImprovementsBloc()..add(LoadOtherImprovement())), ..add(LoadOtherImprovementEdit(
other_imps: const <OtherImprovements>[],
ids: property_info.id!))),
BlocProvider( BlocProvider(
create: (context) => create: (context) =>
TypeOfLocationBloc()..add(LoadTypeOfLocation())), TypeOfLocationBloc()..add(LoadTypeOfLocation())),
@ -326,7 +340,9 @@ Card _listCard(LandPropertyOwner property_info, context, index) {
TypeOfRoadBloc()..add(LoadTypeOfRoad())), TypeOfRoadBloc()..add(LoadTypeOfRoad())),
BlocProvider( BlocProvider(
create: (context) => LandPropertyAssessmentBloc() create: (context) => LandPropertyAssessmentBloc()
..add(LoadLandPropertyAssessment())), ..add(LoadLandPropertyAssessmentEdit(
assessment: <LandPropertyAssessment>[],
id: property_info.id!))),
BlocProvider( BlocProvider(
create: (context) => LandTreesImprovementsBloc() create: (context) => LandTreesImprovementsBloc()
..add(LoadLandTreesImprovements())), ..add(LoadLandTreesImprovements())),
@ -334,7 +350,9 @@ Card _listCard(LandPropertyOwner property_info, context, index) {
create: (context) => LandExtBloc()..add(LoadLandExt())), create: (context) => LandExtBloc()..add(LoadLandExt())),
BlocProvider( BlocProvider(
create: (context) => LandValueAdjustmentsBloc() create: (context) => LandValueAdjustmentsBloc()
..add(LoadLandValueAdjustments())), ..add(LoadLandValueAdjustmentsEdit(
val_adj: <ValueAdjustments>[],
id: property_info.id!))),
BlocProvider( BlocProvider(
create: (context) => create: (context) =>
SignatoriesBloc()..add(LoadSignatories())), SignatoriesBloc()..add(LoadSignatories())),

View File

@ -51,7 +51,7 @@ class _PassoDashBoard extends State<PassoDashBoard> {
child: const LandHome(), child: const LandHome(),
), ),
EmptyData( EmptyData(
message: "Development ongoing ...", message: "Sorry, this page is under construction.",
) )
], ],
), ),

View File

@ -24,6 +24,7 @@ class EditBasicProfileInfoScreen extends StatefulWidget {
State<EditBasicProfileInfoScreen> createState() => State<EditBasicProfileInfoScreen> createState() =>
_EditBasicProfileInfoScreenState(); _EditBasicProfileInfoScreenState();
} }
final bdayController = TextEditingController(); final bdayController = TextEditingController();
ProfileOtherInfo? selectedIndigency; ProfileOtherInfo? selectedIndigency;
ProfileOtherInfo? selectedEthnicity; ProfileOtherInfo? selectedEthnicity;
@ -36,13 +37,13 @@ String? selectedStatus;
String? selectedExtension; String? selectedExtension;
final _formKey = GlobalKey<FormBuilderState>(); final _formKey = GlobalKey<FormBuilderState>();
class _EditBasicProfileInfoScreenState class _EditBasicProfileInfoScreenState
extends State<EditBasicProfileInfoScreen> { extends State<EditBasicProfileInfoScreen> {
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocBuilder<ProfileBloc, ProfileState>( return BlocBuilder<ProfileBloc, ProfileState>(
@ -52,7 +53,8 @@ class _EditBasicProfileInfoScreenState
selectedSex = state.sexes.firstWhere((element) => selectedSex = state.sexes.firstWhere((element) =>
element.toLowerCase() == element.toLowerCase() ==
state.primaryInformation.sex!.toLowerCase()); state.primaryInformation.sex!.toLowerCase());
if (state.primaryInformation.bloodType != null && state.primaryInformation.bloodType != "N/A") { if (state.primaryInformation.bloodType != null &&
state.primaryInformation.bloodType != "N/A") {
selectedBloodType = state.bloodTypes.firstWhere((element) => selectedBloodType = state.bloodTypes.firstWhere((element) =>
element.toLowerCase() == element.toLowerCase() ==
state.primaryInformation.bloodType?.toLowerCase()); state.primaryInformation.bloodType?.toLowerCase());
@ -99,9 +101,6 @@ class _EditBasicProfileInfoScreenState
state.primaryInformation.disability!.toLowerCase()); state.primaryInformation.disability!.toLowerCase());
} }
return Container( return Container(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32), padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
child: FormBuilder( child: FormBuilder(
@ -116,9 +115,7 @@ class _EditBasicProfileInfoScreenState
), ),
FormBuilderTextField( FormBuilderTextField(
name: "lastname", name: "lastname",
inputFormatters: [ inputFormatters: [UpperCaseTextFormatter()],
UpperCaseTextFormatter()
],
initialValue: state.primaryInformation.lastName, initialValue: state.primaryInformation.lastName,
decoration: normalTextFieldStyle("Last name *", ""), decoration: normalTextFieldStyle("Last name *", ""),
validator: FormBuilderValidators.required( validator: FormBuilderValidators.required(
@ -129,9 +126,7 @@ class _EditBasicProfileInfoScreenState
), ),
FormBuilderTextField( FormBuilderTextField(
name: "firstname", name: "firstname",
inputFormatters: [ inputFormatters: [UpperCaseTextFormatter()],
UpperCaseTextFormatter()
],
initialValue: state.primaryInformation.firstName, initialValue: state.primaryInformation.firstName,
decoration: normalTextFieldStyle("First name *", ""), decoration: normalTextFieldStyle("First name *", ""),
validator: FormBuilderValidators.required( validator: FormBuilderValidators.required(
@ -146,12 +141,12 @@ class _EditBasicProfileInfoScreenState
Flexible( Flexible(
flex: 2, flex: 2,
child: FormBuilderTextField( child: FormBuilderTextField(
inputFormatters: [ inputFormatters: [UpperCaseTextFormatter()],
UpperCaseTextFormatter()
],
name: "middlename", name: "middlename",
initialValue: state.primaryInformation.middleName??'', initialValue:
decoration: normalTextFieldStyle("Middle name", ""), state.primaryInformation.middleName ?? '',
decoration:
normalTextFieldStyle("Middle name", ""),
), ),
), ),
const SizedBox( const SizedBox(
@ -164,13 +159,11 @@ class _EditBasicProfileInfoScreenState
value: selectedExtension, value: selectedExtension,
decoration: decoration:
normalTextFieldStyle("Name Extension", ""), normalTextFieldStyle("Name Extension", ""),
items: state.extensions items: state.extensions
.map((element) => DropdownMenuItem<String>( .map((element) => DropdownMenuItem<String>(
value: element, child: Text(element))) value: element, child: Text(element)))
.toList(), .toList(),
onChanged: (e) { onChanged: (e) {
selectedExtension = e; selectedExtension = e;
}, },
), ),
@ -193,7 +186,8 @@ class _EditBasicProfileInfoScreenState
errorText: "This field is required"), errorText: "This field is required"),
timeHintText: "Birthdate", timeHintText: "Birthdate",
decoration: decoration:
normalTextFieldStyle("Birthdate *", "*").copyWith( normalTextFieldStyle("Birthdate *", "*")
.copyWith(
prefixIcon: const Icon( prefixIcon: const Icon(
Icons.date_range, Icons.date_range,
color: Colors.black87, color: Colors.black87,
@ -221,7 +215,7 @@ class _EditBasicProfileInfoScreenState
value: element, child: Text(element))) value: element, child: Text(element)))
.toList(), .toList(),
onChanged: (e) { onChanged: (e) {
selectedSex= e; selectedSex = e;
}, },
), ),
) )
@ -240,7 +234,8 @@ class _EditBasicProfileInfoScreenState
initialValue: selectedBloodType, initialValue: selectedBloodType,
validator: FormBuilderValidators.required( validator: FormBuilderValidators.required(
errorText: "This field is required"), errorText: "This field is required"),
decoration: normalTextFieldStyle("Blood type *", ""), decoration:
normalTextFieldStyle("Blood type *", ""),
name: "bloodtype", name: "bloodtype",
items: state.bloodTypes items: state.bloodTypes
.map((element) => DropdownMenuItem<String>( .map((element) => DropdownMenuItem<String>(
@ -259,7 +254,8 @@ class _EditBasicProfileInfoScreenState
flex: 1, flex: 1,
child: FormBuilderDropdown<String>( child: FormBuilderDropdown<String>(
initialValue: selectedStatus, initialValue: selectedStatus,
decoration: normalTextFieldStyle("Civil status *", ""), decoration:
normalTextFieldStyle("Civil status *", ""),
validator: FormBuilderValidators.required( validator: FormBuilderValidators.required(
errorText: "This field is required"), errorText: "This field is required"),
name: "extension", name: "extension",
@ -309,7 +305,8 @@ class _EditBasicProfileInfoScreenState
initialValue: state.primaryInformation.heightM initialValue: state.primaryInformation.heightM
.toString() .toString()
.toString(), .toString(),
decoration: normalTextFieldStyle("Height (Meter) *", ""), decoration: normalTextFieldStyle(
"Height (Meter) *", ""),
), ),
), ),
const SizedBox( const SizedBox(
@ -317,13 +314,13 @@ class _EditBasicProfileInfoScreenState
), ),
Flexible( Flexible(
flex: 1, flex: 1,
child: FormBuilderTextField( child: FormBuilderTextField(
validator: numericRequired, validator: numericRequired,
name: "weigth", name: "weigth",
initialValue: initialValue: state.primaryInformation.weightKg!
state.primaryInformation.weightKg!.toString(), .toString(),
decoration: normalTextFieldStyle("Weight (Kg) *", ""), decoration:
normalTextFieldStyle("Weight (Kg) *", ""),
), ),
), ),
]), ]),
@ -338,7 +335,8 @@ class _EditBasicProfileInfoScreenState
flex: 1, flex: 1,
child: FormBuilderTextField( child: FormBuilderTextField(
name: "prefix", name: "prefix",
initialValue: state.primaryInformation.titlePrefix initialValue: state
.primaryInformation.titlePrefix
.toString() .toString()
.toString(), .toString(),
decoration: normalTextFieldStyle( decoration: normalTextFieldStyle(
@ -352,7 +350,8 @@ class _EditBasicProfileInfoScreenState
flex: 1, flex: 1,
child: FormBuilderTextField( child: FormBuilderTextField(
name: "suffix", name: "suffix",
initialValue: state.primaryInformation.titleSuffix, initialValue:
state.primaryInformation.titleSuffix,
decoration: normalTextFieldStyle( decoration: normalTextFieldStyle(
"Title Suffix", "PhD.,MD.,MS.,CE"), "Title Suffix", "PhD.,MD.,MS.,CE"),
), ),
@ -371,7 +370,8 @@ class _EditBasicProfileInfoScreenState
child: DropdownButtonFormField<ProfileOtherInfo>( child: DropdownButtonFormField<ProfileOtherInfo>(
isExpanded: true, isExpanded: true,
value: selectedIndigency, value: selectedIndigency,
decoration: normalTextFieldStyle("Indigency", ""), decoration:
normalTextFieldStyle("Indigency", ""),
items: state.indigenous items: state.indigenous
.map((element) => .map((element) =>
DropdownMenuItem<ProfileOtherInfo>( DropdownMenuItem<ProfileOtherInfo>(
@ -392,7 +392,8 @@ class _EditBasicProfileInfoScreenState
child: DropdownButtonFormField<ProfileOtherInfo>( child: DropdownButtonFormField<ProfileOtherInfo>(
isExpanded: true, isExpanded: true,
value: selectedEthnicity, value: selectedEthnicity,
decoration: normalTextFieldStyle("Ethnicity", ""), decoration:
normalTextFieldStyle("Ethnicity", ""),
items: state.ethnicity items: state.ethnicity
.map((element) => .map((element) =>
DropdownMenuItem<ProfileOtherInfo>( DropdownMenuItem<ProfileOtherInfo>(
@ -402,8 +403,7 @@ class _EditBasicProfileInfoScreenState
onChanged: (e) { onChanged: (e) {
selectedEthnicity = e; selectedEthnicity = e;
print(selectedEthnicity!.name); print(selectedEthnicity!.name);
print(selectedEthnicity! print(selectedEthnicity!.id);
.id);
}, },
), ),
), ),
@ -421,7 +421,8 @@ class _EditBasicProfileInfoScreenState
child: DropdownButtonFormField<ProfileOtherInfo>( child: DropdownButtonFormField<ProfileOtherInfo>(
isExpanded: true, isExpanded: true,
value: selectedReligion, value: selectedReligion,
decoration: normalTextFieldStyle("Religion", ""), decoration:
normalTextFieldStyle("Religion", ""),
items: state.religion items: state.religion
.map((element) => .map((element) =>
DropdownMenuItem<ProfileOtherInfo>( DropdownMenuItem<ProfileOtherInfo>(
@ -440,10 +441,10 @@ class _EditBasicProfileInfoScreenState
Flexible( Flexible(
flex: 1, flex: 1,
child: DropdownButtonFormField<ProfileOtherInfo>( child: DropdownButtonFormField<ProfileOtherInfo>(
isExpanded: true, isExpanded: true,
value: selectedDisability, value: selectedDisability,
decoration: normalTextFieldStyle("Disability", ""), decoration:
normalTextFieldStyle("Disability", ""),
items: state.disability items: state.disability
.map((element) => .map((element) =>
DropdownMenuItem<ProfileOtherInfo>( DropdownMenuItem<ProfileOtherInfo>(
@ -464,31 +465,34 @@ class _EditBasicProfileInfoScreenState
width: double.infinity, width: double.infinity,
height: 60, height: 60,
child: ElevatedButton( child: ElevatedButton(
style: style: mainBtnStyle(
mainBtnStyle(primary, Colors.transparent, second), primary, Colors.transparent, second),
onPressed: () { onPressed: () {
if (_formKey.currentState!.saveAndValidate()) { if (_formKey.currentState!.saveAndValidate()) {
String lastName = String lastName =
_formKey.currentState!.value['lastname']; _formKey.currentState!.value['lastname'];
String firstName = String firstName =
_formKey.currentState!.value['firstname']; _formKey.currentState!.value['firstname'];
String? middleName = String? middleName = _formKey
_formKey.currentState?.value['middlename']; .currentState?.value['middlename'];
String? pref = String? pref =
_formKey.currentState?.value['prefix']; _formKey.currentState?.value['prefix'];
String suf = _formKey.currentState?.value['suffix']; String suf =
_formKey.currentState?.value['suffix'];
DateTime birthdate = DateTime birthdate =
DateTime.parse(bdayController.text); DateTime.parse(bdayController.text);
double? hM = double? hM =
_formKey.currentState!.value['height'] == null _formKey.currentState!.value['height'] ==
null
? null ? null
: double.tryParse( : double.tryParse(_formKey
_formKey.currentState?.value['height']); .currentState?.value['height']);
double? wKg = double? wKg =
_formKey.currentState!.value['weigth'] == null _formKey.currentState!.value['weigth'] ==
null
? null ? null
: double.tryParse( : double.tryParse(_formKey
_formKey.currentState?.value['weigth']); .currentState?.value['weigth']);
Profile primaryInformation = Profile( Profile primaryInformation = Profile(
webuserId: null, webuserId: null,
id: state.primaryInformation.id, id: state.primaryInformation.id,
@ -499,14 +503,21 @@ class _EditBasicProfileInfoScreenState
sex: selectedSex, sex: selectedSex,
birthdate: birthdate, birthdate: birthdate,
civilStatus: selectedStatus, civilStatus: selectedStatus,
bloodType: selectedBloodType =="NONE"?null:selectedBloodType, bloodType: selectedBloodType == "NONE"
? null
: selectedBloodType,
heightM: hM, heightM: hM,
weightKg: wKg, weightKg: wKg,
photoPath: state.primaryInformation.photoPath, photoPath:
esigPath: state.primaryInformation.esigPath, state.primaryInformation.photoPath,
maidenName: state.primaryInformation.maidenName, esigPath:
deceased: state.primaryInformation.deceased, state.primaryInformation.esigPath,
uuidQrcode: state.primaryInformation.uuidQrcode, maidenName:
state.primaryInformation.maidenName,
deceased:
state.primaryInformation.deceased,
uuidQrcode:
state.primaryInformation.uuidQrcode,
titlePrefix: pref, titlePrefix: pref,
titleSuffix: suf, titleSuffix: suf,
showTitleId: showTitleId:
@ -525,7 +536,8 @@ class _EditBasicProfileInfoScreenState
genderId: selectedGender?.id, genderId: selectedGender?.id,
indigencyId: selectedIndigency?.id, indigencyId: selectedIndigency?.id,
profileId: widget.profileId, profileId: widget.profileId,
profileInformation: primaryInformation, profileInformation:
primaryInformation,
religionId: selectedReligion?.id, religionId: selectedReligion?.id,
token: widget.token)); token: widget.token));
} }

View File

@ -349,7 +349,8 @@ class _SpouseAlertState extends State<SpouseAlert> {
], ],
itemHeight: 100, itemHeight: 100,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: widget.positions suggestions: widget.positions
.map((PositionTitle position) => .map((PositionTitle position) =>
SearchFieldListItem( SearchFieldListItem(

View File

@ -383,7 +383,8 @@ class _SpouseEditAlertState extends State<SpouseEditAlert> {
suggestionDirection: suggestionDirection:
SuggestionDirection.down, SuggestionDirection.down,
itemHeight: 100, itemHeight: 100,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: widget.positions suggestions: widget.positions
.map((PositionTitle position) => .map((PositionTitle position) =>
SearchFieldListItem( SearchFieldListItem(

View File

@ -1,4 +1,3 @@
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';
@ -6,6 +5,8 @@ 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:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart'; import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/profile/basic_information/primary-information.dart';
import 'package:unit2/screens/profile/components/basic_information/edit_basic_info_modal.dart'; import 'package:unit2/screens/profile/components/basic_information/edit_basic_info_modal.dart';
import 'package:unit2/theme-data.dart/colors.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';
@ -30,6 +31,7 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
bool enabled = false; bool enabled = false;
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
Profile? profile;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: context.watch<ProfileBloc>().state title: context.watch<ProfileBloc>().state
@ -62,7 +64,10 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
padding: const EdgeInsets.all(24), padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87, backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white), indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<ProfileBloc, ProfileState>( child: BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
if (state is UserLoggedIn) {
return BlocConsumer<ProfileBloc, ProfileState>(
listener: (context, state) { listener: (context, state) {
if (state is BasicPrimaryInformationLoadingState) { if (state is BasicPrimaryInformationLoadingState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
@ -76,36 +81,49 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
progress!.dismiss(); progress!.dismiss();
} }
if (state is BasicProfileInfoEditedState) { if (state is BasicProfileInfoEditedState) {
profile = Profile.fromJson(state.response['data']);
if (state.response['success']) { if (state.response['success']) {
successAlert(context, "Updated Successfull!", successAlert(context, "Updated Successfull!",
state.response['message'], () { state.response['message'], () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context.read<ProfileBloc>().add(LoadBasicPrimaryInfo()); context
.read<ProfileBloc>()
.add(LoadBasicPrimaryInfo());
}); });
} else { } else {
errorAlert(context, "Update Failed", errorAlert(context, "Update Failed",
"Something went wrong. Please try again.", () { "Something went wrong. Please try again.", () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context.read<ProfileBloc>().add(LoadBasicPrimaryInfo()); context
.read<ProfileBloc>()
.add(LoadBasicPrimaryInfo());
}); });
} }
} }
}, },
builder: (context, state) { builder: (context, state) {
if (state is BasicInformationProfileLoaded) { if (state is BasicInformationProfileLoaded) {
profile = state.primaryBasicInformation;
return Container( return Container(
padding: padding: const EdgeInsets.symmetric(
const EdgeInsets.symmetric(vertical: 24, horizontal: 24), vertical: 24, horizontal: 24),
child: Column( child: Column(
children: [ children: [
const SizedBox( const SizedBox(
height: 28, height: 28,
), ),
FormBuilderTextField( FormBuilderTextField(
enabled: enabled, enabled: false,
name: lastname, name: lastname,
initialValue: state.primaryBasicInformation.lastName!, initialValue:
decoration: normalTextFieldStyle("Last name", ""), state.primaryBasicInformation.lastName!,
style: const TextStyle(color: Colors.black),
decoration: normalTextFieldStyle("Last name", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle:
const TextStyle(color: Colors.black)),
), ),
const SizedBox( const SizedBox(
height: 15, height: 15,
@ -113,8 +131,15 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
FormBuilderTextField( FormBuilderTextField(
enabled: enabled, enabled: enabled,
name: firstname, name: firstname,
initialValue: state.primaryBasicInformation.firstName!, initialValue:
decoration: normalTextFieldStyle("First name", ""), state.primaryBasicInformation.firstName!,
style: const TextStyle(color: Colors.black),
decoration: normalTextFieldStyle("First name", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle:
const TextStyle(color: Colors.black)),
), ),
const SizedBox( const SizedBox(
height: 15, height: 15,
@ -127,10 +152,17 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
child: FormBuilderTextField( child: FormBuilderTextField(
enabled: enabled, enabled: enabled,
name: middlename, name: middlename,
initialValue: state.primaryBasicInformation.middleName??'' initialValue: state.primaryBasicInformation
, .middleName ??
'',
style: const TextStyle(color: Colors.black),
decoration: decoration:
normalTextFieldStyle("Middle name", ""), normalTextFieldStyle("Middle name", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle: const TextStyle(
color: Colors.black)),
), ),
), ),
const SizedBox( const SizedBox(
@ -143,8 +175,14 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
name: extensionName, name: extensionName,
initialValue: state.primaryBasicInformation initialValue: state.primaryBasicInformation
.nameExtension ??= 'N/A', .nameExtension ??= 'N/A',
decoration: style: const TextStyle(color: Colors.black),
normalTextFieldStyle("Name extension", ""), decoration: normalTextFieldStyle(
"Name extension", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle: const TextStyle(
color: Colors.black)),
), ),
) )
]), ]),
@ -160,10 +198,16 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
child: FormBuilderTextField( child: FormBuilderTextField(
enabled: enabled, enabled: enabled,
name: extensionName, name: extensionName,
initialValue: dteFormat2.format( initialValue: dteFormat2.format(state
state.primaryBasicInformation.birthdate!), .primaryBasicInformation.birthdate!),
style: const TextStyle(color: Colors.black),
decoration: decoration:
normalTextFieldStyle("Birth date", ""), normalTextFieldStyle("Birth date", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle: const TextStyle(
color: Colors.black)),
), ),
), ),
const SizedBox( const SizedBox(
@ -174,8 +218,15 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
child: FormBuilderTextField( child: FormBuilderTextField(
enabled: enabled, enabled: enabled,
name: sex, name: sex,
initialValue: state.primaryBasicInformation.sex!, initialValue:
decoration: normalTextFieldStyle("Sex", ""), state.primaryBasicInformation.sex!,
style: const TextStyle(color: Colors.black),
decoration: normalTextFieldStyle("Sex", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle: const TextStyle(
color: Colors.black)),
), ),
) )
]), ]),
@ -191,10 +242,16 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
child: FormBuilderTextField( child: FormBuilderTextField(
enabled: enabled, enabled: enabled,
name: "bloodType", name: "bloodType",
initialValue: initialValue: state
state.primaryBasicInformation.bloodType!, .primaryBasicInformation.bloodType!,
style: const TextStyle(color: Colors.black),
decoration: decoration:
normalTextFieldStyle("Blood type", ""), normalTextFieldStyle("Blood type", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle: const TextStyle(
color: Colors.black)),
), ),
), ),
const SizedBox( const SizedBox(
@ -205,10 +262,16 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
child: FormBuilderTextField( child: FormBuilderTextField(
enabled: enabled, enabled: enabled,
name: "civilStatus", name: "civilStatus",
initialValue: initialValue: state
state.primaryBasicInformation.civilStatus!, .primaryBasicInformation.civilStatus!,
style: const TextStyle(color: Colors.black),
decoration: decoration:
normalTextFieldStyle("Civil Status", ""), normalTextFieldStyle("Civil Status", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle: const TextStyle(
color: Colors.black)),
), ),
), ),
const SizedBox( const SizedBox(
@ -219,9 +282,16 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
child: FormBuilderTextField( child: FormBuilderTextField(
enabled: enabled, enabled: enabled,
name: "gender", name: "gender",
initialValue: state initialValue: state.primaryBasicInformation
.primaryBasicInformation.gender ??= "N/A", .gender ??= "N/A",
decoration: normalTextFieldStyle("Gender", ""), style: const TextStyle(color: Colors.black),
decoration:
normalTextFieldStyle("Gender", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle: const TextStyle(
color: Colors.black)),
), ),
), ),
]), ]),
@ -241,7 +311,14 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
initialValue: state initialValue: state
.primaryBasicInformation.heightM! .primaryBasicInformation.heightM!
.toString(), .toString(),
decoration: normalTextFieldStyle("Height", ""), style: const TextStyle(color: Colors.black),
decoration:
normalTextFieldStyle("Height", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle: const TextStyle(
color: Colors.black)),
), ),
), ),
const SizedBox( const SizedBox(
@ -255,7 +332,14 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
initialValue: state initialValue: state
.primaryBasicInformation.weightKg! .primaryBasicInformation.weightKg!
.toString(), .toString(),
decoration: normalTextFieldStyle("Weight", ""), style: const TextStyle(color: Colors.black),
decoration:
normalTextFieldStyle("Weight", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle: const TextStyle(
color: Colors.black)),
), ),
), ),
const SizedBox( const SizedBox(
@ -268,41 +352,14 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
name: prefixSuffix, name: prefixSuffix,
initialValue: initialValue:
"${state.primaryBasicInformation.titlePrefix ??= "NA"} | ${state.primaryBasicInformation.titleSuffix ??= "N/A"}", "${state.primaryBasicInformation.titlePrefix ??= "NA"} | ${state.primaryBasicInformation.titleSuffix ??= "N/A"}",
style: const TextStyle(color: Colors.black),
decoration: normalTextFieldStyle( decoration: normalTextFieldStyle(
"Title Prefix and Suffix", ""), "Title Prefix and Suffix", "")
), .copyWith(
), disabledBorder:
]), const OutlineInputBorder(),
), labelStyle: const TextStyle(
const SizedBox( color: Colors.black)),
height: 12,
),
SizedBox(
width: screenWidth,
child: Row(children: [
Flexible(
flex: 1,
child: FormBuilderTextField(
maxLines: 2,
enabled: enabled,
name: height,
initialValue: state.primaryBasicInformation.ip ??=
"N/A",
decoration:
normalTextFieldStyle("Indigenous", ""),
),
),
const SizedBox(
width: 10,
),
Flexible(
flex: 1,
child: FormBuilderTextField(
enabled: enabled,
name: width,
initialValue: state
.primaryBasicInformation.ethnicity ??= "N/A",
decoration: normalTextFieldStyle("Ethnicity", ""),
), ),
), ),
]), ]),
@ -320,8 +377,61 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
enabled: enabled, enabled: enabled,
name: height, name: height,
initialValue: state initialValue: state
.primaryBasicInformation.religion ??= "N/A", .primaryBasicInformation.ip ??= "N/A",
decoration: normalTextFieldStyle("Religion", ""), style: const TextStyle(color: Colors.black),
decoration:
normalTextFieldStyle("Indigenous", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle: const TextStyle(
color: Colors.black)),
),
),
const SizedBox(
width: 10,
),
Flexible(
flex: 1,
child: FormBuilderTextField(
enabled: enabled,
name: width,
initialValue: state.primaryBasicInformation
.ethnicity ??= "N/A",
style: const TextStyle(color: Colors.black),
decoration:
normalTextFieldStyle("Ethnicity", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle: const TextStyle(
color: Colors.black)),
),
),
]),
),
const SizedBox(
height: 12,
),
SizedBox(
width: screenWidth,
child: Row(children: [
Flexible(
flex: 1,
child: FormBuilderTextField(
maxLines: 2,
enabled: enabled,
name: height,
initialValue: state.primaryBasicInformation
.religion ??= "N/A",
style: const TextStyle(color: Colors.black),
decoration:
normalTextFieldStyle("Religion", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle: const TextStyle(
color: Colors.black)),
), ),
), ),
const SizedBox( const SizedBox(
@ -333,10 +443,16 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
maxLines: 2, maxLines: 2,
enabled: enabled, enabled: enabled,
name: width, name: width,
initialValue: state initialValue: state.primaryBasicInformation
.primaryBasicInformation.disability ??= "N/A", .disability ??= "N/A",
style: const TextStyle(color: Colors.black),
decoration: decoration:
normalTextFieldStyle("Disability", ""), normalTextFieldStyle("Disability", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle: const TextStyle(
color: Colors.black)),
), ),
), ),
]), ]),
@ -349,7 +465,9 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
return SomethingWentWrong( return SomethingWentWrong(
message: state.message, message: state.message,
onpressed: () { onpressed: () {
context.read<ProfileBloc>().add(LoadBasicPrimaryInfo()); context
.read<ProfileBloc>()
.add(LoadBasicPrimaryInfo());
}); });
} }
if (state is BasicInformationEditingState) { if (state is BasicInformationEditingState) {
@ -358,6 +476,10 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
} }
return Container(); return Container();
}, },
);
}
return Container();
},
), ),
)); ));
} }

View File

@ -128,7 +128,8 @@ class _AddEducationScreenState extends State<AddEducationScreen> {
return SearchField( return SearchField(
inputFormatters: [UpperCaseTextFormatter()], inputFormatters: [UpperCaseTextFormatter()],
itemHeight: 70, itemHeight: 70,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.schools suggestions: state.schools
.map((School school) => .map((School school) =>
SearchFieldListItem(school.name!, SearchFieldListItem(school.name!,
@ -190,7 +191,8 @@ class _AddEducationScreenState extends State<AddEducationScreen> {
UpperCaseTextFormatter() UpperCaseTextFormatter()
], ],
itemHeight: 100, itemHeight: 100,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.programs suggestions: state.programs
.map((Course program) => .map((Course program) =>
SearchFieldListItem( SearchFieldListItem(

View File

@ -165,7 +165,8 @@ class _EditEducationScreenState extends State<EditEducationScreen> {
}, },
controller: currentSchoolController, controller: currentSchoolController,
itemHeight: 70, itemHeight: 70,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.schools suggestions: state.schools
.map((School school) => .map((School school) =>
SearchFieldListItem(school.name!, SearchFieldListItem(school.name!,
@ -230,7 +231,8 @@ class _EditEducationScreenState extends State<EditEducationScreen> {
SuggestionAction.unfocus, SuggestionAction.unfocus,
controller: currentProgramController, controller: currentProgramController,
itemHeight: 70, itemHeight: 70,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.programs suggestions: state.programs
.map((Course program) => .map((Course program) =>
SearchFieldListItem( SearchFieldListItem(

View File

@ -371,7 +371,7 @@ class _AddLearningAndDevelopmentScreenState
], ],
focusNode: topicFocusNode, focusNode: topicFocusNode,
itemHeight: 100, itemHeight: 100,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.topics suggestions: state.topics
.map((LearningDevelopmentType .map((LearningDevelopmentType
topic) => topic) =>

View File

@ -267,7 +267,7 @@ class _EditLearningAndDevelopmentScreenState
controller: currentTopicController, controller: currentTopicController,
focusNode: topicFocusNode, focusNode: topicFocusNode,
itemHeight: 100, itemHeight: 100,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.topics suggestions: state.topics
.map((LearningDevelopmentType .map((LearningDevelopmentType
topic) => topic) =>

View File

@ -92,7 +92,7 @@ class _AddVoluntaryWorkScreenState extends State<AddVoluntaryWorkScreen> {
return SearchField( return SearchField(
inputFormatters: [UpperCaseTextFormatter()], inputFormatters: [UpperCaseTextFormatter()],
itemHeight: 70, itemHeight: 70,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.positions suggestions: state.positions
.map((PositionTitle position) => .map((PositionTitle position) =>
SearchFieldListItem(position.title!, SearchFieldListItem(position.title!,

View File

@ -128,7 +128,7 @@ class _EditVoluntaryWorkScreenState extends State<EditVoluntaryWorkScreen> {
inputFormatters: [UpperCaseTextFormatter()], inputFormatters: [UpperCaseTextFormatter()],
controller: positionController, controller: positionController,
itemHeight: 70, itemHeight: 70,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.positions suggestions: state.positions
.map((PositionTitle position) => .map((PositionTitle position) =>
SearchFieldListItem(position.title!, SearchFieldListItem(position.title!,

View File

@ -98,7 +98,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
return SearchField( return SearchField(
inputFormatters: [UpperCaseTextFormatter()], inputFormatters: [UpperCaseTextFormatter()],
itemHeight: 70, itemHeight: 70,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.agencyPositions suggestions: state.agencyPositions
.map((PositionTitle position) => .map((PositionTitle position) =>
SearchFieldListItem(position.title!, SearchFieldListItem(position.title!,

View File

@ -121,7 +121,7 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
inputFormatters: [UpperCaseTextFormatter()], inputFormatters: [UpperCaseTextFormatter()],
controller: oldPositionController, controller: oldPositionController,
itemHeight: 100, itemHeight: 100,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.agencyPositions suggestions: state.agencyPositions
.map((PositionTitle position) => .map((PositionTitle position) =>
SearchFieldListItem(position.title!, SearchFieldListItem(position.title!,

View File

@ -30,6 +30,7 @@ import 'package:unit2/screens/profile/components/references_screen.dart';
import 'package:unit2/screens/profile/components/work_history_screen.dart'; import 'package:unit2/screens/profile/components/work_history_screen.dart';
import 'package:unit2/screens/profile/components/voluntary_works_screen.dart'; import 'package:unit2/screens/profile/components/voluntary_works_screen.dart';
import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/utils/global.dart';
import 'package:unit2/widgets/error_state.dart'; import 'package:unit2/widgets/error_state.dart';
import '../../bloc/profile/eligibility/eligibility_bloc.dart'; import '../../bloc/profile/eligibility/eligibility_bloc.dart';
import '../../bloc/profile/family/family_bloc.dart'; import '../../bloc/profile/family/family_bloc.dart';
@ -69,8 +70,12 @@ class ProfileInfo extends StatelessWidget {
if (state is UserLoggedIn) { if (state is UserLoggedIn) {
profileId = state.userData!.user!.login!.user!.profileId; profileId = state.userData!.user!.login!.user!.profileId;
token = state.userData!.user!.login!.token!; token = state.userData!.user!.login!.token!;
if (globalCurrentProfile == null) {
profile = state.userData!.employeeInfo!.profile!; profile = state.userData!.employeeInfo!.profile!;
} else {
profile = globalCurrentProfile!;
}
print(profile.lastName);
return BlocConsumer<ProfileBloc, ProfileState>( return BlocConsumer<ProfileBloc, ProfileState>(
listener: ( listener: (
context, context,

View File

@ -172,7 +172,6 @@ class RbacAgencyScreen extends StatelessWidget {
indicatorWidget: const SpinKitFadingCircle(color: Colors.white), indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<AgencyBloc, AgencyState>( child: BlocConsumer<AgencyBloc, AgencyState>(
listener: (context, state) { listener: (context, state) {
print(state);
if (state is AgencyLoadingState) { if (state is AgencyLoadingState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait..."); progress!.showWithText("Please wait...");
@ -235,7 +234,6 @@ class RbacAgencyScreen extends StatelessWidget {
decoration: box1(), decoration: box1(),
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8), horizontal: 12, vertical: 8),
child: Expanded(
child: Row( child: Row(
children: [ children: [
CircleAvatar( CircleAvatar(
@ -254,7 +252,7 @@ class RbacAgencyScreen extends StatelessWidget {
color: primary)), color: primary)),
), ),
], ],
)), ),
), ),
const SizedBox( const SizedBox(
height: 5, height: 5,
@ -266,8 +264,7 @@ class RbacAgencyScreen extends StatelessWidget {
return const EmptyData( return const EmptyData(
message: "No Object available. Please click + to add."); message: "No Object available. Please click + to add.");
} }
} }if (state is AgencyErrorState) {
if (state is AgencyErrorState) {
return SomethingWentWrong( return SomethingWentWrong(
message: state.message, message: state.message,
onpressed: () { onpressed: () {

File diff suppressed because it is too large Load Diff

View File

@ -213,7 +213,7 @@ class RbacRoleAssignment extends StatelessWidget {
Flexible( Flexible(
child: Text( child: Text(
state.assignedRoles[index].role! state.assignedRoles[index].role!
.name, .name!,
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.titleMedium! .titleMedium!
@ -262,8 +262,8 @@ class RbacRoleAssignment extends StatelessWidget {
], ],
); );
} else { } else {
return const EmptyData( return EmptyData(
message: "No Role available. Please click + to add."); message: "No Role available for ${state.fullname}. Please click + to add.");
} }
} }
if (state is RoleAssignmentErrorState) { if (state is RoleAssignmentErrorState) {

View File

@ -180,7 +180,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
////Station Type ////Station Type
SearchField( SearchField(
itemHeight: 50, itemHeight: 50,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: stationTypes suggestions: stationTypes
.map((StationType stationType) => .map((StationType stationType) =>
SearchFieldListItem( SearchFieldListItem(

View File

@ -46,46 +46,45 @@ class BasicInfo extends StatelessWidget {
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
const CoverImage(), const CoverImage(),
Positioned( // Positioned(
top: blockSizeVertical * 15.5, // top: blockSizeVertical * 15.5,
child: Stack( // child: Stack(
alignment: Alignment.center, // alignment: Alignment.center,
children: [ // children: [
CachedNetworkImage( // CachedNetworkImage(
imageUrl: fileUrl, // imageUrl: fileUrl,
imageBuilder: (context, imageProvider) => // imageBuilder: (context, imageProvider) =>
Container( // Container(
width: 160, // width: 160,
height: 160, // height: 160,
decoration: BoxDecoration( // decoration: BoxDecoration(
border: // border: Border.all(
Border.all(color: Colors.black26, width: 3), // color: Colors.black26, width: 3),
shape: BoxShape.circle, // shape: BoxShape.circle,
image: DecorationImage( // image: DecorationImage(
image: imageProvider, // image: imageProvider,
fit: BoxFit.cover), // fit: BoxFit.cover),
), // ),
), // ),
placeholder: (context, url) => // placeholder: (context, url) =>
const CircularProgressIndicator(), // const CircularProgressIndicator(),
errorWidget: (context, url, error) => // errorWidget: (context, url, error) =>
Container( // Container(
width: 160, // width: 160,
height: 160, // height: 160,
decoration: BoxDecoration( // decoration: BoxDecoration(
border: // border: Border.all(
Border.all(color: Colors.white, width: 3), // color: Colors.white, width: 3),
shape: BoxShape.circle, // shape: BoxShape.circle,
// ),
), // child: SvgPicture.asset(
child: SvgPicture.asset( // 'assets/svgs/male.svg',
'assets/svgs/male.svg', // ),
), // ),
), // ),
), // ],
], // ),
), // ),
),
Positioned( Positioned(
top: 10, top: 10,
left: 20, left: 20,
@ -138,14 +137,15 @@ class BuildInformation extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
final String firstName = globalFistname = globalFistname ?? userData.user!.login!.user!.firstName!.toUpperCase();
userData.user!.login!.user!.firstName!.toUpperCase(); globalLastname =globalLastname ?? userData.user!.login!.user!.lastName!.toUpperCase();
final String lastname = userData.user!.login!.user!.lastName!.toUpperCase(); globalMiddleName = globalMiddleName == null
final String? middlename = userData.employeeInfo == null ? (userData.employeeInfo == null
? '' ? ''
: userData.employeeInfo!.profile?.middleName?.toUpperCase(); : userData.employeeInfo!.profile?.middleName?.toUpperCase())
final String sex = userData.employeeInfo!.profile!.sex!.toUpperCase(); : '';
final DateTime? bday = userData.employeeInfo!.profile!.birthdate; globalSex = globalSex ?? userData.employeeInfo!.profile!.sex!.toUpperCase();
globalBday = globalBday ?? userData.employeeInfo!.profile!.birthdate;
final uuid = userData.employeeInfo!.uuid; final uuid = userData.employeeInfo!.uuid;
return Container( return Container(
padding: const EdgeInsets.symmetric(horizontal: 25), padding: const EdgeInsets.symmetric(horizontal: 25),
@ -156,7 +156,7 @@ class BuildInformation extends StatelessWidget {
height: 25, height: 25,
), ),
Text( Text(
"$firstName ${middlename ?? ''} $lastname", "$globalFistname ${globalMiddleName ?? ''} $globalLastname",
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
@ -167,7 +167,7 @@ class BuildInformation extends StatelessWidget {
height: 10, height: 10,
), ),
Text( Text(
"${dteFormat2.format(bday!)} | $sex", "${dteFormat2.format(globalBday!)} | $sex",
style: style:
Theme.of(context).textTheme.bodySmall!.copyWith(fontSize: 18), Theme.of(context).textTheme.bodySmall!.copyWith(fontSize: 18),
), ),
@ -181,7 +181,7 @@ class BuildInformation extends StatelessWidget {
return QRFullScreenImage(uuid: uuid); return QRFullScreenImage(uuid: uuid);
})); }));
}, },
child: QrImage( child: QrImageView(
data: uuid!, data: uuid!,
size: blockSizeVertical * 24, size: blockSizeVertical * 24,
), ),

View File

@ -16,7 +16,7 @@ class QRFullScreenImage extends StatelessWidget {
centerTitle: true, centerTitle: true,
backgroundColor: primary,title: const Text("Profile QR Code"),), backgroundColor: primary,title: const Text("Profile QR Code"),),
body: Center( body: Center(
child: QrImage( child: QrImageView(
data: uuid, data: uuid,
size: blockSizeVertical * 50 size: blockSizeVertical * 50
), ),

View File

@ -76,9 +76,6 @@ class _DashBoardState extends State<DashBoard> {
tempUnit2Cards = unit2Cards.sublist(0, 4); tempUnit2Cards = unit2Cards.sublist(0, 4);
} }
superadminCards.forEach((el) {
print(el.object.name);
});
return Container( return Container(
padding: padding:

View File

@ -24,11 +24,15 @@ IconData? iconGenerator({required String name}) {
return FontAwesome.box; return FontAwesome.box;
} else if (name.toLowerCase() == 'permission') { } else if (name.toLowerCase() == 'permission') {
return FontAwesome5.door_open; return FontAwesome5.door_open;
} else if (name.toLowerCase() == 'station') { } else if (name.toLowerCase() == 'permission assignment') {
return Icons.assignment_ind;
}
else if (name.toLowerCase() == 'station') {
return ModernPictograms.home; return ModernPictograms.home;
} else if (name.toLowerCase() == 'purok') { } else if (name.toLowerCase() == 'purok') {
return WebSymbols.list_numbered; return WebSymbols.list_numbered;
} else if (name.toLowerCase() == 'barangay') { } else if (name.toLowerCase() == 'baranggay') {
return Maki.industrial_building; return Maki.industrial_building;
} else if (name.toLowerCase() == 'role module') { } else if (name.toLowerCase() == 'role module') {
return FontAwesome5.person_booth; return FontAwesome5.person_booth;

View File

@ -4,6 +4,7 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:unit2/bloc/rbac/rbac_operations/agency/agency_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/agency/agency_bloc.dart';
import 'package:unit2/bloc/rbac/rbac_operations/assign_area/assign_area_bloc.dart';
import 'package:unit2/bloc/rbac/rbac_operations/module/module_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/module/module_bloc.dart';
import 'package:unit2/bloc/rbac/rbac_operations/module_objects/module_objects_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/module_objects/module_objects_bloc.dart';
import 'package:unit2/bloc/rbac/rbac_operations/object/object_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/object/object_bloc.dart';
@ -15,6 +16,7 @@ import 'package:unit2/bloc/rbac/rbac_operations/role_module/role_module_bloc.dar
import 'package:unit2/bloc/rbac/rbac_operations/roles_under/roles_under_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/roles_under/roles_under_bloc.dart';
import 'package:unit2/bloc/rbac/rbac_operations/station/station_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/station/station_bloc.dart';
import 'package:unit2/bloc/role_assignment/role_assignment_bloc.dart'; import 'package:unit2/bloc/role_assignment/role_assignment_bloc.dart';
import 'package:unit2/screens/superadmin/assign_area/assign_area_screen.dart';
import 'package:unit2/screens/superadmin/module/module_screen.dart'; import 'package:unit2/screens/superadmin/module/module_screen.dart';
import 'package:unit2/screens/superadmin/object/object_screen.dart'; import 'package:unit2/screens/superadmin/object/object_screen.dart';
import 'package:unit2/screens/superadmin/operation/operation_screen.dart'; import 'package:unit2/screens/superadmin/operation/operation_screen.dart';
@ -49,6 +51,7 @@ class SuperAdminMenu extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final roleAssignmentKey = GlobalKey<FormBuilderState>(); final roleAssignmentKey = GlobalKey<FormBuilderState>();
final areaKey = GlobalKey<FormBuilderState>();
return AnimationConfiguration.staggeredGrid( return AnimationConfiguration.staggeredGrid(
position: index, position: index,
columnCount: columnCount, columnCount: columnCount,
@ -74,12 +77,9 @@ class SuperAdminMenu extends StatelessWidget {
object.moduleName == 'superadmin' object.moduleName == 'superadmin'
? CardLabel( ? CardLabel(
icon: iconGenerator(name: object.object.name!), icon: iconGenerator(name: object.object.name!),
title: title: object.object.name!,
object.object.name!,
ontap: () { ontap: () {
if (object.object.name == 'Role') { if (object.object.name == 'Role') {
Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return BlocProvider( return BlocProvider(
@ -156,9 +156,7 @@ class SuperAdminMenu extends StatelessWidget {
return BlocProvider( return BlocProvider(
create: (context) => create: (context) =>
AgencyBloc()..add(GetAgencies()), AgencyBloc()..add(GetAgencies()),
child: RbacAgencyScreen( child: const RbacAgencyScreen(),
),
); );
})); }));
} }
@ -211,6 +209,98 @@ class SuperAdminMenu extends StatelessWidget {
); );
})); }));
} }
////////////////////////////////
if (object.object.name == 'Area') {
Navigator.of(context).pop();
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Row(
children: [
const Expanded(
child: Text("Search User")),
IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(Icons.close))
],
),
content: FormBuilder(
key: areaKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderTextField(
name: "firstname",
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
decoration: normalTextFieldStyle(
"First name", "first name"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
name: "lastname",
decoration: normalTextFieldStyle(
"Last name", "last tname"),
),
const SizedBox(
height: 24,
),
SizedBox(
height: 60,
width: double.maxFinite,
child: ElevatedButton(
onPressed: () {
if (areaKey.currentState!
.saveAndValidate()) {
String fname =
areaKey
.currentState!
.value['firstname'];
String lname = areaKey
.currentState!
.value['lastname'];
Navigator.of(context).pop();
Navigator.push(context,
MaterialPageRoute(builder:
(BuildContext
context) {
return BlocProvider(
create: (context) =>
AssignAreaBloc()
..add(
GetAssignArea(
firstname:
fname,
lastname:
lname),
),
child:
RbacAssignedAreaScreen(lname: lname,fname: fname,id: id,),
);
}));
}
},
style: mainBtnStyle(primary,
Colors.transparent, second),
child: const Text("Submit"),
),
)
],
)),
);
});
}
if (object.object.name == 'Role Member') { if (object.object.name == 'Role Member') {
Navigator.of(context).pop(); Navigator.of(context).pop();
showDialog( showDialog(
@ -219,10 +309,13 @@ class SuperAdminMenu extends StatelessWidget {
return AlertDialog( return AlertDialog(
title: Row( title: Row(
children: [ children: [
const Expanded(child: Text("Search User")), const Expanded(
IconButton(onPressed: (){ child: Text("Search User")),
IconButton(
onPressed: () {
Navigator.pop(context); Navigator.pop(context);
}, icon: const Icon(Icons.close)) },
icon: const Icon(Icons.close))
], ],
), ),
content: FormBuilder( content: FormBuilder(
@ -262,7 +355,6 @@ class SuperAdminMenu extends StatelessWidget {
if (roleAssignmentKey if (roleAssignmentKey
.currentState! .currentState!
.saveAndValidate()) { .saveAndValidate()) {
String fname = String fname =
roleAssignmentKey roleAssignmentKey
.currentState! .currentState!
@ -279,11 +371,19 @@ class SuperAdminMenu extends StatelessWidget {
return BlocProvider( return BlocProvider(
create: (context) => create: (context) =>
RoleAssignmentBloc() RoleAssignmentBloc()
..add(GetAssignedRoles( ..add(
GetAssignedRoles(
firstname: firstname:
fname, fname,
lastname: lastname:
lname),),child:RbacRoleAssignment(id:id,name: fname,lname: lname,) ,); lname),
),
child: RbacRoleAssignment(
id: id,
name: fname,
lname: lname,
),
);
})); }));
} }
}, },

View File

@ -17,9 +17,9 @@ class MenuScreen extends StatefulWidget {
class _MenuScreenState extends State<MenuScreen> { class _MenuScreenState extends State<MenuScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final String firstName = final String firstName =globalFistname??
widget.userData!.user!.login!.user!.firstName!.toUpperCase(); widget.userData!.user!.login!.user!.firstName!.toUpperCase();
final String lastname = final String lastname = globalLastname??
widget.userData!.user!.login!.user!.lastName!.toUpperCase(); widget.userData!.user!.login!.user!.lastName!.toUpperCase();
return Drawer( return Drawer(
child: SizedBox( child: SizedBox(

View File

@ -20,8 +20,10 @@ class _MainScreenState extends State<MainScreen> {
List<Role> roles = []; List<Role> roles = [];
List<DisplayCard> cards = []; List<DisplayCard> cards = [];
int? userId; int? userId;
DateTime? ctime;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
setState(() { setState(() {
cards.clear(); cards.clear();
cards=[]; cards=[];
@ -52,7 +54,21 @@ class _MainScreenState extends State<MainScreen> {
} }
} }
return Scaffold( return WillPopScope(
onWillPop: () {
DateTime now = DateTime.now();
if (ctime == null || now.difference(ctime!) > const Duration(seconds: 2)) {
//add duration of press gap
ctime = now;
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Press Again to Exit',textAlign: TextAlign.center,))
);
return Future.value(false);
}
return Future.value(true);
},
child: Scaffold(
appBar: AppBar( appBar: AppBar(
backgroundColor: primary, backgroundColor: primary,
leading: IconButton( leading: IconButton(
@ -80,6 +96,7 @@ class _MainScreenState extends State<MainScreen> {
cards: cards, cards: cards,
) )
: const NoModule(), : const NoModule(),
),
); );
} }
return Container(); return Container();

View File

@ -1,6 +1,8 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:better_open_file/better_open_file.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:easy_app_installer/easy_app_installer.dart'; import 'package:easy_app_installer/easy_app_installer.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -9,6 +11,7 @@ import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:unit2/model/login_data/version_info.dart';
import 'package:unit2/screens/unit2/login/components/showAlert.dart'; import 'package:unit2/screens/unit2/login/components/showAlert.dart';
import 'package:unit2/theme-data.dart/btn-style.dart'; import 'package:unit2/theme-data.dart/btn-style.dart';
@ -20,9 +23,9 @@ import '../../../../widgets/wave.dart';
class Update extends StatefulWidget { class Update extends StatefulWidget {
final String apkVersion; final String apkVersion;
final String currenVersion; final VersionInfo versionInfo;
const Update( const Update(
{super.key, required this.apkVersion, required this.currenVersion}); {super.key, required this.apkVersion, required this.versionInfo});
@override @override
State<Update> createState() => _UpdateState(); State<Update> createState() => _UpdateState();
@ -74,14 +77,14 @@ class _UpdateState extends State<Update> {
], ],
), ),
const SizedBox( const SizedBox(
height: 10, height: 25,
), ),
RichText( RichText(
textAlign: TextAlign.justify, textAlign: TextAlign.justify,
text: TextSpan( text: TextSpan(
text: 'Your app version ', text: 'Your app version ',
style: const TextStyle( style: const TextStyle(
fontSize: 16, fontSize: 14,
color: Colors.black, color: Colors.black,
), ),
children: <TextSpan>[ children: <TextSpan>[
@ -95,7 +98,7 @@ class _UpdateState extends State<Update> {
" did not match with the latest version ", " did not match with the latest version ",
style: TextStyle(color: Colors.black)), style: TextStyle(color: Colors.black)),
TextSpan( TextSpan(
text: widget.currenVersion.toString(), text: widget.versionInfo.versionInfo,
style: const TextStyle( style: const TextStyle(
color: primary, color: primary,
fontWeight: FontWeight.bold)), fontWeight: FontWeight.bold)),
@ -105,7 +108,7 @@ class _UpdateState extends State<Update> {
style: TextStyle(color: Colors.black)), style: TextStyle(color: Colors.black)),
])), ])),
const SizedBox( const SizedBox(
height: 12.0, height: 25,
), ),
Container( Container(
child: downloading child: downloading
@ -131,15 +134,20 @@ class _UpdateState extends State<Update> {
style: mainBtnStyle( style: mainBtnStyle(
primary, Colors.transparent, second), primary, Colors.transparent, second),
onPressed: () async { onPressed: () async {
final progress = ProgressHUD.of(context);
progress?.showWithText(
'Please wait...',
);
setState(() { setState(() {
downloading = true; downloading = true;
progressRating = '0'; progressRating = '0';
}); });
try {
await openFile(); await openFile();
} catch (e) {
showAlert(context, () {
setState(() {
downloading = false;
progressRating = '0';
});
});
}
}, },
label: const Text( label: const Text(
"Download Latest App Version.")), "Download Latest App Version.")),
@ -168,9 +176,9 @@ class _UpdateState extends State<Update> {
Future<void> openFile() async { Future<void> openFile() async {
try { try {
final filePath = await downloadFile(); final filePath = await downloadFile();
await openAPK(filePath); await OpenFile.open(filePath);
} catch (e) { } catch (e) {
print(e.toString()); throw e.toString();
} }
} }
@ -181,16 +189,36 @@ class _UpdateState extends State<Update> {
} }
} }
Future<String> downloadFile() async {
final progress = ProgressHUD.of(context); Future<String> getCPUArchitecture() async {
String downloadURL = "";
DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
AndroidDeviceInfo androidDeviceInfo = await deviceInfoPlugin.androidInfo;
try{
List<String> cpuArchitecture = androidDeviceInfo.supportedAbis;
if (cpuArchitecture.first == 'arm64-v8a') {
downloadURL = widget.versionInfo.arm64v8aDownloadUrl!;
}
else if (cpuArchitecture.first == 'armeabi-v7a') {
downloadURL = widget.versionInfo.armeabiv7aDownloadUrl!;
} else {
downloadURL = widget.versionInfo.x8664DownloadUrl!;
}
print(downloadURL);
}catch(e){
throw e.toString();
}
return downloadURL;
}
Future<String?> downloadFile() async {
final appStorage = await getApplicationDocumentsDirectory(); final appStorage = await getApplicationDocumentsDirectory();
String? appDir;
try { try {
String url = await getCPUArchitecture(); String url = await getCPUArchitecture();
final response = await dio.download(url, '${appStorage.path}/uniT.apk', final response = await dio.download(url, '${appStorage.path}/uniT.apk',
deleteOnError: true, deleteOnError: true,
options: Options( options: Options(
receiveTimeout: 20000,
sendTimeout: 20000,
receiveDataWhenStatusError: true, receiveDataWhenStatusError: true,
responseType: ResponseType.bytes, responseType: ResponseType.bytes,
followRedirects: false, followRedirects: false,
@ -202,47 +230,24 @@ class _UpdateState extends State<Update> {
downloading = true; downloading = true;
}); });
if (progressRating == '100') { if (progressRating == '100') {
final progress = ProgressHUD.of(context);
progress!.dismiss();
setState(() { setState(() {
downloading = false; downloading = false;
isDownloaded = true; isDownloaded = true;
}); });
} }
appDir = '${appStorage.path}/uniT.apk';
}); });
} on TimeoutException catch (_) { } on TimeoutException catch (e) {
progress!.dismiss(); throw e.toString();
showAlert(context, () { } on SocketException catch (e) {
setState(() { throw e.toString();
downloading = false; } on Error catch (e) {
}); throw e.toString();
}); } catch (e) {
throw TimeoutException(timeoutError); throw e.toString();
} on SocketException catch (_) {
progress!.dismiss();
showAlert(context, () {
setState(() {
downloading = false;
});
});
throw const SocketException(timeoutError);
} on DioError catch (_) {
progress!.dismiss();
showAlert(context, () {
setState(() {
downloading = false;
});
});
throw TimeoutException(timeoutError);
} catch (_) {
progress!.dismiss();
showAlert(context, () {
setState(() {
downloading = false;
});
});
throw TimeoutException(timeoutError);
} }
return '${appStorage.path}/uniT.apk';
return appDir!;
} }
} }

View File

@ -22,7 +22,6 @@ import '../../../theme-data.dart/colors.dart';
import '../../../theme-data.dart/form-style.dart'; import '../../../theme-data.dart/form-style.dart';
import '../../../theme-data.dart/btn-style.dart'; import '../../../theme-data.dart/btn-style.dart';
import './components/login-via-qr-label.dart'; import './components/login-via-qr-label.dart';
import './functions/press-again-to-exit.dart';
class UniT2Login extends StatefulWidget { class UniT2Login extends StatefulWidget {
const UniT2Login({super.key}); const UniT2Login({super.key});
@ -37,17 +36,30 @@ class _UniT2LoginState extends State<UniT2Login> {
bool _showPassword = true; bool _showPassword = true;
String? password; String? password;
String? username; String? username;
DateTime? ctime;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return WillPopScope( return WillPopScope(
onWillPop: pressAgainToExit, onWillPop: () {
DateTime now = DateTime.now();
if (ctime == null || now.difference(ctime!) > const Duration(seconds: 2)) {
ctime = now;
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Press Again to Exit',textAlign: TextAlign.center,))
);
return Future.value(false);
}
return Future.value(true);
},
child: Scaffold( child: Scaffold(
body: ProgressHUD( body: ProgressHUD(
backgroundColor: Colors.black87, backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white), indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<UserBloc, UserState>(listener: (context, state) { child: BlocConsumer<UserBloc, UserState>(listener: (context, state) {
print(state); if (state is UserLoggedIn ||
if (state is UserLoggedIn || state is UuidLoaded || state is LoginErrorState) { state is UuidLoaded ||
state is LoginErrorState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.dismiss(); progress!.dismiss();
} }
@ -94,10 +106,11 @@ class _UniT2LoginState extends State<UniT2Login> {
})); }));
} }
}, builder: (context, state) { }, builder: (context, state) {
print(state);
if (state is VersionLoaded) { if (state is VersionLoaded) {
print(state.versionInfo!.id);
print(state.apkVersion);
return Builder(builder: (context) { return Builder(builder: (context) {
if (state.versionInfo!.version != state.apkVersion) { if (state.versionInfo?.id == state.apkVersion) {
return SizedBox( return SizedBox(
child: SingleChildScrollView( child: SingleChildScrollView(
child: Stack( child: Stack(
@ -344,7 +357,7 @@ class _UniT2LoginState extends State<UniT2Login> {
//New update available //New update available
return Update( return Update(
apkVersion: state.apkVersion!, apkVersion: state.apkVersion!,
currenVersion: state.versionInfo!.version!, versionInfo: state.versionInfo!,
); );
} }
}); });
@ -355,7 +368,7 @@ class _UniT2LoginState extends State<UniT2Login> {
onpressed: () { onpressed: () {
BlocProvider.of<UserBloc>( BlocProvider.of<UserBloc>(
NavigationService.navigatorKey.currentContext!) NavigationService.navigatorKey.currentContext!)
.add(GetApkVersion()); .add(LoadVersion(username: username, password: password));
return MaterialPageRoute(builder: (_) { return MaterialPageRoute(builder: (_) {
return const UniT2Login(); return const UniT2Login();
}); });
@ -374,7 +387,7 @@ class _UniT2LoginState extends State<UniT2Login> {
onpressed: () { onpressed: () {
BlocProvider.of<UserBloc>( BlocProvider.of<UserBloc>(
NavigationService.navigatorKey.currentContext!) NavigationService.navigatorKey.currentContext!)
.add(GetApkVersion()); .add(LoadVersion(username: username, password: password));
return MaterialPageRoute(builder: (_) { return MaterialPageRoute(builder: (_) {
return const UniT2Login(); return const UniT2Login();
}); });

View File

@ -158,11 +158,11 @@ class EstPointPersonRoleAssignmentScreen extends StatelessWidget {
if (!assignedRoles.keys.contains(fullName)) { if (!assignedRoles.keys.contains(fullName)) {
assignedRoles.addAll({fullName: []}); assignedRoles.addAll({fullName: []});
assignedRoles[fullName]!.add(Content( assignedRoles[fullName]!.add(Content(
id: assignedRole.id!, name: assignedRole.role!.name)); id: assignedRole.id!, name: assignedRole.role!.name!));
} else { } else {
assignedRoles[fullName]!.add(Content( assignedRoles[fullName]!.add(Content(
id: assignedRole.id!, id: assignedRole.id!,
name: assignedRole.role!.name)); name: assignedRole.role!.name!));
} }
} }
} }

View File

@ -171,7 +171,7 @@ class EstPointPersonStationScreen extends StatelessWidget {
////Station Type ////Station Type
SearchField( SearchField(
itemHeight: 50, itemHeight: 50,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: stationTypes suggestions: stationTypes
.map((StationType stationType) => .map((StationType stationType) =>
SearchFieldListItem( SearchFieldListItem(

View File

@ -222,7 +222,7 @@ class _RBACScreenState extends State<RBACScreen> {
builder: (context, setState) { builder: (context, setState) {
return SearchField( return SearchField(
itemHeight: 40, itemHeight: 40,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.role suggestions: state.role
.map((RBAC role) => .map((RBAC role) =>
SearchFieldListItem( SearchFieldListItem(
@ -305,7 +305,7 @@ class _RBACScreenState extends State<RBACScreen> {
builder: (context, setState) { builder: (context, setState) {
return SearchField( return SearchField(
itemHeight: 40, itemHeight: 40,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.modules suggestions: state.modules
.map((RBAC module) => .map((RBAC module) =>
SearchFieldListItem( SearchFieldListItem(
@ -602,7 +602,7 @@ class _RBACScreenState extends State<RBACScreen> {
), ),
SearchField( SearchField(
itemHeight: 40, itemHeight: 40,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.objects suggestions: state.objects
.map((RBAC object) => SearchFieldListItem(object.name!, .map((RBAC object) => SearchFieldListItem(object.name!,
item: object, item: object,

View File

@ -90,7 +90,7 @@ class PropertyAppraisalServices {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: params, path: path, headers: headers); .getRequest(param: params, path: path, headers: headers);
print('Property_Apraisaledit'); print('Property_Apraisaledit');
print(response.statusCode); print(response.body);
if (response.statusCode == 200) { if (response.statusCode == 200) {
final jsonData = jsonDecode(response.body); final jsonData = jsonDecode(response.body);
final dataList = jsonData['data'] as List<dynamic>; final dataList = jsonData['data'] as List<dynamic>;

View File

@ -98,6 +98,7 @@ class PropertyAssessmentServices {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: params, path: path, headers: headers); .getRequest(param: params, path: path, headers: headers);
print('Assessment'); print('Assessment');
print(response.statusCode);
print(response.body); print(response.body);
if (response.statusCode == 200) { if (response.statusCode == 200) {
final jsonData = jsonDecode(response.body); final jsonData = jsonDecode(response.body);

View File

@ -84,53 +84,55 @@ class LandExtServices {
return response; return response;
} }
// Future<LandExtEdit> fetchEdit(tempID) async { Future<http.Response?> updateEdit(LandExt data, id) async {
// http.Response response = await http.get(Uri.parse( String path = Url.instance.getLandExt();
// '$baseUrl${Url.instance.getLandExt()}?bldgappr_details_id=$tempID')); Map<String, String> headers = {
// print('Assessment'); 'Content-Type': 'application/json; charset=UTF-8',
// print(response.body); 'X-Client-Key': xClientKey,
// if (response.statusCode == 200) { 'X-Client-Secret': xClientKeySecret
// final jsonData = jsonDecode(response.body); };
// final dataList = jsonData['data'] as List<dynamic>; Map<String, String> params = {
// final result = "landappr_details_id": id.toString(),
// LandExtEdit.fromJson(dataList[0] as Map<String, dynamic>); };
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;
}
// return result; Future<LandExt> fetchEdit(tempID) async {
// } else { String path = Url.instance.getLandExt();
// throw Exception(response.reasonPhrase); 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);
// Future<http.Response?> addEdit(LandExtEdit assessment) async { print('Landextedit');
// http.Response? response; print(response.body);
// try {
// response = await http.post(
// Uri.parse("$baseUrl${Url.instance.getLandExt()}"),
// headers: {
// HttpHeaders.contentTypeHeader: "application/json",
// },
// body: jsonEncode(assessment.toJson()));
// } catch (e) {
// log(e.toString());
// }
// return response;
// }
// Future<http.Response?> updateEdit( if (response.statusCode == 200) {
// LandExtEdit assessment, id) async { final jsonData = jsonDecode(response.body);
// print(id); final dataList = jsonData['data'] as List<dynamic>;
// http.Response? response; final result = LandExt.fromJson(dataList[0] as Map<String, dynamic>);
// try {
// response = await http.put(Uri.parse( return result;
// // ignore: unnecessary_brace_in_string_interps } else {
// "$baseUrl${Url.instance.getLandExt()}?bldgappr_details_id=${id}"), print(response.reasonPhrase);
// headers: { throw Exception(response.reasonPhrase);
// HttpHeaders.contentTypeHeader: "application/json", }
// }, } catch (e) {
// body: jsonEncode(assessment.toJson())); throw e.toString();
// } catch (e) { }
// log(e.toString()); }
// }
// return response;
// }
} }

View File

@ -24,11 +24,11 @@ class OtherImprovementServices {
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientKeySecret
}; };
Map<String, String> params = { Map<String, String> params = {
"landappr_details_id": tempID, "landappr_details_id": tempID.toString(),
}; };
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: {}, path: path, headers: headers); .getRequest(param: params, path: path, headers: headers);
if (response.statusCode == 200) { if (response.statusCode == 200) {
final List result = jsonDecode(response.body)['data']; final List result = jsonDecode(response.body)['data'];
@ -67,11 +67,11 @@ class OtherImprovementServices {
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientKeySecret
}; };
Map<String, String> params = { Map<String, String> params = {
"id": id, "id": id.toString(),
}; };
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.deleteRequest(path: path, headers: headers, body: {}, param: {}); .deleteRequest(path: path, headers: headers, body: {}, param: params);
print(id); print(id);
if (response.statusCode == 200) { if (response.statusCode == 200) {
print(response.body); print(response.body);

View File

@ -25,11 +25,11 @@ class ValueAdjustmentsServices {
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientKeySecret
}; };
Map<String, String> params = { Map<String, String> params = {
"landappr_details_id": tempID, "landappr_details_id": tempID.toString(),
}; };
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: {}, path: path, headers: headers); .getRequest(param: params, path: path, headers: headers);
if (response.statusCode == 200) { if (response.statusCode == 200) {
final List result = jsonDecode(response.body)['data']; final List result = jsonDecode(response.body)['data'];
print(result); print(result);
@ -67,11 +67,11 @@ class ValueAdjustmentsServices {
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientKeySecret
}; };
Map<String, String> params = { Map<String, String> params = {
"id": id, "id": id.toString(),
}; };
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.deleteRequest(path: path, headers: headers, body: {}, param: {}); .deleteRequest(path: path, headers: headers, body: {}, param: params);
print(id); print(id);
if (response.statusCode == 200) { if (response.statusCode == 200) {
print(response.body); print(response.body);

View File

@ -1,9 +1,4 @@
import 'dart:convert';
import 'package:unit2/model/passo/barangay.dart';
import 'package:unit2/model/passo/class_components.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:unit2/model/passo/memoranda.dart';
import 'package:unit2/utils/request.dart'; import 'package:unit2/utils/request.dart';
import 'package:unit2/utils/urls.dart'; import 'package:unit2/utils/urls.dart';
@ -14,25 +9,16 @@ class MemorandaServices {
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz"; String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<Memoranda>> fetch() async { Future<http.Response> fetch() async {
String path = Url.instance.getMemoranda(); String path = Url.instance.getMemoranda();
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey, 'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientKeySecret
}; };
try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: {}, path: path, headers: headers); .getRequest(param: {}, path: path, headers: headers);
if (response.statusCode == 200) { return response;
final List result = jsonDecode(response.body)['data'];
return result.map(((e) => Memoranda.fromJson(e))).toList();
} else {
throw Exception(response.reasonPhrase);
}
} catch (e) {
throw e.toString();
}
} }
} }

View File

@ -19,7 +19,7 @@ class SignatoriesServices {
'X-Client-Key': xClientKey, 'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientKeySecret
}; };
try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: {}, path: path, headers: headers); .getRequest(param: {}, path: path, headers: headers);
@ -33,8 +33,5 @@ class SignatoriesServices {
print(response.reasonPhrase); print(response.reasonPhrase);
throw Exception(response.reasonPhrase); throw Exception(response.reasonPhrase);
} }
} catch (e) {
throw e.toString();
}
} }
} }

View File

@ -116,9 +116,9 @@ class PassCheckServices {
} }
////PUROK ////PUROK
if (assignRoleAreaType.areaTypeName.toLowerCase() == 'purok') { if (assignRoleAreaType.areaTypeName.toLowerCase() == 'purok') {
List<Purok> assignedArea = []; List<PassCheckPurok> assignedArea = [];
data['data'][0]['assigned_area'].forEach((var element) { data['data'][0]['assigned_area'].forEach((var element) {
Purok purok = Purok.fromJson(element['area']); PassCheckPurok purok = PassCheckPurok.fromJson(element['area']);
assignedArea.add(purok); assignedArea.add(purok);
}); });
statusResponse = assignedArea; statusResponse = assignedArea;
@ -172,7 +172,7 @@ class PassCheckServices {
double? temp, double? temp,
int? stationId, int? stationId,
String? cpId, String? cpId,
required int roleid}) async { required RoleIdRoleName roleIdRoleName}) async {
String path = Url.instance.postLogs(); String path = Url.instance.postLogs();
bool success; bool success;
Map<String, String> headers = { Map<String, String> headers = {
@ -182,9 +182,8 @@ class PassCheckServices {
}; };
Map body; Map body;
if (otherInputs) { if (otherInputs) {
if (roleid == 41 || roleid == 13 || roleid == 17 || roleid == 22) { if (roleIdRoleName.roleName.toLowerCase() == "security guard" || roleIdRoleName.roleName.toLowerCase() == "qr code scanner") {
if (io == "i") { if (io == "i") {
print("1");
body = { body = {
"station_id": stationId, "station_id": stationId,
"temperature": temp, "temperature": temp,
@ -193,7 +192,6 @@ class PassCheckServices {
"io": io "io": io
}; };
} else { } else {
print("2");
body = { body = {
"station_id": stationId, "station_id": stationId,
"destination": destination, "destination": destination,
@ -203,7 +201,6 @@ class PassCheckServices {
}; };
} }
} else { } else {
print("3");
if (io == "i") { if (io == "i") {
body = { body = {
"cp_id": cpId, "cp_id": cpId,
@ -213,7 +210,6 @@ class PassCheckServices {
"io": io "io": io
}; };
} else { } else {
print("4");
body = { body = {
"cp_id": cpId, "cp_id": cpId,
"destination": destination, "destination": destination,
@ -224,8 +220,7 @@ class PassCheckServices {
} }
} }
} else { } else {
print("5"); if (roleIdRoleName.roleName.toLowerCase() == "security guard" || roleIdRoleName.roleName.toLowerCase() == "qr code scanner") {
if (roleid == 41 || roleid == 13 || roleid == 17 || roleid == 22) {
body = { body = {
"station_id": stationId, "station_id": stationId,
"passer": passerId, "passer": passerId,
@ -233,7 +228,6 @@ class PassCheckServices {
"io": io "io": io
}; };
} else { } else {
print("6");
body = { body = {
"cp_id": cpId, "cp_id": cpId,
"temperature": temp, "temperature": temp,

View File

@ -0,0 +1,89 @@
import 'dart:convert';
import 'package:unit2/model/profile/assigned_area.dart';
import 'package:unit2/utils/urls.dart';
import 'package:http/http.dart' as http;
import '../../../utils/request.dart';
class RbacAssignedAreaServices {
static final RbacAssignedAreaServices _instance = RbacAssignedAreaServices();
static RbacAssignedAreaServices get instance => _instance;
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<UserAssignedArea>> getAssignedArea({required int id}) async {
List<UserAssignedArea> userAssignedAreas = [];
String path = Url.instance.getAssignAreas();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map<String, String> param = {
"assigned_role__user__id": id.toString(),
};
try {
http.Response response = await Request.instance
.getRequest(param: param, path: path, headers: headers);
if (response.statusCode == 200) {
Map data = jsonDecode(response.body);
if (data['data'] != null) {
for (var assignedArea in data['data']) {
UserAssignedArea newArea = UserAssignedArea.fromJson(assignedArea);
userAssignedAreas.add(newArea);
}
}
}
} catch (e) {
throw e.toString();
}
return userAssignedAreas;
}
Future<bool> deleteAssignedArea({required int areaId}) async {
bool success = false;
String path = "${Url.instance.getAssignAreas()}$areaId/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
try {
http.Response response = await Request.instance
.deleteRequest(path: path, headers: headers, body: {}, param: {});
if (response.statusCode == 200) {
success = true;
}else{
success = false;
}
} catch (e) {
throw e.toString();
}
return success;
}
Future<Map<dynamic, dynamic>> add ({required int userId, required int roleId, required int areaTypeId, required String areaId}) async{
String path = Url.instance.getAssignAreas();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map<dynamic, dynamic>? responseStatus = {};
Map body = {
"user_id":userId,
"role_id":roleId,
"assigned_areas": [{"areatypeid":areaTypeId,"areaid":areaId}]
};
try{
http.Response response = await Request.instance.postRequest(path: path, headers: headers, body: body, param: {});
if(response.statusCode == 201){
Map data = jsonDecode(response.body);
responseStatus = data;
} else {
responseStatus.addAll({'success': false});
}
}catch(e){
throw e.toString();
}
return responseStatus;
}
}

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:searchfield/searchfield.dart';
BoxDecoration box1(){ BoxDecoration box1(){
return const BoxDecoration( return const BoxDecoration(
@ -6,3 +7,9 @@ BoxDecoration box1(){
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(3))); borderRadius: BorderRadius.all(Radius.circular(3)));
} }
SuggestionDecoration searchFieldDecoration(){
return SuggestionDecoration(
boxShadow:const [BoxShadow(color: Colors.black12,spreadRadius: 5,blurRadius: 5)] ,
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(3)));
}

View File

@ -27,7 +27,7 @@ class AppRouter {
case '/': case '/':
BlocProvider.of<UserBloc>( BlocProvider.of<UserBloc>(
NavigationService.navigatorKey.currentContext!) NavigationService.navigatorKey.currentContext!)
.add(GetApkVersion()); .add(GetApkVersion(username: "", password: ""));
return MaterialPageRoute(builder: (_) { return MaterialPageRoute(builder: (_) {
return const UniT2Login(); return const UniT2Login();
}); });

View File

@ -13,7 +13,7 @@ Future<String> getCPUArchitecture() async {
try { try {
Response response = await dio.get(apkUrl, Response response = await dio.get(apkUrl,
options: Options( options: Options(
receiveTimeout: 20000, receiveTimeout:const Duration(seconds: 25),
receiveDataWhenStatusError: true, receiveDataWhenStatusError: true,
responseType: ResponseType.json, responseType: ResponseType.json,
followRedirects: false, followRedirects: false,
@ -37,8 +37,8 @@ Future<String> getCPUArchitecture() async {
throw TimeoutException("Connection timeout"); throw TimeoutException("Connection timeout");
} on SocketException catch (_) { } on SocketException catch (_) {
throw const SocketException("Connection timeout"); throw const SocketException("Connection timeout");
} on DioError catch (_) { } on DioException catch (e) {
throw DioErrorType.connectTimeout; throw e.toString();
} }
return downloadURL; return downloadURL;
} }

View File

@ -1,5 +1,7 @@
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import '../model/profile/basic_information/primary-information.dart';
double screenWidth = 0; double screenWidth = 0;
double screenHeight = 0; double screenHeight = 0;
double blockSizeHorizontal = 0; double blockSizeHorizontal = 0;
@ -11,6 +13,22 @@ double safeBlockVertical = 0;
const xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; const xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
const xClientSecret = "unitcYqAN7GGalyz"; const xClientSecret = "unitcYqAN7GGalyz";
String? globalFistname;
String? globalLastname;
String? globalMiddleName;
DateTime? globalBday;
String? globalSex;
Profile? globalCurrentProfile;
const String urlDownloadArmeabiv7aAPK =
"https://agusandelnorte.gov.ph/media/public/transparency/downloadables/UniT-App/v1.0.1/beta/unit_app_v1_0_1_beta_armeabi-v7a-release.apk?download";
const String urlDownloadX8664APK =
"https://agusandelnorte.gov.ph/media/public/transparency/downloadables/UniT-App/v1.0.1/beta/unit_app_v1_0_1_beta_x86_64-release.apk?download";
const String urlDownloadarm64v8aAPK =
"https://agusandelnorte.gov.ph/media/public/transparency/downloadables/UniT-App/v1.0.1/beta/unit_app_v1_0_1_beta_arm64-v8a-release.apk?download";

View File

@ -6,6 +6,7 @@ import 'package:unit2/model/location/city.dart';
import 'package:unit2/model/location/country.dart'; import 'package:unit2/model/location/country.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:unit2/model/location/provinces.dart'; import 'package:unit2/model/location/provinces.dart';
import 'package:unit2/model/location/purok.dart';
import 'package:unit2/utils/request.dart'; import 'package:unit2/utils/request.dart';
import 'package:unit2/utils/urls.dart'; import 'package:unit2/utils/urls.dart';
@ -23,7 +24,7 @@ class LocationUtils {
List<Country> countries = []; List<Country> countries = [];
String path = Url.instance.getCounties(); String path = Url.instance.getCounties();
try{ try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(path: path, param: {}, headers: headers); .getRequest(path: path, param: {}, headers: headers);
if (response.statusCode == 200) { if (response.statusCode == 200) {
@ -35,8 +36,8 @@ class LocationUtils {
}); });
} }
} }
}catch(e){ } catch (e) {
throw(e.toString()); throw (e.toString());
} }
return countries; return countries;
} }
@ -45,7 +46,7 @@ class LocationUtils {
List<Region> regions = []; List<Region> regions = [];
String path = Url.instance.getRegions(); String path = Url.instance.getRegions();
try{ try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(path: path, param: {}, headers: headers); .getRequest(path: path, param: {}, headers: headers);
if (response.statusCode == 200) { if (response.statusCode == 200) {
@ -57,8 +58,8 @@ class LocationUtils {
}); });
} }
} }
}catch(e){ } catch (e) {
throw(e.toString()); throw (e.toString());
} }
return regions; return regions;
} }
@ -70,6 +71,7 @@ class LocationUtils {
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(path: path, param: {}, headers: headers); .getRequest(path: path, param: {}, headers: headers);
if (response.statusCode == 200) {
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
if (data['data'] != null) { if (data['data'] != null) {
data['data'].forEach((var province) { data['data'].forEach((var province) {
@ -77,6 +79,7 @@ class LocationUtils {
provinces.add(newProvince); provinces.add(newProvince);
}); });
} }
}
} catch (e) { } catch (e) {
throw (e.toString()); throw (e.toString());
} }
@ -89,6 +92,7 @@ class LocationUtils {
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(path: path, param: {}, headers: headers); .getRequest(path: path, param: {}, headers: headers);
if (response.statusCode == 200) {
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
if (data['data'] != null) { if (data['data'] != null) {
data['data'].forEach((var city) { data['data'].forEach((var city) {
@ -96,6 +100,7 @@ class LocationUtils {
cities.add(cityMun); cities.add(cityMun);
}); });
} }
}
} catch (e) { } catch (e) {
throw (e.toString()); throw (e.toString());
} }
@ -108,6 +113,7 @@ class LocationUtils {
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(path: path, param: {}, headers: headers); .getRequest(path: path, param: {}, headers: headers);
if (response.statusCode == 200) {
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
if (data['data'] != null) { if (data['data'] != null) {
data['data'].forEach((var city) { data['data'].forEach((var city) {
@ -115,28 +121,50 @@ class LocationUtils {
barangays.add(barangay); barangays.add(barangay);
}); });
} }
}
} catch (e) { } catch (e) {
throw (e.toString()); throw (e.toString());
} }
return barangays; return barangays;
} }
Future<List<AddressCategory>>getAddressCategory()async{
Future<List<Purok>> getPurok({required String barangay}) async {
List<Purok> puroks = [];
String path = Url.instance.getPurok() + barangay;
try {
http.Response response = await Request.instance
.getRequest(path: path, param: {}, headers: headers);
if (response.statusCode == 200) {
Map data = jsonDecode(response.body);
if (data['data'] != null) {
data['data'].forEach((var purok) {
Purok newPurok = Purok.fromJson(purok);
puroks.add(newPurok);
});
}
}
} catch (e) {
throw (e.toString());
}
return puroks;
}
Future<List<AddressCategory>> getAddressCategory() async {
List<AddressCategory> categories = []; List<AddressCategory> categories = [];
String path = Url.instance.getAddressCategory(); String path = Url.instance.getAddressCategory();
try{ try {
http.Response response = await Request.instance.getRequest(path: path,param: {},headers:headers ); http.Response response = await Request.instance
.getRequest(path: path, param: {}, headers: headers);
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
if(data['data'] != null){ if (data['data'] != null) {
data['data'].forEach((var cat){ data['data'].forEach((var cat) {
categories.add(AddressCategory.fromJson(cat)); categories.add(AddressCategory.fromJson(cat));
}); });
} }
categories; categories;
return categories; return categories;
}catch(e){ } catch (e) {
throw e.toString(); throw e.toString();
} }
} }
} }

View File

@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:http/http.dart'; import 'package:http/http.dart';
import 'package:unit2/utils/text_container.dart'; import 'package:unit2/utils/text_container.dart';
import 'package:unit2/utils/urls.dart'; import 'package:unit2/utils/urls.dart';
@ -19,7 +18,7 @@ class Request {
Map<String, String>? param}) async { Map<String, String>? param}) async {
Response response; Response response;
try { try {
response = await get(Uri.http(host, path!, param), headers: headers) response = await get(Uri.https(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 +60,7 @@ class Request {
Map<String, String>? param}) async { Map<String, String>? param}) async {
Response response; Response response;
try { try {
response = await post(Uri.http(host, path!, param), response = await post(Uri.https(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 +103,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.http(host, path, param), response = await put(Uri.https(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 +187,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.http(host, path, param), response = await delete(Uri.https(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 (_) {

Some files were not shown because too many files have changed in this diff Show More