wotk history refactor and create its own Bloc
parent
5dcc1c1efb
commit
fba53ce2dc
|
@ -0,0 +1,214 @@
|
|||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import '../../model/location/city.dart';
|
||||
import '../../model/location/country.dart';
|
||||
import '../../model/location/provinces.dart';
|
||||
import '../../model/location/region.dart';
|
||||
import '../../model/profile/eligibility.dart';
|
||||
import '../../model/utils/eligibility.dart';
|
||||
import '../../sevices/profile/eligibility_services.dart';
|
||||
import '../../utils/location_utilities.dart';
|
||||
import '../../utils/profile_utilities.dart';
|
||||
part 'eligibility_event.dart';
|
||||
part 'eligibility_state.dart';
|
||||
|
||||
class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
|
||||
EligibilityBloc() : super(EligibilityInitial()) {
|
||||
List<Country>? globalCountries;
|
||||
List<Region>? globalRegions;
|
||||
List<Eligibility>? globalEligibilities;
|
||||
List<EligibityCert>? eligibilities;
|
||||
////=====================================================================
|
||||
on<LoadEligibility>((event, emit) {
|
||||
emit(EligibilityLoadingState());
|
||||
eligibilities = event.eligibilities;
|
||||
emit(EligibilityLoaded(eligibilities: event.eligibilities));
|
||||
});
|
||||
////====================================================================
|
||||
on<GetEligibilities>((event, emit) async {
|
||||
try {
|
||||
if (eligibilities != null) {
|
||||
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()));
|
||||
}
|
||||
});
|
||||
////====================================================================
|
||||
on<ShowEditEligibilityForm>((event, emit) async {
|
||||
try {
|
||||
emit(EligibilityLoadingState());
|
||||
if (globalCountries == null) {
|
||||
List<Country> countries = await LocationUtils.instance.getCountries();
|
||||
globalCountries = countries;
|
||||
}
|
||||
if (globalRegions == null) {
|
||||
List<Region> regions = await LocationUtils.instance.getRegions();
|
||||
globalRegions = regions;
|
||||
}
|
||||
if (globalEligibilities == null) {
|
||||
List<Eligibility> eligibilities =
|
||||
await ProfileUtilities.instance.getEligibilities();
|
||||
globalEligibilities = eligibilities;
|
||||
}
|
||||
Eligibility currentEligibility = globalEligibilities!.firstWhere(
|
||||
(Eligibility eligibility) =>
|
||||
event.eligibityCert.eligibility!.id == eligibility.id);
|
||||
bool? isOverseas = event.eligibityCert.overseas;
|
||||
Country currentCountry = globalCountries!.firstWhere(
|
||||
(Country country) =>
|
||||
event.eligibityCert.examAddress!.country!.code == country.code);
|
||||
if (event.eligibityCert.examAddress?.cityMunicipality?.province
|
||||
?.region !=
|
||||
null) {
|
||||
Region currrentRegion = globalRegions!.firstWhere((Region region) =>
|
||||
event.eligibityCert.examAddress!.cityMunicipality!.province!
|
||||
.region!.code ==
|
||||
region.code);
|
||||
List<Province> provinces = await LocationUtils.instance
|
||||
.getProvinces(regionCode: currrentRegion.code.toString());
|
||||
Province currentProvince = provinces.firstWhere((Province province) =>
|
||||
event.eligibityCert.examAddress!.cityMunicipality!.province!
|
||||
.code ==
|
||||
province.code);
|
||||
List<CityMunicipality> cities = await LocationUtils.instance
|
||||
.getCities(code: currentProvince.code.toString());
|
||||
CityMunicipality currentCity = cities.firstWhere(
|
||||
(CityMunicipality cityMunicipality) =>
|
||||
event.eligibityCert.examAddress!.cityMunicipality!.code ==
|
||||
cityMunicipality.code);
|
||||
|
||||
emit(EditEligibilityState(
|
||||
currentCity: currentCity,
|
||||
selectedCountry: currentCountry,
|
||||
currentProvince: currentProvince,
|
||||
currentRegion: currrentRegion,
|
||||
currentEligibility: currentEligibility,
|
||||
provinces: provinces,
|
||||
cities: cities,
|
||||
isOverseas: isOverseas!,
|
||||
eligibityCert: event.eligibityCert,
|
||||
countries: globalCountries!,
|
||||
regions: globalRegions!,
|
||||
eligibilities: globalEligibilities!));
|
||||
} else {
|
||||
emit(EditEligibilityState(
|
||||
selectedCountry: currentCountry,
|
||||
currentCity: null,
|
||||
currentProvince: null,
|
||||
currentRegion: null,
|
||||
provinces: null,
|
||||
cities: null,
|
||||
currentEligibility: currentEligibility,
|
||||
isOverseas: isOverseas!,
|
||||
eligibityCert: event.eligibityCert,
|
||||
countries: globalCountries!,
|
||||
regions: globalRegions!,
|
||||
eligibilities: globalEligibilities!));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(EligibilityErrorState(message: e.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
////====================================================================
|
||||
on<UpdateEligibility>((event, emit) async {
|
||||
try {
|
||||
emit(EligibilityLoadingState());
|
||||
Map<dynamic, dynamic> status = await EligibilityService.instance.update(
|
||||
eligibityCert: event.eligibityCert,
|
||||
token: event.token,
|
||||
profileId: int.parse(event.profileId),
|
||||
oldEligibility: event.oldEligibility);
|
||||
if (status['success']) {
|
||||
EligibityCert newEligibility = EligibityCert.fromJson(status['data']);
|
||||
eligibilities!.removeWhere(
|
||||
(EligibityCert element) => element.id == event.eligibityCert.id);
|
||||
eligibilities!.add(newEligibility);
|
||||
emit(EligibilityEditedState(
|
||||
eligibilities: eligibilities!, response: status));
|
||||
} else {
|
||||
emit(EligibilityEditedState(
|
||||
eligibilities: eligibilities!, response: status));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(EligibilityErrorState(message: e.toString()));
|
||||
}
|
||||
});
|
||||
on<ShowAddEligibilityForm>((event, emit) async {
|
||||
emit(EligibilityLoadingState());
|
||||
if (globalRegions == null) {
|
||||
List<Region> regions = await LocationUtils.instance.getRegions();
|
||||
globalRegions = regions;
|
||||
}
|
||||
if (globalEligibilities == null) {
|
||||
List<Eligibility> eligibilities =
|
||||
await ProfileUtilities.instance.getEligibilities();
|
||||
globalEligibilities = eligibilities;
|
||||
}
|
||||
if (globalCountries == null) {
|
||||
List<Country> countries = await LocationUtils.instance.getCountries();
|
||||
globalCountries = countries;
|
||||
}
|
||||
|
||||
emit(AddEligibilityState(
|
||||
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()));
|
||||
}
|
||||
});
|
||||
////====================================================================
|
||||
on<AddEligibility>(
|
||||
(event, emit) async {
|
||||
try {
|
||||
emit(EligibilityLoadingState());
|
||||
Map<dynamic, dynamic> status = await EligibilityService.instance.add(
|
||||
eligibityCert: event.eligibityCert,
|
||||
token: event.token,
|
||||
profileId: int.parse(event.profileId));
|
||||
if (status['success']) {
|
||||
EligibityCert? eligibityCert =
|
||||
EligibityCert.fromJson(status['data']);
|
||||
eligibilities!.add(eligibityCert);
|
||||
emit(EligibilityAddedState(
|
||||
eligibilities: eligibilities!, response: status));
|
||||
} else {
|
||||
emit(EligibilityAddedState(
|
||||
eligibilities: eligibilities!, response: status));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(EligibilityErrorState(message: e.toString()));
|
||||
}
|
||||
},
|
||||
);
|
||||
on<CallErrorState>((event, emit) {
|
||||
emit(const EligibilityErrorState(
|
||||
message: "Something went wrong. Please try again"));
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
part of 'eligibility_bloc.dart';
|
||||
|
||||
abstract class EligibilityEvent extends Equatable {
|
||||
const EligibilityEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ShowAddEligibilityForm extends EligibilityEvent {
|
||||
|
||||
}
|
||||
|
||||
class GetEligibilities extends EligibilityEvent{
|
||||
final int profileId;
|
||||
final String token;
|
||||
const GetEligibilities({required this.profileId, required this.token});
|
||||
@override
|
||||
List<Object> get props => [profileId,token];
|
||||
}
|
||||
|
||||
class AddEligibility extends EligibilityEvent{
|
||||
final EligibityCert eligibityCert;
|
||||
final String profileId;
|
||||
final String token;
|
||||
const AddEligibility({required this.eligibityCert, required this.profileId, required this.token});
|
||||
@override
|
||||
List<Object> get props => [eligibityCert, profileId, token];
|
||||
}
|
||||
class UpdateEligibility extends EligibilityEvent{
|
||||
final EligibityCert eligibityCert;
|
||||
final String profileId;
|
||||
final String token;
|
||||
final int oldEligibility;
|
||||
const UpdateEligibility({required this.eligibityCert, required this.oldEligibility,required this.profileId, required this.token});
|
||||
|
||||
@override
|
||||
List<Object> get props =>[eligibityCert,profileId,token,oldEligibility];
|
||||
}
|
||||
class LoadEligibility extends EligibilityEvent {
|
||||
final List<EligibityCert> eligibilities;
|
||||
const LoadEligibility({required this.eligibilities});
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ShowEditEligibilityForm extends EligibilityEvent {
|
||||
final EligibityCert eligibityCert;
|
||||
const ShowEditEligibilityForm({required this.eligibityCert});
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
class CallErrorState extends EligibilityEvent{
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
part of 'eligibility_bloc.dart';
|
||||
|
||||
abstract class EligibilityState extends Equatable {
|
||||
const EligibilityState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class EligibilityInitial extends EligibilityState {}
|
||||
|
||||
|
||||
class EditEligibilityState extends EligibilityState {
|
||||
final EligibityCert eligibityCert;
|
||||
final List<Eligibility> eligibilities;
|
||||
final List<Country> countries;
|
||||
final List<Region> regions;
|
||||
final List<Province>? provinces;
|
||||
final List<CityMunicipality>? cities;
|
||||
final bool isOverseas;
|
||||
final Eligibility currentEligibility;
|
||||
final Region? currentRegion;
|
||||
final Province? currentProvince;
|
||||
final CityMunicipality? currentCity;
|
||||
final Country selectedCountry;
|
||||
const EditEligibilityState({
|
||||
required this.provinces,
|
||||
required this.cities,
|
||||
required this.currentProvince,
|
||||
required this.currentCity,
|
||||
required this.currentRegion,
|
||||
required this.currentEligibility,
|
||||
required this.isOverseas,
|
||||
required this.eligibityCert,
|
||||
required this.eligibilities,
|
||||
required this.countries,
|
||||
required this.regions,
|
||||
required this.selectedCountry,
|
||||
});
|
||||
@override
|
||||
List<Object> get props =>
|
||||
[isOverseas, eligibityCert, eligibilities, regions, countries];
|
||||
}
|
||||
|
||||
class DeletedState extends EligibilityState {
|
||||
final List<EligibityCert> eligibilities;
|
||||
final bool success;
|
||||
const DeletedState({required this.eligibilities, required this.success});
|
||||
@override
|
||||
List<Object> get props => [success, eligibilities];
|
||||
}
|
||||
|
||||
class AddEligibilityState extends EligibilityState {
|
||||
final List<Eligibility> eligibilities;
|
||||
final List<Country> countries;
|
||||
final List<Region> regions;
|
||||
const AddEligibilityState({
|
||||
required this.eligibilities,
|
||||
required this.countries,
|
||||
required this.regions,
|
||||
});
|
||||
@override
|
||||
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});
|
||||
@override
|
||||
List<Object> get props =>[eligibilities, response];
|
||||
}
|
||||
|
||||
class EligibilityAddedState extends EligibilityState{
|
||||
final List<EligibityCert> eligibilities;
|
||||
final Map<dynamic,dynamic> response;
|
||||
|
||||
const EligibilityAddedState({required this.eligibilities, required this.response});
|
||||
@override
|
||||
List<Object> get props =>[eligibilities,response];
|
||||
}
|
||||
class EligibilityLoadingState extends EligibilityState{
|
||||
|
||||
}
|
||||
class EligibilityErrorState extends EligibilityState{
|
||||
final String message;
|
||||
const EligibilityErrorState({required this.message});
|
||||
@override
|
||||
List<Object> get props =>[message];
|
||||
}
|
||||
|
||||
class EligibilityLoaded extends EligibilityState {
|
||||
final List<EligibityCert> eligibilities;
|
||||
const EligibilityLoaded({required this.eligibilities});
|
||||
@override
|
||||
List<Object> get props => [eligibilities];
|
||||
}
|
|
@ -1,27 +1,13 @@
|
|||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:unit2/model/profile/eligibility.dart';
|
||||
import 'package:unit2/model/profile/profileInfomation.dart';
|
||||
import 'package:unit2/model/utils/eligibility.dart';
|
||||
import 'package:unit2/sevices/profile/eligibility_services.dart';
|
||||
import 'package:unit2/sevices/profile/profile_service.dart';
|
||||
import 'package:unit2/utils/location_utilities.dart';
|
||||
import 'package:unit2/utils/profile_utilities.dart';
|
||||
import '../../model/location/country.dart';
|
||||
import '../../model/location/region.dart';
|
||||
import '../../model/location/provinces.dart';
|
||||
import '../../model/location/city.dart';
|
||||
part 'profile_event.dart';
|
||||
part 'profile_state.dart';
|
||||
|
||||
class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
||||
ProfileBloc() : super(ProfileInitial()) {
|
||||
ProfileInformation? globalProfileInformation;
|
||||
List<Country>? globalCountries;
|
||||
List<Region>? globalRegions;
|
||||
List<Eligibility>? globalEligibilities;
|
||||
List<EligibityCert>? eligibilities;
|
||||
////=========================================================================
|
||||
on<LoadProfile>((event, emit) async {
|
||||
try {
|
||||
emit(ProfileLoading());
|
||||
|
@ -34,198 +20,6 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
|||
}
|
||||
});
|
||||
|
||||
on<CallErrorState>((event, emit) {
|
||||
emit(const ProfileErrorState(
|
||||
mesage: "Something went wrong. Please try again"));
|
||||
});
|
||||
////=====================================================================
|
||||
on<LoadEligibility>((event, emit) {
|
||||
emit(ProfileLoading());
|
||||
eligibilities = event.eligibilities;
|
||||
emit(EligibilityLoaded(eligibilities: event.eligibilities));
|
||||
});
|
||||
////====================================================================
|
||||
on<GetEligibilities>((event,emit)async{
|
||||
|
||||
print(eligibilities?.length);
|
||||
try{
|
||||
if(eligibilities != null){
|
||||
emit(EligibilityLoaded(eligibilities: eligibilities!));
|
||||
}else{
|
||||
emit(ProfileLoading());
|
||||
eligibilities = await EligibilityService.instance.getEligibilities(event.profileId, event.token);
|
||||
emit(EligibilityLoaded(eligibilities: eligibilities!));
|
||||
}
|
||||
|
||||
}catch(e){
|
||||
emit(ProfileErrorState(mesage: e.toString()));
|
||||
}
|
||||
});
|
||||
////====================================================================
|
||||
on<ShowEditEligibilityForm>((event, emit) async {
|
||||
try {
|
||||
emit(ProfileLoading());
|
||||
if (globalCountries == null) {
|
||||
List<Country> countries = await LocationUtils.instance.getCountries();
|
||||
globalCountries = countries;
|
||||
}
|
||||
if (globalRegions == null) {
|
||||
List<Region> regions = await LocationUtils.instance.getRegions();
|
||||
globalRegions = regions;
|
||||
}
|
||||
if (globalEligibilities == null) {
|
||||
List<Eligibility> eligibilities =
|
||||
await ProfileUtilities.instance.getEligibilities();
|
||||
globalEligibilities = eligibilities;
|
||||
}
|
||||
Eligibility currentEligibility = globalEligibilities!.firstWhere(
|
||||
(Eligibility eligibility) =>
|
||||
event.eligibityCert.eligibility!.id == eligibility.id);
|
||||
bool? isOverseas = event.eligibityCert.overseas;
|
||||
Country currentCountry = globalCountries!.firstWhere(
|
||||
(Country country) =>
|
||||
event.eligibityCert.examAddress!.country!.code == country.code);
|
||||
if (event.eligibityCert.examAddress?.cityMunicipality?.province
|
||||
?.region !=
|
||||
null) {
|
||||
Region currrentRegion = globalRegions!.firstWhere((Region region) =>
|
||||
event.eligibityCert.examAddress!.cityMunicipality!.province!
|
||||
.region!.code ==
|
||||
region.code);
|
||||
List<Province> provinces = await LocationUtils.instance
|
||||
.getProvinces(regionCode: currrentRegion.code.toString());
|
||||
Province currentProvince = provinces.firstWhere((Province province) =>
|
||||
event.eligibityCert.examAddress!.cityMunicipality!.province!
|
||||
.code ==
|
||||
province.code);
|
||||
List<CityMunicipality> cities = await LocationUtils.instance
|
||||
.getCities(code: currentProvince.code.toString());
|
||||
CityMunicipality currentCity = cities.firstWhere(
|
||||
(CityMunicipality cityMunicipality) =>
|
||||
event.eligibityCert.examAddress!.cityMunicipality!.code ==
|
||||
cityMunicipality.code);
|
||||
|
||||
emit(EditEligibilityState(
|
||||
currentCity: currentCity,
|
||||
selectedCountry: currentCountry,
|
||||
currentProvince: currentProvince,
|
||||
currentRegion: currrentRegion,
|
||||
currentEligibility: currentEligibility,
|
||||
provinces: provinces,
|
||||
cities: cities,
|
||||
isOverseas: isOverseas!,
|
||||
eligibityCert: event.eligibityCert,
|
||||
countries: globalCountries!,
|
||||
regions: globalRegions!,
|
||||
eligibilities: globalEligibilities!));
|
||||
} else {
|
||||
emit(EditEligibilityState(
|
||||
selectedCountry: currentCountry,
|
||||
currentCity: null,
|
||||
currentProvince: null,
|
||||
currentRegion: null,
|
||||
provinces: null,
|
||||
cities: null,
|
||||
currentEligibility: currentEligibility,
|
||||
isOverseas: isOverseas!,
|
||||
eligibityCert: event.eligibityCert,
|
||||
countries: globalCountries!,
|
||||
regions: globalRegions!,
|
||||
eligibilities: globalEligibilities!));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(ProfileErrorState(mesage: e.toString()));
|
||||
}
|
||||
});
|
||||
////====================================================================
|
||||
on<UpdateEligibility>((event, emit) async {
|
||||
try {
|
||||
emit(ProfileLoading());
|
||||
Map<dynamic, dynamic> status = await EligibilityService.instance.update(
|
||||
eligibityCert: event.eligibityCert,
|
||||
token: event.token,
|
||||
profileId: int.parse(event.profileId),
|
||||
oldEligibility: event.oldEligibility);
|
||||
if (status['success']) {
|
||||
EligibityCert newEligibility = EligibityCert.fromJson(status['data']);
|
||||
eligibilities!.removeWhere(
|
||||
(EligibityCert element) => element.id == event.eligibityCert.id);
|
||||
eligibilities!.add(newEligibility);
|
||||
emit(EligibilityEditedState(
|
||||
eligibilities: eligibilities!, response: status));
|
||||
} else {
|
||||
emit(EligibilityEditedState(
|
||||
eligibilities: eligibilities!, response: status));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(ProfileErrorState(mesage: e.toString()));
|
||||
}
|
||||
});
|
||||
on<ShowAddEligibilityForm>((event, emit) async {
|
||||
emit(ProfileLoading());
|
||||
if (globalRegions == null) {
|
||||
List<Region> regions = await LocationUtils.instance.getRegions();
|
||||
globalRegions = regions;
|
||||
}
|
||||
if (globalEligibilities == null) {
|
||||
List<Eligibility> eligibilities =
|
||||
await ProfileUtilities.instance.getEligibilities();
|
||||
globalEligibilities = eligibilities;
|
||||
}
|
||||
if (globalCountries == null) {
|
||||
List<Country> countries = await LocationUtils.instance.getCountries();
|
||||
globalCountries = countries;
|
||||
}
|
||||
|
||||
emit(AddEligibilityState(
|
||||
eligibilities: globalEligibilities!,
|
||||
regions: globalRegions!,
|
||||
countries: globalCountries!));
|
||||
});
|
||||
////====================================================================
|
||||
on<DeleteEligibility>((event, emit) async {
|
||||
emit(ProfileLoading());
|
||||
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(ProfileErrorState(mesage: e.toString()));
|
||||
}
|
||||
});
|
||||
////====================================================================
|
||||
on<AddEligibility>(
|
||||
(event, emit) async {
|
||||
try {
|
||||
emit(ProfileLoading());
|
||||
Map<dynamic, dynamic> status = await EligibilityService.instance.add(
|
||||
eligibityCert: event.eligibityCert,
|
||||
token: event.token,
|
||||
profileId: int.parse(event.profileId));
|
||||
if (status['success']) {
|
||||
EligibityCert? eligibityCert =
|
||||
EligibityCert.fromJson(status['data']);
|
||||
eligibilities!.add(eligibityCert);
|
||||
emit(EligibilityAddedState(
|
||||
eligibilities: eligibilities!, response: status));
|
||||
} else {
|
||||
emit(EligibilityAddedState(
|
||||
eligibilities: eligibilities!, response: status));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(ProfileErrorState(mesage: e.toString()));
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,65 +20,5 @@ class LoadProfileInformation extends ProfileEvent {
|
|||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class LoadEligibility extends ProfileEvent {
|
||||
final List<EligibityCert> eligibilities;
|
||||
const LoadEligibility({required this.eligibilities});
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ShowEditEligibilityForm extends ProfileEvent {
|
||||
final EligibityCert eligibityCert;
|
||||
const ShowEditEligibilityForm({required this.eligibityCert});
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class DeleteEligibility extends ProfileEvent {
|
||||
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];
|
||||
}
|
||||
|
||||
class ShowAddEligibilityForm extends ProfileEvent {
|
||||
|
||||
}
|
||||
|
||||
class GetEligibilities extends ProfileEvent{
|
||||
final int profileId;
|
||||
final String token;
|
||||
const GetEligibilities({required this.profileId, required this.token});
|
||||
@override
|
||||
List<Object> get props => [profileId,token];
|
||||
}
|
||||
|
||||
class AddEligibility extends ProfileEvent{
|
||||
final EligibityCert eligibityCert;
|
||||
final String profileId;
|
||||
final String token;
|
||||
const AddEligibility({required this.eligibityCert, required this.profileId, required this.token});
|
||||
@override
|
||||
List<Object> get props => [eligibityCert, profileId, token];
|
||||
}
|
||||
class UpdateEligibility extends ProfileEvent{
|
||||
final EligibityCert eligibityCert;
|
||||
final String profileId;
|
||||
final String token;
|
||||
final int oldEligibility;
|
||||
const UpdateEligibility({required this.eligibityCert, required this.oldEligibility,required this.profileId, required this.token});
|
||||
|
||||
@override
|
||||
List<Object> get props =>[eligibityCert,profileId,token,oldEligibility];
|
||||
}
|
||||
|
||||
class CallErrorState extends ProfileEvent{
|
||||
|
||||
}
|
||||
|
|
|
@ -25,77 +25,5 @@ class ProfileErrorState extends ProfileState {
|
|||
|
||||
class ProfileLoading extends ProfileState {}
|
||||
|
||||
class EligibilityLoaded extends ProfileState {
|
||||
final List<EligibityCert> eligibilities;
|
||||
const EligibilityLoaded({required this.eligibilities});
|
||||
@override
|
||||
List<Object> get props => [eligibilities];
|
||||
}
|
||||
class EditEligibilityState extends ProfileState {
|
||||
final EligibityCert eligibityCert;
|
||||
final List<Eligibility> eligibilities;
|
||||
final List<Country> countries;
|
||||
final List<Region> regions;
|
||||
final List<Province>? provinces;
|
||||
final List<CityMunicipality>? cities;
|
||||
final bool isOverseas;
|
||||
final Eligibility currentEligibility;
|
||||
final Region? currentRegion;
|
||||
final Province? currentProvince;
|
||||
final CityMunicipality? currentCity;
|
||||
final Country selectedCountry;
|
||||
const EditEligibilityState({
|
||||
required this.provinces,
|
||||
required this.cities,
|
||||
required this.currentProvince,
|
||||
required this.currentCity,
|
||||
required this.currentRegion,
|
||||
required this.currentEligibility,
|
||||
required this.isOverseas,
|
||||
required this.eligibityCert,
|
||||
required this.eligibilities,
|
||||
required this.countries,
|
||||
required this.regions,
|
||||
required this.selectedCountry,
|
||||
});
|
||||
@override
|
||||
List<Object> get props =>
|
||||
[isOverseas, eligibityCert, eligibilities, regions, countries];
|
||||
}
|
||||
|
||||
class DeletedState extends ProfileState {
|
||||
final List<EligibityCert> eligibilities;
|
||||
final bool success;
|
||||
const DeletedState({required this.eligibilities, required this.success});
|
||||
@override
|
||||
List<Object> get props => [success, eligibilities];
|
||||
}
|
||||
|
||||
class AddEligibilityState extends ProfileState {
|
||||
final List<Eligibility> eligibilities;
|
||||
final List<Country> countries;
|
||||
final List<Region> regions;
|
||||
const AddEligibilityState({
|
||||
required this.eligibilities,
|
||||
required this.countries,
|
||||
required this.regions,
|
||||
});
|
||||
@override
|
||||
List<Object> get props => [eligibilities,countries,regions];
|
||||
}
|
||||
class EligibilityEditedState extends ProfileState{
|
||||
final List<EligibityCert> eligibilities;
|
||||
final Map<dynamic,dynamic> response;
|
||||
const EligibilityEditedState({required this.eligibilities, required this.response});
|
||||
@override
|
||||
List<Object> get props =>[eligibilities, response];
|
||||
}
|
||||
|
||||
class EligibilityAddedState extends ProfileState{
|
||||
final List<EligibityCert> eligibilities;
|
||||
final Map<dynamic,dynamic> response;
|
||||
|
||||
const EligibilityAddedState({required this.eligibilities, required this.response});
|
||||
@override
|
||||
List<Object> get props =>[eligibilities,response];
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:unit2/model/profile/work_history.dart';
|
||||
import 'package:unit2/sevices/profile/work_history_services.dart';
|
||||
|
||||
part 'workHistory_event.dart';
|
||||
part 'workHistory_state.dart';
|
||||
|
||||
class WorkHistoryBloc extends Bloc<WorkHistorytEvent, WorkHistoryState> {
|
||||
List<WorkHistory> workExperiences = [];
|
||||
WorkHistoryBloc() : super(EducationInitial()) {
|
||||
on<GetWorkHistories>((event, emit)async {
|
||||
emit(WorkHistoryLoadingState());
|
||||
// try{
|
||||
List<WorkHistory> works = await WorkHistoryService.instance.getWorkExperiences(event.profileId, event.token);
|
||||
workExperiences = works;
|
||||
emit(WorkHistoryLoaded(workExperiences: workExperiences));
|
||||
// }catch(e){
|
||||
// emit(WorkHistoryErrorState(message: e.toString()));
|
||||
// }
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
part of 'workHistory_bloc.dart';
|
||||
|
||||
abstract class WorkHistorytEvent extends Equatable {
|
||||
const WorkHistorytEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class GetWorkHistories extends WorkHistorytEvent{
|
||||
final int profileId;
|
||||
final String token;
|
||||
const GetWorkHistories({required this.profileId, required this.token});
|
||||
|
||||
|
||||
@override
|
||||
List<Object> get props => [profileId, token];
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
part of 'workHistory_bloc.dart';
|
||||
|
||||
abstract class WorkHistoryState extends Equatable {
|
||||
const WorkHistoryState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class EducationInitial extends WorkHistoryState {}
|
||||
|
||||
class WorkHistoryLoaded extends WorkHistoryState{
|
||||
final List<WorkHistory> workExperiences;
|
||||
const WorkHistoryLoaded({required this.workExperiences});
|
||||
@override
|
||||
List<Object> get props => [workExperiences];
|
||||
}
|
||||
|
||||
class WorkHistoryLoadingState extends WorkHistoryState{
|
||||
|
||||
}
|
||||
class WorkHistoryErrorState extends WorkHistoryState{
|
||||
final String message;
|
||||
const WorkHistoryErrorState({required this.message});
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
}
|
|
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:device_preview/device_preview.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||
import 'package:unit2/bloc/user/user_bloc.dart';
|
||||
import 'package:unit2/theme-data.dart/colors.dart';
|
||||
import 'package:unit2/utils/app_router.dart';
|
||||
|
@ -47,6 +48,9 @@ class MyApp extends StatelessWidget {
|
|||
BlocProvider(
|
||||
create: (_) => UserBloc(),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (_) => ProfileBloc(),
|
||||
),
|
||||
],
|
||||
child: MaterialApp(
|
||||
navigatorKey: NavigationService.navigatorKey,
|
||||
|
|
|
@ -35,7 +35,7 @@ class WorkHistory {
|
|||
final DateTime? fromDate;
|
||||
// final dynamic attachments;
|
||||
final int? salaryGrade;
|
||||
final int? monthlySalary;
|
||||
final double? monthlySalary;
|
||||
final String? appointmentStatus;
|
||||
|
||||
factory WorkHistory.fromJson(Map<String, dynamic> json) => WorkHistory(
|
||||
|
|
|
@ -6,6 +6,7 @@ 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/eligibility/eligibility_bloc.dart';
|
||||
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||
import 'package:unit2/bloc/user/user_bloc.dart';
|
||||
import 'package:unit2/model/profile/eligibility.dart';
|
||||
|
@ -60,403 +61,428 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
|
|||
token = state.userData!.user!.login!.token;
|
||||
profileId = state.userData!.user!.login!.user!.profileId.toString();
|
||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||
buildWhen: (previous, current) {
|
||||
if (state is EditEligibilityState) {}
|
||||
return false;
|
||||
},
|
||||
builder: (context, state) {
|
||||
//EDIT 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,
|
||||
),
|
||||
|
||||
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(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(
|
||||
children: [
|
||||
//EXAM DATE
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DateTimePicker(
|
||||
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(
|
||||
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!
|
||||
.copyWith(fontSize: blockSizeVertical * 2),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
//OVERSEAS ADDRESS SWITCH
|
||||
Column(
|
||||
if(state is ProfileLoaded){
|
||||
return BlocBuilder<EligibilityBloc, EligibilityState>(
|
||||
buildWhen: (previous, current) {
|
||||
if (state is EditEligibilityState) {}
|
||||
return false;
|
||||
},
|
||||
builder: (context, state) {
|
||||
//EDIT 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: [
|
||||
FormBuilderSwitch(
|
||||
initialValue: overseas,
|
||||
activeColor: second,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
overseas = value;
|
||||
});
|
||||
},
|
||||
decoration: normalTextFieldStyle("", ''),
|
||||
name: 'overseas',
|
||||
title: const Text("Overseas Address?"),
|
||||
//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,
|
||||
),
|
||||
|
||||
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(
|
||||
height: 20,
|
||||
),
|
||||
//COUNTRY DROPDOWN
|
||||
SizedBox(
|
||||
child: overseas == true
|
||||
? FormBuilderDropdown<Country>(
|
||||
initialValue: null,
|
||||
validator: (value) =>
|
||||
value == null
|
||||
? 'required'
|
||||
: null,
|
||||
items: state.countries.map<
|
||||
DropdownMenuItem<
|
||||
Country>>(
|
||||
(Country country) {
|
||||
return DropdownMenuItem<
|
||||
Country>(
|
||||
value: country,
|
||||
child: FittedBox(
|
||||
child: Text(
|
||||
country.name!)));
|
||||
}).toList(),
|
||||
name: 'country',
|
||||
width: screenWidth,
|
||||
child: Row(
|
||||
children: [
|
||||
//EXAM DATE
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DateTimePicker(
|
||||
use24HourFormat: false,
|
||||
icon:
|
||||
const Icon(Icons.date_range),
|
||||
controller: examDateController,
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
timeHintText:
|
||||
"Date of Examination/Conferment",
|
||||
decoration: normalTextFieldStyle(
|
||||
"Country*", "Country"),
|
||||
onChanged: (Country? value) {
|
||||
selectedCountry = value;
|
||||
},
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
//REGION DROPDOWN
|
||||
FormBuilderDropdown<Region?>(
|
||||
autovalidateMode:
|
||||
AutovalidateMode
|
||||
.onUserInteraction,
|
||||
"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(
|
||||
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!
|
||||
.copyWith(
|
||||
fontSize: blockSizeVertical * 2),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
//OVERSEAS ADDRESS SWITCH
|
||||
Column(
|
||||
children: [
|
||||
FormBuilderSwitch(
|
||||
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: (value) =>
|
||||
value == null
|
||||
? 'required'
|
||||
: null,
|
||||
onChanged:
|
||||
(Region? region) async {
|
||||
setState(() {
|
||||
provinceCall = true;
|
||||
});
|
||||
selectedRegion = region;
|
||||
getProvinces();
|
||||
},
|
||||
initialValue: selectedRegion,
|
||||
items: state.countries.map<
|
||||
DropdownMenuItem<
|
||||
Country>>(
|
||||
(Country country) {
|
||||
return DropdownMenuItem<
|
||||
Country>(
|
||||
value: country,
|
||||
child: FittedBox(
|
||||
child: Text(country
|
||||
.name!)));
|
||||
}).toList(),
|
||||
name: 'country',
|
||||
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>(
|
||||
"Country*",
|
||||
"Country"),
|
||||
onChanged: (Country? value) {
|
||||
selectedCountry = value;
|
||||
},
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
//REGION DROPDOWN
|
||||
FormBuilderDropdown<
|
||||
Region?>(
|
||||
autovalidateMode:
|
||||
AutovalidateMode
|
||||
.onUserInteraction,
|
||||
validator: (value) =>
|
||||
value == null
|
||||
? 'required'
|
||||
: null,
|
||||
isExpanded: true,
|
||||
onChanged:
|
||||
(CityMunicipality?
|
||||
city) {
|
||||
selectedMunicipality =
|
||||
city;
|
||||
onChanged: (Region?
|
||||
region) async {
|
||||
setState(() {
|
||||
provinceCall = true;
|
||||
});
|
||||
selectedRegion = region;
|
||||
getProvinces();
|
||||
},
|
||||
initialValue:
|
||||
selectedRegion,
|
||||
decoration:
|
||||
normalTextFieldStyle(
|
||||
"Municipality*",
|
||||
"Municipality"),
|
||||
value:
|
||||
selectedMunicipality,
|
||||
items: citymuns == null
|
||||
? []
|
||||
: citymuns!.map<
|
||||
DropdownMenuItem<
|
||||
CityMunicipality>>(
|
||||
(CityMunicipality
|
||||
c) {
|
||||
return DropdownMenuItem(
|
||||
value: c,
|
||||
child: Text(c
|
||||
.description!));
|
||||
}).toList(),
|
||||
"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")),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
|
||||
const Expanded(
|
||||
child: SizedBox(),
|
||||
),
|
||||
// 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,
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
height: 60,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(
|
||||
primary, Colors.transparent, second),
|
||||
onPressed: () {
|
||||
//rating
|
||||
double? rate = rating == null
|
||||
? null
|
||||
: double.parse(rating!);
|
||||
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);
|
||||
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(
|
||||
ExamAddress examAddress = ExamAddress(
|
||||
barangay: null,
|
||||
id: null,
|
||||
rating: rate,
|
||||
examDate: examDate,
|
||||
attachments: null,
|
||||
eligibility: selectedEligibility,
|
||||
examAddress: examAddress,
|
||||
validityDate: validityDate,
|
||||
licenseNumber: licenseNumber,
|
||||
overseas: overseas);
|
||||
if (formKey.currentState!
|
||||
.saveAndValidate()) {
|
||||
context.read<ProfileBloc>().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,
|
||||
),
|
||||
]),
|
||||
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,
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -477,7 +503,7 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
|
|||
getCities();
|
||||
});
|
||||
} catch (e) {
|
||||
context.read<ProfileBloc>().add(CallErrorState());
|
||||
context.read<EligibilityBloc>().add(CallErrorState());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -491,7 +517,7 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
|
|||
cityCall = false;
|
||||
});
|
||||
} catch (e) {
|
||||
context.read<ProfileBloc>().add(CallErrorState());
|
||||
context.read<EligibilityBloc>().add(CallErrorState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
import 'package:unit2/bloc/eligibility/eligibility_bloc.dart';
|
||||
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||
import 'package:unit2/bloc/user/user_bloc.dart';
|
||||
import 'package:unit2/model/location/city.dart';
|
||||
|
@ -59,446 +60,486 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
|||
token = state.userData!.user!.login!.token;
|
||||
profileId = state.userData!.user!.login!.user!.profileId.toString();
|
||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||
buildWhen: (previous, current) {
|
||||
if (state is EditEligibilityState) {}
|
||||
return false;
|
||||
},
|
||||
builder: (context, state) {
|
||||
//EDIT ELIGIBILITY STATE
|
||||
if (state is EditEligibilityState) {
|
||||
examDateController.text = state.eligibityCert.examDate == null?'': state.eligibityCert.examDate.toString();
|
||||
validityDateController.text = state.eligibityCert.validityDate == null?'': state.eligibityCert.validityDate.toString();
|
||||
|
||||
provinces = state.provinces;
|
||||
citymuns = state.cities;
|
||||
regions = state.regions;
|
||||
overseas = state.isOverseas;
|
||||
selectedRegion = state.currentRegion;
|
||||
selectedProvince = state.currentProvince;
|
||||
selectedMunicipality = state.currentCity;
|
||||
selectedEligibility= state.currentEligibility;
|
||||
rating = state.eligibityCert.rating?.toString();
|
||||
license = state.eligibityCert.licenseNumber;
|
||||
return 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
|
||||
DropdownButtonFormField<Eligibility>(
|
||||
validator: (value) =>
|
||||
value == null ? 'required' : null,
|
||||
isExpanded: true,
|
||||
onChanged: (Eligibility? eligibility) {
|
||||
selectedEligibility = eligibility;
|
||||
},
|
||||
value: selectedEligibility,
|
||||
items: state.eligibilities
|
||||
.map<DropdownMenuItem<Eligibility>>(
|
||||
(Eligibility eligibility) {
|
||||
return DropdownMenuItem<Eligibility>(
|
||||
value: eligibility,
|
||||
child: Text(eligibility.title));
|
||||
}).toList(),
|
||||
decoration:
|
||||
normalTextFieldStyle("Eligibility", "")),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
if(state is ProfileLoaded){
|
||||
return BlocBuilder<EligibilityBloc, EligibilityState>(
|
||||
buildWhen: (previous, current) {
|
||||
if (state is EditEligibilityState) {}
|
||||
return false;
|
||||
},
|
||||
builder: (context, state) {
|
||||
//EDIT ELIGIBILITY STATE
|
||||
if (state is EditEligibilityState) {
|
||||
examDateController.text =
|
||||
state.eligibityCert.examDate == null
|
||||
? ''
|
||||
: state.eligibityCert.examDate.toString();
|
||||
validityDateController.text =
|
||||
state.eligibityCert.validityDate == null
|
||||
? ''
|
||||
: state.eligibityCert.validityDate.toString();
|
||||
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(
|
||||
children: [
|
||||
//LICENSE NUMBER
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderTextField(
|
||||
onChanged: (value) {
|
||||
license = value;
|
||||
},
|
||||
name: 'license_number',
|
||||
initialValue:
|
||||
license,
|
||||
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',
|
||||
initialValue: rating == null
|
||||
? 'N/A'
|
||||
: rating.toString(),
|
||||
decoration: normalTextFieldStyle(
|
||||
'rating', 'rating'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(
|
||||
children: [
|
||||
//EXAM DATE
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DateTimePicker(
|
||||
use24HourFormat: false,
|
||||
controller: examDateController,
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Exam date", "")
|
||||
.copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
)),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
//VALIDITY DATE
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DateTimePicker(
|
||||
use24HourFormat: false,
|
||||
controller: validityDateController,
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
decoration: normalTextFieldStyle(
|
||||
"validity date", "")
|
||||
.copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Text(
|
||||
"Placement of Examination/Confinement",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.displaySmall!
|
||||
.copyWith(fontSize: blockSizeVertical * 2),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
//OVERSEAS ADDRESS SWITCH
|
||||
StatefulBuilder(
|
||||
builder: (context, StateSetter setState) {
|
||||
return Column(
|
||||
children: [
|
||||
FormBuilderSwitch(
|
||||
initialValue: overseas,
|
||||
activeColor: second,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
overseas = value;
|
||||
});
|
||||
provinces = state.provinces;
|
||||
citymuns = state.cities;
|
||||
regions = state.regions;
|
||||
overseas = state.isOverseas;
|
||||
selectedRegion = state.currentRegion;
|
||||
selectedProvince = state.currentProvince;
|
||||
selectedMunicipality = state.currentCity;
|
||||
selectedEligibility = state.currentEligibility;
|
||||
rating = state.eligibityCert.rating?.toString();
|
||||
license = state.eligibityCert.licenseNumber;
|
||||
return 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
|
||||
DropdownButtonFormField<Eligibility>(
|
||||
validator: (value) =>
|
||||
value == null ? 'required' : null,
|
||||
isExpanded: true,
|
||||
onChanged: (Eligibility? eligibility) {
|
||||
selectedEligibility = eligibility;
|
||||
},
|
||||
decoration: normalTextFieldStyle("", ''),
|
||||
name: 'overseas',
|
||||
title: const Text("Overseas Address?"),
|
||||
value: selectedEligibility,
|
||||
items: state.eligibilities
|
||||
.map<DropdownMenuItem<Eligibility>>(
|
||||
(Eligibility eligibility) {
|
||||
return DropdownMenuItem<Eligibility>(
|
||||
value: eligibility,
|
||||
child: Text(eligibility.title));
|
||||
}).toList(),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Eligibility", "")),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(
|
||||
children: [
|
||||
//LICENSE NUMBER
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderTextField(
|
||||
onChanged: (value) {
|
||||
license = value;
|
||||
},
|
||||
name: 'license_number',
|
||||
initialValue: license,
|
||||
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',
|
||||
initialValue: rating == null
|
||||
? 'N/A'
|
||||
: rating.toString(),
|
||||
decoration: normalTextFieldStyle(
|
||||
'rating', 'rating'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(
|
||||
children: [
|
||||
//EXAM DATE
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DateTimePicker(
|
||||
use24HourFormat: false,
|
||||
controller: examDateController,
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Exam date", "")
|
||||
.copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
)),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
//VALIDITY DATE
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DateTimePicker(
|
||||
use24HourFormat: false,
|
||||
controller: validityDateController,
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
decoration: normalTextFieldStyle(
|
||||
"validity date", "")
|
||||
.copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
//COUNTRY DROPDOWN
|
||||
SizedBox(
|
||||
child: overseas == true
|
||||
? FormBuilderDropdown<Country>(
|
||||
validator: (value) =>
|
||||
value == null
|
||||
? 'required'
|
||||
: null,
|
||||
initialValue:
|
||||
state.selectedCountry,
|
||||
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
|
||||
DropdownButtonFormField<
|
||||
Region?>(
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Text(
|
||||
"Placement of Examination/Confinement",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.displaySmall!
|
||||
.copyWith(
|
||||
fontSize: blockSizeVertical * 2),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
//OVERSEAS ADDRESS SWITCH
|
||||
StatefulBuilder(
|
||||
builder: (context, StateSetter setState) {
|
||||
return Column(
|
||||
children: [
|
||||
FormBuilderSwitch(
|
||||
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>(
|
||||
validator: (value) =>
|
||||
value == null
|
||||
? 'required'
|
||||
: null,
|
||||
isExpanded: true,
|
||||
onChanged:
|
||||
(Region? region) async {
|
||||
setState(() {
|
||||
provinceCall = true;
|
||||
});
|
||||
selectedRegion = region;
|
||||
provinces = await LocationUtils
|
||||
.instance
|
||||
.getProvinces(
|
||||
regionCode:
|
||||
selectedRegion!
|
||||
.code
|
||||
.toString());
|
||||
selectedProvince =
|
||||
provinces![0];
|
||||
setState(() {
|
||||
provinceCall = false;
|
||||
cityCall = true;
|
||||
});
|
||||
citymuns = await LocationUtils
|
||||
.instance
|
||||
.getCities(
|
||||
code:
|
||||
selectedProvince!
|
||||
.code!);
|
||||
selectedMunicipality =
|
||||
citymuns![0];
|
||||
setState(() {
|
||||
cityCall = false;
|
||||
});
|
||||
},
|
||||
value: selectedRegion,
|
||||
initialValue:
|
||||
state.selectedCountry,
|
||||
items: state.countries.map<
|
||||
DropdownMenuItem<
|
||||
Country>>(
|
||||
(Country country) {
|
||||
return DropdownMenuItem<
|
||||
Country>(
|
||||
value: country,
|
||||
child: FittedBox(
|
||||
child: Text(country
|
||||
.name!)));
|
||||
}).toList(),
|
||||
name: 'country',
|
||||
decoration:
|
||||
normalTextFieldStyle(
|
||||
"Region*", "Region"),
|
||||
items: regions == null
|
||||
? []
|
||||
: 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?>(
|
||||
validator: (value) =>
|
||||
value == null
|
||||
? 'required'
|
||||
: null,
|
||||
isExpanded: true,
|
||||
value: selectedProvince,
|
||||
onChanged: (Province?
|
||||
province) async {
|
||||
setState(() {
|
||||
cityCall = true;
|
||||
});
|
||||
selectedProvince =
|
||||
province;
|
||||
citymuns = await LocationUtils
|
||||
.instance
|
||||
.getCities(
|
||||
code: selectedProvince!
|
||||
.code
|
||||
.toString());
|
||||
selectedMunicipality =
|
||||
citymuns![0];
|
||||
setState(() {
|
||||
cityCall = false;
|
||||
});
|
||||
},
|
||||
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: 70,
|
||||
child: ModalProgressHUD(
|
||||
color: Colors.transparent,
|
||||
inAsyncCall: cityCall,
|
||||
child:
|
||||
DropdownButtonFormField<
|
||||
CityMunicipality>(
|
||||
"Country*",
|
||||
"Country"),
|
||||
onChanged: (Country? value) {
|
||||
selectedCountry = value;
|
||||
},
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
//REGION DROPDOWN
|
||||
DropdownButtonFormField<
|
||||
Region?>(
|
||||
validator: (value) =>
|
||||
value == null
|
||||
? 'required'
|
||||
: null,
|
||||
isExpanded: true,
|
||||
onChanged:
|
||||
(CityMunicipality?
|
||||
city) {
|
||||
onChanged: (Region?
|
||||
region) async {
|
||||
setState(() {
|
||||
provinceCall = true;
|
||||
});
|
||||
selectedRegion = region;
|
||||
provinces = await LocationUtils
|
||||
.instance
|
||||
.getProvinces(
|
||||
regionCode:
|
||||
selectedRegion!
|
||||
.code
|
||||
.toString());
|
||||
selectedProvince =
|
||||
provinces![0];
|
||||
setState(() {
|
||||
provinceCall = false;
|
||||
cityCall = true;
|
||||
});
|
||||
citymuns = await LocationUtils
|
||||
.instance
|
||||
.getCities(
|
||||
code:
|
||||
selectedProvince!
|
||||
.code!);
|
||||
selectedMunicipality =
|
||||
city;
|
||||
citymuns![0];
|
||||
setState(() {
|
||||
cityCall = false;
|
||||
});
|
||||
},
|
||||
value: selectedRegion,
|
||||
decoration:
|
||||
normalTextFieldStyle(
|
||||
"Municipality*",
|
||||
"Municipality"),
|
||||
value:
|
||||
selectedMunicipality,
|
||||
items: citymuns == null
|
||||
"Region*",
|
||||
"Region"),
|
||||
items: regions == null
|
||||
? []
|
||||
: citymuns!.map<
|
||||
DropdownMenuItem<
|
||||
CityMunicipality>>(
|
||||
(CityMunicipality
|
||||
c) {
|
||||
return DropdownMenuItem(
|
||||
value: c,
|
||||
child: Text(c
|
||||
: regions!.map<
|
||||
DropdownMenuItem<
|
||||
Region>>((Region
|
||||
region) {
|
||||
return DropdownMenuItem<
|
||||
Region>(
|
||||
value: region,
|
||||
child: Text(region
|
||||
.description!));
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
);
|
||||
}),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
//PROVINCE DROPDOWN
|
||||
SizedBox(
|
||||
height: 70,
|
||||
child: ModalProgressHUD(
|
||||
color:
|
||||
Colors.transparent,
|
||||
inAsyncCall:
|
||||
provinceCall,
|
||||
child: DropdownButtonFormField<
|
||||
Province?>(
|
||||
validator: (value) =>
|
||||
value == null
|
||||
? 'required'
|
||||
: null,
|
||||
isExpanded: true,
|
||||
value:
|
||||
selectedProvince,
|
||||
onChanged: (Province?
|
||||
province) async {
|
||||
setState(() {
|
||||
cityCall = true;
|
||||
});
|
||||
selectedProvince =
|
||||
province;
|
||||
citymuns = await LocationUtils
|
||||
.instance
|
||||
.getCities(
|
||||
code: selectedProvince!
|
||||
.code
|
||||
.toString());
|
||||
selectedMunicipality =
|
||||
citymuns![0];
|
||||
setState(() {
|
||||
cityCall =
|
||||
false;
|
||||
});
|
||||
},
|
||||
items: provinces ==
|
||||
null
|
||||
? []
|
||||
: provinces!.map<
|
||||
DropdownMenuItem<
|
||||
Province>>((Province
|
||||
province) {
|
||||
return DropdownMenuItem(
|
||||
value:
|
||||
province,
|
||||
child:
|
||||
FittedBox(
|
||||
child:
|
||||
Text(province.description!),
|
||||
));
|
||||
}).toList(),
|
||||
decoration:
|
||||
normalTextFieldStyle(
|
||||
"Province*",
|
||||
"Province")),
|
||||
),
|
||||
),
|
||||
|
||||
const Expanded(
|
||||
child: SizedBox(),
|
||||
),
|
||||
// City municipality
|
||||
SizedBox(
|
||||
height: 70,
|
||||
child: ModalProgressHUD(
|
||||
color:
|
||||
Colors.transparent,
|
||||
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,
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
);
|
||||
}),
|
||||
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
height: 60,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(
|
||||
primary, Colors.transparent, second),
|
||||
onPressed: () {
|
||||
|
||||
//rating
|
||||
double? rate = rating == null
|
||||
? null
|
||||
: double.parse(rating!);
|
||||
//license
|
||||
String? newLicense = license;
|
||||
//city municipality
|
||||
CityMunicipality? cityMunicipality =
|
||||
selectedMunicipality;
|
||||
//exam date
|
||||
DateTime? examDate =
|
||||
examDateController.text.isEmpty
|
||||
? null
|
||||
: DateTime.parse(
|
||||
examDateController.text);
|
||||
// validity date
|
||||
DateTime? validityDate =
|
||||
validityDateController.text.isEmpty
|
||||
? null
|
||||
: DateTime.parse(
|
||||
validityDateController.text);
|
||||
// exam address
|
||||
ExamAddress examAddress = ExamAddress(
|
||||
barangay: state.eligibityCert.examAddress?.barangay,
|
||||
id: state.eligibityCert.examAddress?.id,
|
||||
addressCategory: state.eligibityCert.examAddress?.addressCategory,
|
||||
examAddressClass: state.eligibityCert.examAddress?.examAddressClass,
|
||||
country: selectedCountry ??= Country(
|
||||
id: 175,
|
||||
name: 'Philippines',
|
||||
code: 'PH'),
|
||||
cityMunicipality: cityMunicipality);
|
||||
EligibityCert eligibityCert =
|
||||
EligibityCert(
|
||||
id: state.eligibityCert.id,
|
||||
rating: rate,
|
||||
examDate: examDate,
|
||||
attachments: null,
|
||||
eligibility: selectedEligibility,
|
||||
examAddress: examAddress,
|
||||
validityDate: validityDate,
|
||||
licenseNumber: newLicense,
|
||||
overseas: overseas);
|
||||
if (formKey.currentState!
|
||||
.saveAndValidate()) {
|
||||
context.read<ProfileBloc>().add(UpdateEligibility(eligibityCert: eligibityCert, oldEligibility: state.eligibityCert.eligibility!.id, profileId: profileId!, token: token!));
|
||||
}
|
||||
},
|
||||
child: const Text(submit)),
|
||||
),
|
||||
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!);
|
||||
//license
|
||||
String? newLicense = license;
|
||||
//city municipality
|
||||
CityMunicipality? cityMunicipality =
|
||||
selectedMunicipality;
|
||||
//exam date
|
||||
DateTime? examDate =
|
||||
examDateController.text.isEmpty
|
||||
? null
|
||||
: DateTime.parse(
|
||||
examDateController.text);
|
||||
// validity date
|
||||
DateTime? validityDate =
|
||||
validityDateController.text.isEmpty
|
||||
? null
|
||||
: DateTime.parse(
|
||||
validityDateController
|
||||
.text);
|
||||
// exam address
|
||||
ExamAddress examAddress = ExamAddress(
|
||||
barangay: state.eligibityCert
|
||||
.examAddress?.barangay,
|
||||
id: state
|
||||
.eligibityCert.examAddress?.id,
|
||||
addressCategory: state.eligibityCert
|
||||
.examAddress?.addressCategory,
|
||||
examAddressClass: state
|
||||
.eligibityCert
|
||||
.examAddress
|
||||
?.examAddressClass,
|
||||
country: selectedCountry ??=
|
||||
Country(
|
||||
id: 175,
|
||||
name: 'Philippines',
|
||||
code: 'PH'),
|
||||
cityMunicipality: cityMunicipality);
|
||||
EligibityCert eligibityCert =
|
||||
EligibityCert(
|
||||
id: state.eligibityCert.id,
|
||||
rating: rate,
|
||||
examDate: examDate,
|
||||
attachments: null,
|
||||
eligibility:
|
||||
selectedEligibility,
|
||||
examAddress: examAddress,
|
||||
validityDate: validityDate,
|
||||
licenseNumber: newLicense,
|
||||
overseas: overseas);
|
||||
if (formKey.currentState!
|
||||
.saveAndValidate()) {
|
||||
context.read<EligibilityBloc>().add(
|
||||
UpdateEligibility(
|
||||
eligibityCert: eligibityCert,
|
||||
oldEligibility: state
|
||||
.eligibityCert
|
||||
.eligibility!
|
||||
.id,
|
||||
profileId: profileId!,
|
||||
token: token!));
|
||||
}
|
||||
},
|
||||
child: const Text(submit)),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
|
|
|
@ -4,6 +4,7 @@ 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/eligibility/eligibility_bloc.dart';
|
||||
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||
import 'package:unit2/bloc/user/user_bloc.dart';
|
||||
import 'package:unit2/model/profile/eligibility.dart';
|
||||
|
@ -25,32 +26,33 @@ class EligibiltyScreen extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
String? token;
|
||||
String? profileId;
|
||||
List<EligibityCert>? eligibilities;
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return true;
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: context.watch<ProfileBloc>().state is AddEligibilityState
|
||||
title: context.watch<EligibilityBloc>().state is AddEligibilityState
|
||||
? const Text("Add Eligiblity")
|
||||
: context.watch<ProfileBloc>().state is EditEligibilityState
|
||||
: context.watch<EligibilityBloc>().state is EditEligibilityState
|
||||
? const Text("Edit Eligibilty")
|
||||
: const Text(elibilityScreenTitle),
|
||||
centerTitle: true,
|
||||
backgroundColor: primary,
|
||||
actions: (context.watch<ProfileBloc>().state is EligibilityLoaded ||
|
||||
context.watch<ProfileBloc>().state is ProfileLoading)
|
||||
actions: (context.watch<EligibilityBloc>().state is EligibilityLoaded ||
|
||||
context.watch<EligibilityBloc>().state is ProfileLoading)
|
||||
? [
|
||||
AddLeading(onPressed: () {
|
||||
context.read<ProfileBloc>().add(ShowAddEligibilityForm());
|
||||
context
|
||||
.read<EligibilityBloc>()
|
||||
.add(ShowAddEligibilityForm());
|
||||
})
|
||||
]
|
||||
: [
|
||||
CloseLeading(onPressed: () {
|
||||
context
|
||||
.read<ProfileBloc>()
|
||||
.add(GetEligibilities(profileId: int.parse(profileId!), token: token!));
|
||||
context.read<EligibilityBloc>().add(GetEligibilities(
|
||||
profileId: int.parse(profileId!), token: token!));
|
||||
})
|
||||
],
|
||||
),
|
||||
|
@ -60,257 +62,278 @@ class EligibiltyScreen extends StatelessWidget {
|
|||
token = state.userData!.user!.login!.token;
|
||||
profileId =
|
||||
state.userData!.user!.login!.user!.profileId.toString();
|
||||
return ProgressHUD(
|
||||
padding: const EdgeInsets.all(24),
|
||||
indicatorWidget: const SpinKitFadingCircle(
|
||||
color: Colors.white,
|
||||
),
|
||||
backgroundColor: Colors.black87,
|
||||
child: BlocConsumer<ProfileBloc, ProfileState>(
|
||||
listener: (context, state) {
|
||||
if (state is ProfileLoading) {
|
||||
final progress = ProgressHUD.of(context);
|
||||
progress!.showWithText("Loading");
|
||||
}
|
||||
if (state is EligibilityLoaded ||
|
||||
state is AddEligibilityState ||
|
||||
state is ProfileErrorState ||
|
||||
state is EditEligibilityState ||
|
||||
state is DeletedState ||
|
||||
state is EligibilityAddedState ||
|
||||
state is EligibilityEditedState) {
|
||||
final progress = ProgressHUD.of(context);
|
||||
progress!.dismiss();
|
||||
}
|
||||
//DELETED STATE
|
||||
if (state is DeletedState) {
|
||||
if (state.success) {
|
||||
successAlert(context, "Deletion Successfull",
|
||||
"Eligibility has been deleted successfully", () {
|
||||
Navigator.of(context).pop();
|
||||
context.read<ProfileBloc>().add(LoadEligibility(
|
||||
eligibilities: state.eligibilities));
|
||||
});
|
||||
} else {
|
||||
errorAlert(context, "Deletion Failed",
|
||||
"Error deleting eligibility", () {
|
||||
Navigator.of(context).pop();
|
||||
context.read<ProfileBloc>().add(LoadEligibility(
|
||||
eligibilities: state.eligibilities));
|
||||
});
|
||||
}
|
||||
}
|
||||
//ADDED STATE
|
||||
if (state is EligibilityAddedState) {
|
||||
if (state.response['success']) {
|
||||
successAlert(context, "Adding Successfull!",
|
||||
state.response['message'], () {
|
||||
Navigator.of(context).pop();
|
||||
context.read<ProfileBloc>().add(LoadEligibility(
|
||||
eligibilities: state.eligibilities));
|
||||
});
|
||||
} else {
|
||||
errorAlert(context, "Adding Failed",
|
||||
"Something went wrong. Please try again.", () {
|
||||
Navigator.of(context).pop();
|
||||
context.read<ProfileBloc>().add(LoadEligibility(
|
||||
eligibilities: state.eligibilities));
|
||||
});
|
||||
}
|
||||
}
|
||||
//UPDATED STATE
|
||||
if (state is EligibilityEditedState) {
|
||||
if (state.response['success']) {
|
||||
successAlert(context, "Update Successfull!",
|
||||
state.response['message'], () {
|
||||
Navigator.of(context).pop();
|
||||
context.read<ProfileBloc>().add(LoadEligibility(
|
||||
eligibilities: state.eligibilities));
|
||||
});
|
||||
} else {
|
||||
errorAlert(context, "Update Failed",
|
||||
"Something went wrong. Please try again.", () {
|
||||
Navigator.of(context).pop();
|
||||
context.read<ProfileBloc>().add(LoadEligibility(
|
||||
eligibilities: state.eligibilities));
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||
builder: (context, state) {
|
||||
if (state is EligibilityLoaded) {
|
||||
eligibilities = state.eligibilities;
|
||||
if (state.eligibilities.isNotEmpty) {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8, horizontal: 10),
|
||||
itemCount: state.eligibilities.length,
|
||||
itemBuilder:
|
||||
(BuildContext context, int index) {
|
||||
String title = state.eligibilities[index]
|
||||
.eligibility!.title;
|
||||
return Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: screenWidth,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 8),
|
||||
decoration: box1(),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment
|
||||
.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium!
|
||||
.copyWith(
|
||||
fontWeight:
|
||||
FontWeight
|
||||
.w500),
|
||||
),
|
||||
const Divider(),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Text(
|
||||
"$licenseNumber: ${state.eligibilities[index].licenseNumber == null ? 'N/A' : state.eligibilities[index].licenseNumber.toString()}",
|
||||
style:
|
||||
Theme.of(context)
|
||||
.textTheme
|
||||
.titleSmall),
|
||||
const SizedBox(
|
||||
height: 3,
|
||||
),
|
||||
Text(
|
||||
"Rating : ${state.eligibilities[index].rating ?? 'N/A'}.",
|
||||
style:
|
||||
Theme.of(context)
|
||||
.textTheme
|
||||
.titleSmall)
|
||||
]),
|
||||
),
|
||||
AppPopupMenu<int>(
|
||||
offset: const Offset(-10, -10),
|
||||
elevation: 3,
|
||||
onSelected: (value) {
|
||||
final progress =
|
||||
ProgressHUD.of(context);
|
||||
progress!.showWithText(
|
||||
"Loading...");
|
||||
////delete eligibilty-= = = = = = = = =>>
|
||||
if (value == 2) {
|
||||
confirmAlert(context, () {
|
||||
BlocProvider.of<
|
||||
ProfileBloc>(
|
||||
context)
|
||||
.add(DeleteEligibility(
|
||||
eligibilities:
|
||||
state
|
||||
.eligibilities,
|
||||
eligibilityId: state
|
||||
.eligibilities[
|
||||
index]
|
||||
.id!,
|
||||
profileId:
|
||||
profileId!,
|
||||
token: token!));
|
||||
}, "Delete?",
|
||||
"Confirm Delete?");
|
||||
}
|
||||
if (value == 1) {
|
||||
////edit eligibilty-= = = = = = = = =>>
|
||||
EligibityCert
|
||||
eligibityCert =
|
||||
state.eligibilities[
|
||||
index];
|
||||
bool overseas = eligibityCert
|
||||
.examAddress!
|
||||
.country!
|
||||
.id
|
||||
.toString() ==
|
||||
'175'
|
||||
? false
|
||||
: true;
|
||||
eligibityCert.overseas =
|
||||
overseas;
|
||||
|
||||
eligibityCert.overseas =
|
||||
overseas;
|
||||
|
||||
context.read<ProfileBloc>().add(
|
||||
ShowEditEligibilityForm(
|
||||
eligibityCert:
|
||||
eligibityCert));
|
||||
}
|
||||
},
|
||||
menuItems: [
|
||||
popMenuItem(
|
||||
text: "Edit",
|
||||
value: 1,
|
||||
icon: Icons.edit),
|
||||
popMenuItem(
|
||||
text: "Delete",
|
||||
value: 2,
|
||||
icon: Icons.delete),
|
||||
popMenuItem(
|
||||
text: "Attachment",
|
||||
value: 3,
|
||||
icon: FontAwesome.attach)
|
||||
],
|
||||
icon: const Icon(
|
||||
Icons.more_vert,
|
||||
color: Colors.grey,
|
||||
),
|
||||
tooltip: "Options",
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
)
|
||||
],
|
||||
);
|
||||
});
|
||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||
builder: (context, state) {
|
||||
if(state is ProfileLoaded){
|
||||
return ProgressHUD(
|
||||
padding: const EdgeInsets.all(24),
|
||||
indicatorWidget: const SpinKitFadingCircle(
|
||||
color: Colors.white,
|
||||
),
|
||||
backgroundColor: Colors.black87,
|
||||
child: BlocConsumer<EligibilityBloc, EligibilityState>(
|
||||
listener: (context, state) {
|
||||
if (state is EligibilityLoadingState) {
|
||||
final progress = ProgressHUD.of(context);
|
||||
progress!.showWithText("Loading");
|
||||
}
|
||||
if (state is EligibilityLoaded ||
|
||||
state is AddEligibilityState ||
|
||||
state is EditEligibilityState ||
|
||||
state is DeletedState ||
|
||||
state is EligibilityAddedState ||
|
||||
state is EligibilityEditedState) {
|
||||
final progress = ProgressHUD.of(context);
|
||||
progress!.dismiss();
|
||||
}
|
||||
//DELETED STATE
|
||||
if (state is DeletedState) {
|
||||
if (state.success) {
|
||||
successAlert(context, "Deletion Successfull",
|
||||
"Eligibility has been deleted successfully",
|
||||
() {
|
||||
Navigator.of(context).pop();
|
||||
context.read<EligibilityBloc>().add(LoadEligibility(
|
||||
eligibilities: state.eligibilities));
|
||||
});
|
||||
} else {
|
||||
return const EmptyData(
|
||||
message:
|
||||
"You don't have any eligibilities added. Please click + to add");
|
||||
errorAlert(context, "Deletion Failed",
|
||||
"Error deleting eligibility", () {
|
||||
Navigator.of(context).pop();
|
||||
context.read<EligibilityBloc>().add(LoadEligibility(
|
||||
eligibilities: state.eligibilities));
|
||||
});
|
||||
}
|
||||
}
|
||||
if (state is EditEligibilityState) {
|
||||
return EditEligibilityScreen(
|
||||
eligibityCert: state.eligibityCert);
|
||||
//ADDED STATE
|
||||
if (state is EligibilityAddedState) {
|
||||
if (state.response['success']) {
|
||||
successAlert(context, "Adding Successfull!",
|
||||
state.response['message'], () {
|
||||
Navigator.of(context).pop();
|
||||
context.read<EligibilityBloc>().add(LoadEligibility(
|
||||
eligibilities: state.eligibilities));
|
||||
});
|
||||
} else {
|
||||
errorAlert(context, "Adding Failed",
|
||||
"Something went wrong. Please try again.",
|
||||
() {
|
||||
Navigator.of(context).pop();
|
||||
context.read<EligibilityBloc>().add(LoadEligibility(
|
||||
eligibilities: state.eligibilities));
|
||||
});
|
||||
}
|
||||
}
|
||||
if (state is AddEligibilityState) {
|
||||
return const AddEligibilityScreen();
|
||||
//UPDATED STATE
|
||||
if (state is EligibilityEditedState) {
|
||||
if (state.response['success']) {
|
||||
successAlert(context, "Update Successfull!",
|
||||
state.response['message'], () {
|
||||
Navigator.of(context).pop();
|
||||
context.read<EligibilityBloc>().add(LoadEligibility(
|
||||
eligibilities: state.eligibilities));
|
||||
});
|
||||
} else {
|
||||
errorAlert(context, "Update Failed",
|
||||
"Something went wrong. Please try again.",
|
||||
() {
|
||||
Navigator.of(context).pop();
|
||||
context.read<EligibilityBloc>().add(LoadEligibility(
|
||||
eligibilities: state.eligibilities));
|
||||
});
|
||||
}
|
||||
}
|
||||
if (state is ProfileErrorState) {
|
||||
return Center(
|
||||
child: Text(state.mesage),
|
||||
);
|
||||
}
|
||||
return Container(
|
||||
color: Colors.grey.shade200,
|
||||
},
|
||||
builder: (context, state) {
|
||||
return BlocBuilder<EligibilityBloc, EligibilityState>(
|
||||
builder: (context, state) {
|
||||
if (state is EligibilityLoaded) {
|
||||
|
||||
if (state.eligibilities.isNotEmpty) {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8, horizontal: 10),
|
||||
itemCount: state.eligibilities.length,
|
||||
itemBuilder:
|
||||
(BuildContext context, int index) {
|
||||
String title = state
|
||||
.eligibilities[index]
|
||||
.eligibility!
|
||||
.title;
|
||||
return Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: screenWidth,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 8),
|
||||
decoration: box1(),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment
|
||||
.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(
|
||||
context)
|
||||
.textTheme
|
||||
.titleMedium!
|
||||
.copyWith(
|
||||
fontWeight:
|
||||
FontWeight
|
||||
.w500),
|
||||
),
|
||||
const Divider(),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Text(
|
||||
"$licenseNumber: ${state.eligibilities[index].licenseNumber == null ? 'N/A' : state.eligibilities[index].licenseNumber.toString()}",
|
||||
style: Theme.of(
|
||||
context)
|
||||
.textTheme
|
||||
.titleSmall),
|
||||
const SizedBox(
|
||||
height: 3,
|
||||
),
|
||||
Text(
|
||||
"Rating : ${state.eligibilities[index].rating ?? 'N/A'}.",
|
||||
style: Theme.of(
|
||||
context)
|
||||
.textTheme
|
||||
.titleSmall)
|
||||
]),
|
||||
),
|
||||
AppPopupMenu<int>(
|
||||
offset:
|
||||
const Offset(-10, -10),
|
||||
elevation: 3,
|
||||
onSelected: (value) {
|
||||
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!,
|
||||
token:
|
||||
token!));
|
||||
}, "Delete?",
|
||||
"Confirm Delete?");
|
||||
}
|
||||
if (value == 1) {
|
||||
////edit eligibilty-= = = = = = = = =>>
|
||||
EligibityCert
|
||||
eligibityCert =
|
||||
state.eligibilities[
|
||||
index];
|
||||
bool overseas = eligibityCert
|
||||
.examAddress!
|
||||
.country!
|
||||
.id
|
||||
.toString() ==
|
||||
'175'
|
||||
? false
|
||||
: true;
|
||||
eligibityCert.overseas =
|
||||
overseas;
|
||||
|
||||
eligibityCert.overseas =
|
||||
overseas;
|
||||
|
||||
context
|
||||
.read<EligibilityBloc>()
|
||||
.add(ShowEditEligibilityForm(
|
||||
eligibityCert:
|
||||
eligibityCert));
|
||||
}
|
||||
},
|
||||
menuItems: [
|
||||
popMenuItem(
|
||||
text: "Edit",
|
||||
value: 1,
|
||||
icon: Icons.edit),
|
||||
popMenuItem(
|
||||
text: "Delete",
|
||||
value: 2,
|
||||
icon: Icons.delete),
|
||||
popMenuItem(
|
||||
text: "Attachment",
|
||||
value: 3,
|
||||
icon: FontAwesome
|
||||
.attach)
|
||||
],
|
||||
icon: const Icon(
|
||||
Icons.more_vert,
|
||||
color: Colors.grey,
|
||||
),
|
||||
tooltip: "Options",
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
)
|
||||
],
|
||||
);
|
||||
});
|
||||
} else {
|
||||
return const EmptyData(
|
||||
message:
|
||||
"You don't have any eligibilities added. Please click + to add");
|
||||
}
|
||||
}
|
||||
if (state is EditEligibilityState) {
|
||||
return EditEligibilityScreen(
|
||||
eligibityCert: state.eligibityCert);
|
||||
}
|
||||
if (state is AddEligibilityState) {
|
||||
return const AddEligibilityScreen();
|
||||
}
|
||||
if (state is EligibilityErrorState) {
|
||||
return Center(
|
||||
child: Text(state.message),
|
||||
);
|
||||
}
|
||||
return Container(
|
||||
color: Colors.grey.shade200,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
}
|
||||
return Container();
|
||||
}
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
|
|
|
@ -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:unit2/model/profile/other_information/non_acedimic_recognition.dart';
|
||||
import 'package:unit2/theme-data.dart/box_shadow.dart';
|
||||
import 'package:unit2/theme-data.dart/colors.dart';
|
||||
|
|
|
@ -1,71 +1,167 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||
import 'package:unit2/bloc/user/user_bloc.dart';
|
||||
import 'package:unit2/bloc/workHistory/workHistory_bloc.dart';
|
||||
import 'package:unit2/model/profile/work_history.dart';
|
||||
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/empty_data.dart';
|
||||
import 'package:unit2/widgets/error_state.dart';
|
||||
|
||||
import '../../../utils/global.dart';
|
||||
|
||||
class WorkHistoryScreen extends StatelessWidget {
|
||||
final List<WorkHistory> workExperiences;
|
||||
const WorkHistoryScreen({super.key, required this.workExperiences});
|
||||
|
||||
|
||||
const WorkHistoryScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
||||
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text(workHistoryScreenTitle),
|
||||
backgroundColor: primary,
|
||||
centerTitle: true,
|
||||
actions: [AddLeading(onPressed: (){})],
|
||||
),
|
||||
body: workExperiences.isNotEmpty? ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
|
||||
itemCount: workExperiences.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
String position = workExperiences[index].position!.title!;
|
||||
String agency = workExperiences[index].agency!.name!;
|
||||
String from =
|
||||
dteFormat2.format(workExperiences[index].fromDate!);
|
||||
String? to = workExperiences[index].toDate == null
|
||||
? present.toUpperCase()
|
||||
: dteFormat2.format(workExperiences[index].toDate!);
|
||||
return Column(
|
||||
|
||||
children: [
|
||||
Container(
|
||||
width: screenWidth,
|
||||
decoration: box1(),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
child: Row(children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(position,style: Theme.of(context).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w600),),
|
||||
const Divider(),
|
||||
const SizedBox(height: 8,),
|
||||
Text(agency,style: Theme.of(context).textTheme.titleSmall!.copyWith(fontWeight: FontWeight.w500),),
|
||||
const SizedBox(height: 5,),
|
||||
Text("$from to $to",style: Theme.of(context).textTheme.bodyMedium,),
|
||||
],
|
||||
)),
|
||||
IconButton(onPressed: () {}, icon: const Icon(Icons.more_vert,color: Colors.grey,))
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
],
|
||||
);
|
||||
}):const EmptyData(message: "You don't have any Work History added. Please click + to add ."),
|
||||
);
|
||||
appBar: AppBar(
|
||||
title: const Text(workHistoryScreenTitle),
|
||||
backgroundColor: primary,
|
||||
centerTitle: true,
|
||||
actions: [AddLeading(onPressed: () {})],
|
||||
),
|
||||
body:
|
||||
//UserBloc
|
||||
ProgressHUD(
|
||||
padding: const EdgeInsets.all(24),
|
||||
backgroundColor: Colors.black87,
|
||||
indicatorWidget: const SpinKitFadingCircle(
|
||||
color: Colors.white,
|
||||
),
|
||||
child: BlocBuilder<UserBloc, UserState>(
|
||||
builder: (context, state) {
|
||||
if (state is UserLoggedIn) {
|
||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||
builder: (context, state) {
|
||||
//ProfileBloc
|
||||
if (state is ProfileLoaded) {
|
||||
//WorkHistoryBloc
|
||||
return BlocConsumer<WorkHistoryBloc, WorkHistoryState>(
|
||||
listener: (context, state) {
|
||||
if (state is WorkHistoryLoadingState) {
|
||||
final progress = ProgressHUD.of(context);
|
||||
progress!.showWithText("Please wait...");
|
||||
}
|
||||
if (state is WorkHistoryLoaded || state is WorkHistoryErrorState) {
|
||||
final progress = ProgressHUD.of(context);
|
||||
progress!.dismiss();
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
if (state is WorkHistoryLoaded) {
|
||||
if (state.workExperiences.isNotEmpty) {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8, horizontal: 10),
|
||||
itemCount: state.workExperiences.length,
|
||||
itemBuilder:
|
||||
(BuildContext context, int index) {
|
||||
String position = state
|
||||
.workExperiences[index]
|
||||
.position!
|
||||
.title!;
|
||||
String agency = state
|
||||
.workExperiences[index].agency!.name!;
|
||||
String from = dteFormat2.format(
|
||||
state.workExperiences[index].fromDate!);
|
||||
String? to =
|
||||
state.workExperiences[index].toDate ==
|
||||
null
|
||||
? present.toUpperCase()
|
||||
: dteFormat2.format(
|
||||
state.workExperiences[index].toDate!);
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
width: screenWidth,
|
||||
decoration: box1(),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 8),
|
||||
child: Row(children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
position,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium!
|
||||
.copyWith(
|
||||
fontWeight:
|
||||
FontWeight.w600),
|
||||
),
|
||||
const Divider(),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Text(
|
||||
agency,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleSmall!
|
||||
.copyWith(
|
||||
fontWeight:
|
||||
FontWeight.w500),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Text(
|
||||
"$from $to ",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium,
|
||||
),
|
||||
],
|
||||
)),
|
||||
IconButton(
|
||||
onPressed: () {},
|
||||
icon: const Icon(
|
||||
Icons.more_vert,
|
||||
color: Colors.grey,
|
||||
))
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
} else {
|
||||
return const EmptyData(
|
||||
message:
|
||||
"You don't have any work experience added. Please click + to add");
|
||||
}
|
||||
}
|
||||
if (state is WorkHistoryErrorState) {
|
||||
return SomethingWentWrong(
|
||||
message: state.message, onpressed: () {});
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,14 +8,15 @@ import 'package:fluttericon/elusive_icons.dart';
|
|||
import 'package:fluttericon/entypo_icons.dart';
|
||||
import 'package:fluttericon/font_awesome5_icons.dart';
|
||||
import 'package:fluttericon/modern_pictograms_icons.dart';
|
||||
import 'package:unit2/bloc/eligibility/eligibility_bloc.dart';
|
||||
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||
import 'package:unit2/bloc/workHistory/workHistory_bloc.dart';
|
||||
import 'package:unit2/model/login_data/employee_info/employee_info.dart';
|
||||
import 'package:unit2/screens/profile/components/basic_information/address_screen.dart';
|
||||
import 'package:unit2/screens/profile/components/basic_information/citizenship_screen.dart';
|
||||
import 'package:unit2/screens/profile/components/basic_information/contact_information_screen.dart';
|
||||
import 'package:unit2/screens/profile/components/basic_information/identification_information_screen.dart';
|
||||
import 'package:unit2/screens/profile/components/basic_information/primary_information_screen.dart';
|
||||
import 'package:unit2/screens/profile/components/education_screen.dart';
|
||||
import 'package:unit2/screens/profile/components/eligibility_screen.dart';
|
||||
import 'package:unit2/screens/profile/components/family_background_screen.dart';
|
||||
import 'package:unit2/screens/profile/components/learning_and_development_screen.dart';
|
||||
|
@ -148,12 +149,7 @@ class _ProfileInfoState extends State<ProfileInfo> {
|
|||
icon: Elusive.group,
|
||||
title: "Family",
|
||||
onTap: () {
|
||||
// Navigator.push(context, MaterialPageRoute(
|
||||
// builder: (BuildContext context) {
|
||||
// return FamilyBackgroundScreen(
|
||||
// familyBackground:
|
||||
// state.profileInformation.families);
|
||||
// }));
|
||||
|
||||
},
|
||||
),
|
||||
const Divider(),
|
||||
|
@ -177,10 +173,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
|
|||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return BlocProvider<ProfileBloc>.value(
|
||||
value: ProfileBloc()
|
||||
..add(GetEligibilities(
|
||||
profileId: profileId!, token: token!)),
|
||||
return BlocProvider(
|
||||
create: (context) => EligibilityBloc()..add(GetEligibilities(profileId: profileId!, token: token!)),
|
||||
child: const EligibiltyScreen(),
|
||||
);
|
||||
}));
|
||||
|
@ -191,12 +185,14 @@ class _ProfileInfoState extends State<ProfileInfo> {
|
|||
icon: FontAwesome5.shopping_bag,
|
||||
title: "Work History",
|
||||
onTap: () {
|
||||
// Navigator.push(context, MaterialPageRoute(
|
||||
// builder: (BuildContext context) {
|
||||
// return WorkHistoryScreen(
|
||||
// workExperiences: state
|
||||
// .profileInformation.workExperiences);
|
||||
// }));
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => WorkHistoryBloc()..add(GetWorkHistories(profileId: profileId!, token: token!)),
|
||||
child: const WorkHistoryScreen(),
|
||||
);
|
||||
}));
|
||||
|
||||
},
|
||||
),
|
||||
const Divider(),
|
||||
|
|
|
@ -20,7 +20,7 @@ class EligibilityService {
|
|||
|
||||
};
|
||||
|
||||
// try{
|
||||
try{
|
||||
http.Response response = await Request.instance.getRequest(path: path,headers: headers,param: {});
|
||||
if(response.statusCode == 200){
|
||||
Map data = jsonDecode(response.body);
|
||||
|
@ -31,9 +31,9 @@ class EligibilityService {
|
|||
});
|
||||
}
|
||||
}
|
||||
// }catch(e){
|
||||
// throw e.toString();
|
||||
// }
|
||||
}catch(e){
|
||||
throw e.toString();
|
||||
}
|
||||
return eligibilities;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:unit2/model/profile/work_history.dart';
|
||||
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:unit2/utils/request.dart';
|
||||
|
||||
import '../../utils/urls.dart';
|
||||
class WorkHistoryService{
|
||||
static final WorkHistoryService _instance = WorkHistoryService();
|
||||
static WorkHistoryService get instance => _instance;
|
||||
|
||||
Future <List<WorkHistory>> getWorkExperiences( int profileId, String token)async{
|
||||
List<WorkHistory> workExperiences = [];
|
||||
String authToken = "Token $token";
|
||||
Map<String, String> headers = {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': authToken
|
||||
};
|
||||
String path= Url.instance.workHistories()+profileId.toString();
|
||||
// try{
|
||||
http.Response response =await Request.instance.getRequest(path: path, headers: headers, param: {});
|
||||
if(response.statusCode == 200){
|
||||
Map data = jsonDecode(response.body);
|
||||
if(data['data'] != null){
|
||||
data['data'].forEach((var workHistory){
|
||||
workExperiences.add(WorkHistory.fromJson(workHistory));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
// }catch(e){
|
||||
// throw e.toString();
|
||||
// }
|
||||
return workExperiences;
|
||||
|
||||
}
|
||||
}
|
|
@ -34,12 +34,12 @@ class AppRouter {
|
|||
return const QRLogin();
|
||||
});
|
||||
case '/profile':
|
||||
ProfileArguments arguments = routeSettings.arguments as ProfileArguments;
|
||||
BlocProvider.of<ProfileBloc>(
|
||||
NavigationService.navigatorKey.currentContext!)
|
||||
.add(LoadProfile(token:arguments.token ,userID:arguments.userID ));
|
||||
return MaterialPageRoute(builder: (_) {
|
||||
ProfileArguments arguments = routeSettings.arguments as ProfileArguments;
|
||||
return BlocProvider(
|
||||
create: (context) => ProfileBloc()..add(LoadProfile(token: arguments.token,userID: arguments.userID)),
|
||||
child: const ProfileInfo(),
|
||||
);
|
||||
return const ProfileInfo();
|
||||
});
|
||||
default:
|
||||
return MaterialPageRoute(builder: (context) {
|
||||
|
|
|
@ -41,6 +41,10 @@ String deleteEligibility(){
|
|||
String updateEligibility(){
|
||||
return "/api/jobnet_app/profile/pds/eligibility/";
|
||||
}
|
||||
//// work history paths
|
||||
String workHistories(){
|
||||
return "/api/jobnet_app/profile/pds/work/";
|
||||
}
|
||||
|
||||
// location utils path
|
||||
String getCounties(){
|
||||
|
|
Loading…
Reference in New Issue