add and edit eligibility with individual pds info API

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
PGAN-MIS 2023-03-02 08:40:47 +08:00
parent 66adcf924f
commit 5dcc1c1efb
29 changed files with 1216 additions and 743 deletions

View File

@ -23,15 +23,20 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
List<EligibityCert>? eligibilities; List<EligibityCert>? eligibilities;
////========================================================================= ////=========================================================================
on<LoadProfile>((event, emit) async { on<LoadProfile>((event, emit) async {
// try { try {
emit(ProfileLoading()); emit(ProfileLoading());
ProfileInformation? profileInformation = ProfileInformation? profileInformation =
await ProfileService.instance.getProfile(event.token, event.userID); await ProfileService.instance.getProfile(event.token, event.userID);
globalProfileInformation = profileInformation; globalProfileInformation = profileInformation;
emit(ProfileLoaded(profileInformation: globalProfileInformation!)); emit(ProfileLoaded(profileInformation: globalProfileInformation!));
// } catch (e) { } catch (e) {
// emit(ProfileErrorState(mesage: e.toString())); emit(ProfileErrorState(mesage: e.toString()));
// } }
});
on<CallErrorState>((event, emit) {
emit(const ProfileErrorState(
mesage: "Something went wrong. Please try again"));
}); });
////===================================================================== ////=====================================================================
on<LoadEligibility>((event, emit) { on<LoadEligibility>((event, emit) {
@ -40,36 +45,121 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
emit(EligibilityLoaded(eligibilities: event.eligibilities)); emit(EligibilityLoaded(eligibilities: event.eligibilities));
}); });
////==================================================================== ////====================================================================
on<EditEligibility>((event, emit) async { on<GetEligibilities>((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;
}
bool? isOverseas = event.eligibityCert.overseas;
emit(EditEligibilityState( print(eligibilities?.length);
isOverseas: isOverseas!, try{
eligibityCert: event.eligibityCert, if(eligibilities != null){
countries: globalCountries!, emit(EligibilityLoaded(eligibilities: eligibilities!));
regions: globalRegions!, }else{
eligibilities: globalEligibilities!)); 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);
// }catch(e){ emit(EditEligibilityState(
// emit(ProfileErrorState(mesage: e.toString())); 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 { on<ShowAddEligibilityForm>((event, emit) async {
emit(ProfileLoading()); emit(ProfileLoading());
@ -113,6 +203,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
emit(ProfileErrorState(mesage: e.toString())); emit(ProfileErrorState(mesage: e.toString()));
} }
}); });
////====================================================================
on<AddEligibility>( on<AddEligibility>(
(event, emit) async { (event, emit) async {
try { try {

View File

@ -27,9 +27,9 @@ class LoadEligibility extends ProfileEvent {
List<Object> get props => []; List<Object> get props => [];
} }
class EditEligibility extends ProfileEvent { class ShowEditEligibilityForm extends ProfileEvent {
final EligibityCert eligibityCert; final EligibityCert eligibityCert;
const EditEligibility({required this.eligibityCert}); const ShowEditEligibilityForm({required this.eligibityCert});
@override @override
List<Object> get props => []; List<Object> get props => [];
} }
@ -51,6 +51,15 @@ class DeleteEligibility extends ProfileEvent {
class ShowAddEligibilityForm extends ProfileEvent { 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{ class AddEligibility extends ProfileEvent{
final EligibityCert eligibityCert; final EligibityCert eligibityCert;
final String profileId; final String profileId;
@ -59,3 +68,17 @@ class AddEligibility extends ProfileEvent{
@override @override
List<Object> get props => [eligibityCert, profileId, token]; 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{
}

View File

@ -36,13 +36,27 @@ class EditEligibilityState extends ProfileState {
final List<Eligibility> eligibilities; final List<Eligibility> eligibilities;
final List<Country> countries; final List<Country> countries;
final List<Region> regions; final List<Region> regions;
final List<Province>? provinces;
final List<CityMunicipality>? cities;
final bool isOverseas; final bool isOverseas;
final Eligibility currentEligibility;
final Region? currentRegion;
final Province? currentProvince;
final CityMunicipality? currentCity;
final Country selectedCountry;
const EditEligibilityState({ 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.isOverseas,
required this.eligibityCert, required this.eligibityCert,
required this.eligibilities, required this.eligibilities,
required this.countries, required this.countries,
required this.regions, required this.regions,
required this.selectedCountry,
}); });
@override @override
List<Object> get props => List<Object> get props =>
@ -69,6 +83,13 @@ class AddEligibilityState extends ProfileState {
@override @override
List<Object> get props => [eligibilities,countries,regions]; 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{ class EligibilityAddedState extends ProfileState{
final List<EligibityCert> eligibilities; final List<EligibityCert> eligibilities;

View File

@ -52,7 +52,9 @@ class EligibityCert {
examAddress: json['exam_address'] == null examAddress: json['exam_address'] == null
? null ? null
: ExamAddress.fromJson(json["exam_address"]), : ExamAddress.fromJson(json["exam_address"]),
validityDate: json["validity_date"], validityDate: json['validity_date'] == null
? null
: DateTime.parse(json["validity_date"]),
licenseNumber: json["license_number"], licenseNumber: json["license_number"],
overseas: null, overseas: null,
); );
@ -65,7 +67,7 @@ class EligibityCert {
"attachments": attachments, "attachments": attachments,
"eligibility": eligibility!.toJson(), "eligibility": eligibility!.toJson(),
"exam_address": examAddress!.toJson(), "exam_address": examAddress!.toJson(),
"validity_date": validityDate, "validity_date": "${validityDate!.year.toString().padLeft(4, '0')}-${validityDate!.month.toString().padLeft(2, '0')}-${validityDate!.day.toString().padLeft(2, '0')}",
"license_number": licenseNumber, "license_number": licenseNumber,
}; };
@override @override

View File

@ -10,14 +10,14 @@ import 'package:unit2/model/profile/voluntary_works.dart';
import 'package:unit2/model/profile/work_history.dart'; import 'package:unit2/model/profile/work_history.dart';
class ProfileInformation{ class ProfileInformation{
BasicInfo basicInfo; final BasicInfo basicInfo;
OtherInformation otherInformation; // OtherInformation otherInformation;
List<EligibityCert> eligibilities; // List<EligibityCert> eligibilities;
List<PersonalReference> references; // List<PersonalReference> references;
List<LearningDevelopement> learningsAndDevelopment; // List<LearningDevelopement> learningsAndDevelopment;
List<EducationalBackground> educationalBackgrounds; // List<EducationalBackground> educationalBackgrounds;
List<FamilyBackground> families; // List<FamilyBackground> families;
List<WorkHistory>workExperiences; // List<WorkHistory>workExperiences;
List<VoluntaryWork> voluntaryWorks; // List<VoluntaryWork> voluntaryWorks;
ProfileInformation({required this.families, required this.otherInformation, required this.voluntaryWorks, required this.workExperiences, required this.basicInfo,required this.eligibilities,required this.references, required this.learningsAndDevelopment,required this.educationalBackgrounds}); ProfileInformation({required this.basicInfo});
} }

View File

@ -4,7 +4,7 @@ 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/global.dart'; import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/text_container.dart'; import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/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';
class AddressScreen extends StatelessWidget { class AddressScreen extends StatelessWidget {

View File

@ -3,7 +3,7 @@ import 'package:unit2/model/profile/basic_information/contact_information.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/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';
class ContactInformationScreen extends StatelessWidget { class ContactInformationScreen extends StatelessWidget {

View File

@ -4,7 +4,7 @@ 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/global.dart'; import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/text_container.dart'; import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/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';
class IdentificationsScreen extends StatelessWidget { class IdentificationsScreen extends StatelessWidget {

View File

@ -4,7 +4,7 @@ import 'package:unit2/model/profile/educational_background.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/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';
class EducationScreen extends StatelessWidget { class EducationScreen extends StatelessWidget {

View File

@ -124,6 +124,8 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
Flexible( Flexible(
flex: 1, flex: 1,
child: FormBuilderTextField( child: FormBuilderTextField(
keyboardType: const TextInputType
.numberWithOptions(),
onChanged: (value) { onChanged: (value) {
rating = value; rating = value;
}, },
@ -149,8 +151,8 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
use24HourFormat: false, use24HourFormat: false,
icon: const Icon(Icons.date_range), icon: const Icon(Icons.date_range),
controller: examDateController, controller: examDateController,
firstDate: DateTime(1970), firstDate: DateTime(1970),
lastDate: DateTime(2100), lastDate: DateTime(2100),
timeHintText: timeHintText:
"Date of Examination/Conferment", "Date of Examination/Conferment",
decoration: normalTextFieldStyle( decoration: normalTextFieldStyle(
@ -222,8 +224,10 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
child: overseas == true child: overseas == true
? FormBuilderDropdown<Country>( ? FormBuilderDropdown<Country>(
initialValue: null, initialValue: null,
validator: (value) => validator: (value) =>
value == null ? 'required' : null, value == null
? 'required'
: null,
items: state.countries.map< items: state.countries.map<
DropdownMenuItem< DropdownMenuItem<
Country>>( Country>>(
@ -249,8 +253,10 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
autovalidateMode: autovalidateMode:
AutovalidateMode AutovalidateMode
.onUserInteraction, .onUserInteraction,
validator: (value) => validator: (value) =>
value == null ? 'required' : null, value == null
? 'required'
: null,
onChanged: onChanged:
(Region? region) async { (Region? region) async {
setState(() { setState(() {
@ -283,14 +289,16 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
height: 70, height: 70,
child: ModalProgressHUD( child: ModalProgressHUD(
color: Colors.transparent, color: Colors.transparent,
inAsyncCall: cityCall, inAsyncCall: provinceCall,
child: DropdownButtonFormField< child: DropdownButtonFormField<
Province?>( Province?>(
autovalidateMode: autovalidateMode:
AutovalidateMode AutovalidateMode
.onUserInteraction, .onUserInteraction,
validator: (value) => validator: (value) =>
value == null ? 'required' : null, value == null
? 'required'
: null,
isExpanded: true, isExpanded: true,
value: selectedProvince, value: selectedProvince,
onChanged: (Province? onChanged: (Province?
@ -325,40 +333,46 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
"Province")), "Province")),
), ),
), ),
const SizedBox(
height: 20, // CityMunicipalities dropdown
),
SizedBox( SizedBox(
height: 70, height: 70,
child: child: ModalProgressHUD(
DropdownButtonFormField< color: Colors.white,
CityMunicipality>( inAsyncCall: cityCall,
validator: (value) => child:
value == null ? 'required' : null, DropdownButtonFormField<
isExpanded: true, CityMunicipality>(
onChanged: validator: (value) =>
(CityMunicipality? value == null
city) { ? 'required'
selectedMunicipality = : null,
city; isExpanded: true,
}, onChanged:
decoration: (CityMunicipality?
normalTextFieldStyle( city) {
"Municipality*", selectedMunicipality =
"Municipality"), city;
value: selectedMunicipality, },
items: citymuns == null decoration:
? [] normalTextFieldStyle(
: citymuns!.map< "Municipality*",
DropdownMenuItem< "Municipality"),
CityMunicipality>>( value:
(CityMunicipality selectedMunicipality,
c) { items: citymuns == null
return DropdownMenuItem( ? []
value: c, : citymuns!.map<
child: Text(c DropdownMenuItem<
.description!)); CityMunicipality>>(
}).toList(), (CityMunicipality
c) {
return DropdownMenuItem(
value: c,
child: Text(c
.description!));
}).toList(),
),
), ),
), ),
const SizedBox( const SizedBox(
@ -380,9 +394,11 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
style: mainBtnStyle( style: mainBtnStyle(
primary, Colors.transparent, second), primary, Colors.transparent, second),
onPressed: () { onPressed: () {
//rating
double? rate = rating == null double? rate = rating == null
? null ? null
: double.parse(rating!); : double.parse(rating!);
//lisence
String? licenseNumber = license; String? licenseNumber = license;
CityMunicipality? cityMunicipality = CityMunicipality? cityMunicipality =
selectedMunicipality; selectedMunicipality;
@ -450,23 +466,32 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
} }
Future<void> getProvinces() async { Future<void> getProvinces() async {
List<Province> newProvinces = await LocationUtils.instance try {
.getProvinces(regionCode: selectedRegion!.code.toString()); List<Province> newProvinces = await LocationUtils.instance
setState(() { .getProvinces(regionCode: selectedRegion!.code.toString());
provinces = newProvinces; setState(() {
selectedProvince = provinces![0]; provinces = newProvinces;
getCities(); selectedProvince = provinces![0];
provinceCall = false; provinceCall = false;
}); cityCall = true;
getCities();
});
} catch (e) {
context.read<ProfileBloc>().add(CallErrorState());
}
} }
Future<void> getCities() async { Future<void> getCities() async {
List<CityMunicipality> newCities = await LocationUtils.instance try {
.getCities(code: selectedProvince!.code.toString()); List<CityMunicipality> newCities = await LocationUtils.instance
citymuns = newCities; .getCities(code: selectedProvince!.code.toString());
setState(() { citymuns = newCities;
selectedMunicipality = newCities[0]; setState(() {
cityCall = false; selectedMunicipality = newCities[0];
}); cityCall = false;
});
} catch (e) {
context.read<ProfileBloc>().add(CallErrorState());
}
} }
} }

View File

@ -2,13 +2,11 @@ import 'package:date_time_picker/date_time_picker.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package: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/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';
import 'package:unit2/model/login_data/employee_info/employee_info.dart';
import 'package:unit2/model/profile/eligibility.dart'; import 'package:unit2/model/profile/eligibility.dart';
import 'package:unit2/model/utils/eligibility.dart'; import 'package:unit2/model/utils/eligibility.dart';
import 'package:unit2/utils/location_utilities.dart'; import 'package:unit2/utils/location_utilities.dart';
@ -33,18 +31,23 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
final formKey = GlobalKey<FormBuilderState>(); final formKey = GlobalKey<FormBuilderState>();
final provinceKey = GlobalKey<FormBuilderState>(); final provinceKey = GlobalKey<FormBuilderState>();
bool? overseas; bool? overseas;
List<Province>? provinces;
List<CityMunicipality>? citymuns;
List<Region>? regions;
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
Region? selectedRegion; Region? selectedRegion;
Province? selectedProvince; Province? selectedProvince;
CityMunicipality? selectedMunicipality; CityMunicipality? selectedMunicipality;
Country? selectedCountry; Country? selectedCountry;
Eligibility? selectedEligibility; Eligibility? selectedEligibility;
List<Province>? provinces;
List<CityMunicipality>? citymuns;
bool provinceCall = false; bool provinceCall = false;
bool cityCall = false; bool cityCall = false;
// final examDateController = TextEditingController(); String? token;
// final validityDateController = TextEditingController(); String? profileId;
String? rating;
String? license;
final examDateController = TextEditingController();
final validityDateController = TextEditingController();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
//USERBLOC //USERBLOC
@ -53,6 +56,8 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
//LOGGED IN USER STATE //LOGGED IN USER STATE
if (state is UserLoggedIn) { if (state is UserLoggedIn) {
//PROFIILE BLOC //PROFIILE BLOC
token = state.userData!.user!.login!.token;
profileId = state.userData!.user!.login!.user!.profileId.toString();
return BlocBuilder<ProfileBloc, ProfileState>( return BlocBuilder<ProfileBloc, ProfileState>(
buildWhen: (previous, current) { buildWhen: (previous, current) {
if (state is EditEligibilityState) {} if (state is EditEligibilityState) {}
@ -61,23 +66,38 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
builder: (context, state) { builder: (context, state) {
//EDIT ELIGIBILITY STATE //EDIT ELIGIBILITY STATE
if (state is EditEligibilityState) { if (state is EditEligibilityState) {
return ProgressHUD( examDateController.text = state.eligibityCert.examDate == null?'': state.eligibityCert.examDate.toString();
child: Center( validityDateController.text = state.eligibityCert.validityDate == null?'': state.eligibityCert.validityDate.toString();
child: Padding(
padding: const EdgeInsets.symmetric( provinces = state.provinces;
vertical: 25, horizontal: 18), citymuns = state.cities;
child: FormBuilder( regions = state.regions;
key: formKey, overseas = state.isOverseas;
child: Column( selectedRegion = state.currentRegion;
mainAxisAlignment: MainAxisAlignment.center, selectedProvince = state.currentProvince;
crossAxisAlignment: CrossAxisAlignment.center, selectedMunicipality = state.currentCity;
children: [ selectedEligibility= state.currentEligibility;
//ELIGIBILITIES DROPDOWN rating = state.eligibityCert.rating?.toString();
FormBuilderDropdown<Eligibility>( license = state.eligibityCert.licenseNumber;
return Center(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 25, horizontal: 18),
child: FormBuilder(
key: formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
//ELIGIBILITIES DROPDOWN
DropdownButtonFormField<Eligibility>(
validator: (value) =>
value == null ? 'required' : null,
isExpanded: true,
onChanged: (Eligibility? eligibility) { onChanged: (Eligibility? eligibility) {
selectedEligibility = eligibility; selectedEligibility = eligibility;
}, },
initialValue: null, value: selectedEligibility,
items: state.eligibilities items: state.eligibilities
.map<DropdownMenuItem<Eligibility>>( .map<DropdownMenuItem<Eligibility>>(
(Eligibility eligibility) { (Eligibility eligibility) {
@ -85,120 +105,116 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
value: eligibility, value: eligibility,
child: Text(eligibility.title)); child: Text(eligibility.title));
}).toList(), }).toList(),
name: "eligibility",
decoration: decoration:
normalTextFieldStyle("Eligibility", "") normalTextFieldStyle("Eligibility", "")),
.copyWith( const SizedBox(
hintStyle: const TextStyle( height: 20,
color: Colors.black, ),
),
labelStyle: const TextStyle(
color: Colors.black)),
),
const SizedBox(
height: 20,
),
SizedBox( SizedBox(
width: screenWidth, width: screenWidth,
child: Row( child: Row(
children: [ children: [
//LICENSE NUMBER //LICENSE NUMBER
Flexible( Flexible(
flex: 1, flex: 1,
child: FormBuilderTextField( child: FormBuilderTextField(
name: 'license_number', onChanged: (value) {
initialValue: license = value;
widget.eligibityCert.licenseNumber, },
decoration: normalTextFieldStyle( name: 'license_number',
"license number", "license number"), initialValue:
), license,
decoration: normalTextFieldStyle(
"license number", "license number"),
), ),
const SizedBox( ),
width: 12, 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'),
), ),
//RATING ),
Flexible( ],
flex: 1,
child: FormBuilderTextField(
name: 'rating',
// ignore: prefer_null_aware_operators
initialValue:
widget.eligibityCert.rating == null
? null
: widget.eligibityCert.rating
.toString(),
decoration: normalTextFieldStyle(
'rating', 'rating'),
),
),
],
),
), ),
const SizedBox( ),
height: 20, const SizedBox(
), height: 20,
SizedBox( ),
width: screenWidth, SizedBox(
child: Row( width: screenWidth,
children: [ child: Row(
//EXAM DATE children: [
Flexible( //EXAM DATE
flex: 1, Flexible(
child: DateTimePicker(
// controller: examDateController,
firstDate: DateTime(2000),
lastDate: DateTime(2100),
decoration: normalTextFieldStyle(
"Exam date", "Exam date"),
initialValue:
widget.eligibityCert.examDate ==
null
? ''
: dteFormat2.format(widget
.eligibityCert.examDate!),
)),
const SizedBox(
width: 12,
),
//VALIDITY DATE
Flexible(
flex: 1, flex: 1,
child: DateTimePicker( child: DateTimePicker(
// controller: validityDateController, use24HourFormat: false,
firstDate: DateTime(2000), controller: examDateController,
firstDate: DateTime(1970),
lastDate: DateTime(2100), lastDate: DateTime(2100),
decoration: normalTextFieldStyle( decoration: normalTextFieldStyle(
"Validity date", "Validity date"), "Exam date", "")
initialValue: .copyWith(
widget.eligibityCert.validityDate == prefixIcon: const Icon(
null Icons.date_range,
? '' color: Colors.black87,
: dteFormat2.format(widget )),
.eligibityCert )),
.validityDate!), 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, const SizedBox(
), height: 20,
Text( ),
"Placement of Examination/Confinement", Text(
style: Theme.of(context) "Placement of Examination/Confinement",
.textTheme style: Theme.of(context)
.displaySmall! .textTheme
.copyWith(fontSize: blockSizeVertical * 2), .displaySmall!
), .copyWith(fontSize: blockSizeVertical * 2),
const SizedBox( ),
height: 12, const SizedBox(
), height: 12,
//OVERSEAS ADDRESS SWITCH ),
Column( //OVERSEAS ADDRESS SWITCH
StatefulBuilder(
builder: (context, StateSetter setState) {
return Column(
children: [ children: [
FormBuilderSwitch( FormBuilderSwitch(
initialValue: overseas, initialValue: overseas,
@ -219,7 +235,12 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
SizedBox( SizedBox(
child: overseas == true child: overseas == true
? FormBuilderDropdown<Country>( ? FormBuilderDropdown<Country>(
initialValue: null, validator: (value) =>
value == null
? 'required'
: null,
initialValue:
state.selectedCountry,
items: state.countries.map< items: state.countries.map<
DropdownMenuItem< DropdownMenuItem<
Country>>( Country>>(
@ -241,50 +262,96 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
: Column( : Column(
children: [ children: [
//REGION DROPDOWN //REGION DROPDOWN
FormBuilderDropdown<Region?>( DropdownButtonFormField<
Region?>(
validator: (value) =>
value == null
? 'required'
: null,
isExpanded: true,
onChanged: onChanged:
(Region? region) async { (Region? region) async {
setState(() { setState(() {
provinceCall = true; provinceCall = true;
}); });
selectedRegion = region; selectedRegion = region;
getProvinces(); provinces = await LocationUtils
.instance
.getProvinces(
regionCode:
selectedRegion!
.code
.toString());
selectedProvince =
provinces![0];
setState(() {
provinceCall = false;
cityCall = true;
});
citymuns = await LocationUtils
.instance
.getCities(
code:
selectedProvince!
.code!);
selectedMunicipality =
citymuns![0];
setState(() {
cityCall = false;
});
}, },
initialValue: selectedRegion, value: selectedRegion,
decoration: decoration:
normalTextFieldStyle( normalTextFieldStyle(
"Region*", "Region"), "Region*", "Region"),
name: 'region', items: regions == null
items: state.regions.map< ? []
DropdownMenuItem< : regions!.map<
Region>>( DropdownMenuItem<
(Region region) { Region>>(
return DropdownMenuItem< (Region region) {
Region>( return DropdownMenuItem<
value: region, Region>(
child: Text(region value: region,
.description!)); child: Text(region
}).toList(), .description!));
}).toList(),
), ),
const SizedBox( const SizedBox(
height: 20, height: 20,
), ),
//PROVINCE DROPDOWN //PROVINCE DROPDOWN
SizedBox( SizedBox(
height: 50, height: 70,
child: ModalProgressHUD( child: ModalProgressHUD(
inAsyncCall: cityCall, color: Colors.transparent,
inAsyncCall: provinceCall,
child: DropdownButtonFormField< child: DropdownButtonFormField<
Province?>( Province?>(
isExpanded: true, validator: (value) =>
value == null
? 'required'
: null,
isExpanded: true,
value: selectedProvince, value: selectedProvince,
onChanged: (Province? onChanged: (Province?
province) { province) async {
setState(() { setState(() {
cityCall = true; cityCall = true;
});
selectedProvince =
province;
citymuns = await LocationUtils
.instance
.getCities(
code: selectedProvince!
.code
.toString());
selectedMunicipality =
citymuns![0];
setState(() {
cityCall = false;
}); });
selectedProvince = province;
getCities();
}, },
items: provinces == null items: provinces == null
? [] ? []
@ -296,7 +363,8 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
return DropdownMenuItem( return DropdownMenuItem(
value: value:
province, province,
child: FittedBox( child:
FittedBox(
child: Text( child: Text(
province province
.description!), .description!),
@ -308,13 +376,21 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
"Province")), "Province")),
), ),
), ),
const SizedBox(
height: 20, // City municipality
),
SizedBox( SizedBox(
height: 50, height: 70,
child: DropdownButtonFormField< child: ModalProgressHUD(
CityMunicipality>( color: Colors.transparent,
inAsyncCall: cityCall,
child:
DropdownButtonFormField<
CityMunicipality>(
validator: (value) =>
value == null
? 'required'
: null,
isExpanded: true,
onChanged: onChanged:
(CityMunicipality? (CityMunicipality?
city) { city) {
@ -325,7 +401,8 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
normalTextFieldStyle( normalTextFieldStyle(
"Municipality*", "Municipality*",
"Municipality"), "Municipality"),
value: selectedMunicipality, value:
selectedMunicipality,
items: citymuns == null items: citymuns == null
? [] ? []
: citymuns!.map< : citymuns!.map<
@ -338,7 +415,8 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
child: Text(c child: Text(c
.description!)); .description!));
}).toList(), }).toList(),
), ),
),
), ),
const SizedBox( const SizedBox(
height: 20, height: 20,
@ -346,26 +424,75 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
], ],
)), )),
], ],
), );
}),
const Expanded( const Expanded(
child: SizedBox(), child: SizedBox(),
), ),
SizedBox( SizedBox(
width: screenWidth, width: screenWidth,
height: 60, height: 60,
child: ElevatedButton( child: ElevatedButton(
style: mainBtnStyle( style: mainBtnStyle(
primary, Colors.transparent, second), primary, Colors.transparent, second),
onPressed: () {}, onPressed: () {
child: const Text(submit)),
), //rating
const SizedBox( double? rate = rating == null
height: 20, ? null
), : double.parse(rating!);
]), //license
), String? newLicense = license;
//city municipality
CityMunicipality? cityMunicipality =
selectedMunicipality;
//exam date
DateTime? examDate =
examDateController.text.isEmpty
? null
: DateTime.parse(
examDateController.text);
// validity date
DateTime? validityDate =
validityDateController.text.isEmpty
? null
: DateTime.parse(
validityDateController.text);
// exam address
ExamAddress examAddress = ExamAddress(
barangay: state.eligibityCert.examAddress?.barangay,
id: state.eligibityCert.examAddress?.id,
addressCategory: state.eligibityCert.examAddress?.addressCategory,
examAddressClass: state.eligibityCert.examAddress?.examAddressClass,
country: selectedCountry ??= Country(
id: 175,
name: 'Philippines',
code: 'PH'),
cityMunicipality: cityMunicipality);
EligibityCert eligibityCert =
EligibityCert(
id: state.eligibityCert.id,
rating: rate,
examDate: examDate,
attachments: null,
eligibility: selectedEligibility,
examAddress: examAddress,
validityDate: validityDate,
licenseNumber: newLicense,
overseas: overseas);
if (formKey.currentState!
.saveAndValidate()) {
context.read<ProfileBloc>().add(UpdateEligibility(eligibityCert: eligibityCert, oldEligibility: state.eligibityCert.eligibility!.id, profileId: profileId!, token: token!));
}
},
child: const Text(submit)),
),
const SizedBox(
height: 20,
),
]),
), ),
), ),
); );
@ -378,23 +505,4 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
}, },
); );
} }
Future<void> getProvinces() async {
List<Province> _provinces = await LocationUtils.instance
.getProvinces(regionCode: selectedRegion!.code.toString());
setState(() {
provinces = _provinces;
selectedProvince = provinces![0];
getCities();
provinceCall = false;
});
}
Future<void> getCities()async{
List<CityMunicipality> _cities = await LocationUtils.instance.getCities(code: selectedProvince!.code.toString());
citymuns = _cities;
setState(() {
selectedMunicipality = _cities[0];
cityCall = false;
});
}
} }

View File

@ -2,6 +2,7 @@ import 'package:app_popup_menu/app_popup_menu.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.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/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';
@ -12,9 +13,9 @@ 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/global.dart'; import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/text_container.dart'; import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/add_leading.dart'; import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/Leadings/close_leading.dart';
import 'package:unit2/widgets/empty_data.dart'; import 'package:unit2/widgets/empty_data.dart';
import '../../../utils/alerts.dart'; import '../../../utils/alerts.dart';
class EligibiltyScreen extends StatelessWidget { class EligibiltyScreen extends StatelessWidget {
@ -24,240 +25,298 @@ class EligibiltyScreen extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
String? token; String? token;
String? profileId; String? profileId;
return Scaffold( List<EligibityCert>? eligibilities;
appBar: AppBar( return WillPopScope(
title: const Text(elibilityScreenTitle), onWillPop: () async {
centerTitle: true, return true;
backgroundColor: primary, },
actions: [ child: Scaffold(
AddLeading(onPressed: () { appBar: AppBar(
context.read<ProfileBloc>().add(ShowAddEligibilityForm()); title: context.watch<ProfileBloc>().state is AddEligibilityState
}) ? const Text("Add Eligiblity")
], : context.watch<ProfileBloc>().state is EditEligibilityState
), ? const Text("Edit Eligibilty")
body: BlocBuilder<UserBloc, UserState>( : const Text(elibilityScreenTitle),
builder: (context, state) { centerTitle: true,
if (state is UserLoggedIn) { backgroundColor: primary,
token = state.userData!.user!.login!.token; actions: (context.watch<ProfileBloc>().state is EligibilityLoaded ||
profileId = context.watch<ProfileBloc>().state is ProfileLoading)
state.userData!.user!.login!.user!.profileId.toString(); ? [
return ProgressHUD( AddLeading(onPressed: () {
child: BlocConsumer<ProfileBloc, ProfileState>( context.read<ProfileBloc>().add(ShowAddEligibilityForm());
listener: (context, state) { })
if (state is EditEligibilityState) { ]
final progress = ProgressHUD.of(context); : [
progress!.dismiss(); CloseLeading(onPressed: () {
} context
if (state is ProfileLoading) { .read<ProfileBloc>()
final progress = ProgressHUD.of(context); .add(GetEligibilities(profileId: int.parse(profileId!), token: token!));
progress!.showWithText("Loading"); })
} ],
if (state is EligibilityLoaded || ),
state is AddEligibilityState || body: BlocBuilder<UserBloc, UserState>(
state is ProfileErrorState) { builder: (context, state) {
final progress = ProgressHUD.of(context); if (state is UserLoggedIn) {
progress!.dismiss(); token = state.userData!.user!.login!.token;
} profileId =
if (state is DeletedState) { state.userData!.user!.login!.user!.profileId.toString();
if (state.success) { return ProgressHUD(
successAlert(context, "Deletion Successfull", padding: const EdgeInsets.all(24),
"Eligibility has been deleted successfully", () { indicatorWidget: const SpinKitFadingCircle(
context.read<ProfileBloc>().add(LoadEligibility( color: Colors.white,
eligibilities: state.eligibilities)); ),
}); backgroundColor: Colors.black87,
} else { child: BlocConsumer<ProfileBloc, ProfileState>(
errorAlert(context, "Deletion Failed", listener: (context, state) {
"Error deleting eligibility", () { if (state is ProfileLoading) {
Navigator.of(context).pop(); final progress = ProgressHUD.of(context);
context.read<ProfileBloc>().add(LoadEligibility( progress!.showWithText("Loading");
eligibilities: state.eligibilities));
});
} }
} if (state is EligibilityLoaded ||
if (state is EligibilityAddedState) { state is AddEligibilityState ||
if (state.response['success']) { state is ProfileErrorState ||
Navigator.of(context).pop(); state is EditEligibilityState ||
successAlert(context, "Adding Successfull!", state is DeletedState ||
state.response['message'], () { state is EligibilityAddedState ||
context.read<ProfileBloc>().add(LoadEligibility( state is EligibilityEditedState) {
eligibilities: state.eligibilities)); final progress = ProgressHUD.of(context);
}); progress!.dismiss();
} else {
errorAlert(context, "Adding Failed",
"Something went wrong. Please try again.", () {
Navigator.of(context).pop();
context.read<ProfileBloc>().add(LoadEligibility(
eligibilities: state.eligibilities));
});
} }
} //DELETED STATE
}, if (state is DeletedState) {
builder: (context, state) { if (state.success) {
return BlocBuilder<ProfileBloc, ProfileState>( successAlert(context, "Deletion Successfull",
builder: (context, state) { "Eligibility has been deleted successfully", () {
if (state is EligibilityLoaded) { Navigator.of(context).pop();
if (state.eligibilities.isNotEmpty) { context.read<ProfileBloc>().add(LoadEligibility(
return ListView.builder( eligibilities: state.eligibilities));
padding: const EdgeInsets.symmetric( });
vertical: 8, horizontal: 10), } else {
itemCount: state.eligibilities.length, errorAlert(context, "Deletion Failed",
itemBuilder: (BuildContext context, int index) { "Error deleting eligibility", () {
String title = state Navigator.of(context).pop();
.eligibilities[index].eligibility!.title; context.read<ProfileBloc>().add(LoadEligibility(
return Column( eligibilities: state.eligibilities));
mainAxisAlignment: MainAxisAlignment.start, });
crossAxisAlignment: }
CrossAxisAlignment.start, }
children: [ //ADDED STATE
Container( if (state is EligibilityAddedState) {
width: screenWidth, if (state.response['success']) {
padding: const EdgeInsets.symmetric( successAlert(context, "Adding Successfull!",
horizontal: 12, vertical: 8), state.response['message'], () {
decoration: box1(), Navigator.of(context).pop();
child: Row( context.read<ProfileBloc>().add(LoadEligibility(
children: [ eligibilities: state.eligibilities));
Expanded( });
child: Column( } else {
mainAxisAlignment: errorAlert(context, "Adding Failed",
MainAxisAlignment.start, "Something went wrong. Please try again.", () {
crossAxisAlignment: Navigator.of(context).pop();
CrossAxisAlignment.start, context.read<ProfileBloc>().add(LoadEligibility(
children: [ eligibilities: state.eligibilities));
Text( });
title, }
style: Theme.of(context) }
.textTheme //UPDATED STATE
.titleMedium! if (state is EligibilityEditedState) {
.copyWith( if (state.response['success']) {
fontWeight: successAlert(context, "Update Successfull!",
FontWeight state.response['message'], () {
.w500), Navigator.of(context).pop();
), context.read<ProfileBloc>().add(LoadEligibility(
const Divider(), eligibilities: state.eligibilities));
const SizedBox( });
height: 5, } else {
), errorAlert(context, "Update Failed",
Text( "Something went wrong. Please try again.", () {
"$licenseNumber: ${state.eligibilities[index].licenseNumber == null ? 'N/A' : state.eligibilities[index].licenseNumber.toString()}", 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) style: Theme.of(context)
.textTheme .textTheme
.titleSmall), .titleMedium!
const SizedBox( .copyWith(
height: 3, fontWeight:
), FontWeight
Text( .w500),
"Rating : ${state.eligibilities[index].rating ?? 'N/A'}.", ),
style: Theme.of(context) const Divider(),
.textTheme const SizedBox(
.titleSmall) height: 5,
]), ),
), Text(
AppPopupMenu<int>( "$licenseNumber: ${state.eligibilities[index].licenseNumber == null ? 'N/A' : state.eligibilities[index].licenseNumber.toString()}",
offset: const Offset(-10, -10), style:
elevation: 3, Theme.of(context)
onSelected: (value) { .textTheme
if (value == 2) { .titleSmall),
confirmAlert(context, () { const SizedBox(
BlocProvider.of< height: 3,
ProfileBloc>( ),
context) Text(
.add(DeleteEligibility( "Rating : ${state.eligibilities[index].rating ?? 'N/A'}.",
eligibilities: state style:
.eligibilities, Theme.of(context)
eligibilityId: state .textTheme
.eligibilities[ .titleSmall)
index] ]),
.id!, ),
profileId: AppPopupMenu<int>(
profileId!, offset: const Offset(-10, -10),
token: token!)); elevation: 3,
}, "Delete?", onSelected: (value) {
"Confirm Delete?");
}
if (value == 1) {
EligibityCert eligibityCert =
state
.eligibilities[index];
bool overseas = eligibityCert
.examAddress!
.country!
.id
.toString() ==
'175'
? false
: true;
eligibityCert.overseas =
overseas;
final progress = final progress =
ProgressHUD.of(context); ProgressHUD.of(context);
eligibityCert.overseas =
overseas;
progress!.showWithText( progress!.showWithText(
"Loading..."); "Loading...");
context ////delete eligibilty-= = = = = = = = =>>
.read<ProfileBloc>() if (value == 2) {
.add(EditEligibility( confirmAlert(context, () {
eligibityCert: BlocProvider.of<
eligibityCert)); ProfileBloc>(
} context)
}, .add(DeleteEligibility(
menuItems: [ eligibilities:
popMenuItem( state
text: "Edit", .eligibilities,
value: 1, eligibilityId: state
icon: Icons.edit), .eligibilities[
popMenuItem( index]
text: "Delete", .id!,
value: 2, profileId:
icon: Icons.delete), profileId!,
popMenuItem( token: token!));
text: "Attachment", }, "Delete?",
value: 3, "Confirm Delete?");
icon: FontAwesome.attach) }
], if (value == 1) {
icon: const Icon( ////edit eligibilty-= = = = = = = = =>>
Icons.more_vert, EligibityCert
color: Colors.grey, eligibityCert =
), state.eligibilities[
tooltip: "Options", 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(
const SizedBox( height: 5,
height: 5, )
) ],
], );
); });
}); } else {
} else { return const EmptyData(
return const EmptyData( message:
message: "You don't have any eligibilities added. Please click + to add");
"You don't have any eligibilities added. Please click + to add"); }
} }
} if (state is EditEligibilityState) {
if (state is EditEligibilityState) { return EditEligibilityScreen(
return EditEligibilityScreen( eligibityCert: state.eligibityCert);
eligibityCert: state.eligibityCert); }
} if (state is AddEligibilityState) {
if (state is AddEligibilityState) { return const AddEligibilityScreen();
return const AddEligibilityScreen(); }
} if (state is ProfileErrorState) {
if (state is ProfileErrorState) { return Center(
return Center( child: Text(state.mesage),
child: Text(state.mesage), );
}
return Container(
color: Colors.grey.shade200,
); );
} },
return Container(); );
}, },
); ),
}, );
), }
); return Container();
} },
return Container(); )),
}, );
));
} }
PopupMenuItem<int> popMenuItem({String? text, int? value, IconData? icon}) { PopupMenuItem<int> popMenuItem({String? text, int? value, IconData? icon}) {

View File

@ -7,7 +7,7 @@ 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/global.dart'; import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/text_container.dart'; import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/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';
class LearningAndDevelopmentScreen extends StatelessWidget { class LearningAndDevelopmentScreen extends StatelessWidget {

View File

@ -6,7 +6,7 @@ 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/global.dart'; import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/text_container.dart'; import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/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';
class NonAcademicRecognitionScreen extends StatelessWidget { class NonAcademicRecognitionScreen extends StatelessWidget {

View File

@ -3,7 +3,7 @@ import 'package:unit2/model/profile/other_information/organization_memberships.d
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/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 '../../../../utils/global.dart'; import '../../../../utils/global.dart';

View File

@ -5,7 +5,7 @@ import 'package:unit2/model/profile/other_information/skills_and_hobbies.dart';
import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/utils/global.dart'; import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/text_container.dart'; import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/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';
class SkillHobbiesScreen extends StatelessWidget { class SkillHobbiesScreen extends StatelessWidget {

View File

@ -5,7 +5,7 @@ import 'package:unit2/model/profile/references.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/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';
class ReferencesScreen extends StatelessWidget { class ReferencesScreen extends StatelessWidget {

View File

@ -4,7 +4,7 @@ import 'package:unit2/model/profile/voluntary_works.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/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';
class VolunataryWorkScreen extends StatelessWidget { class VolunataryWorkScreen extends StatelessWidget {

View File

@ -4,7 +4,7 @@ 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/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 '../../../utils/global.dart'; import '../../../utils/global.dart';

View File

@ -2,6 +2,7 @@ import 'package:expandable_group/expandable_group_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:fluttericon/brandico_icons.dart'; import 'package:fluttericon/brandico_icons.dart';
import 'package:fluttericon/elusive_icons.dart'; import 'package:fluttericon/elusive_icons.dart';
import 'package:fluttericon/entypo_icons.dart'; import 'package:fluttericon/entypo_icons.dart';
@ -38,6 +39,8 @@ class ProfileInfo extends StatefulWidget {
} }
class _ProfileInfoState extends State<ProfileInfo> { class _ProfileInfoState extends State<ProfileInfo> {
int? profileId;
String? token;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -47,8 +50,12 @@ class _ProfileInfoState extends State<ProfileInfo> {
title: const Text('Profile'), title: const Text('Profile'),
), ),
body: ProgressHUD( body: ProgressHUD(
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocBuilder<UserBloc, UserState>(builder: (context, state) { child: BlocBuilder<UserBloc, UserState>(builder: (context, state) {
if (state is UserLoggedIn) { if (state is UserLoggedIn) {
profileId = state.userData!.user!.login!.user!.profileId;
token = state.userData!.user!.login!.token!;
return BlocConsumer<ProfileBloc, ProfileState>( return BlocConsumer<ProfileBloc, ProfileState>(
listener: (context, state) { listener: (context, state) {
if (state is ProfileLoading) { if (state is ProfileLoading) {
@ -57,7 +64,7 @@ class _ProfileInfoState extends State<ProfileInfo> {
'Loading Profile', 'Loading Profile',
); );
} }
if (state is ProfileLoaded) { if (state is ProfileLoaded || state is ProfileErrorState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress?.dismiss(); progress?.dismiss();
} }
@ -141,12 +148,12 @@ class _ProfileInfoState extends State<ProfileInfo> {
icon: Elusive.group, icon: Elusive.group,
title: "Family", title: "Family",
onTap: () { onTap: () {
Navigator.push(context, MaterialPageRoute( // Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { // builder: (BuildContext context) {
return FamilyBackgroundScreen( // return FamilyBackgroundScreen(
familyBackground: // familyBackground:
state.profileInformation.families); // state.profileInformation.families);
})); // }));
}, },
), ),
const Divider(), const Divider(),
@ -154,13 +161,13 @@ class _ProfileInfoState extends State<ProfileInfo> {
icon: FontAwesome5.graduation_cap, icon: FontAwesome5.graduation_cap,
title: "Education", title: "Education",
onTap: () { onTap: () {
Navigator.push(context, MaterialPageRoute( // Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { // builder: (BuildContext context) {
return EducationScreen( // return EducationScreen(
educationBackgrounds: state // educationBackgrounds: state
.profileInformation // .profileInformation
.educationalBackgrounds); // .educationalBackgrounds);
})); // }));
}, },
), ),
const Divider(), const Divider(),
@ -170,10 +177,11 @@ 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(value: ProfileBloc()..add(LoadEligibility(eligibilities: state.profileInformation.eligibilities)), return BlocProvider<ProfileBloc>.value(
value: ProfileBloc()
child: EligibiltyScreen( ..add(GetEligibilities(
), profileId: profileId!, token: token!)),
child: const EligibiltyScreen(),
); );
})); }));
}, },
@ -183,12 +191,12 @@ 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 WorkHistoryScreen(
workExperiences: state // workExperiences: state
.profileInformation.workExperiences); // .profileInformation.workExperiences);
})); // }));
}, },
), ),
const Divider(), const Divider(),
@ -196,12 +204,12 @@ class _ProfileInfoState extends State<ProfileInfo> {
icon: FontAwesome5.walking, icon: FontAwesome5.walking,
title: "Voluntary Work & Civic Services", title: "Voluntary Work & Civic Services",
onTap: () { onTap: () {
Navigator.push(context, MaterialPageRoute( // Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { // builder: (BuildContext context) {
return VolunataryWorkScreen( // return VolunataryWorkScreen(
voluntaryWorks: state // voluntaryWorks: state
.profileInformation.voluntaryWorks); // .profileInformation.voluntaryWorks);
})); // }));
}, },
), ),
const Divider(), const Divider(),
@ -209,13 +217,13 @@ class _ProfileInfoState extends State<ProfileInfo> {
icon: Elusive.lightbulb, icon: Elusive.lightbulb,
title: "Learning & Development", title: "Learning & Development",
onTap: () { onTap: () {
Navigator.push(context, MaterialPageRoute( // Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { // builder: (BuildContext context) {
return LearningAndDevelopmentScreen( // return LearningAndDevelopmentScreen(
learningDevelopments: state // learningDevelopments: state
.profileInformation // .profileInformation
.learningsAndDevelopment); // .learningsAndDevelopment);
})); // }));
}, },
), ),
const Divider(), const Divider(),
@ -223,12 +231,12 @@ class _ProfileInfoState extends State<ProfileInfo> {
icon: Brandico.codepen, icon: Brandico.codepen,
title: "Personal References", title: "Personal References",
onTap: () { onTap: () {
Navigator.push(context, MaterialPageRoute( // Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { // builder: (BuildContext context) {
return ReferencesScreen( // return ReferencesScreen(
references: // references:
state.profileInformation.references); // state.profileInformation.references);
})); // }));
}, },
), ),
ExpandableGroup( ExpandableGroup(
@ -249,32 +257,32 @@ class _ProfileInfoState extends State<ProfileInfo> {
subMenu( subMenu(
Icons.fitness_center, "Skills & Hobbies", Icons.fitness_center, "Skills & Hobbies",
() { () {
Navigator.push(context, MaterialPageRoute( // Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { // builder: (BuildContext context) {
return SkillHobbiesScreen( // return SkillHobbiesScreen(
skillsHobbies: state.profileInformation // skillsHobbies: state.profileInformation
.otherInformation.skillsAndHobbies); // .otherInformation.skillsAndHobbies);
})); // }));
}), }),
subMenu(FontAwesome5.certificate, subMenu(FontAwesome5.certificate,
"Organization Memberships", () { "Organization Memberships", () {
Navigator.push(context, MaterialPageRoute( // Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { // builder: (BuildContext context) {
return OrgMembershipsScreen( // return OrgMembershipsScreen(
orgMemberships: state.profileInformation // orgMemberships: state.profileInformation
.otherInformation.orgMemberships); // .otherInformation.orgMemberships);
})); // }));
}), }),
subMenu(Entypo.doc_text, subMenu(Entypo.doc_text,
"Non-Academic Recognitions", () { "Non-Academic Recognitions", () {
Navigator.push(context, MaterialPageRoute( // Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { // builder: (BuildContext context) {
return NonAcademicRecognitionScreen( // return NonAcademicRecognitionScreen(
nonAcademicRecognitions: state // nonAcademicRecognitions: state
.profileInformation // .profileInformation
.otherInformation // .otherInformation
.nonAcademicRecognition); // .nonAcademicRecognition);
})); // }));
}), }),
]), ]),
ExpandableGroup( ExpandableGroup(
@ -302,6 +310,9 @@ class _ProfileInfoState extends State<ProfileInfo> {
if (state is ProfileLoading) { if (state is ProfileLoading) {
return const LoadingScreen(); return const LoadingScreen();
} }
if (state is ProfileErrorState) {
return Text(state.mesage);
}
return Container(); return Container();
}, },

View File

@ -1,6 +1,7 @@
import 'package:barcode_scan2/barcode_scan2.dart'; import 'package:barcode_scan2/barcode_scan2.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:fluttericon/font_awesome5_icons.dart'; import 'package:fluttericon/font_awesome5_icons.dart';
@ -38,29 +39,21 @@ class _UniT2LoginState extends State<UniT2Login> {
onWillPop: pressAgainToExit, onWillPop: pressAgainToExit,
child: Scaffold( child: Scaffold(
body: ProgressHUD( body: ProgressHUD(
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<UserBloc, UserState>(listener: (context, state) { child: BlocConsumer<UserBloc, UserState>(listener: (context, state) {
if (state is UserLoggedIn) { if (state is UserLoggedIn ||
state is UuidLoaded ||
state is UserError ||
state is InternetTimeout) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.dismiss(); progress!.dismiss();
Navigator.pushReplacementNamed(context, '/module-screen'); Navigator.pushReplacementNamed(context, '/module-screen');
} }
if (state is UuidLoaded) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
Navigator.pushNamed(context, '/qr-login');
}
if (state is UserError) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
if (state is InternetTimeout) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
if (state is InvalidCredentials) { if (state is InvalidCredentials) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.dismiss(); progress!.dismiss();
errorAlert(context, "Error Login", state.message,(){}); errorAlert(context, "Error Login", state.message, () {});
context.read<UserBloc>().add(LoadVersion()); context.read<UserBloc>().add(LoadVersion());
} }
}, builder: (context, state) { }, builder: (context, state) {
@ -321,8 +314,8 @@ class _UniT2LoginState extends State<UniT2Login> {
} }
if (state is UserError) { if (state is UserError) {
return SomethingWentWrong( return SomethingWentWrong(
message:onError , message: onError,
onpressed:(){} , onpressed: () {},
); );
} }
if (state is InternetTimeout) { if (state is InternetTimeout) {

View File

@ -8,6 +8,34 @@ import 'package:http/http.dart' as http;
class EligibilityService { class EligibilityService {
static final EligibilityService _instance = EligibilityService(); static final EligibilityService _instance = EligibilityService();
static EligibilityService get instance => _instance; static EligibilityService get instance => _instance;
Future<List<EligibityCert>> getEligibilities(int profileId, String token)async{
List<EligibityCert> eligibilities = [];
String authToken = "Token $token";
String path = "${Url.instance.getEligibilities()}$profileId/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': authToken
};
// 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 cert) {
EligibityCert eligibility = EligibityCert.fromJson(cert);
eligibilities.add(eligibility);
});
}
}
// }catch(e){
// throw e.toString();
// }
return eligibilities;
}
Future<bool> delete( Future<bool> delete(
{required int eligibilityId, {required int eligibilityId,
@ -22,7 +50,7 @@ class EligibilityService {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'Authorization': authtoken 'Authorization': authtoken
}; };
// try{ try{
http.Response response = await Request.instance http.Response response = await Request.instance
.deleteRequest(path: path, headers: headers, body: body, param: params); .deleteRequest(path: path, headers: headers, body: body, param: params);
if (response.statusCode == 200) { if (response.statusCode == 200) {
@ -32,9 +60,9 @@ class EligibilityService {
success = false; success = false;
} }
// }catch(e){ }catch(e){
// throw(e.toString()); throw(e.toString());
// } }
return success!; return success!;
} }
@ -43,7 +71,7 @@ class EligibilityService {
required String token, required String token,
required int profileId}) async { required int profileId}) async {
Map<dynamic, dynamic>? _response={}; Map<dynamic, dynamic>? _response={};
String authtoken = "Token $token+1"; String authtoken = "Token $token";
String path = '${Url.instance.addEligibility()}$profileId/'; String path = '${Url.instance.addEligibility()}$profileId/';
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
@ -74,4 +102,42 @@ class EligibilityService {
throw e.toString(); throw e.toString();
} }
} }
Future<Map<dynamic, dynamic>> update(
{required EligibityCert eligibityCert,
required String token,
required int profileId, required int oldEligibility}) async {
Map<dynamic, dynamic>? response={};
String authtoken = "Token $token";
String path = '${Url.instance.addEligibility()}$profileId/';
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': authtoken
};
Map body = {
'eligibility_id': eligibityCert.eligibility!.id,
'license_number': eligibityCert.licenseNumber,
'exam_date': eligibityCert.examDate?.toString(),
'validity_date': eligibityCert.validityDate?.toString(),
'rating': eligibityCert.rating,
'_citymunCode': eligibityCert.examAddress?.cityMunicipality?.code,
'_countryId': eligibityCert.examAddress?.country!.id,
'_oldEligibilityId': oldEligibility
};
try {
http.Response res = await Request.instance
.putRequest(path: path, body: body, headers: headers, param: {});
if (res.statusCode == 200) {
Map data = jsonDecode(res.body);
response = data;
} else {
response.addAll({'success':false});
}
return response;
} catch (e) {
throw e.toString();
}
}
} }

View File

@ -37,7 +37,7 @@ class ProfileService {
List<MainAdress> addresses = []; List<MainAdress> addresses = [];
List<Identification> identificationInformation = []; List<Identification> identificationInformation = [];
List<ContactInfo> contactInformation = []; List<ContactInfo> contactInformation = [];
List<EligibityCert> eligibilities = [];
List<FamilyBackground> families = []; List<FamilyBackground> families = [];
List<Citizenship> citizenships = []; List<Citizenship> citizenships = [];
List<LearningDevelopement> learningsDevelopments = []; List<LearningDevelopement> learningsDevelopments = [];
@ -50,9 +50,10 @@ class ProfileService {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'Authorization': "Token $token" 'Authorization': "Token $token"
}; };
Map<String,String> param={"basic":"true"};
// try{ // try{
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(path: path, param: {}, headers: headers); .getRequest(path: path, param: param, headers: headers);
if (response.statusCode == 200) { if (response.statusCode == 200) {
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
@ -92,100 +93,100 @@ class ProfileService {
} }
// get all family background // get all family background
if(data['data']['family_background'] != null){ // if(data['data']['family_background'] != null){
data['data']['family_background'].forEach((var family){ // data['data']['family_background'].forEach((var family){
FamilyBackground familyBackground = FamilyBackground.fromJson(family); // FamilyBackground familyBackground = FamilyBackground.fromJson(family);
families.add(familyBackground); // families.add(familyBackground);
}); // });
} // }
//get all eligibilities //get all eligibilities
if (data['data']['eligibilities'] != null) { // if (data['data']['eligibilities'] != null) {
data['data']['eligibilities']!.forEach((var cert) { // data['data']['eligibilities']!.forEach((var cert) {
EligibityCert eligibility = EligibityCert.fromJson(cert); // EligibityCert eligibility = EligibityCert.fromJson(cert);
eligibilities.add(eligibility); // eligibilities.add(eligibility);
}); // });
} // }
// get all citizenships // get all citizenships
if (data['data']['citizenship'] != null) { // if (data['data']['citizenship'] != null) {
data['data']['citizenships']!.forEach((var citizenship) { // data['data']['citizenships']!.forEach((var citizenship) {
Citizenship person = Citizenship.fromJson(citizenship); // Citizenship person = Citizenship.fromJson(citizenship);
citizenships.add(person); // citizenships.add(person);
}); // });
} // }
// get all references; // get all references;
if (data['data']['personal_references'] != null) { // if (data['data']['personal_references'] != null) {
data['data']['personal_references'].forEach((var person) { // data['data']['personal_references'].forEach((var person) {
PersonalReference reference = PersonalReference.fromJson(person); // PersonalReference reference = PersonalReference.fromJson(person);
references.add(reference); // references.add(reference);
}); // });
} // }
//get all learning and developments //get all learning and developments
if (data['data']['learning_development'] != null) { // if (data['data']['learning_development'] != null) {
data['data']['learning_development'].forEach((var training) { // data['data']['learning_development'].forEach((var training) {
LearningDevelopement learnings = // LearningDevelopement learnings =
LearningDevelopement.fromJson(training); // LearningDevelopement.fromJson(training);
learningsDevelopments.add(learnings); // learningsDevelopments.add(learnings);
}); // });
} // }
//get all educational background //get all educational background
if (data['data']['education_background'] != null) { // if (data['data']['education_background'] != null) {
data['data']['education_background'].forEach((var education) { // data['data']['education_background'].forEach((var education) {
EducationalBackground educationalBackground = // EducationalBackground educationalBackground =
EducationalBackground.fromJson(education); // EducationalBackground.fromJson(education);
educationalBackgrounds.add(educationalBackground); // educationalBackgrounds.add(educationalBackground);
}); // });
} // }
// get all work history // get all work history
if (data['data']['work_experiences'] != null) { // if (data['data']['work_experiences'] != null) {
data['data']['work_experiences'].forEach((var work) { // data['data']['work_experiences'].forEach((var work) {
WorkHistory experience = WorkHistory.fromJson(work); // WorkHistory experience = WorkHistory.fromJson(work);
workExperiences.add(experience); // workExperiences.add(experience);
}); // });
} // }
// get all voluntary works // get all voluntary works
if (data['data']['voluntary_works'] != null) { // if (data['data']['voluntary_works'] != null) {
data['data']['voluntary_works'].forEach((var work) { // data['data']['voluntary_works'].forEach((var work) {
VoluntaryWork vwork = VoluntaryWork.fromJson(work); // VoluntaryWork vwork = VoluntaryWork.fromJson(work);
voluntaryWorks.add(vwork); // voluntaryWorks.add(vwork);
}); // });
} // }
// get all hobbies // get all hobbies
if (data['data']['other_information']['skills_hobbies'] != null) { // if (data['data']['other_information']['skills_hobbies'] != null) {
data['data']['other_information']['skills_hobbies'] // data['data']['other_information']['skills_hobbies']
.forEach((var skills_hobbies) { // .forEach((var skills_hobbies) {
SkillsHobbies skillsAndHobbies = // SkillsHobbies skillsAndHobbies =
SkillsHobbies.fromJson(skills_hobbies); // SkillsHobbies.fromJson(skills_hobbies);
skillsHobbies.add(skillsAndHobbies); // skillsHobbies.add(skillsAndHobbies);
}); // });
} // }
//get all organization memberships //get all organization memberships
if (data['data']['other_information']['organization_memberships'] != // if (data['data']['other_information']['organization_memberships'] !=
null) { // null) {
data['data']['other_information']['organization_memberships'] // data['data']['other_information']['organization_memberships']
.forEach((var org) { // .forEach((var org) {
OrganizationMembership organization = // OrganizationMembership organization =
OrganizationMembership.fromJson(org); // OrganizationMembership.fromJson(org);
orgMemberships.add(organization); // orgMemberships.add(organization);
}); // });
} // }
//get all non academic recognition //get all non academic recognition
if (data['data']['other_information']['non_academic_records'] != null) { // if (data['data']['other_information']['non_academic_records'] != null) {
data['data']['other_information']['non_academic_records'] // data['data']['other_information']['non_academic_records']
.forEach((var recognition) { // .forEach((var recognition) {
NonAcademicRecognition nonAcademicRecognition = // NonAcademicRecognition nonAcademicRecognition =
NonAcademicRecognition.fromJson(recognition); // NonAcademicRecognition.fromJson(recognition);
nonAcademicRecognitions.add(nonAcademicRecognition); // nonAcademicRecognitions.add(nonAcademicRecognition);
}); // });
} // }
BasicInfo basicInfo = BasicInfo( BasicInfo basicInfo = BasicInfo(
contactInformation: contactInformation, contactInformation: contactInformation,
@ -193,20 +194,21 @@ class ProfileService {
identifications: identificationInformation, identifications: identificationInformation,
citizenships: citizenships, citizenships: citizenships,
addresses: addresses); addresses: addresses);
OtherInformation otherInformation = OtherInformation( // OtherInformation otherInformation = OtherInformation(
skillsAndHobbies: skillsHobbies, // skillsAndHobbies: skillsHobbies,
orgMemberships: orgMemberships, // orgMemberships: orgMemberships,
nonAcademicRecognition: nonAcademicRecognitions); // nonAcademicRecognition: nonAcademicRecognitions);
ProfileInformation profileInformation = ProfileInformation( ProfileInformation profileInformation = ProfileInformation(
families: families, // families: families,
otherInformation: otherInformation, // otherInformation: otherInformation,
workExperiences: workExperiences, // workExperiences: workExperiences,
basicInfo: basicInfo, basicInfo: basicInfo,
eligibilities: eligibilities, // eligibilities: eligibilities,
references: references, // references: references,
learningsAndDevelopment: learningsDevelopments, // learningsAndDevelopment: learningsDevelopments,
educationalBackgrounds: educationalBackgrounds, // educationalBackgrounds: educationalBackgrounds,
voluntaryWorks: voluntaryWorks); // voluntaryWorks: voluntaryWorks
);
profileInformation0 = profileInformation; profileInformation0 = profileInformation;
} }
// }catch(e){ // }catch(e){
@ -215,3 +217,5 @@ class ProfileService {
return profileInformation0; return profileInformation0;
} }
} }

View File

@ -58,6 +58,6 @@ successAlert(context, title, description,Function() func) {
headerAnimationLoop: false, headerAnimationLoop: false,
title: title, title: title,
desc: description, desc: description,
btnOk: SizedBox(height: 50,child: ElevatedButton(style: mainBtnStyle(primary, Colors.transparent, second), onPressed: func, child: const Text("OK")), ) btnOk: SizedBox(height: 50,child: ElevatedButton(style: mainBtnStyle(success2, Colors.transparent, success), onPressed: func, child: const Text("OK")), )
).show(); ).show();
} }

View File

@ -97,46 +97,86 @@ class Request {
return response; return response;
} }
Future<Response> putRequest(
{required String path,
required Map<String, String>? headers,
required Map? body,
required Map<String, dynamic>? param}) async {
Response response;
try {
response =await put(Uri.http(host,path,param),headers: headers,body: jsonEncode(body));
} on TimeoutException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
throw (timeoutError);
} on SocketException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
throw (timeoutError);
} on FormatException catch (_) {
throw const FormatException(formatError);
} on HttpException catch (_) {
throw const HttpException(httpError);
} on Error catch (e) {
debugPrint("post request error: $e");
Fluttertoast.showToast(
msg: onError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
throw (e.toString());
}
return response;
}
Future<Response> deleteRequest( Future<Response> deleteRequest(
{required String path, {required String path,
required Map<String, String>? headers, required Map<String, String>? headers,
required Map? body, required Map? body,
required Map<String, dynamic>? param}) async { required Map<String, dynamic>? param}) async {
Response response; Response response;
// try { try {
response = await delete(Uri.http(host, path, param), response = await delete(Uri.http(host, path, param),
headers: headers, body: jsonEncode(body)) headers: headers, body: jsonEncode(body))
.timeout(Duration(seconds: requestTimeout)); .timeout(Duration(seconds: requestTimeout));
// } on TimeoutException catch (_) { } on TimeoutException catch (_) {
// Fluttertoast.showToast( Fluttertoast.showToast(
// msg: timeoutError, msg: timeoutError,
// toastLength: Toast.LENGTH_LONG, toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM, gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black, backgroundColor: Colors.black,
// ); );
// throw (timeoutError); throw (timeoutError);
// } on SocketException catch (_) { } on SocketException catch (_) {
// Fluttertoast.showToast( Fluttertoast.showToast(
// msg: timeoutError, msg: timeoutError,
// toastLength: Toast.LENGTH_LONG, toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM, gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black, backgroundColor: Colors.black,
// ); );
// throw (timeoutError); throw (timeoutError);
// } on FormatException catch (_) { } on FormatException catch (_) {
// throw const FormatException(formatError); throw const FormatException(formatError);
// } on HttpException catch (_) { } on HttpException catch (_) {
// throw const HttpException(httpError); throw const HttpException(httpError);
// } on Error catch (e) { } on Error catch (e) {
// debugPrint("post request error: $e"); Fluttertoast.showToast(
// Fluttertoast.showToast( msg: onError,
// msg: onError, toastLength: Toast.LENGTH_LONG,
// toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.BOTTOM,
// gravity: ToastGravity.BOTTOM, backgroundColor: Colors.black,
// backgroundColor: Colors.black, );
// ); throw (e.toString());
// throw (e.toString()); }
// }
return response; return response;
} }
} }

View File

@ -3,10 +3,11 @@ class Url {
static Url get instance => _instance; static Url get instance => _instance;
String host() { String host() {
// return '192.168.10.221:3003'; // // return '192.168.10.221:3003';
// return 'agusandelnorte.gov.ph'; // return 'agusandelnorte.gov.ph';
// return "192.168.10.219:3000"; // return "192.168.10.219:3000";
return 'devweb.agusandelnorte.gov.ph'; return "devweb.agusandelnorte.gov.ph";
// return 'devapi.agusandelnorte.gov.ph:3004';
} }
String authentication() { String authentication() {
@ -14,23 +15,33 @@ class Url {
} }
String profileInformation(){ String profileInformation(){
return '/api/jobnet_app/profile/pds/'; return 'api/jobnet_app/profile/pds/';
} }
String latestApk(){ String latestApk(){
return "/api/system_app/apk_version/latest"; return "/api/system_app/apk_version/latest";
} }
////ELIGIBILITIES PATHS
String eligibilities(){ String eligibilities(){
return "/api/jobnet_app/eligibilities/"; return "/api/jobnet_app/eligibilities/";
} }
String getEligibilities(){
return "/api/jobnet_app/profile/pds/eligibility/";
}
String addEligibility(){ String addEligibility(){
return "/api/jobnet_app/profile/pds/eligibility/"; return "/api/jobnet_app/profile/pds/eligibility/";
} }
String deleteEligibility(){ String deleteEligibility(){
return "/api/jobnet_app/profile/pds/eligibility/"; return "/api/jobnet_app/profile/pds/eligibility/";
} }
String updateEligibility(){
return "/api/jobnet_app/profile/pds/eligibility/";
}
// location utils path // location utils path
String getCounties(){ String getCounties(){
return "/api/jobnet_app/countries/"; return "/api/jobnet_app/countries/";

View File

@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
class CloseLeading extends StatelessWidget {
final Function() onPressed;
const CloseLeading({super.key, required this.onPressed});
@override
Widget build(BuildContext context) {
return IconButton(onPressed: onPressed, icon: const Icon(Icons.close));
}
}

View File

@ -3,6 +3,8 @@ PODS:
- FMDB (2.7.5): - FMDB (2.7.5):
- FMDB/standard (= 2.7.5) - FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5) - FMDB/standard (2.7.5)
- modal_progress_hud_nsn (0.0.1):
- FlutterMacOS
- package_info_plus (0.0.1): - package_info_plus (0.0.1):
- FlutterMacOS - FlutterMacOS
- path_provider_foundation (0.0.1): - path_provider_foundation (0.0.1):
@ -17,6 +19,7 @@ PODS:
DEPENDENCIES: DEPENDENCIES:
- FlutterMacOS (from `Flutter/ephemeral`) - FlutterMacOS (from `Flutter/ephemeral`)
- modal_progress_hud_nsn (from `Flutter/ephemeral/.symlinks/plugins/modal_progress_hud_nsn/macos`)
- package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`) - package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`)
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/macos`) - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/macos`)
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/macos`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/macos`)
@ -29,6 +32,8 @@ SPEC REPOS:
EXTERNAL SOURCES: EXTERNAL SOURCES:
FlutterMacOS: FlutterMacOS:
:path: Flutter/ephemeral :path: Flutter/ephemeral
modal_progress_hud_nsn:
:path: Flutter/ephemeral/.symlinks/plugins/modal_progress_hud_nsn/macos
package_info_plus: package_info_plus:
:path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos :path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos
path_provider_foundation: path_provider_foundation:
@ -41,6 +46,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
modal_progress_hud_nsn: 8099d46c2cf9de7af8fe0a3f8f5d2aa32cf956c3
package_info_plus: 02d7a575e80f194102bef286361c6c326e4c29ce package_info_plus: 02d7a575e80f194102bef286361c6c326e4c29ce
path_provider_foundation: 37748e03f12783f9de2cb2c4eadfaa25fe6d4852 path_provider_foundation: 37748e03f12783f9de2cb2c4eadfaa25fe6d4852
shared_preferences_foundation: 297b3ebca31b34ec92be11acd7fb0ba932c822ca shared_preferences_foundation: 297b3ebca31b34ec92be11acd7fb0ba932c822ca