resolve address issues

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
PGAN-MIS 2023-02-23 13:51:53 +08:00
parent a7ee63627d
commit 424b1f3b47
15 changed files with 575 additions and 577 deletions

View File

@ -74,70 +74,12 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
bool? isOverseas = event.eligibityCert.overseas;
if (event.selectedRegion != null) {
if (event.selectedProvince == null) {
currentRegion = event.selectedRegion;
List<Province> provinces = await LocationUtils.instance
.getProvinces(regionCode: event.selectedRegion!.code.toString());
_provinces = provinces;
currentProvince = null;
currentCity = null;
}
if (event.selectedProvince != null) {
currentRegion = event.selectedRegion;
List<Province> provinces = await LocationUtils.instance
.getProvinces(regionCode: event.selectedRegion!.code.toString());
_provinces = provinces;
currentProvince = _provinces!.firstWhere(
(Province p) => event.selectedProvince!.code == p.code);
List<CityMunicipality> citymuns = await LocationUtils.instance
.getCities(code: currentProvince.code.toString());
_cities = citymuns;
currentCity = null;
}
} else {
// if exam address region is not equal to null get the region, provinces and citymunicipalities
if (event.eligibityCert.examAddress?.cityMunicipality?.province
?.region !=
null) {
currentRegion = _regions!.firstWhere((Region r) =>
event.eligibityCert.examAddress!.cityMunicipality!.province!
.region!.code ==
r.code);
List<Province> provinces = await LocationUtils.instance.getProvinces(
regionCode: event.eligibityCert.examAddress!.cityMunicipality!
.province!.region!.code!
.toString());
_provinces = provinces;
currentProvince = _provinces!.firstWhere((Province p) =>
event.eligibityCert.examAddress!.cityMunicipality!.province!
.code ==
p.code);
List<CityMunicipality> citymuns = await LocationUtils.instance
.getCities(
code: event.eligibityCert.examAddress!.cityMunicipality!
.province!.code!);
_cities = citymuns;
currentCity = _cities!.firstWhere((CityMunicipality c) =>
event.eligibityCert.examAddress!.cityMunicipality!.code ==
c.code);
}
}
emit(EditEligibilityState(
isOverseas: isOverseas!,
currentEligibility: currentEligibility,
currentCountry: currentCountry,
currentRegion: currentRegion,
currentCity: currentCity,
cityMuns: _cities,
provinces: _provinces,
eligibityCert: event.eligibityCert,
countries: _countries!,
regions: _regions!,
currentProvince: currentProvince,
eligibilities: _eligibilities!));
// }catch(e){
@ -147,13 +89,9 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
////====================================================================
});
on<AddEligibility>((event, emit) async {
Region? currentRegion;
Province? currentProvince;
CityMunicipality? currentCity;
List<CityMunicipality>? cities;
List<Province>? provinces;
Eligibility? currentEligibility;
final bool overseas = event.overseas;
emit(ProfileLoading());
if (_regions == null) {
List<Region> regions = await LocationUtils.instance.getRegions();
@ -168,49 +106,8 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
List<Country> countries = await LocationUtils.instance.getCountries();
_countries = countries;
}
if(event.selectedEligibility != null){
currentEligibility = _eligibilities!.firstWhere((Eligibility element) => element.id == event.selectedEligibility!.id);
}else{
currentEligibility = null;
}
if (event.selectedRegion != null) {
if (event.selectedProvince == null) {
currentRegion = event.selectedRegion;
provinces = await LocationUtils.instance
.getProvinces(regionCode: event.selectedRegion!.code.toString());
_provinces = provinces;
currentProvince = null;
currentCity = null;
}
if (event.selectedProvince != null) {
currentRegion = event.selectedRegion;
provinces = await LocationUtils.instance
.getProvinces(regionCode: event.selectedRegion!.code.toString());
_provinces = provinces;
currentProvince = _provinces!.firstWhere(
(Province p) => event.selectedProvince!.code == p.code);
cities = await LocationUtils.instance
.getCities(code: currentProvince.code.toString());
_cities = cities;
currentCity = null;
}
}else{
print("executed");
currentRegion = null;
currentProvince = null;
currentCity = null;
_provinces = null;
_cities = null;
}
emit(AddEligibilityState(
cities: cities,
provinces: provinces,
currentEligibility: currentEligibility,
currentRegion: overseas? null: currentRegion,
currentProvince: currentProvince,
overseas: overseas,
eligibilities: _eligibilities!,
regions: _regions!,
countries: _countries!));

View File

@ -30,15 +30,12 @@ class LoadEligibility extends ProfileEvent{
class EditEligibility extends ProfileEvent{
final EligibityCert eligibityCert;
final Region? selectedRegion;
final Province? selectedProvince;
const EditEligibility({required this.eligibityCert,this.selectedRegion, required this.selectedProvince});
const EditEligibility({required this.eligibityCert});
@override
List<Object> get props => [];
}
class DeleteEligibility extends ProfileEvent{
final List<EligibityCert> eligibilities;
final String profileId;
final int eligibilityId;
@ -49,14 +46,7 @@ const DeleteEligibility({ required this.eligibilities, required this.eligibility
}
class AddEligibility extends ProfileEvent{
final bool overseas;
final Eligibility? selectedEligibility;
final Region? selectedRegion;
final Province? selectedProvince;
const AddEligibility({required this.selectedEligibility, required this.overseas, required this.selectedProvince,this.selectedRegion});
@override
List<Object> get props => [overseas];
}

View File

@ -31,33 +31,22 @@ class EligibilityLoaded extends ProfileState {
@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;
List<Province>? provinces;
List<CityMunicipality>? cityMuns;
Eligibility? currentEligibility;
Country? currentCountry;
Region? currentRegion;
Province? currentProvince;
CityMunicipality? currentCity;
bool isOverseas;
EditEligibilityState(
{required this.currentEligibility,
required this.currentCountry,
required this.currentRegion,
required this.isOverseas,
required this.cityMuns,
required this.provinces,
required this.eligibityCert,
required this.eligibilities,
required this.countries,
required this.regions,
required this.currentProvince,
required this.currentCity});
final bool isOverseas;
const EditEligibilityState({
required this.isOverseas,
required this.eligibityCert,
required this.eligibilities,
required this.countries,
required this.regions,
});
@override
List<Object> get props =>
[isOverseas, eligibityCert, eligibilities, regions, countries];
}
class DeletedState extends ProfileState {
@ -69,26 +58,14 @@ class DeletedState extends ProfileState {
}
class AddEligibilityState extends ProfileState {
bool overseas;
Eligibility? currentEligibility;
Region? currentRegion;
Province? currentProvince;
final List<Eligibility> eligibilities;
final List<Country> countries;
final List<Region> regions;
final List<Province>? provinces;
final List<CityMunicipality>? cities;
AddEligibilityState(
{required this.overseas,
required this.eligibilities,
required this.countries,
required this.regions,
required this.cities,
required this.provinces,
required this.currentEligibility,
required this.currentProvince,
required this.currentRegion,
});
@override
List<Object> get props => [overseas];
const AddEligibilityState({
required this.eligibilities,
required this.countries,
required this.regions,
});
@override
List<Object> get props => [eligibilities,countries,regions];
}

View File

@ -1,10 +1,10 @@
import 'package:date_time_picker/date_time_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:intl/intl.dart';
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart';
@ -17,6 +17,7 @@ import '../../../../theme-data.dart/btn-style.dart';
import '../../../../theme-data.dart/colors.dart';
import '../../../../theme-data.dart/form-style.dart';
import '../../../../utils/global.dart';
import '../../../../utils/location_utilities.dart';
import '../../../../utils/text_container.dart';
class AddEligibilityScreen extends StatefulWidget {
@ -27,285 +28,355 @@ class AddEligibilityScreen extends StatefulWidget {
}
class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
final formKey = GlobalKey<FormBuilderState>();
final provinceKey = GlobalKey<FormBuilderState>();
bool? overseas;
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
Region? selectedRegion;
Province? selectedProvince;
CityMunicipality? selectedMunicipality;
Country? selectedCountry;
Eligibility? selectedEligibility;
List<Province>? provinces;
List<CityMunicipality>? citymuns;
bool provinceCall = false;
bool cityCall = false;
@override
Widget build(BuildContext context) {
bool? overseas;
final formKey = GlobalKey<FormBuilderState>();
final regionKey = GlobalKey<FormBuilderState>();
Region? selectedRegion;
Province? selectedProvince;
Country? selectedCountry;
CityMunicipality selectedCity;
Eligibility? selectedEligibility;
//USERBLOC
return BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
//LOGGED IN USER STATE
if (state is UserLoggedIn) {
//PROFIILE BLOC
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if (state is AddEligibilityState) {
overseas = state.overseas;
selectedEligibility = state.currentEligibility;
return ProgressHUD(
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 25, horizontal: 18),
child: FormBuilder(
key: formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
//ELIGIBILITIES DROPDOWN
FormBuilderDropdown<Eligibility>(
initialValue: selectedEligibility,
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(
name: 'license number',
initialValue: "",
decoration: normalTextFieldStyle(
"license number", "license number"),
),
buildWhen: (previous, current) {
if (state is EditEligibilityState) {}
return false;
},
builder: (context, state) {
//EDIT ELIGIBILITY STATE
if (state is AddEligibilityState) {
return ProgressHUD(
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 25, horizontal: 18),
child: FormBuilder(
key: formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
//ELIGIBILITIES DROPDOWN
FormBuilderDropdown<Eligibility>(
onChanged: (Eligibility? eligibility) {
selectedEligibility = eligibility;
},
initialValue: state.eligibilities[0],
items: state.eligibilities
.map<DropdownMenuItem<Eligibility>>(
(Eligibility eligibility) {
return DropdownMenuItem<Eligibility>(
value: eligibility,
child: Text(eligibility.title));
}).toList(),
name: "eligibility",
decoration:
normalTextFieldStyle("Eligibility", "")
.copyWith(
hintStyle: const TextStyle(
color: Colors.black,
),
labelStyle: const TextStyle(
color: Colors.black)),
),
const SizedBox(
height: 20,
),
SizedBox(
width: screenWidth,
child: Row(
children: [
//LICENSE NUMBER
Flexible(
flex: 1,
child: FormBuilderTextField(
name: 'license_number',
initialValue:null,
decoration: normalTextFieldStyle(
"license number", "license number"),
),
),
const SizedBox(
width: 12,
),
//RATING
Flexible(
flex: 1,
child: FormBuilderTextField(
name: 'rating',
// ignore: prefer_null_aware_operators
initialValue:null,
decoration: normalTextFieldStyle(
'rating', 'rating'),
),
),
],
),
const SizedBox(
width: 12,
),
//RATING
Flexible(
flex: 1,
child: FormBuilderTextField(
name: 'rating',
initialValue: "",
decoration: normalTextFieldStyle(
'rating', 'rating'),
),
),
],
),
),
const SizedBox(
height: 20,
),
SizedBox(
width: screenWidth,
child: Row(
children: [
//EXAM DATE
Flexible(
flex: 1,
child: DateTimePicker(
firstDate: DateTime(2000),
lastDate: DateTime(2100),
decoration: normalTextFieldStyle(
"Exam date", "Exam date"),
initialValue: "",
)),
const SizedBox(
width: 12,
),
//VALIDITY DATE
Flexible(
flex: 1,
child: DateTimePicker(
firstDate: DateTime(2000),
lastDate: DateTime(2100),
decoration: normalTextFieldStyle(
"Validity date", "Validity date"),
initialValue: "",
),
),
],
),
),
const SizedBox(
height: 20,
),
Text(
"Placement of Examination/Confinement",
style: Theme.of(context)
.textTheme
.displaySmall!
.copyWith(fontSize: blockSizeVertical * 2),
),
const SizedBox(
height: 12,
),
FormBuilderSwitch(
initialValue: overseas,
activeColor: second,
onChanged: (value) {
overseas = value;
regionKey.currentState?.fields['region']?.reset();
context.read<ProfileBloc>().add(AddEligibility(
selectedEligibility: selectedEligibility,
overseas: overseas!,
selectedProvince: null,
selectedRegion: null));
},
decoration: normalTextFieldStyle("", ''),
name: 'overseas',
title: const Text("Overseas Address?"),
),
const SizedBox(
height: 12,
),
SizedBox(
child: overseas == true
? FormBuilderDropdown<Country>(
initialValue: null,
items: state.countries
.map<DropdownMenuItem<Country>>(
(Country country) {
return DropdownMenuItem<Country>(
value: country,
child: FittedBox(
child: Text(country.name!)));
}).toList(),
name: 'country',
decoration: normalTextFieldStyle(
"Country*", "Country"),
onChanged: (Country? value) {
selectedCountry = value;
},
)
: Column(
children: [
//REGION DROPDOWN
FormBuilderDropdown<Region?>(
onChanged: (Region? region) {
selectedRegion = region;
context.read<ProfileBloc>().add(
AddEligibility(
selectedEligibility: selectedEligibility,
overseas: overseas!,
selectedProvince:
null,
selectedRegion:
selectedRegion));
},
initialValue: state.currentRegion,
),
const SizedBox(
height: 20,
),
SizedBox(
width: screenWidth,
child: Row(
children: [
//EXAM DATE
Flexible(
flex: 1,
child: DateTimePicker(
// controller: examDateController,
firstDate: DateTime(2000),
lastDate: DateTime(2100),
decoration: normalTextFieldStyle(
"Region*", "Region"),
name: 'region',
items: state.regions
.map<DropdownMenuItem<Region>>(
(Region region) {
return DropdownMenuItem<Region>(
value: region,
child:
Text(region.description!));
}).toList(),
),
const SizedBox(
height: 12,
),
//PROVINCE DROPDOWN
FormBuilderDropdown<Province?>(
initialValue: state.currentProvince,
name: 'province',
onChanged: (Province? province) {
selectedProvince = province;
context.read<ProfileBloc>().add(
AddEligibility(
selectedEligibility: selectedEligibility,
overseas: overseas!,
selectedProvince:
selectedProvince,
selectedRegion:
state.currentRegion));
},
items: state.provinces == null
? []
: state.provinces!.map<
DropdownMenuItem<
Province>>(
(Province province) {
return DropdownMenuItem(
value: province,
child: Text(province
.description!));
}).toList(),
decoration: normalTextFieldStyle(
"Province*", "Province")),
const SizedBox(
height: 12,
),
FormBuilderDropdown<CityMunicipality>(
onChanged:
(CityMunicipality? city) {
selectedCity = city!;
},
decoration: normalTextFieldStyle(
"Municipality*",
"Municipality"),
name: 'municipality',
items: state.cities == null
? []
: state.cities!.map<
DropdownMenuItem<
CityMunicipality>>(
(CityMunicipality c) {
return DropdownMenuItem(
value: c,
child: Text(c
.description!));
}).toList(),
initialValue: null),
const SizedBox(
height: 20,
),
],
)),
const Expanded(
child: SizedBox(),
),
SizedBox(
width: screenWidth,
height: 60,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {},
child: const Text(submit)),
),
const SizedBox(
height: 20,
),
],
"Exam date", "Exam date"),
initialValue:null,
)),
const SizedBox(
width: 12,
),
//VALIDITY DATE
Flexible(
flex: 1,
child: DateTimePicker(
// controller: validityDateController,
firstDate: DateTime(2000),
lastDate: DateTime(2100),
decoration: normalTextFieldStyle(
"Validity date", "Validity date"),
initialValue:null,
),
),
],
),
),
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
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,
items: state.countries.map<
DropdownMenuItem<
Country>>(
(Country country) {
return DropdownMenuItem<
Country>(
value: country,
child: FittedBox(
child: Text(
country.name!)));
}).toList(),
name: 'country',
decoration: normalTextFieldStyle(
"Country*", "Country"),
onChanged: (Country? value) {
selectedCountry = value;
},
)
: Column(
children: [
//REGION DROPDOWN
FormBuilderDropdown<Region?>(
onChanged:
(Region? region) async {
setState(() {
provinceCall = true;
});
selectedRegion = region;
getProvinces();
},
initialValue: selectedRegion,
decoration:
normalTextFieldStyle(
"Region*", "Region"),
name: 'region',
items: state.regions.map<
DropdownMenuItem<
Region>>(
(Region region) {
return DropdownMenuItem<
Region>(
value: region,
child: Text(region
.description!));
}).toList(),
),
const SizedBox(
height: 20,
),
//PROVINCE DROPDOWN
SizedBox(
height: 50,
child: ModalProgressHUD(
inAsyncCall: cityCall,
child: DropdownButtonFormField<
Province?>(
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,
),
SizedBox(
height: 50,
child: DropdownButtonFormField<
CityMunicipality>(
onChanged:
(CityMunicipality?
city) {
selectedMunicipality =
city;
},
decoration:
normalTextFieldStyle(
"Municipality*",
"Municipality"),
value: selectedMunicipality,
items: citymuns == null
? []
: citymuns!.map<
DropdownMenuItem<
CityMunicipality>>(
(CityMunicipality
c) {
return DropdownMenuItem(
value: c,
child: Text(c
.description!));
}).toList(),
),
),
const SizedBox(
height: 20,
),
],
)),
],
),
const Expanded(
child: SizedBox(),
),
SizedBox(
width: screenWidth,
height: 60,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {},
child: const Text(submit)),
),
const SizedBox(
height: 20,
),
]),
),
),
),
),
);
}
return Container();
});
);
}
return Container();
},
);
}
return Container();
},
);
}
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

@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:intl/intl.dart';
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/location/city.dart';
@ -30,17 +31,18 @@ class EditEligibilityScreen extends StatefulWidget {
class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
final formKey = GlobalKey<FormBuilderState>();
final provinceKey = GlobalKey<FormBuilderState>();
bool? overseas;
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
Region? selectedRegion;
Province? selectedProvince;
CityMunicipality? selectedMunicipality;
Region? regions;
Province? province;
CityMunicipality? city;
Country? selectedCountry;
Eligibility? selectedEligibility;
List<Province>? provinces;
List<CityMunicipality>? citymuns;
bool provinceCall = false;
bool cityCall = false;
// final examDateController = TextEditingController();
// final validityDateController = TextEditingController();
@override
@ -52,10 +54,13 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
if (state is UserLoggedIn) {
//PROFIILE BLOC
return BlocBuilder<ProfileBloc, ProfileState>(
buildWhen: (previous, current) {
if (state is EditEligibilityState) {}
return false;
},
builder: (context, state) {
//EDIT ELIGIBILITY STATE
if (state is EditEligibilityState) {
overseas = state.isOverseas;
return ProgressHUD(
child: Center(
child: Padding(
@ -69,10 +74,10 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
children: [
//ELIGIBILITIES DROPDOWN
FormBuilderDropdown<Eligibility>(
onChanged: (Eligibility? eligibility){
onChanged: (Eligibility? eligibility) {
selectedEligibility = eligibility;
},
initialValue: state.currentEligibility,
initialValue: null,
items: state.eligibilities
.map<DropdownMenuItem<Eligibility>>(
(Eligibility eligibility) {
@ -117,11 +122,14 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
flex: 1,
child: FormBuilderTextField(
name: 'rating',
// ignore: prefer_null_aware_operators
initialValue: widget
.eligibityCert.rating== null?null:widget.eligibityCert.rating.toString(),
initialValue:
widget.eligibityCert.rating == null
? null
: widget.eligibityCert.rating
.toString(),
decoration: normalTextFieldStyle(
'rating', 'rating'),
),
@ -190,143 +198,156 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
height: 12,
),
//OVERSEAS ADDRESS SWITCH
FormBuilderSwitch(
initialValue: overseas,
activeColor: second,
onChanged: (value) {
EligibityCert newEligibility =
state.eligibityCert;
newEligibility.overseas = value!;
// formKey.currentState!.reset();
context.read<ProfileBloc>().add(
EditEligibility(
selectedRegion: null,
selectedProvince: null,
eligibityCert: newEligibility));
},
decoration: normalTextFieldStyle("", ''),
name: 'overseas',
title: const Text("Overseas Address?"),
),
const SizedBox(
height: 20,
),
//COUNTRY DROPDOWN
SizedBox(
child: overseas == true
? FormBuilderDropdown<Country>(
initialValue: state.currentCountry,
items: state.countries
.map<DropdownMenuItem<Country>>(
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,
items: state.countries.map<
DropdownMenuItem<
Country>>(
(Country country) {
return DropdownMenuItem<Country>(
value: country,
child: FittedBox(
child:
Text(country.name!)));
}).toList(),
name: 'country',
decoration: normalTextFieldStyle(
"Country*", "Country"),
onChanged: (Country? value) {
selectedCountry = value;
},
)
: Column(
children: [
//REGION DROPDOWN
FormBuilderDropdown<Region?>(
onChanged: (Region? region) {
selectedRegion = region;
context.read<ProfileBloc>().add(
EditEligibility(
eligibityCert:
state.eligibityCert,
selectedProvince: null,
selectedRegion:
selectedRegion));
},
initialValue: state.currentRegion,
decoration: normalTextFieldStyle(
"Region*", "Region"),
name: 'region',
items: state.regions.map<
DropdownMenuItem<Region>>(
(Region region) {
return DropdownMenuItem<Region>(
value: region,
child: Text(
region.description!));
return DropdownMenuItem<
Country>(
value: country,
child: FittedBox(
child: Text(
country.name!)));
}).toList(),
),
const SizedBox(
height: 20,
),
//PROVINCE DROPDOWN
FormBuilderDropdown<Province?>(
initialValue:state.currentProvince,
name: 'province',
onChanged:
(Province? province) {
selectedProvince = province;
context
.read<ProfileBloc>()
.add(EditEligibility(
eligibityCert: state
.eligibityCert,
selectedProvince:
selectedProvince,
selectedRegion: state
.currentRegion));
},
items: state.provinces == null
? []
: state.provinces!.map<
DropdownMenuItem<
Province>>(
(Province province) {
return DropdownMenuItem(
value: province,
child: Text(province
.description!));
}).toList(),
decoration:
normalTextFieldStyle(
"Province*",
"Province")),
const SizedBox(
height: 20,
),
FormBuilderDropdown<
CityMunicipality>(
onChanged: (CityMunicipality? city){
selectedMunicipality = city;
name: 'country',
decoration: normalTextFieldStyle(
"Country*", "Country"),
onChanged: (Country? value) {
selectedCountry = value;
},
)
: Column(
children: [
//REGION DROPDOWN
FormBuilderDropdown<Region?>(
onChanged:
(Region? region) async {
setState(() {
provinceCall = true;
});
selectedRegion = region;
getProvinces();
},
initialValue: selectedRegion,
decoration:
normalTextFieldStyle(
"Region*", "Region"),
name: 'region',
items: state.regions.map<
DropdownMenuItem<
Region>>(
(Region region) {
return DropdownMenuItem<
Region>(
value: region,
child: Text(region
.description!));
}).toList(),
),
const SizedBox(
height: 20,
),
//PROVINCE DROPDOWN
SizedBox(
height: 50,
child: ModalProgressHUD(
inAsyncCall: cityCall,
child: DropdownButtonFormField<
Province?>(
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,
),
SizedBox(
height: 50,
child: DropdownButtonFormField<
CityMunicipality>(
onChanged:
(CityMunicipality?
city) {
selectedMunicipality =
city;
},
decoration:
normalTextFieldStyle(
"Municipality*",
"Municipality"),
name: 'municipality',
items: state.cityMuns == null
? []
: state.cityMuns!.map<
DropdownMenuItem<
CityMunicipality>>(
(CityMunicipality c) {
return DropdownMenuItem(
value: c,
child: Text(c
.description!));
}).toList(),
initialValue:
state.currentCity),
const SizedBox(
height: 20,
),
],
)),
decoration:
normalTextFieldStyle(
"Municipality*",
"Municipality"),
value: selectedMunicipality,
items: citymuns == null
? []
: citymuns!.map<
DropdownMenuItem<
CityMunicipality>>(
(CityMunicipality
c) {
return DropdownMenuItem(
value: c,
child: Text(c
.description!));
}).toList(),
),
),
const SizedBox(
height: 20,
),
],
)),
],
),
const Expanded(
child: SizedBox(),
),
@ -357,4 +378,23 @@ 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

@ -29,7 +29,7 @@ class EligibiltyScreen extends StatelessWidget {
centerTitle: true,
backgroundColor: primary,
actions: [AddLeading(onPressed: () {
context.read<ProfileBloc>().add(const AddEligibility(overseas: false,selectedProvince: null,selectedRegion: null,selectedEligibility: null));
context.read<ProfileBloc>().add( AddEligibility());
})],
),
body: BlocBuilder<UserBloc, UserState>(
@ -172,8 +172,7 @@ class EligibiltyScreen extends StatelessWidget {
.showWithText("Loading...");
context.read<ProfileBloc>().add(
EditEligibility(
selectedProvince: null,
selectedRegion: null,
eligibityCert:
eligibityCert));
}

View File

@ -20,10 +20,9 @@ class AuthService {
'X-User': ""
};
try {
http.Response response = await http.get(
Uri.https('unitylb1.agusandelnorte.gov.ph',
'/unit2/api/sys/apk_version/latest/'),
headers: headers);
String path = Url.instance.latestApk();
http.Response response = await Request.instance.getRequest(path: path,headers: headers,param: {});
if (response.statusCode == 200) {
Map data = jsonDecode(response.body);
versionInfo = VersionInfo.fromJson(data['data']);

View File

@ -5,7 +5,8 @@ class Url {
String host() {
// return '192.168.10.221:3003';
// return 'agusandelnorte.gov.ph';
return 'devweb.agusandelnorte.gov.ph';
return "192.168.10.219:3000";
// return 'devweb.agusandelnorte.gov.ph';
}
String authentication() {
@ -16,6 +17,10 @@ class Url {
return '/api/jobnet_app/profile/pds/';
}
String latestApk(){
return "/api/system_app/apk_version/latest";
}
String eligibilities(){
return "/api/jobnet_app/eligibilities/";
}

View File

@ -6,6 +6,10 @@
#include "generated_plugin_registrant.h"
#include <modal_progress_hud_nsn/modal_progress_hud_nsn_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) modal_progress_hud_nsn_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "ModalProgressHudNsnPlugin");
modal_progress_hud_nsn_plugin_register_with_registrar(modal_progress_hud_nsn_registrar);
}

View File

@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
modal_progress_hud_nsn
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST

View File

@ -5,12 +5,14 @@
import FlutterMacOS
import Foundation
import modal_progress_hud_nsn
import package_info_plus
import path_provider_foundation
import shared_preferences_foundation
import sqflite
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
ModalProgressHudNsnPlugin.register(with: registry.registrar(forPlugin: "ModalProgressHudNsnPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))

View File

@ -517,6 +517,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.8.0"
modal_progress_hud_nsn:
dependency: "direct main"
description:
name: modal_progress_hud_nsn
sha256: "408b9bcce97567de94637de932260e50be48db1842edc761aeea61670e5ec30c"
url: "https://pub.dev"
source: hosted
version: "0.3.0"
nested:
dependency: transitive
description:

View File

@ -69,6 +69,7 @@ dependencies:
expandable_group: ^0.0.8
badges: ^3.0.2
app_popup_menu: ^1.0.0
modal_progress_hud_nsn: ^0.3.0
dev_dependencies:
flutter_test:

View File

@ -6,9 +6,12 @@
#include "generated_plugin_registrant.h"
#include <modal_progress_hud_nsn/modal_progress_hud_nsn_plugin.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
ModalProgressHudNsnPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ModalProgressHudNsnPlugin"));
PermissionHandlerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
}

View File

@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
modal_progress_hud_nsn
permission_handler_windows
)