erge into develop

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
PGAN-MIS 2023-04-11 09:27:53 +08:00
parent 3789d998a8
commit 5dcfd32a51
38 changed files with 2409 additions and 2549 deletions

View File

@ -16,33 +16,57 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
EligibilityBloc() : super(EligibilityInitial()) {
List<Country>? globalCountries;
List<Region>? globalRegions;
List<Eligibility>? globalEligibilities;
List<EligibityCert>? eligibilities;
////=====================================================================
List<Eligibility> globalEligibilities = [];
List<EligibityCert> eligibilities = [];
//// LOAD ELIGIBILTY
on<LoadEligibility>((event, emit) {
emit(EligibilityLoadingState());
eligibilities = event.eligibilities;
emit(EligibilityLoaded(eligibilities: event.eligibilities));
if (eligibilities.isEmpty) {
GetEligibilities(profileId: event.profileId!, token: event.token!);
} else {
emit(EligibilityLoaded(eligibilities: eligibilities));
}
});
////====================================================================
on<GetEligibilities>((event, emit) async {
//// DELETE
on<DeleteEligibility>((event, emit) async {
try {
if (eligibilities != null) {
emit(EligibilityLoaded(eligibilities: eligibilities!));
final bool success = await EligibilityService.instance.delete(
eligibilityId: event.eligibilityId,
profileId: int.parse(event.profileId),
token: event.token);
if (success) {
eligibilities.removeWhere(
((EligibityCert element) => element.id == event.eligibilityId));
emit(DeletedState(
success: success,
));
} else {
emit(EligibilityLoadingState());
eligibilities = await EligibilityService.instance
.getEligibilities(event.profileId, event.token);
emit(EligibilityLoaded(eligibilities: eligibilities!));
emit(DeletedState(success: success));
}
} catch (e) {
emit(EligibilityErrorState(message: e.toString()));
}
});
////====================================================================
//// GET ELIGIBILITY
on<GetEligibilities>((event, emit) async {
try {
if (eligibilities.isNotEmpty) {
emit(EligibilityLoaded(eligibilities: eligibilities));
} else {
emit(EligibilityLoadingState());
eligibilities = await EligibilityService.instance
.getEligibilities(event.profileId, event.token);
emit(EligibilityLoaded(eligibilities: eligibilities));
}
} catch (e) {
emit(EligibilityErrorState(message: e.toString()));
}
});
//// SHOW EDIT FORM
on<ShowEditEligibilityForm>((event, emit) async {
try {
emit(EligibilityLoadingState());
if (globalCountries == null) {
List<Country> countries = await LocationUtils.instance.getCountries();
globalCountries = countries;
@ -51,12 +75,12 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
List<Region> regions = await LocationUtils.instance.getRegions();
globalRegions = regions;
}
if (globalEligibilities == null) {
if (globalEligibilities.isEmpty) {
List<Eligibility> eligibilities =
await ProfileUtilities.instance.getEligibilities();
globalEligibilities = eligibilities;
}
Eligibility currentEligibility = globalEligibilities!.firstWhere(
Eligibility currentEligibility = globalEligibilities.firstWhere(
(Eligibility eligibility) =>
event.eligibityCert.eligibility!.id == eligibility.id);
bool? isOverseas = event.eligibityCert.overseas;
@ -95,7 +119,7 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
eligibityCert: event.eligibityCert,
countries: globalCountries!,
regions: globalRegions!,
eligibilities: globalEligibilities!));
eligibilities: globalEligibilities));
} else {
emit(EditEligibilityState(
selectedCountry: currentCountry,
@ -109,17 +133,16 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
eligibityCert: event.eligibityCert,
countries: globalCountries!,
regions: globalRegions!,
eligibilities: globalEligibilities!));
eligibilities: globalEligibilities));
}
} catch (e) {
emit(EligibilityErrorState(message: e.toString()));
}
});
////====================================================================
//// UPDATE
on<UpdateEligibility>((event, emit) async {
try {
emit(EligibilityLoadingState());
Map<dynamic, dynamic> status = await EligibilityService.instance.update(
eligibityCert: event.eligibityCert,
token: event.token,
@ -127,26 +150,25 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
oldEligibility: event.oldEligibility);
if (status['success']) {
EligibityCert newEligibility = EligibityCert.fromJson(status['data']);
eligibilities!.removeWhere(
eligibilities.removeWhere(
(EligibityCert element) => element.id == event.eligibityCert.id);
eligibilities!.add(newEligibility);
emit(EligibilityEditedState(
eligibilities: eligibilities!, response: status));
eligibilities.add(newEligibility);
emit(EligibilityEditedState(response: status));
} else {
emit(EligibilityEditedState(
eligibilities: eligibilities!, response: status));
emit(EligibilityEditedState(response: status));
}
} catch (e) {
emit(EligibilityErrorState(message: e.toString()));
}
});
//// SHOW ADD FORM
on<ShowAddEligibilityForm>((event, emit) async {
emit(EligibilityLoadingState());
if (globalRegions == null) {
List<Region> regions = await LocationUtils.instance.getRegions();
globalRegions = regions;
}
if (globalEligibilities == null) {
if (globalEligibilities.isEmpty) {
List<Eligibility> eligibilities =
await ProfileUtilities.instance.getEligibilities();
globalEligibilities = eligibilities;
@ -157,37 +179,15 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
}
emit(AddEligibilityState(
eligibilities: globalEligibilities!,
eligibilities: globalEligibilities,
regions: globalRegions!,
countries: globalCountries!));
});
////====================================================================
on<DeleteEligibility>((event, emit) async {
emit(EligibilityLoadingState());
try {
final bool success = await EligibilityService.instance.delete(
eligibilityId: event.eligibilityId,
profileId: int.parse(event.profileId),
token: event.token);
if (success) {
event.eligibilities.removeWhere(
((EligibityCert element) => element.id == event.eligibilityId));
List<EligibityCert> eligibilities = event.eligibilities;
emit(DeletedState(success: success, eligibilities: eligibilities));
} else {
emit(DeletedState(
success: success, eligibilities: event.eligibilities));
}
} catch (e) {
emit(EligibilityErrorState(message: e.toString()));
}
});
////====================================================================
//// ADD
on<AddEligibility>(
(event, emit) async {
try {
emit(EligibilityLoadingState());
Map<dynamic, dynamic> status = await EligibilityService.instance.add(
eligibityCert: event.eligibityCert,
token: event.token,
@ -195,12 +195,10 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
if (status['success']) {
EligibityCert? eligibityCert =
EligibityCert.fromJson(status['data']);
eligibilities!.add(eligibityCert);
emit(EligibilityAddedState(
eligibilities: eligibilities!, response: status));
eligibilities.add(eligibityCert);
emit(EligibilityAddedState(response: status));
} else {
emit(EligibilityAddedState(
eligibilities: eligibilities!, response: status));
emit(EligibilityAddedState(response: status));
}
} catch (e) {
emit(EligibilityErrorState(message: e.toString()));

View File

@ -38,8 +38,9 @@ class UpdateEligibility extends EligibilityEvent{
List<Object> get props =>[eligibityCert,profileId,token,oldEligibility];
}
class LoadEligibility extends EligibilityEvent {
final List<EligibityCert> eligibilities;
const LoadEligibility({required this.eligibilities});
final int? profileId;
final String? token;
const LoadEligibility({ this.profileId, this.token});
@override
List<Object> get props => [];
}
@ -52,17 +53,16 @@ class ShowEditEligibilityForm extends EligibilityEvent {
}
class DeleteEligibility extends EligibilityEvent {
final List<EligibityCert> eligibilities;
final String profileId;
final int eligibilityId;
final String token;
const DeleteEligibility(
{required this.eligibilities,
{
required this.eligibilityId,
required this.profileId,
required this.token});
@override
List<Object> get props => [eligibilities, profileId, eligibilityId, token];
List<Object> get props => [ profileId, eligibilityId, token];
}
class CallErrorState extends EligibilityEvent{

View File

@ -43,11 +43,10 @@ class EditEligibilityState extends EligibilityState {
}
class DeletedState extends EligibilityState {
final List<EligibityCert> eligibilities;
final bool success;
const DeletedState({required this.eligibilities, required this.success});
const DeletedState({required this.success});
@override
List<Object> get props => [success, eligibilities];
List<Object> get props => [success];
}
class AddEligibilityState extends EligibilityState {
@ -63,20 +62,18 @@ class AddEligibilityState extends EligibilityState {
List<Object> get props => [eligibilities,countries,regions];
}
class EligibilityEditedState extends EligibilityState{
final List<EligibityCert> eligibilities;
final Map<dynamic,dynamic> response;
const EligibilityEditedState({required this.eligibilities, required this.response});
const EligibilityEditedState({required this.response});
@override
List<Object> get props =>[eligibilities, response];
List<Object> get props =>[ response];
}
class EligibilityAddedState extends EligibilityState{
final List<EligibityCert> eligibilities;
final Map<dynamic,dynamic> response;
const EligibilityAddedState({required this.eligibilities, required this.response});
const EligibilityAddedState({ required this.response});
@override
List<Object> get props =>[eligibilities,response];
List<Object> get props =>[response];
}
class EligibilityLoadingState extends EligibilityState{

View File

@ -1,6 +1,5 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/profile/work_history.dart';
import 'package:unit2/model/utils/agency.dart';
import 'package:unit2/model/utils/category.dart';
import 'package:unit2/sevices/profile/orgmembership_services.dart';
@ -30,7 +29,7 @@ class OrganizationMembershipBloc extends Bloc<OrganizationMembershipEvent, Organ
}
});
on<LoadOrganizationMemberships>((event,emit){
emit(OrganizationMembershipLoaded(orgMemberships: event.organizationMemberships));
emit(OrganizationMembershipLoaded(orgMemberships: organizationMemberships));
});
////SHOW ADD ORG MEMBERSHIP FORM
@ -52,15 +51,14 @@ class OrganizationMembershipBloc extends Bloc<OrganizationMembershipEvent, Organ
});
//// ADD ORGMEMBERSHIP
on<AddOrgMembership>((event,emit)async{
emit(OrgmembershipLoadingState());
try{
Map<dynamic,dynamic> status= await OrganizationMembershipServices.instance.add(agency: event.agency, token: event.token, profileId: event.profileId.toString());
if(status["success"]){
OrganizationMembership organizationMembership = OrganizationMembership.fromJson(status["data"]);
organizationMemberships.add(organizationMembership);
emit(OrgMembershipAddedState(orgMemberships: organizationMemberships, response: status));
emit(OrgMembershipAddedState( response: status));
}else{
emit(OrgMembershipAddedState(orgMemberships: organizationMemberships, response: status));
emit(OrgMembershipAddedState( response: status));
}
}catch(e){
emit(OrganizationMembershipErrorState(message: e.toString()));
@ -72,11 +70,10 @@ class OrganizationMembershipBloc extends Bloc<OrganizationMembershipEvent, Organ
try{
final bool success = await OrganizationMembershipServices.instance.delete(agency: event.org.agency!, profileId: event.profileId, token: event.token);
if(success){
event.organizationMemberships.removeWhere((element) => element.agency!.id == event.org.agency!.id );
List<OrganizationMembership> orgmemberships = event.organizationMemberships;
emit(OrgMembershipDeletedState(organizationMemberships: orgmemberships, success: success));
organizationMemberships.removeWhere((element) => element.agency!.id == event.org.agency!.id );
emit(OrgMembershipDeletedState(success: success));
}else{
emit(OrgMembershipDeletedState(organizationMemberships: organizationMemberships, success: success));
emit(OrgMembershipDeletedState(success: success));
}
}catch(e){
emit(OrganizationMembershipErrorState(message: e.toString()));

View File

@ -8,17 +8,15 @@ abstract class OrganizationMembershipEvent extends Equatable {
}
class LoadOrganizationMemberships extends OrganizationMembershipEvent{
final List<OrganizationMembership> organizationMemberships;
const LoadOrganizationMemberships({required this.organizationMemberships});
@override
List<Object> get props => [organizationMemberships];
List<Object> get props => [];
}
class GetOrganizationMembership extends OrganizationMembershipEvent{
final int? profileId;
final String? token;
const GetOrganizationMembership({ this.profileId, this.token});
const GetOrganizationMembership({this.profileId, this.token});
}
class ShowAddOrgMembershipForm extends OrganizationMembershipEvent{
@ -37,9 +35,9 @@ class DeleteOrgMemberShip extends OrganizationMembershipEvent{
final int profileId;
final String token;
final OrganizationMembership org;
final List<OrganizationMembership> organizationMemberships;
const DeleteOrgMemberShip({required this.profileId, required this.token, required this.org, required this.organizationMemberships});
const DeleteOrgMemberShip({required this.profileId, required this.token, required this.org,});
@override
List<Object> get props => [profileId,token,org,organizationMemberships];
List<Object> get props => [profileId,token,org];
}

View File

@ -27,18 +27,16 @@ class OrgmembershipLoadingState extends OrganizationMembershipState{
}
class OrgMembershipDeletedState extends OrganizationMembershipState{
final List<OrganizationMembership> organizationMemberships;
final bool success;
const OrgMembershipDeletedState({required this.organizationMemberships, required this.success});
const OrgMembershipDeletedState({ required this.success});
@override
List<Object> get props => [organizationMemberships,success];
List<Object> get props => [success];
}
class OrgMembershipAddedState extends OrganizationMembershipState{
final List<OrganizationMembership> orgMemberships;
final Map<dynamic,dynamic> response;
const OrgMembershipAddedState({required this.orgMemberships, required this.response});
const OrgMembershipAddedState({required this.response});
@override
List<Object> get props => [orgMemberships,response];
List<Object> get props => [response];
}
class AddOrgMembershipState extends OrganizationMembershipState{

View File

@ -14,7 +14,7 @@ part 'contact_state.dart';
class ContactBloc extends Bloc<ContactEvent, ContactState> {
ContactBloc() : super(ContactInitial()) {
List<ContactInfo> contactInformations = [];
List<ServiceType> serviceTypes =[];
List<ServiceType> serviceTypes = [];
//// get all contacts
on<GetContacts>((event, emit) {
emit(ContactLoadingState());
@ -26,72 +26,118 @@ class ContactBloc extends Bloc<ContactEvent, ContactState> {
}
});
//// Load Contacts
on<LoadContacts>((event,emit){
emit(ContactLoadedState(contactInformation: event.contactInformation));
on<LoadContacts>((event, emit) {
emit(ContactLoadedState(contactInformation: contactInformations));
});
//// show add form
on<ShowAddForm>((event,emit)async{
try{
emit(ContactLoadingState());
if(serviceTypes.isEmpty){
//// show add form
on<ShowAddForm>((event, emit) async {
try {
emit(ContactLoadingState());
if (serviceTypes.isEmpty) {
serviceTypes = await ProfileUtilities.instance.getServiceType();
}
emit(ContactAddingState(serviceTypes: serviceTypes));
} catch (e) {
emit(ContactErrorState(message: e.toString()));
}
});
///// Show edit form
on<ShowEditForm>((event, emit) async {
ServiceType serviceType;
List<CommService> commServiceProvivers;
CommService serviceProvider;
try{
if (serviceTypes.isEmpty) {
serviceTypes = await ProfileUtilities.instance.getServiceType();
}
emit(ContactAddingState(serviceTypes: serviceTypes));
}catch(e){
emit(ContactErrorState(message: e.toString()));
}
});
///// Show edit form
on<ShowEditForm>((event,emit)async{
ServiceType serviceType;
List<ServiceProvider> serviceProvivers;
ServiceProvider serviceProvider;
try{
if(serviceTypes.isEmpty){
serviceTypes = await ProfileUtilities.instance.getServiceType();
}
serviceType = serviceTypes.firstWhere((var element){
return event.contactInfo.commService!.serviceType!.id == element.id;
serviceType = serviceTypes.firstWhere((ServiceType element) {
return element.id == event.contactInfo.commService!.serviceType!.id;
});
serviceProvivers = await ContactService.instance.getServiceProvider(serviceTypeId: serviceType.id!);
serviceProvider = serviceProvivers.firstWhere((element) => element.id == event.contactInfo.commService!.serviceProvider!.id);
emit(ContactEditingState(serviceTypes: serviceTypes,selectedServiceType: serviceType,serviceProviders: serviceProvivers,selectedProvider: serviceProvider, contactInfo: event.contactInfo));
}catch(e){
emit(ContactErrorState(message: e.toString()));
}
});
////edit contact
on<EditContactInformation>((event,emit)async{
Map<dynamic,dynamic> responseStatus = await ContactService.instance.update(profileId: event.profileId, token: event.token, contactInfo: event.contactInfo);
if(responseStatus['success']){
ContactInfo contactInfo = ContactInfo.fromJson(responseStatus['data']['contact_info']);
contactInformations.removeWhere((ContactInfo element) => element.id == event.contactInfo.id);
contactInformations.add(contactInfo);
emit(ContactEditedState(contactInformation: contactInformations, response: responseStatus));
}else{
emit(ContactEditedState(contactInformation: contactInformations, response: responseStatus));
}
});
//// add contact
try{
}catch(e){
emit(ContactErrorState(message: e.toString()));
}
//// delete contact
on<DeleteContactInformation>((event, emit)async{
try{
final bool success = await ContactService.instance.deleteContact(profileId: event.profileId, token: event.token, contactInfo: event.contactInfo);
if(success){
contactInformations.removeWhere((element) => element.id == event.contactInfo.id);
emit(ContactDeletedState(contactInformation: contactInformations, succcess: success));
}else{
emit(ContactDeletedState(contactInformation: contactInformations, succcess: success));
commServiceProvivers = await ContactService.instance
.getServiceProvider(serviceTypeId: serviceType.id!);
serviceProvider = commServiceProvivers.firstWhere((CommService element) =>
element.id == event.contactInfo.commService!.id);
emit(ContactEditingState(
serviceTypes: serviceTypes,
selectedServiceType: serviceType,
commServiceProviders: commServiceProvivers,
selectedProvider: serviceProvider,
contactInfo: event.contactInfo));
}catch(e){
emit(ContactErrorState(message: e.toString()));
}
}catch(e){
emit(ContactErrorState(message: e.toString()));
}
});
});
////edit contact
on<EditContactInformation>((event, emit) async {
try {
Map<dynamic, dynamic> responseStatus = await ContactService.instance
.update(
profileId: event.profileId,
token: event.token,
contactInfo: event.contactInfo);
if (responseStatus['success']) {
ContactInfo contactInfo =
ContactInfo.fromJson(responseStatus['data']['contact_info']);
contactInformations.removeWhere(
(ContactInfo element) => element.id == event.contactInfo.id);
contactInformations.add(contactInfo);
emit(ContactEditedState(
response: responseStatus));
} else {
emit(ContactEditedState(
response: responseStatus));
}
} catch (e) {
emit(ContactErrorState(message: e.toString()));
}
});
//// add contact
on<AddContactInformation>((event, emit) async {
try {
Map<dynamic, dynamic> responseStatus = await ContactService.instance
.add(
profileId: event.profileId,
token: event.token,
contactInfo: event.contactInfo);
if (responseStatus['success']) {
ContactInfo contactInfo =
ContactInfo.fromJson(responseStatus['data']['contact_info']);
contactInformations.add(contactInfo);
emit(ContactEditedState(
response: responseStatus));
} else {
emit(ContactEditedState(
response: responseStatus));
}
} catch (e) {
emit(ContactErrorState(message: e.toString()));
}
});
//// delete contact
on<DeleteContactInformation>((event, emit) async {
try {
final bool success = await ContactService.instance.deleteContact(
profileId: event.profileId,
token: event.token,
contactInfo: event.contactInfo);
if (success) {
contactInformations
.removeWhere((element) => element.id == event.contactInfo.id);
emit(ContactDeletedState(
succcess: success));
} else {
emit(ContactDeletedState(
succcess: success));
}
} catch (e) {
emit(ContactErrorState(message: e.toString()));
}
});
}
}

View File

@ -17,10 +17,9 @@ class GetContacts extends ContactEvent{
//// load contacts
class LoadContacts extends ContactEvent{
final List<ContactInfo> contactInformation;
const LoadContacts({required this.contactInformation});
@override
List<Object> get props => [contactInformation];
List<Object> get props => [];
}
//// show add form

View File

@ -30,11 +30,11 @@ class ContactAddingState extends ContactState{
//// Editing state
class ContactEditingState extends ContactState{
final List<ServiceType> serviceTypes;
final List<ServiceProvider> serviceProviders;
final ServiceProvider selectedProvider;
final List<CommService> commServiceProviders;
final CommService selectedProvider;
final ServiceType selectedServiceType;
final ContactInfo contactInfo;
const ContactEditingState({ required this.serviceTypes, required this.selectedServiceType, required this.selectedProvider, required this.serviceProviders, required this.contactInfo});
const ContactEditingState({ required this.serviceTypes, required this.selectedServiceType, required this.selectedProvider, required this.commServiceProviders, required this.contactInfo});
@override
List<Object> get props => [serviceTypes];
}
@ -42,11 +42,11 @@ class ContactEditingState extends ContactState{
//// added state
class ContactAddedState extends ContactState{
final List<ContactInfo> contactInformation;
final Map<dynamic,dynamic> response;
const ContactAddedState({required this.contactInformation, required this.response});
const ContactAddedState({ required this.response});
@override
List<Object> get props => [contactInformation,response];
List<Object> get props => [response];
}
@ -54,19 +54,19 @@ class ContactAddedState extends ContactState{
//// edited state
class ContactEditedState extends ContactState{
final List<ContactInfo> contactInformation;
final Map<dynamic,dynamic> response;
const ContactEditedState({required this.contactInformation, required this.response});
const ContactEditedState({ required this.response});
@override
List<Object> get props => [contactInformation,response];
List<Object> get props => [response];
}
////deleted state
class ContactDeletedState extends ContactState{
final List<ContactInfo> contactInformation;
final bool succcess;
const ContactDeletedState({required this.contactInformation, required this.succcess});
const ContactDeletedState({required this.succcess});
@override
List<Object> get props => [contactInformation,succcess];
List<Object> get props => [succcess];
}
////error state

View File

@ -104,7 +104,11 @@ class ReferencesBloc extends Bloc<ReferencesEvent, ReferencesState> {
event.personalReference.address!.cityMunicipality!.code ==
city.code);
List<Barangay> barangays = await LocationUtils.instance.getBarangay(code: selectedCity.code.toString());
selectedBarangay = barangays.firstWhere((Barangay barangay)=>event.personalReference.address!.barangay!.code == barangay.code);
if(event.personalReference.address?.barangay!=null){
selectedBarangay = barangays.firstWhere((Barangay barangay)=>event.personalReference.address?.barangay?.code == barangay.code);
}else{
selectedBarangay = null;
}
emit(EditReferenceState(
selectedRegion: selectedRegion,
ref: event.personalReference,
@ -144,17 +148,16 @@ class ReferencesBloc extends Bloc<ReferencesEvent, ReferencesState> {
message: "Something went wrong. Please try again"));
//// EDIT REFERENCES EVENT
});on<EditReference>((event,emit)async{
emit(ReferencesLoadingState());
Map<dynamic,dynamic> status =await ReferencesServices.instace.update(ref: event.reference, token: event.token, profileId: event.profileId);
if (status['success']) {
PersonalReference ref = PersonalReference.fromJson(status['data']);
references.removeWhere((PersonalReference element)=>element.id == event.reference.id);
references.add(ref);
emit(
ReferenceEditedState(personalRefs: references, response: status));
ReferenceEditedState( response: status));
} else {
emit(
ReferenceEditedState(personalRefs: references, response: status));
ReferenceEditedState( response: status));
}
});
@ -171,10 +174,10 @@ class ReferencesBloc extends Bloc<ReferencesEvent, ReferencesState> {
PersonalReference ref = PersonalReference.fromJson(status['data']);
references.add(ref);
emit(
ReferencesAddedState(personalRefs: references, response: status));
ReferencesAddedState( response: status));
} else {
emit(
ReferencesAddedState(personalRefs: references, response: status));
ReferencesAddedState( response: status));
}
} catch (e) {
emit(ReferencesErrorState(message: e.toString()));
@ -183,7 +186,6 @@ class ReferencesBloc extends Bloc<ReferencesEvent, ReferencesState> {
////LOAD REFERENCE
on<LoadReferences>((event, emit) {
emit(ReferencesLoadingState());
references = event.references;
emit(ReferencesLoadedState(references: references));
});
@ -196,9 +198,9 @@ class ReferencesBloc extends Bloc<ReferencesEvent, ReferencesState> {
event.references.removeWhere(
(PersonalReference element) => element.id == event.refId);
references = event.references;
emit(DeleteReferenceState(references: references, success: success));
emit(DeleteReferenceState( success: success));
} else {
emit(DeleteReferenceState(references: references, success: success));
emit(DeleteReferenceState(success: success));
}
} catch (e) {
emit(ReferencesErrorState(message: e.toString()));

View File

@ -7,63 +7,60 @@ abstract class ReferencesEvent extends Equatable {
List<Object> get props => [];
}
class GetReferences extends ReferencesEvent{
class GetReferences extends ReferencesEvent {
final int profileId;
final String token;
const GetReferences({required this.profileId, required this.token});
@override
List<Object> get props => [profileId,token];
@override
List<Object> get props => [profileId, token];
}
class ShowAddReferenceForm extends ReferencesEvent{
}
class ShowAddReferenceForm extends ReferencesEvent {}
class ShowEditReferenceForm extends ReferencesEvent{
class ShowEditReferenceForm extends ReferencesEvent {
final PersonalReference personalReference;
const ShowEditReferenceForm({required this.personalReference});
@override
@override
List<Object> get props => [personalReference];
}
class CallErrorState extends ReferencesEvent{
}
class CallErrorState extends ReferencesEvent {}
class AddReference extends ReferencesEvent{
class AddReference extends ReferencesEvent {
final PersonalReference reference;
final String token;
final int profileId;
const AddReference({required this.profileId, required this.reference,required this.token});
@override
List<Object> get props => [profileId,token,reference];
}
class EditReference extends ReferencesEvent{
final PersonalReference reference;
final String token;
final int profileId;
const EditReference({required this.profileId, required this.reference,required this.token});
@override
List<Object> get props => [profileId,token,reference];
const AddReference(
{required this.profileId, required this.reference, required this.token});
@override
List<Object> get props => [profileId, token, reference];
}
class DeleteReference extends ReferencesEvent{
final List<PersonalReference>references;
class EditReference extends ReferencesEvent {
final PersonalReference reference;
final String token;
final int profileId;
const EditReference(
{required this.profileId, required this.reference, required this.token});
@override
List<Object> get props => [profileId, token, reference];
}
class DeleteReference extends ReferencesEvent {
final List<PersonalReference> references;
final int profileId;
final String token;
final int refId;
const DeleteReference({required this.profileId, required this.refId, required this.references, required this.token});
@override
List<Object> get props => [profileId,token,refId,references];
}
class LoadReferences extends ReferencesEvent{
final List<PersonalReference> references;
const LoadReferences({required this.references});
const DeleteReference(
{required this.profileId,
required this.refId,
required this.references,
required this.token});
@override
List<Object> get props => [references];
List<Object> get props => [profileId, token, refId, references];
}
class LoadReferences extends ReferencesEvent {
@override
List<Object> get props => [];
}

View File

@ -28,20 +28,19 @@ class ReferencesErrorState extends ReferencesState {
class ReferencesLoadingState extends ReferencesState {}
class ReferencesAddedState extends ReferencesState {
final List<PersonalReference> personalRefs;
final Map<dynamic, dynamic> response;
const ReferencesAddedState(
{required this.personalRefs, required this.response});
{ required this.response});
@override
List<Object> get props => [personalRefs, response];
List<Object> get props => [ response];
}
class ReferenceEditedState extends ReferencesState {
final List<PersonalReference> personalRefs;
final Map<dynamic, dynamic> response;
const ReferenceEditedState(
{required this.personalRefs, required this.response});
{ required this.response});
@override
List<Object> get props => [personalRefs, response];
List<Object> get props => [ response];
}
class EditReferenceState extends ReferencesState {
@ -89,7 +88,6 @@ class AddReferenceState extends ReferencesState {
}
class DeleteReferenceState extends ReferencesState {
final List<PersonalReference> references;
final bool success;
const DeleteReferenceState({required this.references, required this.success});
const DeleteReferenceState({ required this.success});
}

View File

@ -24,9 +24,12 @@ class WorkHistoryBloc extends Bloc<WorkHistorytEvent, WorkHistoryState> {
on<GetWorkHistories>((event, emit) async {
emit(WorkHistoryLoadingState());
try {
List<WorkHistory> works = await WorkHistoryService.instance
.getWorkExperiences(event.profileId, event.token);
workExperiences = works;
if (workExperiences.isEmpty) {
List<WorkHistory> works = await WorkHistoryService.instance
.getWorkExperiences(event.profileId!, event.token!);
workExperiences = works;
}
emit(WorkHistoryLoaded(workExperiences: workExperiences));
} catch (e) {
emit(WorkHistoryErrorState(message: e.toString()));
@ -35,34 +38,29 @@ class WorkHistoryBloc extends Bloc<WorkHistorytEvent, WorkHistoryState> {
///// LOAD WORK HISTORIES
on<LoadWorkHistories>((event, emit) {
emit(WorkHistoryLoadingState());
workExperiences = event.workHistories;
emit(WorkHistoryLoaded(workExperiences: workExperiences));
});
////DELETE
on<DeleteWorkHistory>((event, emit) async {
emit(WorkHistoryLoadingState());
try {
final bool success = await WorkHistoryService.instance.delete(
profileId: event.profileId,
token: event.token,
work: event.workHistory);
if (success) {
event.workHistories.removeWhere(
workExperiences.removeWhere(
(WorkHistory element) => element.id == event.workHistory.id);
List<WorkHistory> newWorkHistories = event.workHistories;
emit(DeletedState(success: success, workHistories: newWorkHistories));
emit(DeletedState(success: success));
} else {
emit(DeletedState(
success: success, workHistories: event.workHistories));
emit(DeletedState(success: success));
}
} catch (e) {
emit(WorkHistoryErrorState(message: e.toString()));
}
});
//// ADD WORK HISTORIES
//// ADD WORK HISTORIES
on<AddWorkHostory>((event, emit) async {
try {
emit(WorkHistoryLoadingState());
Map<dynamic, dynamic> status = await WorkHistoryService.instance.add(
isPrivate: event.isPrivate,
workHistory: event.workHistory,
@ -71,39 +69,39 @@ class WorkHistoryBloc extends Bloc<WorkHistorytEvent, WorkHistoryState> {
if (status['success']) {
WorkHistory workHistory = WorkHistory.fromJson(status['data']);
workExperiences.add(workHistory);
emit(WorkHistoryAddedState(
response: status, workExperiences: workExperiences));
emit(WorkHistoryAddedState(response: status));
} else {
emit(WorkHistoryAddedState(
response: status, workExperiences: workExperiences));
emit(WorkHistoryAddedState(response: status));
}
} catch (e) {
emit(WorkHistoryErrorState(message: e.toString()));
}
});
////UPDATE WORK HISTORY
on<UpdateWorkHistory>((event, emit)async{
emit(WorkHistoryLoadingState());
// try{
Map<dynamic,dynamic> status = await WorkHistoryService.instance.update(oldWorkHistory: event.oldWorkHistory, newWorkHistory: event.workHistory, token: event.token, profileId: event.profileId);
if(status['success']){
WorkHistory workHistory = WorkHistory.fromJson(status['data']);
workExperiences.removeWhere((WorkHistory work) {
return work.id == event.oldWorkHistory.id;
on<UpdateWorkHistory>((event, emit) async {
try {
Map<dynamic, dynamic> status = await WorkHistoryService.instance.update(
oldWorkHistory: event.oldWorkHistory,
newWorkHistory: event.workHistory,
token: event.token,
profileId: event.profileId);
if (status['success']) {
WorkHistory workHistory = WorkHistory.fromJson(status['data']);
workExperiences.removeWhere((WorkHistory work) {
return work.id == event.oldWorkHistory.id;
});
workExperiences.add(workHistory);
emit(WorkHistoryEditedState(response: status));
} else {
emit(WorkHistoryEditedState(
response: status,
));
}
} catch (e) {
emit(WorkHistoryErrorState(message: e.toString()));
}
});
workExperiences.add(workHistory);
emit(WorkHistoryEditedState(workExperiences: workExperiences,response: status));
}else{
emit(WorkHistoryEditedState(response: status, workExperiences: workExperiences));
}
// }catch(e){
// emit(WorkHistoryErrorState(message: e.toString()));
// }
});
////SHOW EDIT WORK HISTORIES
on<ShowEditWorkHistoryForm>((event, emit) async {
@ -150,23 +148,31 @@ on<UpdateWorkHistory>((event, emit)async{
emit(WorkHistoryLoadingState());
try {
/////POSITIONS------------------------------------------
List<Position> positions =
await WorkHistoryService.instance.getAgencyPosition();
agencyPositions = positions;
if (agencyPositions.isEmpty) {
List<Position> positions =
await WorkHistoryService.instance.getAgencyPosition();
agencyPositions = positions;
}
/////AGENCIES------------------------------------------
List<Agency> newAgencies =
await ProfileUtilities.instance.getAgecies();
agencies = newAgencies;
if (agencies.isEmpty) {
List<Agency> newAgencies =
await ProfileUtilities.instance.getAgecies();
agencies = newAgencies;
}
/////Category Agency------------------------------------------
List<Category> categoryAgencies =
await ProfileUtilities.instance.agencyCategory();
agencyCategory = categoryAgencies;
if (agencyCategory.isEmpty) {
List<Category> categoryAgencies =
await ProfileUtilities.instance.agencyCategory();
agencyCategory = categoryAgencies;
}
/////////-------------------------------------
List<AppoinemtStatus> status =
WorkHistoryService.instance.getAppointmentStatusList();
appointmentStatus = status;
if (appointmentStatus.isEmpty) {
List<AppoinemtStatus> status =
WorkHistoryService.instance.getAppointmentStatusList();
appointmentStatus = status;
}
emit(AddWorkHistoryState(
agencyPositions: agencyPositions,

View File

@ -18,10 +18,8 @@ class GetWorkHistories extends WorkHistorytEvent{
}
class LoadWorkHistories extends WorkHistorytEvent{
final List<WorkHistory> workHistories;
const LoadWorkHistories({required this.workHistories});
@override
List<Object> get props => [workHistories];
List<Object> get props => [];
}
class ShowAddWorkHistoryForm extends WorkHistorytEvent{
@ -35,13 +33,12 @@ class ShowEditWorkHistoryForm extends WorkHistorytEvent{
}
class DeleteWorkHistory extends WorkHistorytEvent{
final List<WorkHistory> workHistories;
final String token;
final int profileId;
final WorkHistory workHistory;
const DeleteWorkHistory({required this.profileId, required this.token, required this.workHistory, required this.workHistories});
const DeleteWorkHistory({required this.profileId, required this.token, required this.workHistory});
@override
List<Object> get props => [token, profileId,workHistory, workHistories];
List<Object> get props => [token, profileId,workHistory];
}
class UpdateWorkHistory extends WorkHistorytEvent{

View File

@ -53,25 +53,22 @@ class EditWorkHistoryState extends WorkHistoryState{
}
class DeletedState extends WorkHistoryState{
final List<WorkHistory> workHistories;
final bool success;
const DeletedState({required this.success, required this.workHistories});
const DeletedState({required this.success});
@override
List<Object> get props => [workHistories,success];
List<Object> get props => [success];
}
class WorkHistoryEditedState extends WorkHistoryState{
final List<WorkHistory> workExperiences;
final Map<dynamic,dynamic> response;
const WorkHistoryEditedState({required this.response, required this.workExperiences});
const WorkHistoryEditedState({required this.response});
@override
List<Object> get props => [workExperiences,response];
List<Object> get props => [response];
}
class WorkHistoryAddedState extends WorkHistoryState{
final List<WorkHistory> workExperiences;
final Map<dynamic,dynamic> response;
const WorkHistoryAddedState({required this.response, required this.workExperiences});
const WorkHistoryAddedState({required this.response});
@override
List<Object> get props => [workExperiences,response];
List<Object> get props => [response];
}

View File

@ -34,6 +34,8 @@ class UserBloc extends Bloc<UserEvent, UserState> {
final String? saved = CREDENTIALS?.get('saved');
final String? username = CREDENTIALS?.get('username');
final String? password = CREDENTIALS?.get('password');
debugPrint(username);
debugPrint(password);
if (saved != null) {
save = true;
add(UserLogin(username: username, password: password));

View File

@ -31,14 +31,14 @@ class _AddContactInformationScreenState
extends State<AddContactInformationScreen> {
final formKey = GlobalKey<FormBuilderState>();
ServiceType? selectedServiceType;
ServiceProvider? selectedProvider;
List<ServiceProvider> serviceProviders = [];
CommService? selectedCommServiceProvider;
List<CommService> commServiceProviders = [];
bool callServiceType = false;
bool primaryaContact = false;
bool active = false;
String? numberMail;
var mobileFormatter = MaskTextInputFormatter(
mask: "+63 (##) ###-###",
mask: "+63 (###) ###-####",
filter: {"#": RegExp(r"^[1-9][0-9]*$")},
type: MaskAutoCompletionType.lazy,
initialText: "0");
@ -82,7 +82,7 @@ class _AddContactInformationScreenState
setState(() {
callServiceType = true;
});
serviceProviders = await ContactService.instance
commServiceProviders = await ContactService.instance
.getServiceProvider(
serviceTypeId: selectedServiceType!.id!);
setState(() {
@ -101,22 +101,22 @@ class _AddContactInformationScreenState
child: ModalProgressHUD(
color: Colors.transparent,
inAsyncCall: callServiceType,
child: FormBuilderDropdown<ServiceProvider>(
child: FormBuilderDropdown<CommService>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "Service Provider",
items: serviceProviders.isEmpty
items: commServiceProviders.isEmpty
? []
: serviceProviders
.map<DropdownMenuItem<ServiceProvider>>(
(ServiceProvider e) {
return DropdownMenuItem<ServiceProvider>(
value: e, child: Text(e.agency!.name!));
: commServiceProviders
.map<DropdownMenuItem<CommService>>(
(CommService e) {
return DropdownMenuItem<CommService>(
value: e, child: Text(e.serviceProvider!.agency!.name!));
}).toList(),
decoration: normalTextFieldStyle(
"Communication Service *", ""),
onChanged: (var serviceProvider) {
selectedProvider = serviceProvider;
selectedCommServiceProvider = serviceProvider;
}),
),
),
@ -215,10 +215,7 @@ class _AddContactInformationScreenState
numberMail =
formKey.currentState!.value['number-mail'];
CommService commService = CommService(
id: null,
serviceType: selectedServiceType,
serviceProvider: selectedProvider);
CommService commService = selectedCommServiceProvider!;
ContactInfo contactInfo = ContactInfo(
id: null,
active: active,

View File

@ -31,15 +31,15 @@ class _EditContactInformationScreenState
extends State<EditContactInformationScreen> {
final formKey = GlobalKey<FormBuilderState>();
ServiceType? selectedServiceType;
ServiceProvider? selectedProvider;
List<ServiceProvider> serviceProviders = [];
CommService? selectedCommProvider;
List<CommService> commServiceProviders = [];
String? numberMail;
bool callServiceType = false;
bool? primaryaContact;
bool? active;
var mobileFormatter = MaskTextInputFormatter(
mask: "+63 (##) ###-###",
mask: "+63 (###) ###-####",
filter: {"#": RegExp(r"^[1-9][0-9]*$")},
type: MaskAutoCompletionType.lazy,
initialText: "0");
@ -56,8 +56,8 @@ class _EditContactInformationScreenState
builder: (context, state) {
if (state is ContactEditingState) {
selectedServiceType = state.selectedServiceType;
selectedProvider = state.selectedProvider;
serviceProviders = state.serviceProviders;
selectedCommProvider = state.selectedProvider;
commServiceProviders = state.commServiceProviders;
primaryaContact = state.contactInfo.primary!;
active = state.contactInfo.active!;
return FormBuilder(
@ -91,11 +91,11 @@ class _EditContactInformationScreenState
setState(() {
callServiceType = true;
});
serviceProviders = await ContactService.instance
commServiceProviders = await ContactService.instance
.getServiceProvider(
serviceTypeId:
selectedServiceType!.id!);
selectedProvider = null;
selectedCommProvider = null;
setState(() {
setState(() {
callServiceType = false;
@ -112,24 +112,24 @@ class _EditContactInformationScreenState
child: ModalProgressHUD(
color: Colors.transparent,
inAsyncCall: callServiceType,
child: DropdownButtonFormField<ServiceProvider>(
value: selectedProvider,
child: DropdownButtonFormField<CommService>(
value: selectedCommProvider,
validator: FormBuilderValidators.required(
errorText: "This field is required"),
items: serviceProviders.isEmpty
items: commServiceProviders.isEmpty
? []
: serviceProviders
.map<DropdownMenuItem<ServiceProvider>>(
(ServiceProvider e) {
: commServiceProviders
.map<DropdownMenuItem<CommService>>(
(CommService e) {
return DropdownMenuItem<
ServiceProvider>(
CommService>(
value: e,
child: Text(e.agency!.name!));
child: Text(e.serviceProvider!.agency!.name!));
}).toList(),
decoration: normalTextFieldStyle(
"Communication Service *", ""),
onChanged: (var serviceProvider) {
selectedProvider = serviceProvider;
onChanged: (var commServiceProvider) {
selectedCommProvider = commServiceProvider;
}),
),
),
@ -243,10 +243,7 @@ class _EditContactInformationScreenState
if (formKey.currentState!.saveAndValidate()) {
numberMail =
formKey.currentState!.value['number-mail'];
CommService commService = CommService(
id: state.contactInfo.commService!.id,
serviceType: selectedServiceType,
serviceProvider: selectedProvider);
CommService commService = selectedCommProvider!;
ContactInfo contactInfo = ContactInfo(
id: state.contactInfo.id,
active: active,

View File

@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:fluttericon/font_awesome_icons.dart';
import 'package:unit2/bloc/profile/primary_information/contact/contact_bloc.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart';
@ -14,9 +13,9 @@ import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/utils/alerts.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/Leadings/close_leading.dart';
import 'package:unit2/widgets/empty_data.dart';
import '../../../../bloc/profile/eligibility/eligibility_bloc.dart';
import 'package:unit2/widgets/error_state.dart';
class ContactInformationScreen extends StatelessWidget {
const ContactInformationScreen({
@ -33,11 +32,15 @@ class ContactInformationScreen extends StatelessWidget {
title: const Text(contactScreenTitle),
centerTitle: true,
backgroundColor: primary,
actions: [
actions: context.watch<ContactBloc>().state is ContactLoadedState? [
AddLeading(onPressed: () {
context.read<ContactBloc>().add(ShowAddForm());
})
],
]:( context.watch<ContactBloc>().state is ContactAddingState || context.watch<ContactBloc>().state is ContactEditingState)?[
CloseLeading(onPressed: (){
context.read<ContactBloc>().add(LoadContacts());
})
]:[]
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
@ -67,15 +70,14 @@ class ContactInformationScreen extends StatelessWidget {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
////EDIT CONTACT STATE
if (state is ContactEditedState) {
////ADDED CONTACT STATE
if (state is ContactAddedState) {
if (state.response['success']) {
successAlert(context, "Update Successfull!",
state.response['message'], () {
Navigator.of(context).pop();
context.read<ContactBloc>().add(LoadContacts(
contactInformation:
state.contactInformation));
));
});
} else {
errorAlert(context, "Update Failed",
@ -83,8 +85,27 @@ class ContactInformationScreen extends StatelessWidget {
() {
Navigator.of(context).pop();
context.read<ContactBloc>().add(LoadContacts(
contactInformation:
state.contactInformation));
));
});
}
}
////EDIT CONTACT STATE
if (state is ContactEditedState) {
if (state.response['success']) {
successAlert(context, "Update Successfull!",
state.response['message'], () {
Navigator.of(context).pop();
context.read<ContactBloc>().add(LoadContacts(
));
});
} else {
errorAlert(context, "Update Failed",
"Something went wrong. Please try again.",
() {
Navigator.of(context).pop();
context.read<ContactBloc>().add(LoadContacts(
));
});
}
}
@ -97,16 +118,14 @@ class ContactInformationScreen extends StatelessWidget {
() {
Navigator.of(context).pop();
context.read<ContactBloc>().add(LoadContacts(
contactInformation:
state.contactInformation));
));
});
} else {
errorAlert(context, "Deletion Failed",
"Error deleting Contact Info", () {
Navigator.of(context).pop();
context.read<ContactBloc>().add(LoadContacts(
contactInformation:
state.contactInformation));
));
});
}
}
@ -136,8 +155,7 @@ class ContactInformationScreen extends StatelessWidget {
children: [
Container(
decoration: box1(),
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8),
padding: const EdgeInsets.fromLTRB(12, 12, 0, 12),
child: Row(
children: [
Expanded(
@ -149,30 +167,18 @@ class ContactInformationScreen extends StatelessWidget {
CrossAxisAlignment
.start,
children: [
Text(numberMail,
style: Theme.of(
context)
.textTheme
.titleMedium!
.copyWith(
fontWeight:
FontWeight
.w500)),
const Divider(),
const SizedBox(
height: 5,
),
Row(
children: [
Expanded(
child: Text(
commService
.toString(),
style: Theme.of(
context)
.textTheme
.titleSmall,
),
numberMail,
style: Theme.of(
context)
.textTheme
.titleMedium!
.copyWith(
fontWeight:
FontWeight.w500)),
),
state.contactInformation[index]
.active ==
@ -201,17 +207,40 @@ class ContactInformationScreen extends StatelessWidget {
: const SizedBox()
],
),
const Divider(),
const SizedBox(
height: 5,
),
Text(state
.contactInformation[
index]
.commService!
.serviceProvider!
.agency!
.name
.toString()),
Row(
children: [
Flexible(
flex: 2,
child: Text(
commService
.toString().toUpperCase(),
style: Theme.of(
context)
.textTheme
.titleSmall,
),
),
const SizedBox(
child: Text(" - "),
),
Flexible(
flex: 1,
child: Text(state
.contactInformation[
index]
.commService!
.serviceProvider!
.agency!
.name
.toString()),
),
],
),
]),
),
AppPopupMenu<int>(
@ -298,6 +327,12 @@ class ContactInformationScreen extends StatelessWidget {
return EditContactInformationScreen(
profileId: profileId, token: token);
}
if (state is ContactErrorState) {
return SomethingWentWrong(
message: state.message, onpressed: () {
context.read<ContactBloc>().add(LoadContacts());
});
}
return Container();
},
);

View File

@ -24,7 +24,10 @@ import '../../../../utils/location_utilities.dart';
import '../../../../utils/text_container.dart';
class AddEligibilityScreen extends StatefulWidget {
const AddEligibilityScreen({super.key});
const AddEligibilityScreen(
{super.key, required this.profileId, required this.token});
final int profileId;
final String token;
@override
State<AddEligibilityScreen> createState() => _AddEligibilityScreenState();
@ -32,7 +35,7 @@ class AddEligibilityScreen extends StatefulWidget {
class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
final formKey = GlobalKey<FormBuilderState>();
bool? overseas;
bool? overseas = false;
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
Region? selectedRegion;
Province? selectedProvince;
@ -51,449 +54,400 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
String? license;
@override
Widget build(BuildContext context) {
////USERBLOC
return BlocBuilder<UserBloc, UserState>(
return BlocBuilder<EligibilityBloc, EligibilityState>(
buildWhen: (previous, current) {
return false;
},
builder: (context, state) {
////LOGGED IN USER STATE
if (state is UserLoggedIn) {
////PROFIILE BLOC
token = state.userData!.user!.login!.token;
profileId = state.userData!.user!.login!.user!.profileId.toString();
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if (state is ProfileLoaded) {
return BlocBuilder<EligibilityBloc, EligibilityState>(
buildWhen: (previous, current) {
if (state is EditEligibilityState) {}
return false;
},
builder: (context, state) {
////ADD ELIGIBILITY STATE
if (state is AddEligibilityState) {
return ProgressHUD(
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 25, horizontal: 18),
child: FormBuilder(
key: formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
////ELIGIBILITIES DROPDOWN
FormBuilderDropdown<Eligibility>(
onChanged: (Eligibility? eligibility) {
selectedEligibility = eligibility;
},
autovalidateMode:
AutovalidateMode.onUserInteraction,
validator: (value) =>
value == null ? 'required' : null,
items: state.eligibilities
.map<DropdownMenuItem<Eligibility>>(
(Eligibility eligibility) {
return DropdownMenuItem<Eligibility>(
value: eligibility,
child: Text(eligibility.title));
}).toList(),
name: "eligibility",
decoration: normalTextFieldStyle(
"Eligibility", "Eligibility")),
const SizedBox(
height: 20,
////ADD ELIGIBILITY STATE
if (state is AddEligibilityState) {
return SingleChildScrollView(
child: SizedBox(
height: screenHeight * .95,
child: ProgressHUD(
child: Center(
child: Padding(
padding:
const EdgeInsets.symmetric(vertical: 25, horizontal: 18),
child: FormBuilder(
key: formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
////ELIGIBILITIES DROPDOWN
FormBuilderDropdown<Eligibility>(
onChanged: (Eligibility? eligibility) {
selectedEligibility = eligibility;
},
autovalidateMode:
AutovalidateMode.onUserInteraction,
validator: (value) =>
value == null ? 'required' : null,
items: state.eligibilities
.map<DropdownMenuItem<Eligibility>>(
(Eligibility eligibility) {
return DropdownMenuItem<Eligibility>(
value: eligibility,
child: Text(eligibility.title));
}).toList(),
name: "eligibility",
decoration: normalTextFieldStyle(
"Eligibility", "Eligibility")),
const SizedBox(
height: 8,
),
SizedBox(
width: screenWidth,
child: Row(
children: [
////LICENSE NUMBER
Flexible(
flex: 1,
child: FormBuilderTextField(
onChanged: (value) {
license = value;
},
name: 'license_number',
decoration: normalTextFieldStyle(
"license number", "license number"),
),
SizedBox(
width: screenWidth,
child: Row(
children: [
////LICENSE NUMBER
Flexible(
flex: 1,
child: FormBuilderTextField(
onChanged: (value) {
license = value;
},
name: 'license_number',
decoration: normalTextFieldStyle(
"license number",
"license number"),
),
),
const SizedBox(
width: 12,
),
////RATING
Flexible(
flex: 1,
child: FormBuilderTextField(
keyboardType: const TextInputType
.numberWithOptions(),
onChanged: (value) {
rating = value;
},
name: 'rating',
decoration: normalTextFieldStyle(
'rating %', 'rating'),
),
),
],
),
),
const SizedBox(
width: 8,
),
////RATING
Flexible(
flex: 1,
child: FormBuilderTextField(
keyboardType:
const TextInputType.numberWithOptions(),
onChanged: (value) {
rating = value;
},
name: 'rating',
decoration: normalTextFieldStyle(
'rating %', 'rating'),
),
const SizedBox(
height: 20,
),
SizedBox(
width: screenWidth,
child: Row(
children: [
////EXAM DATE
Flexible(
flex: 1,
child: DateTimePicker(
validator: FormBuilderValidators.required(errorText: "This field is required"),
use24HourFormat: false,
icon: const Icon(
Icons.date_range),
controller: examDateController,
firstDate: DateTime(1970),
lastDate: DateTime(2100),
timeHintText:
"Date of Examination/Conferment",
decoration:
normalTextFieldStyle(
"Exam date", "")
.copyWith(
prefixIcon:
const Icon(
Icons.date_range,
color: Colors.black87,
)),
initialValue: null,
)),
const SizedBox(
width: 12,
),
////VALIDITY DATE
Flexible(
flex: 1,
child: DateTimePicker(
validator: FormBuilderValidators.required(errorText: "This field is required"),
controller:
validityDateController,
firstDate: DateTime(1970),
lastDate: DateTime(2100),
decoration: normalTextFieldStyle(
"Validity date",
"Validity date")
.copyWith(
prefixIcon: const Icon(
Icons.date_range,
color: Colors.black87,
)),
initialValue: null,
),
),
],
),
),
const SizedBox(
height: 20,
),
Text(
"Placement of Examination/Conferment",
style: Theme.of(context)
.textTheme
.displaySmall!
),
],
),
),
const SizedBox(
height: 8,
),
SizedBox(
width: screenWidth,
child: Row(
children: [
////EXAM DATE
Flexible(
flex: 1,
child: DateTimePicker(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
use24HourFormat: false,
icon: const Icon(Icons.date_range),
controller: examDateController,
firstDate: DateTime(1970),
lastDate: DateTime(2100),
timeHintText:
"Date of Examination/Conferment",
decoration:
normalTextFieldStyle("Exam date", "")
.copyWith(
prefixIcon: const Icon(
Icons.date_range,
color: Colors.black87,
)),
initialValue: null,
)),
const SizedBox(
width: 8,
),
////VALIDITY DATE
Flexible(
flex: 1,
child: DateTimePicker(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
controller: validityDateController,
firstDate: DateTime(1970),
lastDate: DateTime(2100),
decoration: normalTextFieldStyle(
"Validity date", "Validity date")
.copyWith(
fontSize: blockSizeVertical * 2),
prefixIcon: const Icon(
Icons.date_range,
color: Colors.black87,
)),
initialValue: null,
),
const SizedBox(
height: 12,
),
////OVERSEAS ADDRESS SWITCH
Column(
children: [
FormBuilderSwitch(
validator: FormBuilderValidators.required(errorText: 'This field is required'),
initialValue: overseas,
activeColor: second,
onChanged: (value) {
setState(() {
overseas = value;
});
},
decoration:
normalTextFieldStyle("", ''),
name: 'overseas',
title:
const Text("Overseas Address?"),
),
const SizedBox(
height: 20,
),
////COUNTRY DROPDOWN
SizedBox(
child: overseas == true
? FormBuilderDropdown<Country>(
initialValue: null,
validator: FormBuilderValidators.required(errorText: "This field is required"),
items: state.countries.map<
DropdownMenuItem<
Country>>(
(Country country) {
return DropdownMenuItem<
Country>(
value: country,
child: FittedBox(
child: Text(
country
.name!)));
}).toList(),
name: 'country',
),
],
),
),
const SizedBox(
height: 8,
),
Text(
"Placement of Examination/Conferment",
style: Theme.of(context)
.textTheme
.displaySmall!
.copyWith(fontSize: blockSizeVertical * 2),
),
const SizedBox(
height: 8,
),
////OVERSEAS ADDRESS SWITCH
Column(
children: [
FormBuilderSwitch(
validator: FormBuilderValidators.required(
errorText: 'This field is required'),
initialValue: overseas,
activeColor: second,
onChanged: (value) {
setState(() {
overseas = value;
});
},
decoration: normalTextFieldStyle("", ''),
name: 'overseas',
title: const Text("Overseas Address?"),
),
const SizedBox(
height: 8,
),
////COUNTRY DROPDOWN
SizedBox(
child: overseas == true
? FormBuilderDropdown<Country>(
initialValue: null,
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
items: state.countries
.map<DropdownMenuItem<Country>>(
(Country country) {
return DropdownMenuItem<Country>(
value: country,
child: FittedBox(
child: Text(country.name!)));
}).toList(),
name: 'country',
decoration: normalTextFieldStyle(
"Country*", "Country"),
onChanged: (Country? value) {
selectedCountry = value;
},
)
: Column(
children: [
////REGION DROPDOWN
FormBuilderDropdown<Region?>(
autovalidateMode: AutovalidateMode
.onUserInteraction,
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
//// region onchange
onChanged: (Region? region) async {
if(selectedRegion != region){
setState(() {
provinceCall = true;
});
selectedRegion = region;
getProvinces();
}
},
initialValue: selectedRegion,
decoration: normalTextFieldStyle(
"Region*", "Region"),
name: 'region',
items: state.regions
.map<DropdownMenuItem<Region>>(
(Region region) {
return DropdownMenuItem<Region>(
value: region,
child: Text(
region.description!));
}).toList(),
),
const SizedBox(
height: 8,
),
////PROVINCE DROPDOWN
SizedBox(
height: 70,
child: ModalProgressHUD(
color: Colors.transparent,
inAsyncCall: provinceCall,
child: DropdownButtonFormField<
Province?>(
autovalidateMode:
AutovalidateMode
.onUserInteraction,
validator: (value) =>
value == null
? 'required'
: null,
isExpanded: true,
value: selectedProvince,
onChanged:
(Province? province) {
if(selectedProvince != province){
setState(() {
cityCall = true;
});
selectedProvince = province;
getCities();
}
},
items: provinces == null
? []
: provinces!.map<
DropdownMenuItem<
Province>>(
(Province province) {
return DropdownMenuItem(
value: province,
child: FittedBox(
child: Text(province
.description!),
));
}).toList(),
decoration:
normalTextFieldStyle(
"Province*",
"Province")),
),
),
//// CityMunicipalities dropdown
SizedBox(
height: 60,
child: ModalProgressHUD(
color: Colors.white,
inAsyncCall: cityCall,
child: DropdownButtonFormField<
CityMunicipality>(
validator: (value) =>
value == null
? 'required'
: null,
isExpanded: true,
onChanged:
(CityMunicipality? city) {
selectedMunicipality = city;
},
decoration:
normalTextFieldStyle(
"Country*",
"Country"),
onChanged:
(Country? value) {
selectedCountry = value;
},
)
: Column(
children: [
////REGION DROPDOWN
FormBuilderDropdown<
Region?>(
autovalidateMode:
AutovalidateMode
.onUserInteraction,
validator: FormBuilderValidators.required(errorText: "This field is required"),
//// region onchange
onChanged: (Region?
region) async {
setState(() {
provinceCall = true;
});
selectedRegion =
region;
getProvinces();
},
initialValue:
selectedRegion,
decoration:
normalTextFieldStyle(
"Region*",
"Region"),
name: 'region',
items: state.regions.map<
DropdownMenuItem<
Region>>((Region
region) {
return DropdownMenuItem<
Region>(
value: region,
child: Text(region
.description!));
}).toList(),
),
const SizedBox(
height: 20,
),
////PROVINCE DROPDOWN
SizedBox(
height: 70,
child: ModalProgressHUD(
color: Colors
.transparent,
inAsyncCall:
provinceCall,
child: DropdownButtonFormField<
Province?>(
autovalidateMode:
AutovalidateMode
.onUserInteraction,
validator: (value) =>
value == null
? 'required'
: null,
isExpanded: true,
value:
selectedProvince,
onChanged:
(Province?
province) {
setState(() {
cityCall =
true;
});
selectedProvince =
province;
getCities();
},
items: provinces ==
null
? []
: provinces!.map<
DropdownMenuItem<
Province>>((Province
province) {
return DropdownMenuItem(
value:
province,
child:
FittedBox(
child:
Text(province.description!),
));
}).toList(),
decoration:
normalTextFieldStyle(
"Province*",
"Province")),
),
),
//// CityMunicipalities dropdown
SizedBox(
height: 70,
child: ModalProgressHUD(
color: Colors.white,
inAsyncCall: cityCall,
child: DropdownButtonFormField<
CityMunicipality>(
validator: (value) =>
value == null
? 'required'
: null,
isExpanded: true,
onChanged:
(CityMunicipality?
city) {
selectedMunicipality =
city;
},
decoration: normalTextFieldStyle(
"Municipality*",
"Municipality"),
value:
selectedMunicipality,
items: citymuns ==
null
? []
: citymuns!.map<
DropdownMenuItem<
CityMunicipality>>(
(CityMunicipality
c) {
return DropdownMenuItem(
value:
c,
child: Text(
c.description!));
}).toList(),
),
),
),
const SizedBox(
height: 20,
),
],
)),
],
),
const Expanded(
child: SizedBox(),
),
SizedBox(
width: screenWidth,
height: 60,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
onPressed: () {
//rating
double? rate = rating == null
? null
: double.parse(rating!);
//lisence
String? licenseNumber = license;
CityMunicipality? cityMunicipality =
selectedMunicipality;
DateTime? examDate =
examDateController.text.isEmpty
? null
: DateTime.parse(
examDateController
.text);
DateTime? validityDate =
validityDateController
.text.isEmpty
? null
: DateTime.parse(
validityDateController
.text);
ExamAddress examAddress =
ExamAddress(
barangay: null,
id: null,
addressCategory: null,
examAddressClass: null,
country: selectedCountry ??
Country(
id: 175,
name: 'Philippines',
code: 'PH'),
cityMunicipality:
cityMunicipality);
EligibityCert eligibityCert =
EligibityCert(
id: null,
rating: rate,
examDate: examDate,
attachments: null,
eligibility:
selectedEligibility,
examAddress: examAddress,
validityDate: validityDate,
licenseNumber:
licenseNumber,
overseas: overseas);
if (formKey.currentState!
.saveAndValidate()) {
context
.read<EligibilityBloc>()
.add(AddEligibility(
eligibityCert:
eligibityCert,
profileId: profileId!,
token: token!));
}
// context.read<ProfileBloc>().add(AddEligibility(eligibityCert: eligibityCert, profileId: profileId, token: token))
},
child: const Text(submit)),
),
const SizedBox(
height: 20,
),
]),
"Municipality*",
"Municipality"),
value: selectedMunicipality,
items: citymuns == null
? []
: citymuns!.map<
DropdownMenuItem<
CityMunicipality>>(
(CityMunicipality c) {
return DropdownMenuItem(
value: c,
child: Text(c
.description!));
}).toList(),
),
),
),
],
)),
],
),
),
),
);
}
return Container();
},
);
}
return Container();
},
const Expanded(
child: SizedBox(),
),
SizedBox(
width: screenWidth,
height: 60,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
//rating
double? rate = rating == null
? null
: double.parse(rating!);
//lisence
String? licenseNumber = license;
CityMunicipality? cityMunicipality =
selectedMunicipality;
DateTime? examDate = examDateController
.text.isEmpty
? null
: DateTime.parse(examDateController.text);
DateTime? validityDate =
validityDateController.text.isEmpty
? null
: DateTime.parse(
validityDateController.text);
ExamAddress examAddress = ExamAddress(
barangay: null,
id: null,
addressCategory: null,
examAddressClass: null,
country: selectedCountry ??
Country(
id: 175,
name: 'Philippines',
code: 'PH'),
cityMunicipality: cityMunicipality);
EligibityCert eligibityCert = EligibityCert(
id: null,
rating: rate,
examDate: examDate,
attachments: null,
eligibility: selectedEligibility,
examAddress: examAddress,
validityDate: validityDate,
licenseNumber: licenseNumber,
overseas: overseas);
if (formKey.currentState!.saveAndValidate()) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Loading...");
context.read<EligibilityBloc>().add(
AddEligibility(
eligibityCert: eligibityCert,
profileId:
widget.profileId.toString(),
token: widget.token));
}
// context.read<ProfileBloc>().add(AddEligibility(eligibityCert: eligibityCert, profileId: profileId, token: token))
},
child: const Text(submit)),
),
const SizedBox(
height: 20,
),
]),
),
),
),
),
),
);
}
return Container();
},
);

View File

@ -2,11 +2,10 @@ import 'package:date_time_picker/date_time_picker.dart';
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:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/location/city.dart';
import 'package:unit2/model/profile/eligibility.dart';
import 'package:unit2/model/utils/eligibility.dart';
@ -23,7 +22,9 @@ import '../../../../utils/text_container.dart';
class EditEligibilityScreen extends StatefulWidget {
final EligibityCert eligibityCert;
const EditEligibilityScreen({super.key, required this.eligibityCert});
final int profileId;
final String token;
const EditEligibilityScreen({super.key, required this.eligibityCert, required this.profileId, required this.token});
@override
State<EditEligibilityScreen> createState() => _EditEligibilityScreenState();
@ -52,20 +53,10 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
final validityDateController = TextEditingController();
@override
Widget build(BuildContext context) {
//USERBLOC
return BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
//LOGGED IN USER STATE
if (state is UserLoggedIn) {
//PROFIILE BLOC
token = state.userData!.user!.login!.token;
profileId = state.userData!.user!.login!.user!.profileId.toString();
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if(state is ProfileLoaded){
return BlocBuilder<EligibilityBloc, EligibilityState>(
buildWhen: (previous, current) {
if (state is EditEligibilityState) {}
return false;
},
builder: (context, state) {
@ -194,6 +185,8 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
Flexible(
flex: 1,
child: DateTimePicker(
validator: FormBuilderValidators.required(errorText: "This field is required"),
use24HourFormat: false,
controller: validityDateController,
firstDate: DateTime(1970),
@ -514,6 +507,11 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
overseas: overseas);
if (formKey.currentState!
.saveAndValidate()) {
final progress =
ProgressHUD.of(
context);
progress!.showWithText(
"Loading...");
context.read<EligibilityBloc>().add(
UpdateEligibility(
eligibityCert: eligibityCert,
@ -521,8 +519,8 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
.eligibityCert
.eligibility!
.id,
profileId: profileId!,
token: token!));
profileId:widget.profileId.toString(),
token: widget.token));
}
},
child: const Text(submit)),
@ -534,15 +532,8 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
),
),
);
}
return Container();
},
);
}
return Container();
},
);
}
return Container();
},

View File

@ -16,6 +16,7 @@ import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/Leadings/close_leading.dart';
import 'package:unit2/widgets/empty_data.dart';
import 'package:unit2/widgets/error_state.dart';
import '../../../bloc/profile/eligibility/eligibility_bloc.dart';
import '../../../utils/alerts.dart';
@ -25,13 +26,14 @@ class EligibiltyScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
String? token;
String? profileId;
int? profileId;
return WillPopScope(
onWillPop: () async {
return true;
},
child: Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBar(
title: context.watch<EligibilityBloc>().state is AddEligibilityState
? const Text("Add Eligiblity")
@ -40,8 +42,8 @@ class EligibiltyScreen extends StatelessWidget {
: const Text(elibilityScreenTitle),
centerTitle: true,
backgroundColor: primary,
actions: (context.watch<EligibilityBloc>().state is EligibilityLoaded ||
context.watch<EligibilityBloc>().state is ProfileLoading)
actions: (context.watch<EligibilityBloc>().state is EligibilityLoaded)
? [
AddLeading(onPressed: () {
context
@ -49,19 +51,18 @@ class EligibiltyScreen extends StatelessWidget {
.add(ShowAddEligibilityForm());
})
]
: [
:(context.watch<EligibilityBloc>().state is AddEligibilityState || context.watch<EligibilityBloc>().state is EditEligibilityState)? [
CloseLeading(onPressed: () {
context.read<EligibilityBloc>().add(GetEligibilities(
profileId: int.parse(profileId!), token: token!));
context.read<EligibilityBloc>().add(const LoadEligibility());
})
],
]:[],
),
body: BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
if (state is UserLoggedIn) {
token = state.userData!.user!.login!.token;
profileId =
state.userData!.user!.login!.user!.profileId.toString();
state.userData!.user!.login!.user!.profileId;
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if(state is ProfileLoaded){
@ -82,7 +83,9 @@ class EligibiltyScreen extends StatelessWidget {
state is EditEligibilityState ||
state is DeletedState ||
state is EligibilityAddedState ||
state is EligibilityEditedState) {
state is EligibilityEditedState ||
state is EligibilityErrorState
) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
@ -93,15 +96,15 @@ class EligibiltyScreen extends StatelessWidget {
"Eligibility has been deleted successfully",
() {
Navigator.of(context).pop();
context.read<EligibilityBloc>().add(LoadEligibility(
eligibilities: state.eligibilities));
context.read<EligibilityBloc>().add(const LoadEligibility(
));
});
} else {
errorAlert(context, "Deletion Failed",
"Error deleting eligibility", () {
Navigator.of(context).pop();
context.read<EligibilityBloc>().add(LoadEligibility(
eligibilities: state.eligibilities));
context.read<EligibilityBloc>().add(const LoadEligibility(
));
});
}
}
@ -111,16 +114,16 @@ class EligibiltyScreen extends StatelessWidget {
successAlert(context, "Adding Successfull!",
state.response['message'], () {
Navigator.of(context).pop();
context.read<EligibilityBloc>().add(LoadEligibility(
eligibilities: state.eligibilities));
context.read<EligibilityBloc>().add(const LoadEligibility(
));
});
} else {
errorAlert(context, "Adding Failed",
"Something went wrong. Please try again.",
() {
Navigator.of(context).pop();
context.read<EligibilityBloc>().add(LoadEligibility(
eligibilities: state.eligibilities));
context.read<EligibilityBloc>().add(const LoadEligibility(
));
});
}
}
@ -130,16 +133,16 @@ class EligibiltyScreen extends StatelessWidget {
successAlert(context, "Update Successfull!",
state.response['message'], () {
Navigator.of(context).pop();
context.read<EligibilityBloc>().add(LoadEligibility(
eligibilities: state.eligibilities));
context.read<EligibilityBloc>().add(const LoadEligibility(
));
});
} else {
errorAlert(context, "Update Failed",
"Something went wrong. Please try again.",
() {
Navigator.of(context).pop();
context.read<EligibilityBloc>().add(LoadEligibility(
eligibilities: state.eligibilities));
context.read<EligibilityBloc>().add(const LoadEligibility(
));
});
}
}
@ -221,27 +224,29 @@ class EligibiltyScreen extends StatelessWidget {
const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
final progress =
////delete eligibilty-= = = = = = = = =>>
if (value == 2) {
confirmAlert(context,
() {
final progress =
ProgressHUD.of(
context);
progress!.showWithText(
"Loading...");
////delete eligibilty-= = = = = = = = =>>
if (value == 2) {
confirmAlert(context,
() {
BlocProvider.of<
EligibilityBloc>(
context)
.add(DeleteEligibility(
eligibilities: state
.eligibilities,
eligibilityId: state
.eligibilities[
index]
.id!,
profileId:
profileId!,
profileId.toString(),
token:
token!));
}, "Delete?",
@ -249,6 +254,11 @@ class EligibiltyScreen extends StatelessWidget {
}
if (value == 1) {
////edit eligibilty-= = = = = = = = =>>
final progress =
ProgressHUD.of(
context);
progress!.showWithText(
"Loading...");
EligibityCert
eligibityCert =
state.eligibilities[
@ -312,15 +322,17 @@ class EligibiltyScreen extends StatelessWidget {
}
if (state is EditEligibilityState) {
return EditEligibilityScreen(
profileId: profileId!,
token: token!,
eligibityCert: state.eligibityCert);
}
if (state is AddEligibilityState) {
return const AddEligibilityScreen();
return AddEligibilityScreen(token: token!,profileId: profileId!,);
}
if (state is EligibilityErrorState) {
return Center(
child: Text(state.message),
);
return SomethingWentWrong(message: state.message, onpressed: (){
context.read<EligibilityBloc>().add(LoadEligibility(token: token,profileId: profileId));
});
}
return Container(
color: Colors.grey.shade200,

View File

@ -135,21 +135,20 @@ class LoadingScreen extends StatelessWidget {
),
Center(
child: Container(
height: 120,
width: 120,
height: 80,
width: 80,
decoration:const BoxDecoration(
color: Colors.black87,
borderRadius: BorderRadius.all(Radius.circular(25))
borderRadius: BorderRadius.all(Radius.circular(8))
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: const[
SpinKitFadingCircle(
size: 42,
color: Colors.white),
SizedBox(height: 10,),
Text("Loading Profile",textAlign: TextAlign.center, style: TextStyle(color: Colors.white,fontSize: 10),)
],
),
),

View File

@ -5,11 +5,8 @@ import 'package:fluttericon/font_awesome_icons.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:searchfield/searchfield.dart';
import 'package:unit2/bloc/profile/other_information/org_membership/organization_membership_bloc.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/utils/agency.dart';
import 'package:unit2/utils/text_container.dart';
import '../../../../../model/utils/category.dart';
import '../../../../../theme-data.dart/box_shadow.dart';
import '../../../../../theme-data.dart/btn-style.dart';
@ -17,7 +14,10 @@ import '../../../../../theme-data.dart/colors.dart';
import '../../../../../theme-data.dart/form-style.dart';
class AddOrgMemberShipScreen extends StatefulWidget {
const AddOrgMemberShipScreen({super.key});
final int profileId;
final String token;
const AddOrgMemberShipScreen(
{super.key, required this.profileId, required this.token});
@override
State<AddOrgMemberShipScreen> createState() => _AddOrgMemberShipScreenState();
@ -34,339 +34,290 @@ Agency? newAgency;
bool showIsPrivateRadio = false;
bool? isPrivate = false;
final _formKey = GlobalKey<FormBuilderState>();
int? profileId;
String? token;
class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
@override
Widget build(BuildContext context) {
return BlocBuilder<UserBloc, UserState>(
return BlocBuilder<OrganizationMembershipBloc, OrganizationMembershipState>(
builder: (context, state) {
if (state is UserLoggedIn) {
token = state.userData!.user!.login!.token;
profileId = state.userData!.user!.login!.user!.profileId;
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if (state is ProfileLoaded) {
return BlocBuilder<OrganizationMembershipBloc,
OrganizationMembershipState>(
builder: (context, state) {
if (state is AddOrgMembershipState) {
return SingleChildScrollView(
child: FormBuilder(
key: _formKey,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 25, horizontal: 18),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
const SizedBox(
height: 100,
),
StatefulBuilder(
builder: (context, setState) {
//// AGENCY SEARCHFIELD
return Column(
children: [
SearchField(
itemHeight: 70,
suggestions: state.agencies
.map((Agency agency) =>
SearchFieldListItem(
agency.name!,
item: agency,
child: ListTile(
title: Text(
agency.name!
.toUpperCase(),
overflow:
TextOverflow
.ellipsis,
),
subtitle: Text(agency
.privateEntity ==
true
? "Private"
: agency.privateEntity ==
false
? "Government"
: ""),
)))
.toList(),
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
focusNode: agencyFocusNode,
searchInputDecoration:
normalTextFieldStyle(
"Agency *", "")
.copyWith(
suffixIcon:
const Icon(Icons
.arrow_drop_down)),
////agency suggestion tap
onSuggestionTap: (agency) {
setState(() {
selectedAgency = agency.item;
agencyFocusNode.unfocus();
if (selectedAgency
?.category ==
null) {
showAgencyCategory = true;
showIsPrivateRadio = true;
} else {
showAgencyCategory = false;
showIsPrivateRadio = false;
}
});
},
emptyWidget: Container(
decoration: box1(),
height: 100,
child: Column(
mainAxisAlignment:
MainAxisAlignment
.center,
crossAxisAlignment:
CrossAxisAlignment
.center,
children: [
const SizedBox(
height: 20,
),
const Text(
"No result found..."),
const SizedBox(
height: 10,
),
TextButton(
//// Add agency onpressed
onPressed: () {
showDialog(
context:
context,
builder:
(BuildContext
context) {
return AlertDialog(
title: const Text(
"Add Agency?"),
content:
SizedBox(
height:
130,
child:
Column(
children: [
TextFormField(
controller:
addAgencyController,
decoration:
normalTextFieldStyle("", ""),
),
const SizedBox(
height:
12,
),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(primary, Colors.transparent, second),
//// onpressed
onPressed: () {
setState(() {
newAgency = Agency(id: null, name: addAgencyController.text.toUpperCase(), category: null, privateEntity: null);
state.agencies.insert(0, newAgency!);
addAgencyController.clear();
Navigator.pop(context);
});
},
child: const Text("Add"))),
],
),
),
);
});
},
child: const Text(
"Add position"))
]),
),
),
const SizedBox(
height: 8,
),
SizedBox(
child: showAgencyCategory
? SearchField(
focusNode:
agencyCategoryFocusNode,
itemHeight: 70,
suggestions: state
.agencyCategories
.map((Category
category) =>
SearchFieldListItem(
category
.name!,
item:
category,
child:
ListTile(
title: Text(
category
.name!),
subtitle: Text(category
.industryClass!
.name!),
)))
.toList(),
emptyWidget: Container(
height: 100,
decoration: box1(),
child: const Center(
child: Text(
"No result found ...")),
),
////agency controller suggestion tap
onSuggestionTap:
(agencyCategory) {
setState(() {
selectedCategory =
agencyCategory
.item;
agencyCategoryFocusNode
.unfocus();
});
},
searchInputDecoration:
normalTextFieldStyle(
"Category *",
"")
.copyWith(
suffixIcon:
const Icon(
Icons
.arrow_drop_down)),
validator:
FormBuilderValidators
.required(
errorText:
"This field is required"),
)
: const SizedBox(),
),
////PRVIATE SECTOR
SizedBox(
child: showIsPrivateRadio
? FormBuilderRadioGroup(
decoration:
InputDecoration(
border:
InputBorder.none,
label: Row(
if (state is AddOrgMembershipState) {
return SingleChildScrollView(
child: FormBuilder(
key: _formKey,
child: Padding(
padding:
const EdgeInsets.symmetric(vertical: 25, horizontal: 18),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(
height: 100,
),
StatefulBuilder(builder: (context, setState) {
//// AGENCY SEARCHFIELD
return Column(
children: [
SearchField(
itemHeight: 70,
suggestions: state.agencies
.map((Agency agency) =>
SearchFieldListItem(agency.name!,
item: agency,
child: ListTile(
title: Text(
agency.name!.toUpperCase(),
overflow: TextOverflow.ellipsis,
),
subtitle: Text(
agency.privateEntity == true
? "Private"
: agency.privateEntity ==
false
? "Government"
: ""),
)))
.toList(),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
focusNode: agencyFocusNode,
searchInputDecoration: normalTextFieldStyle(
"Agency *", "")
.copyWith(
suffixIcon:
const Icon(Icons.arrow_drop_down)),
////agency suggestion tap
onSuggestionTap: (agency) {
setState(() {
selectedAgency = agency.item;
agencyFocusNode.unfocus();
if (selectedAgency?.category == null) {
showAgencyCategory = true;
showIsPrivateRadio = true;
} else {
showAgencyCategory = false;
showIsPrivateRadio = false;
}
});
},
emptyWidget: Container(
decoration: box1(),
height: 100,
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
const SizedBox(
height: 20,
),
const Text("No result found..."),
const SizedBox(
height: 10,
),
TextButton(
//// Add agency onpressed
onPressed: () {
showDialog(
context: context,
builder:
(BuildContext context) {
return AlertDialog(
title: const Text(
"Add Agency?"),
content: SizedBox(
height: 130,
child: Column(
children: [
Text(
"Is this private sector? ",
style: Theme.of(
context)
.textTheme
.headlineSmall!
.copyWith(
fontSize:
24),
TextFormField(
controller:
addAgencyController,
decoration:
normalTextFieldStyle(
"", ""),
),
const Icon(FontAwesome
.help_circled)
const SizedBox(
height: 12,
),
SizedBox(
width: double
.infinity,
height: 50,
child:
ElevatedButton(
style: mainBtnStyle(
primary,
Colors
.transparent,
second),
//// onpressed
onPressed:
() {
setState(
() {
newAgency = Agency(
id: null,
name: addAgencyController.text.toUpperCase(),
category: null,
privateEntity: null);
state.agencies.insert(0,
newAgency!);
addAgencyController.clear();
Navigator.pop(context);
});
},
child: const Text(
"Add"))),
],
),
),
////onvhange private sector
onChanged: (value) {
setState(() {
if (value
.toString() ==
"YES") {
isPrivate = true;
} else {
isPrivate = false;
}
});
},
name: 'isPrivate',
validator:
FormBuilderValidators
.required(
errorText:
"This field is required"),
options: ["YES", "NO"]
.map((lang) =>
FormBuilderFieldOption(
value:
lang))
.toList(
growable:
false),
)
: const SizedBox()),
],
);
}),
////SHOW CATEGORY AGENCY
const SizedBox(
height: 24,
),
SizedBox(
height: 60,
width: double.infinity,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
onPressed: () {
if (_formKey.currentState!
.saveAndValidate()) {
if(selectedAgency?.privateEntity != null){
newAgency = selectedAgency;
}else{
newAgency = Agency(
id: selectedAgency?.id,
name: selectedAgency!.name,
category:
selectedCategory,
privateEntity: isPrivate);
}
context.read<OrganizationMembershipBloc>().add(AddOrgMembership(agency: newAgency!, profileId: profileId!, token: token!));
setState(() {
showAgencyCategory = false;
showIsPrivateRadio = false;
);
});
}
},
child: const Text("Add position"))
]),
),
),
const SizedBox(
height: 8,
),
SizedBox(
child: showAgencyCategory
? SearchField(
focusNode: agencyCategoryFocusNode,
itemHeight: 70,
suggestions: state.agencyCategories
.map((Category category) =>
SearchFieldListItem(
category.name!,
item: category,
child: ListTile(
title:
Text(category.name!),
subtitle: Text(category
.industryClass!
.name!),
)))
.toList(),
emptyWidget: Container(
height: 100,
decoration: box1(),
child: const Center(
child:
Text("No result found ...")),
),
////agency controller suggestion tap
onSuggestionTap: (agencyCategory) {
setState(() {
selectedCategory =
agencyCategory.item;
agencyCategoryFocusNode.unfocus();
});
},
searchInputDecoration:
normalTextFieldStyle(
"Category *", "")
.copyWith(
suffixIcon: const Icon(
Icons.arrow_drop_down)),
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
)
: const SizedBox(),
),
////PRVIATE SECTOR
SizedBox(
child: showIsPrivateRadio
? FormBuilderRadioGroup(
decoration: InputDecoration(
border: InputBorder.none,
label: Row(
children: [
Text(
"Is this private sector? ",
style: Theme.of(context)
.textTheme
.headlineSmall!
.copyWith(fontSize: 24),
),
const Icon(
FontAwesome.help_circled)
],
),
),
////onvhange private sector
onChanged: (value) {
setState(() {
if (value.toString() == "YES") {
isPrivate = true;
} else {
isPrivate = false;
}
});
},
child: const Text(submit)),
)
]),
)),
);
}
return Container();
},
);
}
return Container();
},
name: 'isPrivate',
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
options: ["YES", "NO"]
.map((lang) =>
FormBuilderFieldOption(
value: lang))
.toList(growable: false),
)
: const SizedBox()),
],
);
}),
////SHOW CATEGORY AGENCY
const SizedBox(
height: 24,
),
SizedBox(
height: 60,
width: double.infinity,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
if (_formKey.currentState!.saveAndValidate()) {
if (selectedAgency?.privateEntity != null) {
newAgency = selectedAgency;
} else {
newAgency = Agency(
id: selectedAgency?.id,
name: selectedAgency!.name,
category: selectedCategory,
privateEntity: isPrivate);
}
context
.read<OrganizationMembershipBloc>()
.add(AddOrgMembership(
agency: newAgency!,
profileId: widget.profileId,
token: widget.token));
setState(() {
showAgencyCategory = false;
showIsPrivateRadio = false;
});
}
},
child: const Text(submit)),
)
]),
)),
);
}
return const Placeholder();
return Container();
},
);
}

View File

@ -14,6 +14,7 @@ import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/Leadings/close_leading.dart';
import 'package:unit2/widgets/empty_data.dart';
import 'package:unit2/widgets/error_state.dart';
import '../../../../bloc/profile/other_information/org_membership/organization_membership_bloc.dart';
import '../../../../utils/alerts.dart';
import '../../../../utils/global.dart';
@ -65,6 +66,7 @@ class OrgMembershipsScreen extends StatelessWidget {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
////ADDED STATE
if (state is OrgMembershipAddedState) {
if (state.response['success']) {
@ -73,8 +75,7 @@ class OrgMembershipsScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<OrganizationMembershipBloc>().add(
LoadOrganizationMemberships(
organizationMemberships:
state.orgMemberships));
));
});
} else {
errorAlert(context, "Adding Failed",
@ -83,8 +84,7 @@ class OrgMembershipsScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<OrganizationMembershipBloc>().add(
LoadOrganizationMemberships(
organizationMemberships:
state.orgMemberships));
));
});
}
}
@ -96,7 +96,7 @@ class OrgMembershipsScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<OrganizationMembershipBloc>().add(
LoadOrganizationMemberships(
organizationMemberships: state.organizationMemberships));
));
});
} else {
errorAlert(context, "Deletion Failed",
@ -104,7 +104,7 @@ class OrgMembershipsScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<OrganizationMembershipBloc>().add(
LoadOrganizationMemberships(
organizationMemberships: state.organizationMemberships));
));
});
}
}
@ -161,14 +161,15 @@ class OrgMembershipsScreen extends StatelessWidget {
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
final progress =
ProgressHUD.of(context);
progress!
.showWithText("Loading...");
////delete orgmembership-= = = = = = = = =>>
if (value == 1) {
confirmAlert(context, () {
context.read<OrganizationMembershipBloc>().add(DeleteOrgMemberShip(profileId: profileId, token: token!, org: state.orgMemberships[index], organizationMemberships: state.orgMemberships));
final progress =
ProgressHUD.of(context);
progress!
.showWithText("Loading...");
context.read<OrganizationMembershipBloc>().add(DeleteOrgMemberShip(profileId: profileId, token: token!, org: state.orgMemberships[index]));
}, "Delete?",
"Confirm Delete?");
}
@ -198,9 +199,13 @@ class OrgMembershipsScreen extends StatelessWidget {
});
}
if (state is AddOrgMembershipState) {
return const AddOrgMemberShipScreen();
return AlertDialog(
content: AddOrgMemberShipScreen(profileId: profileId,token: token!,)
);
}if(state is OrganizationMembershipErrorState){
return Container(child: Text(state.message),);
return SomethingWentWrong(message: state.message, onpressed: (){
context.read<OrganizationMembershipBloc>().add(GetOrganizationMembership(token: token,profileId: profileId));
});
}
return Container();
},

View File

@ -1,6 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
@ -9,9 +7,7 @@ import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/profile/other_information/skills_and_hobbies.dart';
import 'package:unit2/screens/profile/components/other_information/skills_hobbies/add_modal.dart';
import 'package:unit2/theme-data.dart/box_shadow.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/empty_data.dart';

View File

@ -4,14 +4,13 @@ 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:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/profile/references/references_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/location/address_category.dart';
import 'package:unit2/model/location/barangay.dart';
import 'package:unit2/model/profile/references.dart';
import 'package:unit2/theme-data.dart/btn-style.dart';
import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/global.dart';
import '../../../../model/location/city.dart';
import '../../../../model/location/country.dart';
import '../../../../model/location/provinces.dart';
@ -21,7 +20,10 @@ import '../../../../utils/location_utilities.dart';
import '../../../../utils/text_container.dart';
class AddReferenceScreen extends StatefulWidget {
const AddReferenceScreen({super.key});
final int profileId;
final String token;
const AddReferenceScreen(
{super.key, required this.profileId, required this.token});
@override
State<AddReferenceScreen> createState() => _AddReferenceScreenState();
@ -29,8 +31,6 @@ class AddReferenceScreen extends StatefulWidget {
class _AddReferenceScreenState extends State<AddReferenceScreen> {
final formKey = GlobalKey<FormBuilderState>();
String? token;
String? profileId;
bool provinceCall = false;
bool cityCall = false;
bool barangayCall = false;
@ -48,452 +48,376 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
AddressCategory? selectedCategory;
@override
Widget build(BuildContext context) {
return BlocBuilder<UserBloc, UserState>(
return BlocBuilder<ReferencesBloc, ReferencesState>(
builder: (context, state) {
if (state is UserLoggedIn) {
token = state.userData!.user!.login!.token;
profileId = state.userData!.user!.login!.user!.profileId.toString();
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if (state is ProfileLoaded) {
return BlocBuilder<ReferencesBloc, ReferencesState>(
builder: (context, state) {
if (state is AddReferenceState) {
return ProgressHUD(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 25, horizontal: 18),
child: FormBuilder(
key: formKey,
child: Column(
children: [
const SizedBox(height: 25),
Row(
if (state is AddReferenceState) {
return SingleChildScrollView(
child: SizedBox(
height: screenHeight * .95,
child: ProgressHUD(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 18),
child: FormBuilder(
key: formKey,
child: Column(
children: [
const SizedBox(height: 25),
Row(
children: [
////LAST NAME
Flexible(
flex: 1,
child: FormBuilderTextField(
decoration: normalTextFieldStyle(
"Last name *", "Last name *"),
name: "lastname",
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
),
const SizedBox(
width: 5,
),
////FIRST NAME
Flexible(
flex: 1,
child: FormBuilderTextField(
decoration: normalTextFieldStyle(
"First name *", "First name *"),
name: "firstname",
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
),
],
),
const SizedBox(
height: 8,
),
Row(
children: [
Flexible(
flex: 1,
child: FormBuilderTextField(
decoration: normalTextFieldStyle(
"Middle name *", "Midlle name *"),
name: "middlename",
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
),
const SizedBox(
width: 5,
),
////CATEGORY
Flexible(
flex: 1,
child: FormBuilderDropdown<AddressCategory>(
name: 'category',
validator:
FormBuilderValidators.required(errorText: ""),
decoration:
normalTextFieldStyle("Category", "Category"),
items: state.categories
.map<DropdownMenuItem<AddressCategory>>(
(AddressCategory cat) {
return DropdownMenuItem<AddressCategory>(
value: cat,
child: Text(cat.name!),
);
}).toList(),
onChanged: (value) {
setState(() {
selectedCategory = value;
});
},
),
),
],
),
const SizedBox(
height: 8,
),
////OVERSEAS ADDRESS
FormBuilderSwitch(
initialValue: overseas,
activeColor: second,
onChanged: (value) {
setState(() {
overseas = value!;
});
},
decoration: normalTextFieldStyle("", ''),
name: 'overseas',
title: const Text("Overseas Address?"),
),
SizedBox(
height: overseas == true ? 8 : 0,
),
SizedBox(
child: overseas == false
? Column(
children: [
////LAST NAME
Flexible(
flex: 1,
child: FormBuilderTextField(
decoration: normalTextFieldStyle(
"Last name *", "Last name *"),
name: "lastname",
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
),
const SizedBox(
height: 12,
),
////REGION DROPDOWN
FormBuilderDropdown<Region?>(
autovalidateMode:
AutovalidateMode.onUserInteraction,
validator: FormBuilderValidators.required(
errorText: "This field is required"),
onChanged: (Region? region) async {
if(selectedRegion != region){
setState(() {
provinceCall = true;
});
selectedRegion = region;
getProvinces();
}
},
initialValue: null,
decoration: normalTextFieldStyle(
"Region*", "Region"),
name: 'region',
items: state.regions
.map<DropdownMenuItem<Region>>(
(Region region) {
return DropdownMenuItem<Region>(
value: region,
child: Text(region.description!));
}).toList(),
),
const SizedBox(
width: 5,
height: 8,
),
////FIRST NAME
Flexible(
flex: 1,
child: FormBuilderTextField(
decoration: normalTextFieldStyle(
"First name *", "First name *"),
name: "firstname",
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
),
),
],
),
const SizedBox(
height: 8,
),
Row(
children: [
Flexible(
flex: 1,
child: FormBuilderTextField(
decoration: normalTextFieldStyle(
"Middle name *", "Midlle name *"),
name: "middlename",
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
),
),
const SizedBox(
width: 5,
),
////CATEGORY
Flexible(
flex: 1,
child: FormBuilderDropdown<
AddressCategory>(
name: 'category',
validator:
FormBuilderValidators.required(
errorText: ""),
decoration: normalTextFieldStyle(
"Category", "Category"),
items: state.categories.map<
DropdownMenuItem<
AddressCategory>>(
(AddressCategory cat) {
return DropdownMenuItem<
AddressCategory>(
value: cat,
child: Text(cat.name!),
);
}).toList(),
onChanged: (value) {
setState(() {
selectedCategory = value;
});
},
),
),
],
),
const SizedBox(
height: 8,
),
////OVERSEAS ADDRESS
FormBuilderSwitch(
initialValue: overseas,
activeColor: second,
onChanged: (value) {
setState(() {
overseas = value!;
});
},
decoration: normalTextFieldStyle("", ''),
name: 'overseas',
title: const Text("Overseas Address?"),
),
SizedBox(
height: overseas == true ? 8 : 0,
),
SizedBox(
child: overseas == false
? Column(
children: [
const SizedBox(
height: 12,
),
////REGION DROPDOWN
FormBuilderDropdown<Region?>(
autovalidateMode:
AutovalidateMode
.onUserInteraction,
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
onChanged:
(Region? region) async {
//// PROVINCE DROPDOWN
SizedBox(
height: 60,
child: ModalProgressHUD(
color: Colors.transparent,
inAsyncCall: provinceCall,
child: DropdownButtonFormField<Province?>(
autovalidateMode: AutovalidateMode
.onUserInteraction,
validator: (value) =>
value == null ? 'required' : null,
isExpanded: true,
value: selectedProvince,
onChanged: (Province? province) {
if(selectedProvince != province){
setState(() {
provinceCall = true;
});
selectedRegion = region;
getProvinces();
},
initialValue: null,
decoration:
normalTextFieldStyle(
"Region*", "Region"),
name: 'region',
items: state.regions.map<
DropdownMenuItem<
Region>>(
(Region region) {
return DropdownMenuItem<
Region>(
value: region,
child: Text(
region.description!));
}).toList(),
),
const SizedBox(
height: 8,
),
//// PROVINCE DROPDOWN
SizedBox(
height: 60,
child: ModalProgressHUD(
color: Colors.transparent,
inAsyncCall: provinceCall,
child: DropdownButtonFormField<
Province?>(
autovalidateMode:
AutovalidateMode
.onUserInteraction,
validator: (value) =>
value == null
? 'required'
: null,
isExpanded: true,
value: selectedProvince,
onChanged:
(Province? province) {
setState(() {
cityCall = true;
});
selectedProvince =
province;
getCities();
},
items: provinces == null
? []
: provinces!.map<
DropdownMenuItem<
Province>>(
(Province
province) {
return DropdownMenuItem(
value:
province,
child:
FittedBox(
child: Text(
province
.description!),
));
}).toList(),
decoration:
normalTextFieldStyle(
"Province*",
"Province")),
),
),
////CITY MUNICIPALITY
SizedBox(
height: 60,
child: ModalProgressHUD(
color: Colors.white,
inAsyncCall: cityCall,
child:
DropdownButtonFormField<
CityMunicipality>(
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
isExpanded: true,
onChanged:
(CityMunicipality?
city) {
setState(() {
barangayCall = true;
});
selectedMunicipality =
city;
getBarangays();
},
decoration:
normalTextFieldStyle(
"Municipality*",
"Municipality"),
value: selectedMunicipality,
items: citymuns == null
? []
: citymuns!.map<
DropdownMenuItem<
CityMunicipality>>(
(CityMunicipality
c) {
return DropdownMenuItem(
value: c,
child: Text(c
.description!));
}).toList(),
),
),
),
//// BARANGAY
SizedBox(
height: 60,
child: ModalProgressHUD(
color: Colors.white,
inAsyncCall: barangayCall,
child:
DropdownButtonFormField<
Barangay>(
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
isExpanded: true,
onChanged:
(Barangay? baragay) {
selectedBarangay =
baragay;
},
decoration:
normalTextFieldStyle(
"Barangay*",
"Barangay"),
value: selectedBarangay,
items: barangays == null
? []
: barangays!.map<
DropdownMenuItem<
Barangay>>(
(Barangay
barangay) {
return DropdownMenuItem(
value: barangay,
child: Text(barangay
.description!));
}).toList(),
),
),
),
],
)
//// COUNTRY DROPDOWN
: SizedBox(
height: 60,
child: FormBuilderDropdown<Country>(
initialValue: null,
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
items: state.countries.map<
DropdownMenuItem<
Country>>(
(Country country) {
return DropdownMenuItem<
Country>(
value: country,
child: FittedBox(
child: Text(
country.name!)));
}).toList(),
name: 'country',
decoration: normalTextFieldStyle(
"Country*", "Country"),
onChanged: (Country? value) {
selectedCountry = value;
cityCall = true;
});
selectedProvince = province;
getCities();
}
},
),
items: provinces == null
? []
: provinces!.map<
DropdownMenuItem<
Province>>(
(Province province) {
return DropdownMenuItem(
value: province,
child: FittedBox(
child: Text(province
.description!),
));
}).toList(),
decoration: normalTextFieldStyle(
"Province*", "Province")),
),
),
////CITY MUNICIPALITY
SizedBox(
height: 60,
child: ModalProgressHUD(
color: Colors.white,
inAsyncCall: cityCall,
child: DropdownButtonFormField<
CityMunicipality>(
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
isExpanded: true,
onChanged: (CityMunicipality? city) {
if(selectedMunicipality != city){
setState(() {
barangayCall = true;
});
selectedMunicipality = city;
getBarangays();
}
},
decoration: normalTextFieldStyle(
"Municipality*", "Municipality"),
value: selectedMunicipality,
items: citymuns == null
? []
: citymuns!.map<
DropdownMenuItem<
CityMunicipality>>(
(CityMunicipality c) {
return DropdownMenuItem(
value: c,
child:
Text(c.description!));
}).toList(),
),
),
FormBuilderTextField(
name: "mobile",
decoration: normalTextFieldStyle(
"Tel./Mobile *", "Tel./Mobile"),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
const Expanded(
child: SizedBox(),
),
SizedBox(
width: double.infinity,
),
),
//// BARANGAY
SizedBox(
height: 60,
child: ModalProgressHUD(
color: Colors.white,
inAsyncCall: barangayCall,
child: DropdownButtonFormField<Barangay>(
isExpanded: true,
onChanged: (Barangay? baragay) {
selectedBarangay = baragay;
},
decoration: normalTextFieldStyle(
"Barangay*", "Barangay"),
value: selectedBarangay,
items: barangays == null
? []
: barangays!.map<
DropdownMenuItem<Barangay>>(
(Barangay barangay) {
return DropdownMenuItem(
value: barangay,
child: Text(
barangay.description!));
}).toList(),
),
),
),
],
)
//// COUNTRY DROPDOWN
: SizedBox(
height: 60,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
child: const Text(submit),
onPressed: () {
PersonalReference? personalReference;
if (formKey.currentState!
.saveAndValidate()) {
String lastname = formKey
.currentState!.value['lastname'];
String firstname = formKey
.currentState!.value['firstname'];
String middlename = formKey
.currentState!
.value['middlename'];
String mobile = formKey
.currentState!.value['mobile'];
Region? region = selectedRegion;
Province? province = Province(
code: selectedProvince?.code,
description:
selectedProvince?.description,
region: region,
psgcCode:
selectedProvince?.psgcCode,
shortname:
selectedProvince?.shortname);
CityMunicipality? city =
CityMunicipality(
code: selectedMunicipality
?.code,
description:
selectedMunicipality
?.description,
province: province,
psgcCode: selectedMunicipality
?.psgcCode,
zipcode: selectedMunicipality
?.zipcode);
Address address = Address(
id: null,
addressCategory: selectedCategory,
country: selectedCountry,
barangay: selectedBarangay,
addressClass: null,
cityMunicipality: city);
if (selectedCountry != null) {
personalReference =
PersonalReference(
id: null,
address: Address(
id: null,
addressCategory:
selectedCategory,
country: selectedCountry,
barangay: null,
cityMunicipality: null,
addressClass: null),
lastName: lastname,
contactNo: mobile,
firstName: firstname,
middleName: middlename);
} else {
personalReference =
PersonalReference(
id: null,
address: address,
lastName: lastname,
contactNo: mobile,
firstName: firstname,
middleName: middlename);
}
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
context.read<ReferencesBloc>().add(
AddReference(
profileId:
int.parse(profileId!),
reference: personalReference,
token: token!));
}
child: FormBuilderDropdown<Country>(
initialValue: null,
validator: FormBuilderValidators.required(
errorText: "This field is required"),
items: state.countries
.map<DropdownMenuItem<Country>>(
(Country country) {
return DropdownMenuItem<Country>(
value: country,
child: FittedBox(
child: Text(country.name!)));
}).toList(),
name: 'country',
decoration: normalTextFieldStyle(
"Country*", "Country"),
onChanged: (Country? value) {
selectedCountry = value;
},
),
),
const SizedBox(
height: 20,
),
],
)),
),
);
}
return Container();
},
);
}
return Container();
},
),
FormBuilderTextField(
name: "mobile",
decoration: normalTextFieldStyle(
"Tel./Mobile *", "Tel./Mobile"),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
const Expanded(
child: SizedBox(),
),
SizedBox(
width: double.infinity,
height: 60,
child: ElevatedButton(
style:
mainBtnStyle(primary, Colors.transparent, second),
child: const Text(submit),
onPressed: () {
PersonalReference? personalReference;
if (formKey.currentState!.saveAndValidate()) {
String lastname =
formKey.currentState!.value['lastname'];
String firstname =
formKey.currentState!.value['firstname'];
String middlename =
formKey.currentState!.value['middlename'];
String mobile =
formKey.currentState!.value['mobile'];
Region? region = selectedRegion;
Province? province = Province(
code: selectedProvince?.code,
description: selectedProvince?.description,
region: region,
psgcCode: selectedProvince?.psgcCode,
shortname: selectedProvince?.shortname);
CityMunicipality? city = CityMunicipality(
code: selectedMunicipality?.code,
description:
selectedMunicipality?.description,
province: province,
psgcCode: selectedMunicipality?.psgcCode,
zipcode: selectedMunicipality?.zipcode);
Address address = Address(
id: null,
addressCategory: selectedCategory,
country: selectedCountry,
barangay: selectedBarangay,
addressClass: null,
cityMunicipality: city);
if (selectedCountry != null) {
personalReference = PersonalReference(
id: null,
address: Address(
id: null,
addressCategory: selectedCategory,
country: selectedCountry,
barangay: null,
cityMunicipality: null,
addressClass: null),
lastName: lastname,
contactNo: mobile,
firstName: firstname,
middleName: middlename);
} else {
personalReference = PersonalReference(
id: null,
address: address,
lastName: lastname,
contactNo: mobile,
firstName: firstname,
middleName: middlename);
}
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
context.read<ReferencesBloc>().add(AddReference(
profileId: widget.profileId,
reference: personalReference,
token: widget.token));
}
},
),
),
const SizedBox(
height: 20,
),
],
)),
),
),
),
);
}
return Container();

View File

@ -4,9 +4,7 @@ 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:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
import '../../../../bloc/profile/profile_bloc.dart';
import '../../../../bloc/profile/references/references_bloc.dart';
import '../../../../bloc/user/user_bloc.dart';
import '../../../../model/location/address_category.dart';
import '../../../../model/location/barangay.dart';
import '../../../../model/location/city.dart';
@ -21,7 +19,9 @@ import '../../../../utils/location_utilities.dart';
import '../../../../utils/text_container.dart';
class EditReferenceScreen extends StatefulWidget {
const EditReferenceScreen({super.key});
final String token;
final int profileId;
const EditReferenceScreen({super.key,required this.profileId, required this.token});
@override
State<EditReferenceScreen> createState() => _EditReferenceScreenState();
@ -29,8 +29,6 @@ class EditReferenceScreen extends StatefulWidget {
class _EditReferenceScreenState extends State<EditReferenceScreen> {
final formKey = GlobalKey<FormBuilderState>();
String? token;
String? profileId;
bool provinceCall = false;
bool cityCall = false;
bool barangayCall = false;
@ -48,14 +46,7 @@ class _EditReferenceScreenState extends State<EditReferenceScreen> {
@override
Widget build(BuildContext context) {
return BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
if (state is UserLoggedIn) {
token = state.userData!.user!.login!.token;
profileId = state.userData!.user!.login!.user!.profileId.toString();
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if (state is ProfileLoaded) {
return BlocBuilder<ReferencesBloc, ReferencesState>(
buildWhen: (previous, current) => false,
builder: (context, state) {
@ -525,6 +516,10 @@ class _EditReferenceScreenState extends State<EditReferenceScreen> {
PersonalReference? personalReference;
if (formKey.currentState!
.saveAndValidate()) {
final progress =
ProgressHUD.of(context);
progress!.showWithText(
"Please wait...");
String lastname = formKey
.currentState!.value['lastname'];
String firstname = formKey
@ -607,9 +602,9 @@ class _EditReferenceScreenState extends State<EditReferenceScreen> {
context.read<ReferencesBloc>().add(
EditReference(
profileId:
int.parse(profileId!),
widget.profileId,
reference: personalReference,
token: token!));
token: widget.token));
}
},
),
@ -624,14 +619,7 @@ class _EditReferenceScreenState extends State<EditReferenceScreen> {
}
return Container();
},
);
}
return Container();
},
);
}
return Container();
},
);
}
}

View File

@ -26,25 +26,37 @@ class ReferencesScreen extends StatelessWidget {
int? profileId;
String? token;
return Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBar(
title: context.watch<ReferencesBloc>().state is AddReferenceState?const Text("Add Personal Reference"):context.watch<ReferencesBloc>().state is EditReferenceState?const Text("Edit Personal Reference"):const Text("Personal References"),
centerTitle: true,
backgroundColor: primary,
////if state is adding or editing state show close button
actions: (context.watch<ReferencesBloc>().state is AddReferenceState || context.watch<ReferencesBloc>().state is EditReferenceState)?
[
//// close button
CloseLeading(onPressed: (){
context.read<ReferencesBloc>().add(GetReferences(profileId: profileId!, token: token!));
}),
]:
//// if state is loaded state show add button
context.watch<ReferencesBloc>().state is ReferencesLoadedState?[
AddLeading(onPressed: (){
context.read<ReferencesBloc>().add(ShowAddReferenceForm());
}),
]:[]
),
title: context.watch<ReferencesBloc>().state is AddReferenceState
? const Text("Add Personal Reference")
: context.watch<ReferencesBloc>().state is EditReferenceState
? const Text("Edit Personal Reference")
: const Text("Personal References"),
centerTitle: true,
backgroundColor: primary,
////if state is adding or editing state show close button
actions: (context.watch<ReferencesBloc>().state
is AddReferenceState ||
context.watch<ReferencesBloc>().state is EditReferenceState)
? [
//// close button
CloseLeading(onPressed: () {
context.read<ReferencesBloc>().add(
GetReferences(profileId: profileId!, token: token!));
}),
]
:
//// if state is loaded state show add button
context.watch<ReferencesBloc>().state is ReferencesLoadedState
? [
AddLeading(onPressed: () {
context
.read<ReferencesBloc>()
.add(ShowAddReferenceForm());
}),
]
: []),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
@ -83,7 +95,7 @@ class ReferencesScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<ReferencesBloc>().add(
LoadReferences(
references: state.personalRefs));
));
});
} else {
errorAlert(context, "Adding Failed",
@ -92,7 +104,7 @@ class ReferencesScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<ReferencesBloc>().add(
LoadReferences(
references: state.personalRefs));
));
});
}
}
@ -104,7 +116,7 @@ class ReferencesScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<ReferencesBloc>().add(
LoadReferences(
references: state.personalRefs));
));
});
} else {
errorAlert(context, "Update Failed",
@ -113,7 +125,7 @@ class ReferencesScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<ReferencesBloc>().add(
LoadReferences(
references: state.personalRefs));
));
});
}
}
@ -127,7 +139,7 @@ class ReferencesScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<ReferencesBloc>().add(
LoadReferences(
references: state.references));
));
});
} else {
errorAlert(context, "Deletion Failed",
@ -135,7 +147,7 @@ class ReferencesScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<ReferencesBloc>().add(
LoadReferences(
references: state.references));
));
});
}
}
@ -212,12 +224,14 @@ class ReferencesScreen extends StatelessWidget {
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
////delete eligibilty-= = = = = = = = =>>
if (value == 2) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
confirmAlert(context, () {
final progress =
ProgressHUD.of(context);
progress!.showWithText(
"Please wait...");
context
.read<
ReferencesBloc>()
@ -236,6 +250,10 @@ progress!.showWithText("Please wait...");
}
if (value == 1) {
////edit reference-= = = = = = = = =>>
final progress =
ProgressHUD.of(context);
progress!.showWithText(
"Please wait...");
context
.read<ReferencesBloc>()
.add(ShowEditReferenceForm(
@ -276,14 +294,16 @@ progress!.showWithText("Please wait...");
}
}
if (state is AddReferenceState) {
return const AddReferenceScreen();
return AddReferenceScreen(profileId: profileId!, token: token!,);
}
if (state is EditReferenceState) {
return const EditReferenceScreen();
return EditReferenceScreen(profileId: profileId!,token: token!,);
}
if (state is ReferencesErrorState) {
return SomethingWentWrong(
message: state.message, onpressed: () {});
message: state.message, onpressed: () {
context.read<ReferencesBloc>().add(GetReferences(profileId: profileId!, token: token!));
});
}
return Container();
},

View File

@ -24,7 +24,9 @@ import 'package:unit2/utils/validators.dart';
import '../../../../model/utils/position.dart';
class AddWorkHistoryScreen extends StatefulWidget {
const AddWorkHistoryScreen({super.key});
final int profileId;
final String token;
const AddWorkHistoryScreen({super.key, required this.profileId, required this.token});
@override
State<AddWorkHistoryScreen> createState() => _AddWorkHistoryScreenState();
@ -65,14 +67,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
@override
Widget build(BuildContext context) {
return BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
if (state is UserLoggedIn) {
profileId = state.userData!.user!.login!.user!.profileId;
token = state.userData!.user!.login!.token;
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if (state is ProfileLoaded) {
return BlocConsumer<WorkHistoryBloc, WorkHistoryState>(
listener: (context, state) {
if (state is AddWorkHistoryState) {
@ -121,6 +116,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
positionFocusNode.unfocus();
});
},
////EMPTY WIDGET
emptyWidget: Container(
decoration: box1(),
height: 100,
@ -139,6 +135,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
),
TextButton(
onPressed: () {
////ADD POSITION DIALOG
showDialog(
context: context,
builder: (BuildContext
@ -638,12 +635,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
Flexible(
flex: 1,
child: DateTimePicker(
validator: (value) {
if (value == null) {
return "This field is required";
}
return null;
},
validator: FormBuilderValidators.required(errorText: "This field is required"),
use24HourFormat: false,
icon: const Icon(
Icons.date_range),
@ -684,9 +676,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
.copyWith(),
)
: DateTimePicker(
validator: (val) {
return null;
},
validator: FormBuilderValidators.required(errorText: "This field is required"),
controller:
toDateController,
firstDate: DateTime(1970),
@ -723,17 +713,12 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
print(selectedPosition?.title);
print(selectedStatus?.label);
print(selectedAgency?.name);
print(salary);
print(fromDateController.text);
print(toDateController.text);
print(salaryGrade);
print(salaryGradeStep);
print(isPrivate);
if (_formKey.currentState!.validate()) {
final progress =
ProgressHUD.of(context);
progress!.showWithText(
"Loading...");
WorkHistory workHistory = WorkHistory(
position: selectedPosition,
id: null,
@ -780,17 +765,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
),
);
}
return Container();
});
}
return Container();
},
);
}
return const Center(
child: Text("Add Work History"),
);
},
);
return Container();
});
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,4 @@
import 'dart:io';
import 'package:app_popup_menu/app_popup_menu.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@ -15,6 +14,7 @@ import 'package:unit2/theme-data.dart/box_shadow.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/Leadings/close_leading.dart';
import 'package:unit2/widgets/empty_data.dart';
import 'package:unit2/widgets/error_state.dart';
@ -36,11 +36,15 @@ class WorkHistoryScreen extends StatelessWidget {
title: const Text(workHistoryScreenTitle),
backgroundColor: primary,
centerTitle: true,
actions: [
actions: context.watch<WorkHistoryBloc>().state is WorkHistoryLoaded?[
AddLeading(onPressed: () {
context.read<WorkHistoryBloc>().add(ShowAddWorkHistoryForm());
})
],
]:(context.watch<WorkHistoryBloc>().state is AddWorkHistoryState || context.watch<WorkHistoryBloc>().state is EditWorkHistoryState)?[
CloseLeading(onPressed: (){
context.read<WorkHistoryBloc>().add(LoadWorkHistories());
})
]:[],
),
body:
//UserBloc
@ -68,7 +72,9 @@ class WorkHistoryScreen extends StatelessWidget {
}
if (state is WorkHistoryLoaded ||
state is WorkHistoryErrorState ||
state is AddWorkHistoryState ||state is WorkHistoryAddedState || state is EditWorkHistoryState) {
state is AddWorkHistoryState ||
state is WorkHistoryAddedState ||
state is EditWorkHistoryState) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
@ -78,55 +84,59 @@ class WorkHistoryScreen extends StatelessWidget {
successAlert(context, "Deletion Successfull",
"Work has been deleted successfully", () {
Navigator.of(context).pop();
context.read<WorkHistoryBloc>().add(
LoadWorkHistories(
workHistories: state.workHistories));
context
.read<WorkHistoryBloc>()
.add(LoadWorkHistories());
});
} else {
errorAlert(context, "Deletion Failed",
"Error deleting Work History", () {
Navigator.of(context).pop();
context.read<WorkHistoryBloc>().add(
LoadWorkHistories(
workHistories: state.workHistories));
context
.read<WorkHistoryBloc>()
.add(LoadWorkHistories());
});
}
}
////ADDED STATE
if(state is WorkHistoryAddedState){
if (state.response['success']) {
if (state is WorkHistoryAddedState) {
if (state.response['success']) {
successAlert(context, "Adding Successfull!",
state.response['message'], () {
Navigator.of(context).pop();
context.read<WorkHistoryBloc>().add(LoadWorkHistories(
workHistories: state.workExperiences));
context
.read<WorkHistoryBloc>()
.add(LoadWorkHistories());
});
} else {
errorAlert(context, "Adding Failed",
"Something went wrong. Please try again.",
() {
Navigator.of(context).pop();
context.read<WorkHistoryBloc>().add(LoadWorkHistories(
workHistories: state.workExperiences));
context
.read<WorkHistoryBloc>()
.add(LoadWorkHistories());
});
}
}
//// EDITED STATE
if(state is WorkHistoryEditedState){
if (state.response['success']) {
if (state is WorkHistoryEditedState) {
if (state.response['success']) {
successAlert(context, "Update Successfull!",
state.response['message'], () {
Navigator.of(context).pop();
context.read<WorkHistoryBloc>().add(LoadWorkHistories(
workHistories: state.workExperiences));
context
.read<WorkHistoryBloc>()
.add(LoadWorkHistories());
});
} else {
errorAlert(context, "Update Failed",
"Something went wrong. Please try again.",
() {
Navigator.of(context).pop();
context.read<WorkHistoryBloc>().add(LoadWorkHistories(
workHistories: state.workExperiences));
context
.read<WorkHistoryBloc>()
.add(LoadWorkHistories());
});
}
}
@ -207,31 +217,41 @@ class WorkHistoryScreen extends StatelessWidget {
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
final progress =
ProgressHUD.of(context);
progress!
.showWithText("Loading...");
////delete workhistory-= = = = = = = = =>>
if (value == 2) {
confirmAlert(context, () {
BlocProvider.of<WorkHistoryBloc>(
final progress =
ProgressHUD.of(context);
progress!.showWithText(
"Loading...");
BlocProvider.of<
WorkHistoryBloc>(
context)
.add(DeleteWorkHistory(
profileId:
profileId,
token: token!,
workHistory: state
.workExperiences[
index],
workHistories: state
.workExperiences));
profileId: profileId,
token: token!,
workHistory:
state.workExperiences[
index],
));
}, "Delete?",
"Confirm Delete?");
}
if (value == 1) {
////edit eligibilty-= = = = = = = = =>>
WorkHistory workHistory = state.workExperiences[index];
context.read<WorkHistoryBloc>().add(ShowEditWorkHistoryForm(workHistory: workHistory));
final progress =
ProgressHUD.of(context);
progress!.showWithText(
"Loading...");
WorkHistory workHistory =
state.workExperiences[
index];
context
.read<WorkHistoryBloc>()
.add(
ShowEditWorkHistoryForm(
workHistory:
workHistory));
}
},
menuItems: [
@ -269,14 +289,16 @@ class WorkHistoryScreen extends StatelessWidget {
}
}
if (state is AddWorkHistoryState) {
return const AddWorkHistoryScreen();
return AddWorkHistoryScreen(profileId: profileId, token: token!,);
}
if(state is EditWorkHistoryState){
return const EditWorkHistoryScreen();
if (state is EditWorkHistoryState) {
return EditWorkHistoryScreen(profileId: profileId,token: token!,);
}
if (state is WorkHistoryErrorState) {
return SomethingWentWrong(
message: state.message, onpressed: () {});
message: state.message, onpressed: () {
context.read<WorkHistoryBloc>().add(GetWorkHistories(profileId: profileId,token: token!));
});
}
return Container();
},

View File

@ -10,7 +10,8 @@ class CoverImage extends StatelessWidget {
color: Colors.grey,
child: CachedNetworkImage(
imageUrl:
'https://static.vecteezy.com/system/resources/thumbnails/008/074/253/small/tropical-forest-sunset-nature-background-with-coconut-trees-vector.jpg',
"https://live.staticflickr.com/7320/9052838885_af9b21c79b_b.jpg",
// 'https://static.vecteezy.com/system/resources/thumbnails/008/074/253/small/tropical-forest-sunset-nature-background-with-coconut-trees-vector.jpg',
width: double.infinity,
height: 220,
fit: BoxFit.cover,

View File

@ -21,12 +21,15 @@ Widget getTile(
if (title.toLowerCase() == "logout") {
confirmAlert(context, () async{
await CREDENTIALS!.clear();
await CREDENTIALS!.deleteAll(['username','password','saved']);
Navigator.pushReplacementNamed (context,"/");
},"Logout","Are You sure you want to logout?");
}if(title.toLowerCase() == 'profile'){
ProfileArguments profileArguments = ProfileArguments(token: userData.user!.login!.token!, userID:userData.user!.login!.user!.profileId!);
Navigator.pushNamed(context, route,arguments: profileArguments);
}if(title.toLowerCase() == 'basic info'){
Navigator.pushNamed(context, '/basic-info');
}
},

View File

@ -36,6 +36,7 @@ class _UniT2LoginState extends State<UniT2Login> {
bool showSuffixIcon = false;
bool _showPassword = true;
String? password;
String? username;
@override
Widget build(BuildContext context) {
return WillPopScope(
@ -236,7 +237,7 @@ class _UniT2LoginState extends State<UniT2Login> {
TextStyle(color: Colors.white),
),
onPressed: () {
password = "nav071394";
final progress =
ProgressHUD.of(context);
@ -244,20 +245,21 @@ class _UniT2LoginState extends State<UniT2Login> {
if (_formKey.currentState!
.saveAndValidate()) {
password = _formKey
.currentState!
.value['password'];
username = _formKey
.currentState!
.value['username'];
progress?.showWithText(
'Logging in...',
);
BlocProvider.of<UserBloc>(context)
.add(UserLogin(
username: "rjvincentlopeplopez",
password: "shesthequ33n",
// username: _formKey
// .currentState!
// .value['username'],
// password: _formKey
// .currentState!
// .value['password'])
username:username,
password: password
));
}
},

View File

@ -9,11 +9,11 @@ class ContactService {
static final ContactService _instance = ContactService();
static ContactService get instance => _instance;
Future<List<ServiceProvider>> getServiceProvider(
Future<List<CommService>> getServiceProvider(
{required int serviceTypeId}) async {
String path = Url.instance.getServiceType();
String path = Url.instance.getCommunicationProvider();
Map<String, String> params = {"service_type__id": serviceTypeId.toString()};
List<ServiceProvider> serviceProviders = [];
List<CommService> serviceProviders = [];
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
};
@ -25,7 +25,7 @@ class ContactService {
if (data['data'] != null) {
for (var element in data['data']) {
CommService commService = CommService.fromJson(element);
serviceProviders.add(commService.serviceProvider!);
serviceProviders.add(commService);
}
}
}
@ -52,7 +52,7 @@ class ContactService {
"_numbermail": contactInfo.numbermail,
"_active": contactInfo.active,
"_primary": contactInfo.primary,
"_commServiceId": contactInfo.commService!.serviceProvider!.id!
"_commServiceId": contactInfo.commService!.id
};
Map<dynamic, dynamic> responseStatus = {};
try {
@ -71,24 +71,38 @@ class ContactService {
}
//// add
// Future<Map<dynamic, dynamic>> update(
// {required int profileId,
// required String token,
// required ContactInfo contactInfo}) async {
// String path = "${Url.instance.contactPath()}$profileId/";
// String authToken = "Token $token";
// Map<String, String> headers = {
// 'Content-Type': 'application/json; charset=UTF-8',
// 'Authorization': authToken
// };
// Map body ={
// "personid": profileId,
// "_numbermail": contactInfo.numbermail,
// "_active": contactInfo.active,
// "_primary": contactInfo.primary,
// "_commServiceId": contactInfo
// }
// }
Future<Map<dynamic, dynamic>> add(
{required int profileId,
required String token,
required ContactInfo contactInfo}) async {
String path = "${Url.instance.contactPath()}$profileId/";
String authToken = "Token $token";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': authToken
};
Map<dynamic, dynamic> responseStatus = {};
Map body = {
"personid": profileId,
"_numbermail": contactInfo.numbermail,
"_active": contactInfo.active,
"_primary": contactInfo.primary,
"_commServiceId": contactInfo.commService!.id
};
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});
}
return responseStatus;
} catch (e) {
throw e.toString();
}
}
////delete
Future<bool> deleteContact(
@ -116,7 +130,7 @@ class ContactService {
try {
http.Response response = await Request.instance.deleteRequest(
path: path, headers: headers, body: body, param: params);
if (response.statusCode == 20) {
if (response.statusCode == 200) {
Map data = jsonDecode(response.body);
success = data['success'];
}

View File

@ -4,10 +4,10 @@ class Url {
String host() {
// return '192.168.10.221:3003';
// return 'agusandelnorte.gov.ph';
return 'agusandelnorte.gov.ph';
// return "192.168.10.219:3000";
// return "devweb.agusandelnorte.gov.ph";
return 'devapi.agusandelnorte.gov.ph:3004';
// return 'devapi.agusandelnorte.gov.ph:3004';
}
String authentication() {
@ -111,7 +111,7 @@ String getServiceTypes(){
String contactPath(){
return "/api/jobnet_app/profile/pds/basic/contact/";
}
String getServiceType(){
String getCommunicationProvider(){
return "/api/jobnet_app/comm_services/";
}
String deleteContact (){

View File

@ -45,8 +45,8 @@ class UniTSplashScreen extends StatelessWidget {
height: 1,
color: Colors.black)),
),
const SizedBox(height: 5,),
SpinKitThreeBounce(color: Colors.black,size: 32,)
const SizedBox(height: 150,),
const SpinKitCircle(color: primary,size: 42,)
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,