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:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:unit2/model/profile/eligibility.dart';
|
|
||||||
import 'package:unit2/model/profile/profileInfomation.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/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_event.dart';
|
||||||
part 'profile_state.dart';
|
part 'profile_state.dart';
|
||||||
|
|
||||||
class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
||||||
ProfileBloc() : super(ProfileInitial()) {
|
ProfileBloc() : super(ProfileInitial()) {
|
||||||
ProfileInformation? globalProfileInformation;
|
ProfileInformation? globalProfileInformation;
|
||||||
List<Country>? globalCountries;
|
|
||||||
List<Region>? globalRegions;
|
|
||||||
List<Eligibility>? globalEligibilities;
|
|
||||||
List<EligibityCert>? eligibilities;
|
|
||||||
////=========================================================================
|
|
||||||
on<LoadProfile>((event, emit) async {
|
on<LoadProfile>((event, emit) async {
|
||||||
try {
|
try {
|
||||||
emit(ProfileLoading());
|
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 => [];
|
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 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:device_preview/device_preview.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.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/bloc/user/user_bloc.dart';
|
||||||
import 'package:unit2/theme-data.dart/colors.dart';
|
import 'package:unit2/theme-data.dart/colors.dart';
|
||||||
import 'package:unit2/utils/app_router.dart';
|
import 'package:unit2/utils/app_router.dart';
|
||||||
|
@ -47,6 +48,9 @@ class MyApp extends StatelessWidget {
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (_) => UserBloc(),
|
create: (_) => UserBloc(),
|
||||||
),
|
),
|
||||||
|
BlocProvider(
|
||||||
|
create: (_) => ProfileBloc(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
child: MaterialApp(
|
child: MaterialApp(
|
||||||
navigatorKey: NavigationService.navigatorKey,
|
navigatorKey: NavigationService.navigatorKey,
|
||||||
|
|
|
@ -35,7 +35,7 @@ class WorkHistory {
|
||||||
final DateTime? fromDate;
|
final DateTime? fromDate;
|
||||||
// final dynamic attachments;
|
// final dynamic attachments;
|
||||||
final int? salaryGrade;
|
final int? salaryGrade;
|
||||||
final int? monthlySalary;
|
final double? monthlySalary;
|
||||||
final String? appointmentStatus;
|
final String? appointmentStatus;
|
||||||
|
|
||||||
factory WorkHistory.fromJson(Map<String, dynamic> json) => WorkHistory(
|
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:form_builder_validators/form_builder_validators.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.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/profile/profile_bloc.dart';
|
||||||
import 'package:unit2/bloc/user/user_bloc.dart';
|
import 'package:unit2/bloc/user/user_bloc.dart';
|
||||||
import 'package:unit2/model/profile/eligibility.dart';
|
import 'package:unit2/model/profile/eligibility.dart';
|
||||||
|
@ -60,403 +61,428 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
|
||||||
token = state.userData!.user!.login!.token;
|
token = state.userData!.user!.login!.token;
|
||||||
profileId = state.userData!.user!.login!.user!.profileId.toString();
|
profileId = state.userData!.user!.login!.user!.profileId.toString();
|
||||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||||
buildWhen: (previous, current) {
|
|
||||||
if (state is EditEligibilityState) {}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
//EDIT ELIGIBILITY STATE
|
if(state is ProfileLoaded){
|
||||||
if (state is AddEligibilityState) {
|
return BlocBuilder<EligibilityBloc, EligibilityState>(
|
||||||
return ProgressHUD(
|
buildWhen: (previous, current) {
|
||||||
child: Center(
|
if (state is EditEligibilityState) {}
|
||||||
child: Padding(
|
return false;
|
||||||
padding: const EdgeInsets.symmetric(
|
},
|
||||||
vertical: 25, horizontal: 18),
|
builder: (context, state) {
|
||||||
child: FormBuilder(
|
//EDIT ELIGIBILITY STATE
|
||||||
key: formKey,
|
if (state is AddEligibilityState) {
|
||||||
child: Column(
|
return ProgressHUD(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
child: Center(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
child: Padding(
|
||||||
children: [
|
padding: const EdgeInsets.symmetric(
|
||||||
//ELIGIBILITIES DROPDOWN
|
vertical: 25, horizontal: 18),
|
||||||
FormBuilderDropdown<Eligibility>(
|
child: FormBuilder(
|
||||||
onChanged: (Eligibility? eligibility) {
|
key: formKey,
|
||||||
selectedEligibility = eligibility;
|
child: Column(
|
||||||
},
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
autovalidateMode:
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
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(
|
|
||||||
children: [
|
children: [
|
||||||
FormBuilderSwitch(
|
//ELIGIBILITIES DROPDOWN
|
||||||
initialValue: overseas,
|
FormBuilderDropdown<Eligibility>(
|
||||||
activeColor: second,
|
onChanged: (Eligibility? eligibility) {
|
||||||
onChanged: (value) {
|
selectedEligibility = eligibility;
|
||||||
setState(() {
|
},
|
||||||
overseas = value;
|
autovalidateMode:
|
||||||
});
|
AutovalidateMode.onUserInteraction,
|
||||||
},
|
validator: (value) =>
|
||||||
decoration: normalTextFieldStyle("", ''),
|
value == null ? 'required' : null,
|
||||||
name: 'overseas',
|
items: state.eligibilities
|
||||||
title: const Text("Overseas Address?"),
|
.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(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
//COUNTRY DROPDOWN
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
child: overseas == true
|
width: screenWidth,
|
||||||
? FormBuilderDropdown<Country>(
|
child: Row(
|
||||||
initialValue: null,
|
children: [
|
||||||
validator: (value) =>
|
//EXAM DATE
|
||||||
value == null
|
Flexible(
|
||||||
? 'required'
|
flex: 1,
|
||||||
: null,
|
child: DateTimePicker(
|
||||||
items: state.countries.map<
|
use24HourFormat: false,
|
||||||
DropdownMenuItem<
|
icon:
|
||||||
Country>>(
|
const Icon(Icons.date_range),
|
||||||
(Country country) {
|
controller: examDateController,
|
||||||
return DropdownMenuItem<
|
firstDate: DateTime(1970),
|
||||||
Country>(
|
lastDate: DateTime(2100),
|
||||||
value: country,
|
timeHintText:
|
||||||
child: FittedBox(
|
"Date of Examination/Conferment",
|
||||||
child: Text(
|
|
||||||
country.name!)));
|
|
||||||
}).toList(),
|
|
||||||
name: 'country',
|
|
||||||
decoration: normalTextFieldStyle(
|
decoration: normalTextFieldStyle(
|
||||||
"Country*", "Country"),
|
"Exam date", "")
|
||||||
onChanged: (Country? value) {
|
.copyWith(
|
||||||
selectedCountry = value;
|
prefixIcon: const Icon(
|
||||||
},
|
Icons.date_range,
|
||||||
)
|
color: Colors.black87,
|
||||||
: Column(
|
)),
|
||||||
children: [
|
initialValue: null,
|
||||||
//REGION DROPDOWN
|
)),
|
||||||
FormBuilderDropdown<Region?>(
|
const SizedBox(
|
||||||
autovalidateMode:
|
width: 12,
|
||||||
AutovalidateMode
|
),
|
||||||
.onUserInteraction,
|
//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) =>
|
validator: (value) =>
|
||||||
value == null
|
value == null
|
||||||
? 'required'
|
? 'required'
|
||||||
: null,
|
: null,
|
||||||
onChanged:
|
items: state.countries.map<
|
||||||
(Region? region) async {
|
DropdownMenuItem<
|
||||||
setState(() {
|
Country>>(
|
||||||
provinceCall = true;
|
(Country country) {
|
||||||
});
|
return DropdownMenuItem<
|
||||||
selectedRegion = region;
|
Country>(
|
||||||
getProvinces();
|
value: country,
|
||||||
},
|
child: FittedBox(
|
||||||
initialValue: selectedRegion,
|
child: Text(country
|
||||||
|
.name!)));
|
||||||
|
}).toList(),
|
||||||
|
name: 'country',
|
||||||
decoration:
|
decoration:
|
||||||
normalTextFieldStyle(
|
normalTextFieldStyle(
|
||||||
"Region*", "Region"),
|
"Country*",
|
||||||
name: 'region',
|
"Country"),
|
||||||
items: state.regions.map<
|
onChanged: (Country? value) {
|
||||||
DropdownMenuItem<
|
selectedCountry = value;
|
||||||
Region>>(
|
},
|
||||||
(Region region) {
|
)
|
||||||
return DropdownMenuItem<
|
: Column(
|
||||||
Region>(
|
children: [
|
||||||
value: region,
|
//REGION DROPDOWN
|
||||||
child: Text(region
|
FormBuilderDropdown<
|
||||||
.description!));
|
Region?>(
|
||||||
}).toList(),
|
autovalidateMode:
|
||||||
),
|
AutovalidateMode
|
||||||
const SizedBox(
|
.onUserInteraction,
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
//PROVINCE DROPDOWN
|
|
||||||
SizedBox(
|
|
||||||
height: 70,
|
|
||||||
child: ModalProgressHUD(
|
|
||||||
color: Colors.transparent,
|
|
||||||
inAsyncCall: provinceCall,
|
|
||||||
child: DropdownButtonFormField<
|
|
||||||
Province?>(
|
|
||||||
autovalidateMode:
|
|
||||||
AutovalidateMode
|
|
||||||
.onUserInteraction,
|
|
||||||
validator: (value) =>
|
|
||||||
value == null
|
|
||||||
? 'required'
|
|
||||||
: null,
|
|
||||||
isExpanded: true,
|
|
||||||
value: selectedProvince,
|
|
||||||
onChanged: (Province?
|
|
||||||
province) {
|
|
||||||
setState(() {
|
|
||||||
cityCall = true;
|
|
||||||
});
|
|
||||||
selectedProvince =
|
|
||||||
province;
|
|
||||||
getCities();
|
|
||||||
},
|
|
||||||
items: provinces == null
|
|
||||||
? []
|
|
||||||
: provinces!.map<
|
|
||||||
DropdownMenuItem<
|
|
||||||
Province>>(
|
|
||||||
(Province
|
|
||||||
province) {
|
|
||||||
return DropdownMenuItem(
|
|
||||||
value:
|
|
||||||
province,
|
|
||||||
child:
|
|
||||||
FittedBox(
|
|
||||||
child: Text(
|
|
||||||
province
|
|
||||||
.description!),
|
|
||||||
));
|
|
||||||
}).toList(),
|
|
||||||
decoration:
|
|
||||||
normalTextFieldStyle(
|
|
||||||
"Province*",
|
|
||||||
"Province")),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// CityMunicipalities dropdown
|
|
||||||
SizedBox(
|
|
||||||
height: 70,
|
|
||||||
child: ModalProgressHUD(
|
|
||||||
color: Colors.white,
|
|
||||||
inAsyncCall: cityCall,
|
|
||||||
child:
|
|
||||||
DropdownButtonFormField<
|
|
||||||
CityMunicipality>(
|
|
||||||
validator: (value) =>
|
validator: (value) =>
|
||||||
value == null
|
value == null
|
||||||
? 'required'
|
? 'required'
|
||||||
: null,
|
: null,
|
||||||
isExpanded: true,
|
onChanged: (Region?
|
||||||
onChanged:
|
region) async {
|
||||||
(CityMunicipality?
|
setState(() {
|
||||||
city) {
|
provinceCall = true;
|
||||||
selectedMunicipality =
|
});
|
||||||
city;
|
selectedRegion = region;
|
||||||
|
getProvinces();
|
||||||
},
|
},
|
||||||
|
initialValue:
|
||||||
|
selectedRegion,
|
||||||
decoration:
|
decoration:
|
||||||
normalTextFieldStyle(
|
normalTextFieldStyle(
|
||||||
"Municipality*",
|
"Region*",
|
||||||
"Municipality"),
|
"Region"),
|
||||||
value:
|
name: 'region',
|
||||||
selectedMunicipality,
|
items: state.regions.map<
|
||||||
items: citymuns == null
|
DropdownMenuItem<
|
||||||
? []
|
Region>>(
|
||||||
: citymuns!.map<
|
(Region region) {
|
||||||
DropdownMenuItem<
|
return DropdownMenuItem<
|
||||||
CityMunicipality>>(
|
Region>(
|
||||||
(CityMunicipality
|
value: region,
|
||||||
c) {
|
child: Text(region
|
||||||
return DropdownMenuItem(
|
.description!));
|
||||||
value: c,
|
}).toList(),
|
||||||
child: Text(c
|
),
|
||||||
.description!));
|
const SizedBox(
|
||||||
}).toList(),
|
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(
|
// CityMunicipalities dropdown
|
||||||
child: SizedBox(),
|
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(
|
const Expanded(
|
||||||
width: screenWidth,
|
child: SizedBox(),
|
||||||
height: 60,
|
),
|
||||||
child: ElevatedButton(
|
|
||||||
style: mainBtnStyle(
|
SizedBox(
|
||||||
primary, Colors.transparent, second),
|
width: screenWidth,
|
||||||
onPressed: () {
|
height: 60,
|
||||||
//rating
|
child: ElevatedButton(
|
||||||
double? rate = rating == null
|
style: mainBtnStyle(primary,
|
||||||
? null
|
Colors.transparent, second),
|
||||||
: double.parse(rating!);
|
onPressed: () {
|
||||||
|
//rating
|
||||||
|
double? rate = rating == null
|
||||||
|
? null
|
||||||
|
: double.parse(rating!);
|
||||||
//lisence
|
//lisence
|
||||||
String? licenseNumber = license;
|
String? licenseNumber = license;
|
||||||
CityMunicipality? cityMunicipality =
|
CityMunicipality? cityMunicipality =
|
||||||
selectedMunicipality;
|
selectedMunicipality;
|
||||||
DateTime? examDate =
|
DateTime? examDate =
|
||||||
examDateController.text.isEmpty
|
examDateController.text.isEmpty
|
||||||
? null
|
? null
|
||||||
: DateTime.parse(
|
: DateTime.parse(
|
||||||
examDateController.text);
|
examDateController.text);
|
||||||
DateTime? validityDate =
|
DateTime? validityDate =
|
||||||
validityDateController.text.isEmpty
|
validityDateController
|
||||||
? null
|
.text.isEmpty
|
||||||
: DateTime.parse(
|
? null
|
||||||
validityDateController.text);
|
: DateTime.parse(
|
||||||
|
validityDateController
|
||||||
|
.text);
|
||||||
|
|
||||||
ExamAddress examAddress = ExamAddress(
|
ExamAddress examAddress = ExamAddress(
|
||||||
barangay: null,
|
barangay: null,
|
||||||
id: null,
|
|
||||||
addressCategory: null,
|
|
||||||
examAddressClass: null,
|
|
||||||
country: selectedCountry ??
|
|
||||||
Country(
|
|
||||||
id: 175,
|
|
||||||
name: 'Philippines',
|
|
||||||
code: 'PH'),
|
|
||||||
cityMunicipality: cityMunicipality);
|
|
||||||
EligibityCert eligibityCert =
|
|
||||||
EligibityCert(
|
|
||||||
id: null,
|
id: null,
|
||||||
rating: rate,
|
addressCategory: null,
|
||||||
examDate: examDate,
|
examAddressClass: null,
|
||||||
attachments: null,
|
country: selectedCountry ??
|
||||||
eligibility: selectedEligibility,
|
Country(
|
||||||
examAddress: examAddress,
|
id: 175,
|
||||||
validityDate: validityDate,
|
name: 'Philippines',
|
||||||
licenseNumber: licenseNumber,
|
code: 'PH'),
|
||||||
overseas: overseas);
|
cityMunicipality:
|
||||||
if (formKey.currentState!
|
cityMunicipality);
|
||||||
.saveAndValidate()) {
|
EligibityCert eligibityCert =
|
||||||
context.read<ProfileBloc>().add(
|
EligibityCert(
|
||||||
AddEligibility(
|
id: null,
|
||||||
eligibityCert: eligibityCert,
|
rating: rate,
|
||||||
profileId: profileId!,
|
examDate: examDate,
|
||||||
token: token!));
|
attachments: null,
|
||||||
}
|
eligibility:
|
||||||
// context.read<ProfileBloc>().add(AddEligibility(eligibityCert: eligibityCert, profileId: profileId, token: token))
|
selectedEligibility,
|
||||||
},
|
examAddress: examAddress,
|
||||||
child: const Text(submit)),
|
validityDate: validityDate,
|
||||||
),
|
licenseNumber: licenseNumber,
|
||||||
const SizedBox(
|
overseas: overseas);
|
||||||
height: 20,
|
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();
|
getCities();
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
context.read<ProfileBloc>().add(CallErrorState());
|
context.read<EligibilityBloc>().add(CallErrorState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,7 +517,7 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
|
||||||
cityCall = false;
|
cityCall = false;
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} 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:flutter_form_builder/flutter_form_builder.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.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/profile/profile_bloc.dart';
|
||||||
import 'package:unit2/bloc/user/user_bloc.dart';
|
import 'package:unit2/bloc/user/user_bloc.dart';
|
||||||
import 'package:unit2/model/location/city.dart';
|
import 'package:unit2/model/location/city.dart';
|
||||||
|
@ -59,446 +60,486 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
token = state.userData!.user!.login!.token;
|
token = state.userData!.user!.login!.token;
|
||||||
profileId = state.userData!.user!.login!.user!.profileId.toString();
|
profileId = state.userData!.user!.login!.user!.profileId.toString();
|
||||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||||
buildWhen: (previous, current) {
|
|
||||||
if (state is EditEligibilityState) {}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
//EDIT ELIGIBILITY STATE
|
if(state is ProfileLoaded){
|
||||||
if (state is EditEligibilityState) {
|
return BlocBuilder<EligibilityBloc, EligibilityState>(
|
||||||
examDateController.text = state.eligibityCert.examDate == null?'': state.eligibityCert.examDate.toString();
|
buildWhen: (previous, current) {
|
||||||
validityDateController.text = state.eligibityCert.validityDate == null?'': state.eligibityCert.validityDate.toString();
|
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;
|
provinces = state.provinces;
|
||||||
citymuns = state.cities;
|
citymuns = state.cities;
|
||||||
regions = state.regions;
|
regions = state.regions;
|
||||||
overseas = state.isOverseas;
|
overseas = state.isOverseas;
|
||||||
selectedRegion = state.currentRegion;
|
selectedRegion = state.currentRegion;
|
||||||
selectedProvince = state.currentProvince;
|
selectedProvince = state.currentProvince;
|
||||||
selectedMunicipality = state.currentCity;
|
selectedMunicipality = state.currentCity;
|
||||||
selectedEligibility= state.currentEligibility;
|
selectedEligibility = state.currentEligibility;
|
||||||
rating = state.eligibityCert.rating?.toString();
|
rating = state.eligibityCert.rating?.toString();
|
||||||
license = state.eligibityCert.licenseNumber;
|
license = state.eligibityCert.licenseNumber;
|
||||||
return Center(
|
return Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 25, horizontal: 18),
|
vertical: 25, horizontal: 18),
|
||||||
child: FormBuilder(
|
child: FormBuilder(
|
||||||
key: formKey,
|
key: formKey,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
//ELIGIBILITIES DROPDOWN
|
//ELIGIBILITIES DROPDOWN
|
||||||
DropdownButtonFormField<Eligibility>(
|
DropdownButtonFormField<Eligibility>(
|
||||||
validator: (value) =>
|
validator: (value) =>
|
||||||
value == null ? 'required' : null,
|
value == null ? 'required' : null,
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
onChanged: (Eligibility? eligibility) {
|
onChanged: (Eligibility? eligibility) {
|
||||||
selectedEligibility = 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,
|
|
||||||
),
|
|
||||||
|
|
||||||
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;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
decoration: normalTextFieldStyle("", ''),
|
value: selectedEligibility,
|
||||||
name: 'overseas',
|
items: state.eligibilities
|
||||||
title: const Text("Overseas Address?"),
|
.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(
|
const SizedBox(
|
||||||
child: overseas == true
|
height: 20,
|
||||||
? FormBuilderDropdown<Country>(
|
),
|
||||||
validator: (value) =>
|
Text(
|
||||||
value == null
|
"Placement of Examination/Confinement",
|
||||||
? 'required'
|
style: Theme.of(context)
|
||||||
: null,
|
.textTheme
|
||||||
initialValue:
|
.displaySmall!
|
||||||
state.selectedCountry,
|
.copyWith(
|
||||||
items: state.countries.map<
|
fontSize: blockSizeVertical * 2),
|
||||||
DropdownMenuItem<
|
),
|
||||||
Country>>(
|
const SizedBox(
|
||||||
(Country country) {
|
height: 12,
|
||||||
return DropdownMenuItem<
|
),
|
||||||
Country>(
|
//OVERSEAS ADDRESS SWITCH
|
||||||
value: country,
|
StatefulBuilder(
|
||||||
child: FittedBox(
|
builder: (context, StateSetter setState) {
|
||||||
child: Text(
|
return Column(
|
||||||
country.name!)));
|
children: [
|
||||||
}).toList(),
|
FormBuilderSwitch(
|
||||||
name: 'country',
|
initialValue: overseas,
|
||||||
decoration: normalTextFieldStyle(
|
activeColor: second,
|
||||||
"Country*", "Country"),
|
onChanged: (value) {
|
||||||
onChanged: (Country? value) {
|
setState(() {
|
||||||
selectedCountry = value;
|
overseas = value;
|
||||||
},
|
});
|
||||||
)
|
},
|
||||||
: Column(
|
decoration:
|
||||||
children: [
|
normalTextFieldStyle("", ''),
|
||||||
//REGION DROPDOWN
|
name: 'overseas',
|
||||||
DropdownButtonFormField<
|
title: const Text("Overseas Address?"),
|
||||||
Region?>(
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
//COUNTRY DROPDOWN
|
||||||
|
SizedBox(
|
||||||
|
child: overseas == true
|
||||||
|
? FormBuilderDropdown<Country>(
|
||||||
validator: (value) =>
|
validator: (value) =>
|
||||||
value == null
|
value == null
|
||||||
? 'required'
|
? 'required'
|
||||||
: null,
|
: null,
|
||||||
isExpanded: true,
|
initialValue:
|
||||||
onChanged:
|
state.selectedCountry,
|
||||||
(Region? region) async {
|
items: state.countries.map<
|
||||||
setState(() {
|
DropdownMenuItem<
|
||||||
provinceCall = true;
|
Country>>(
|
||||||
});
|
(Country country) {
|
||||||
selectedRegion = region;
|
return DropdownMenuItem<
|
||||||
provinces = await LocationUtils
|
Country>(
|
||||||
.instance
|
value: country,
|
||||||
.getProvinces(
|
child: FittedBox(
|
||||||
regionCode:
|
child: Text(country
|
||||||
selectedRegion!
|
.name!)));
|
||||||
.code
|
}).toList(),
|
||||||
.toString());
|
name: 'country',
|
||||||
selectedProvince =
|
|
||||||
provinces![0];
|
|
||||||
setState(() {
|
|
||||||
provinceCall = false;
|
|
||||||
cityCall = true;
|
|
||||||
});
|
|
||||||
citymuns = await LocationUtils
|
|
||||||
.instance
|
|
||||||
.getCities(
|
|
||||||
code:
|
|
||||||
selectedProvince!
|
|
||||||
.code!);
|
|
||||||
selectedMunicipality =
|
|
||||||
citymuns![0];
|
|
||||||
setState(() {
|
|
||||||
cityCall = false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
value: selectedRegion,
|
|
||||||
decoration:
|
decoration:
|
||||||
normalTextFieldStyle(
|
normalTextFieldStyle(
|
||||||
"Region*", "Region"),
|
"Country*",
|
||||||
items: regions == null
|
"Country"),
|
||||||
? []
|
onChanged: (Country? value) {
|
||||||
: regions!.map<
|
selectedCountry = value;
|
||||||
DropdownMenuItem<
|
},
|
||||||
Region>>(
|
)
|
||||||
(Region region) {
|
: Column(
|
||||||
return DropdownMenuItem<
|
children: [
|
||||||
Region>(
|
//REGION DROPDOWN
|
||||||
value: region,
|
DropdownButtonFormField<
|
||||||
child: Text(region
|
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>(
|
|
||||||
validator: (value) =>
|
validator: (value) =>
|
||||||
value == null
|
value == null
|
||||||
? 'required'
|
? 'required'
|
||||||
: null,
|
: null,
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
onChanged:
|
onChanged: (Region?
|
||||||
(CityMunicipality?
|
region) async {
|
||||||
city) {
|
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 =
|
selectedMunicipality =
|
||||||
city;
|
citymuns![0];
|
||||||
|
setState(() {
|
||||||
|
cityCall = false;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
value: selectedRegion,
|
||||||
decoration:
|
decoration:
|
||||||
normalTextFieldStyle(
|
normalTextFieldStyle(
|
||||||
"Municipality*",
|
"Region*",
|
||||||
"Municipality"),
|
"Region"),
|
||||||
value:
|
items: regions == null
|
||||||
selectedMunicipality,
|
|
||||||
items: citymuns == null
|
|
||||||
? []
|
? []
|
||||||
: citymuns!.map<
|
: regions!.map<
|
||||||
DropdownMenuItem<
|
DropdownMenuItem<
|
||||||
CityMunicipality>>(
|
Region>>((Region
|
||||||
(CityMunicipality
|
region) {
|
||||||
c) {
|
return DropdownMenuItem<
|
||||||
return DropdownMenuItem(
|
Region>(
|
||||||
value: c,
|
value: region,
|
||||||
child: Text(c
|
child: Text(region
|
||||||
.description!));
|
.description!));
|
||||||
}).toList(),
|
}).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(
|
// City municipality
|
||||||
child: SizedBox(),
|
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(
|
const Expanded(
|
||||||
width: screenWidth,
|
child: SizedBox(),
|
||||||
height: 60,
|
),
|
||||||
child: ElevatedButton(
|
|
||||||
style: mainBtnStyle(
|
|
||||||
primary, Colors.transparent, second),
|
|
||||||
onPressed: () {
|
|
||||||
|
|
||||||
//rating
|
SizedBox(
|
||||||
double? rate = rating == null
|
width: screenWidth,
|
||||||
? null
|
height: 60,
|
||||||
: double.parse(rating!);
|
child: ElevatedButton(
|
||||||
//license
|
style: mainBtnStyle(
|
||||||
String? newLicense = license;
|
primary, Colors.transparent, second),
|
||||||
//city municipality
|
onPressed: () {
|
||||||
CityMunicipality? cityMunicipality =
|
//rating
|
||||||
selectedMunicipality;
|
double? rate = rating == null
|
||||||
//exam date
|
? null
|
||||||
DateTime? examDate =
|
: double.parse(rating!);
|
||||||
examDateController.text.isEmpty
|
//license
|
||||||
? null
|
String? newLicense = license;
|
||||||
: DateTime.parse(
|
//city municipality
|
||||||
examDateController.text);
|
CityMunicipality? cityMunicipality =
|
||||||
// validity date
|
selectedMunicipality;
|
||||||
DateTime? validityDate =
|
//exam date
|
||||||
validityDateController.text.isEmpty
|
DateTime? examDate =
|
||||||
? null
|
examDateController.text.isEmpty
|
||||||
: DateTime.parse(
|
? null
|
||||||
validityDateController.text);
|
: DateTime.parse(
|
||||||
// exam address
|
examDateController.text);
|
||||||
ExamAddress examAddress = ExamAddress(
|
// validity date
|
||||||
barangay: state.eligibityCert.examAddress?.barangay,
|
DateTime? validityDate =
|
||||||
id: state.eligibityCert.examAddress?.id,
|
validityDateController.text.isEmpty
|
||||||
addressCategory: state.eligibityCert.examAddress?.addressCategory,
|
? null
|
||||||
examAddressClass: state.eligibityCert.examAddress?.examAddressClass,
|
: DateTime.parse(
|
||||||
country: selectedCountry ??= Country(
|
validityDateController
|
||||||
id: 175,
|
.text);
|
||||||
name: 'Philippines',
|
// exam address
|
||||||
code: 'PH'),
|
ExamAddress examAddress = ExamAddress(
|
||||||
cityMunicipality: cityMunicipality);
|
barangay: state.eligibityCert
|
||||||
EligibityCert eligibityCert =
|
.examAddress?.barangay,
|
||||||
EligibityCert(
|
id: state
|
||||||
id: state.eligibityCert.id,
|
.eligibityCert.examAddress?.id,
|
||||||
rating: rate,
|
addressCategory: state.eligibityCert
|
||||||
examDate: examDate,
|
.examAddress?.addressCategory,
|
||||||
attachments: null,
|
examAddressClass: state
|
||||||
eligibility: selectedEligibility,
|
.eligibityCert
|
||||||
examAddress: examAddress,
|
.examAddress
|
||||||
validityDate: validityDate,
|
?.examAddressClass,
|
||||||
licenseNumber: newLicense,
|
country: selectedCountry ??=
|
||||||
overseas: overseas);
|
Country(
|
||||||
if (formKey.currentState!
|
id: 175,
|
||||||
.saveAndValidate()) {
|
name: 'Philippines',
|
||||||
context.read<ProfileBloc>().add(UpdateEligibility(eligibityCert: eligibityCert, oldEligibility: state.eligibityCert.eligibility!.id, profileId: profileId!, token: token!));
|
code: 'PH'),
|
||||||
}
|
cityMunicipality: cityMunicipality);
|
||||||
},
|
EligibityCert eligibityCert =
|
||||||
child: const Text(submit)),
|
EligibityCert(
|
||||||
),
|
id: state.eligibityCert.id,
|
||||||
const SizedBox(
|
rating: rate,
|
||||||
height: 20,
|
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();
|
||||||
},
|
},
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
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_progress_hud/flutter_progress_hud.dart';
|
||||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||||
import 'package:fluttericon/font_awesome_icons.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/profile/profile_bloc.dart';
|
||||||
import 'package:unit2/bloc/user/user_bloc.dart';
|
import 'package:unit2/bloc/user/user_bloc.dart';
|
||||||
import 'package:unit2/model/profile/eligibility.dart';
|
import 'package:unit2/model/profile/eligibility.dart';
|
||||||
|
@ -25,32 +26,33 @@ class EligibiltyScreen extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
String? token;
|
String? token;
|
||||||
String? profileId;
|
String? profileId;
|
||||||
List<EligibityCert>? eligibilities;
|
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: context.watch<ProfileBloc>().state is AddEligibilityState
|
title: context.watch<EligibilityBloc>().state is AddEligibilityState
|
||||||
? const Text("Add Eligiblity")
|
? const Text("Add Eligiblity")
|
||||||
: context.watch<ProfileBloc>().state is EditEligibilityState
|
: context.watch<EligibilityBloc>().state is EditEligibilityState
|
||||||
? const Text("Edit Eligibilty")
|
? const Text("Edit Eligibilty")
|
||||||
: const Text(elibilityScreenTitle),
|
: const Text(elibilityScreenTitle),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
backgroundColor: primary,
|
backgroundColor: primary,
|
||||||
actions: (context.watch<ProfileBloc>().state is EligibilityLoaded ||
|
actions: (context.watch<EligibilityBloc>().state is EligibilityLoaded ||
|
||||||
context.watch<ProfileBloc>().state is ProfileLoading)
|
context.watch<EligibilityBloc>().state is ProfileLoading)
|
||||||
? [
|
? [
|
||||||
AddLeading(onPressed: () {
|
AddLeading(onPressed: () {
|
||||||
context.read<ProfileBloc>().add(ShowAddEligibilityForm());
|
context
|
||||||
|
.read<EligibilityBloc>()
|
||||||
|
.add(ShowAddEligibilityForm());
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
: [
|
: [
|
||||||
CloseLeading(onPressed: () {
|
CloseLeading(onPressed: () {
|
||||||
context
|
context.read<EligibilityBloc>().add(GetEligibilities(
|
||||||
.read<ProfileBloc>()
|
profileId: int.parse(profileId!), token: token!));
|
||||||
.add(GetEligibilities(profileId: int.parse(profileId!), token: token!));
|
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -60,257 +62,278 @@ class EligibiltyScreen extends StatelessWidget {
|
||||||
token = state.userData!.user!.login!.token;
|
token = state.userData!.user!.login!.token;
|
||||||
profileId =
|
profileId =
|
||||||
state.userData!.user!.login!.user!.profileId.toString();
|
state.userData!.user!.login!.user!.profileId.toString();
|
||||||
return ProgressHUD(
|
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||||
padding: const EdgeInsets.all(24),
|
builder: (context, state) {
|
||||||
indicatorWidget: const SpinKitFadingCircle(
|
if(state is ProfileLoaded){
|
||||||
color: Colors.white,
|
return ProgressHUD(
|
||||||
),
|
padding: const EdgeInsets.all(24),
|
||||||
backgroundColor: Colors.black87,
|
indicatorWidget: const SpinKitFadingCircle(
|
||||||
child: BlocConsumer<ProfileBloc, ProfileState>(
|
color: Colors.white,
|
||||||
listener: (context, state) {
|
),
|
||||||
if (state is ProfileLoading) {
|
backgroundColor: Colors.black87,
|
||||||
final progress = ProgressHUD.of(context);
|
child: BlocConsumer<EligibilityBloc, EligibilityState>(
|
||||||
progress!.showWithText("Loading");
|
listener: (context, state) {
|
||||||
}
|
if (state is EligibilityLoadingState) {
|
||||||
if (state is EligibilityLoaded ||
|
final progress = ProgressHUD.of(context);
|
||||||
state is AddEligibilityState ||
|
progress!.showWithText("Loading");
|
||||||
state is ProfileErrorState ||
|
}
|
||||||
state is EditEligibilityState ||
|
if (state is EligibilityLoaded ||
|
||||||
state is DeletedState ||
|
state is AddEligibilityState ||
|
||||||
state is EligibilityAddedState ||
|
state is EditEligibilityState ||
|
||||||
state is EligibilityEditedState) {
|
state is DeletedState ||
|
||||||
final progress = ProgressHUD.of(context);
|
state is EligibilityAddedState ||
|
||||||
progress!.dismiss();
|
state is EligibilityEditedState) {
|
||||||
}
|
final progress = ProgressHUD.of(context);
|
||||||
//DELETED STATE
|
progress!.dismiss();
|
||||||
if (state is DeletedState) {
|
}
|
||||||
if (state.success) {
|
//DELETED STATE
|
||||||
successAlert(context, "Deletion Successfull",
|
if (state is DeletedState) {
|
||||||
"Eligibility has been deleted successfully", () {
|
if (state.success) {
|
||||||
Navigator.of(context).pop();
|
successAlert(context, "Deletion Successfull",
|
||||||
context.read<ProfileBloc>().add(LoadEligibility(
|
"Eligibility has been deleted successfully",
|
||||||
eligibilities: state.eligibilities));
|
() {
|
||||||
});
|
Navigator.of(context).pop();
|
||||||
} else {
|
context.read<EligibilityBloc>().add(LoadEligibility(
|
||||||
errorAlert(context, "Deletion Failed",
|
eligibilities: state.eligibilities));
|
||||||
"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,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
return const EmptyData(
|
errorAlert(context, "Deletion Failed",
|
||||||
message:
|
"Error deleting eligibility", () {
|
||||||
"You don't have any eligibilities added. Please click + to add");
|
Navigator.of(context).pop();
|
||||||
|
context.read<EligibilityBloc>().add(LoadEligibility(
|
||||||
|
eligibilities: state.eligibilities));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state is EditEligibilityState) {
|
//ADDED STATE
|
||||||
return EditEligibilityScreen(
|
if (state is EligibilityAddedState) {
|
||||||
eligibityCert: state.eligibityCert);
|
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) {
|
//UPDATED STATE
|
||||||
return const AddEligibilityScreen();
|
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(
|
builder: (context, state) {
|
||||||
child: Text(state.mesage),
|
return BlocBuilder<EligibilityBloc, EligibilityState>(
|
||||||
);
|
builder: (context, state) {
|
||||||
}
|
if (state is EligibilityLoaded) {
|
||||||
return Container(
|
|
||||||
color: Colors.grey.shade200,
|
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();
|
return Container();
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import 'package:flutter/material.dart';
|
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/model/profile/other_information/non_acedimic_recognition.dart';
|
||||||
import 'package:unit2/theme-data.dart/box_shadow.dart';
|
import 'package:unit2/theme-data.dart/box_shadow.dart';
|
||||||
import 'package:unit2/theme-data.dart/colors.dart';
|
import 'package:unit2/theme-data.dart/colors.dart';
|
||||||
|
|
|
@ -1,71 +1,167 @@
|
||||||
import 'package:flutter/material.dart';
|
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: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/model/profile/work_history.dart';
|
||||||
import 'package:unit2/theme-data.dart/box_shadow.dart';
|
import 'package:unit2/theme-data.dart/box_shadow.dart';
|
||||||
import 'package:unit2/theme-data.dart/colors.dart';
|
import 'package:unit2/theme-data.dart/colors.dart';
|
||||||
import 'package:unit2/utils/text_container.dart';
|
import 'package:unit2/utils/text_container.dart';
|
||||||
import 'package:unit2/widgets/Leadings/add_leading.dart';
|
import 'package:unit2/widgets/Leadings/add_leading.dart';
|
||||||
import 'package:unit2/widgets/empty_data.dart';
|
import 'package:unit2/widgets/empty_data.dart';
|
||||||
|
import 'package:unit2/widgets/error_state.dart';
|
||||||
|
|
||||||
import '../../../utils/global.dart';
|
import '../../../utils/global.dart';
|
||||||
|
|
||||||
class WorkHistoryScreen extends StatelessWidget {
|
class WorkHistoryScreen extends StatelessWidget {
|
||||||
final List<WorkHistory> workExperiences;
|
const WorkHistoryScreen({super.key});
|
||||||
const WorkHistoryScreen({super.key, required this.workExperiences});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text(workHistoryScreenTitle),
|
title: const Text(workHistoryScreenTitle),
|
||||||
backgroundColor: primary,
|
backgroundColor: primary,
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
actions: [AddLeading(onPressed: (){})],
|
actions: [AddLeading(onPressed: () {})],
|
||||||
),
|
),
|
||||||
body: workExperiences.isNotEmpty? ListView.builder(
|
body:
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
|
//UserBloc
|
||||||
itemCount: workExperiences.length,
|
ProgressHUD(
|
||||||
itemBuilder: (BuildContext context, int index) {
|
padding: const EdgeInsets.all(24),
|
||||||
String position = workExperiences[index].position!.title!;
|
backgroundColor: Colors.black87,
|
||||||
String agency = workExperiences[index].agency!.name!;
|
indicatorWidget: const SpinKitFadingCircle(
|
||||||
String from =
|
color: Colors.white,
|
||||||
dteFormat2.format(workExperiences[index].fromDate!);
|
),
|
||||||
String? to = workExperiences[index].toDate == null
|
child: BlocBuilder<UserBloc, UserState>(
|
||||||
? present.toUpperCase()
|
builder: (context, state) {
|
||||||
: dteFormat2.format(workExperiences[index].toDate!);
|
if (state is UserLoggedIn) {
|
||||||
return Column(
|
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||||
|
builder: (context, state) {
|
||||||
children: [
|
//ProfileBloc
|
||||||
Container(
|
if (state is ProfileLoaded) {
|
||||||
width: screenWidth,
|
//WorkHistoryBloc
|
||||||
decoration: box1(),
|
return BlocConsumer<WorkHistoryBloc, WorkHistoryState>(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
listener: (context, state) {
|
||||||
child: Row(children: [
|
if (state is WorkHistoryLoadingState) {
|
||||||
Expanded(
|
final progress = ProgressHUD.of(context);
|
||||||
child: Column(
|
progress!.showWithText("Please wait...");
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
}
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
if (state is WorkHistoryLoaded || state is WorkHistoryErrorState) {
|
||||||
children: [
|
final progress = ProgressHUD.of(context);
|
||||||
Text(position,style: Theme.of(context).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w600),),
|
progress!.dismiss();
|
||||||
const Divider(),
|
}
|
||||||
const SizedBox(height: 8,),
|
},
|
||||||
Text(agency,style: Theme.of(context).textTheme.titleSmall!.copyWith(fontWeight: FontWeight.w500),),
|
builder: (context, state) {
|
||||||
const SizedBox(height: 5,),
|
if (state is WorkHistoryLoaded) {
|
||||||
Text("$from to $to",style: Theme.of(context).textTheme.bodyMedium,),
|
if (state.workExperiences.isNotEmpty) {
|
||||||
],
|
return ListView.builder(
|
||||||
)),
|
padding: const EdgeInsets.symmetric(
|
||||||
IconButton(onPressed: () {}, icon: const Icon(Icons.more_vert,color: Colors.grey,))
|
vertical: 8, horizontal: 10),
|
||||||
]),
|
itemCount: state.workExperiences.length,
|
||||||
),
|
itemBuilder:
|
||||||
const SizedBox(
|
(BuildContext context, int index) {
|
||||||
height: 5,
|
String position = state
|
||||||
),
|
.workExperiences[index]
|
||||||
],
|
.position!
|
||||||
);
|
.title!;
|
||||||
}):const EmptyData(message: "You don't have any Work History added. Please click + to add ."),
|
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/entypo_icons.dart';
|
||||||
import 'package:fluttericon/font_awesome5_icons.dart';
|
import 'package:fluttericon/font_awesome5_icons.dart';
|
||||||
import 'package:fluttericon/modern_pictograms_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/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/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/address_screen.dart';
|
||||||
import 'package:unit2/screens/profile/components/basic_information/citizenship_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/contact_information_screen.dart';
|
||||||
import 'package:unit2/screens/profile/components/basic_information/identification_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/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/eligibility_screen.dart';
|
||||||
import 'package:unit2/screens/profile/components/family_background_screen.dart';
|
import 'package:unit2/screens/profile/components/family_background_screen.dart';
|
||||||
import 'package:unit2/screens/profile/components/learning_and_development_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,
|
icon: Elusive.group,
|
||||||
title: "Family",
|
title: "Family",
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Navigator.push(context, MaterialPageRoute(
|
|
||||||
// builder: (BuildContext context) {
|
|
||||||
// return FamilyBackgroundScreen(
|
|
||||||
// familyBackground:
|
|
||||||
// state.profileInformation.families);
|
|
||||||
// }));
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
|
@ -177,10 +173,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(context, MaterialPageRoute(
|
Navigator.push(context, MaterialPageRoute(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return BlocProvider<ProfileBloc>.value(
|
return BlocProvider(
|
||||||
value: ProfileBloc()
|
create: (context) => EligibilityBloc()..add(GetEligibilities(profileId: profileId!, token: token!)),
|
||||||
..add(GetEligibilities(
|
|
||||||
profileId: profileId!, token: token!)),
|
|
||||||
child: const EligibiltyScreen(),
|
child: const EligibiltyScreen(),
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
|
@ -191,12 +185,14 @@ class _ProfileInfoState extends State<ProfileInfo> {
|
||||||
icon: FontAwesome5.shopping_bag,
|
icon: FontAwesome5.shopping_bag,
|
||||||
title: "Work History",
|
title: "Work History",
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Navigator.push(context, MaterialPageRoute(
|
Navigator.push(context, MaterialPageRoute(
|
||||||
// builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
// return WorkHistoryScreen(
|
return BlocProvider(
|
||||||
// workExperiences: state
|
create: (context) => WorkHistoryBloc()..add(GetWorkHistories(profileId: profileId!, token: token!)),
|
||||||
// .profileInformation.workExperiences);
|
child: const WorkHistoryScreen(),
|
||||||
// }));
|
);
|
||||||
|
}));
|
||||||
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
|
|
|
@ -20,7 +20,7 @@ class EligibilityService {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// try{
|
try{
|
||||||
http.Response response = await Request.instance.getRequest(path: path,headers: headers,param: {});
|
http.Response response = await Request.instance.getRequest(path: path,headers: headers,param: {});
|
||||||
if(response.statusCode == 200){
|
if(response.statusCode == 200){
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
|
@ -31,9 +31,9 @@ class EligibilityService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }catch(e){
|
}catch(e){
|
||||||
// throw e.toString();
|
throw e.toString();
|
||||||
// }
|
}
|
||||||
return eligibilities;
|
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();
|
return const QRLogin();
|
||||||
});
|
});
|
||||||
case '/profile':
|
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: (_) {
|
return MaterialPageRoute(builder: (_) {
|
||||||
ProfileArguments arguments = routeSettings.arguments as ProfileArguments;
|
return const ProfileInfo();
|
||||||
return BlocProvider(
|
|
||||||
create: (context) => ProfileBloc()..add(LoadProfile(token: arguments.token,userID: arguments.userID)),
|
|
||||||
child: const ProfileInfo(),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
default:
|
default:
|
||||||
return MaterialPageRoute(builder: (context) {
|
return MaterialPageRoute(builder: (context) {
|
||||||
|
|
|
@ -41,6 +41,10 @@ String deleteEligibility(){
|
||||||
String updateEligibility(){
|
String updateEligibility(){
|
||||||
return "/api/jobnet_app/profile/pds/eligibility/";
|
return "/api/jobnet_app/profile/pds/eligibility/";
|
||||||
}
|
}
|
||||||
|
//// work history paths
|
||||||
|
String workHistories(){
|
||||||
|
return "/api/jobnet_app/profile/pds/work/";
|
||||||
|
}
|
||||||
|
|
||||||
// location utils path
|
// location utils path
|
||||||
String getCounties(){
|
String getCounties(){
|
||||||
|
|
Loading…
Reference in New Issue