add location utilities and profile utilities services
parent
4418107f21
commit
e7d5e933dd
|
@ -4,7 +4,12 @@ import 'package:unit2/model/profile/basic_info.dart';
|
|||
import 'package:unit2/model/profile/basic_information/primary-information.dart';
|
||||
import 'package:unit2/model/profile/eligibility.dart';
|
||||
import 'package:unit2/model/profile/profileInfomation.dart';
|
||||
import 'package:unit2/model/utils/eligibilities_choices.dart';
|
||||
import 'package:unit2/sevices/profile/profile_service.dart';
|
||||
import 'package:unit2/utils/location_utilities.dart';
|
||||
import 'package:unit2/utils/profile_utilities.dart';
|
||||
import '../../model/location/country.dart' as country;
|
||||
import '../../model/location/region.dart' as region;
|
||||
|
||||
part 'profile_event.dart';
|
||||
part 'profile_state.dart';
|
||||
|
@ -28,8 +33,16 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
|||
emit(ProfileLoading());
|
||||
emit(EligibilityLoaded(eligibilities: event.eligibilities));
|
||||
});
|
||||
on<EditEligibility>((event, emit) {
|
||||
emit(EditEligibilityState(eligibityCert: event.eligibityCert));
|
||||
on<EditEligibility>((event, emit) async{
|
||||
// try{
|
||||
List<country.Country> countries = await LocationUtils.instance.getCountries();
|
||||
List<region.Region> regions = await LocationUtils.instance.getRegions();
|
||||
List<EligibilityList> eligibilities = await ProfileUtilities.instance.getEligibilities();
|
||||
emit(EditEligibilityState(eligibityCert: event.eligibityCert,countries: countries,regions: regions,eligibilities: eligibilities));
|
||||
// }catch(e){
|
||||
// emit(ProfileErrorState(mesage: e.toString()));
|
||||
// }
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,10 @@ class EligibilityLoaded extends ProfileState{
|
|||
|
||||
class EditEligibilityState extends ProfileState{
|
||||
final EligibityCert eligibityCert;
|
||||
const EditEligibilityState({required this.eligibityCert});
|
||||
final List<EligibilityList> eligibilities;
|
||||
final List<country.Country> countries;
|
||||
final List<region.Region> regions;
|
||||
const EditEligibilityState({required this.eligibityCert, required this.eligibilities, required this.countries, required this.regions});
|
||||
@override
|
||||
List<Object> get props => [eligibityCert];
|
||||
}
|
||||
|
|
|
@ -16,20 +16,20 @@ class Barangay {
|
|||
required this.cityMunicipality,
|
||||
});
|
||||
|
||||
final String code;
|
||||
final String description;
|
||||
final CityMunicipality cityMunicipality;
|
||||
final String? code;
|
||||
final String? description;
|
||||
final CityMunicipality? cityMunicipality;
|
||||
|
||||
factory Barangay.fromJson(Map<String, dynamic> json) => Barangay(
|
||||
code: json["code"],
|
||||
description: json["description"],
|
||||
cityMunicipality: CityMunicipality.fromJson(json["city_municipality"]),
|
||||
cityMunicipality: json['city_municipality'] == null? null: CityMunicipality.fromJson(json["city_municipality"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"code": code,
|
||||
"description": description,
|
||||
"city_municipality": cityMunicipality.toJson(),
|
||||
"city_municipality": cityMunicipality!.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -42,16 +42,16 @@ class CityMunicipality {
|
|||
required this.zipcode,
|
||||
});
|
||||
|
||||
final String code;
|
||||
final String description;
|
||||
final Province province;
|
||||
final String psgcCode;
|
||||
final String zipcode;
|
||||
final String? code;
|
||||
final String? description;
|
||||
final Province? province;
|
||||
final String? psgcCode;
|
||||
final String? zipcode;
|
||||
|
||||
factory CityMunicipality.fromJson(Map<String, dynamic> json) => CityMunicipality(
|
||||
code: json["code"],
|
||||
description: json["description"],
|
||||
province: Province.fromJson(json["province"]),
|
||||
province: json['province'] == null? null:Province.fromJson(json["province"]),
|
||||
psgcCode: json["psgc_code"],
|
||||
zipcode: json["zipcode"],
|
||||
);
|
||||
|
@ -59,7 +59,7 @@ class CityMunicipality {
|
|||
Map<String, dynamic> toJson() => {
|
||||
"code": code,
|
||||
"description": description,
|
||||
"province": province.toJson(),
|
||||
"province": province!.toJson(),
|
||||
"psgc_code": psgcCode,
|
||||
"zipcode": zipcode,
|
||||
};
|
||||
|
@ -74,16 +74,16 @@ class Province {
|
|||
required this.shortname,
|
||||
});
|
||||
|
||||
final String code;
|
||||
final String description;
|
||||
final Region region;
|
||||
final String psgcCode;
|
||||
final String shortname;
|
||||
final String? code;
|
||||
final String? description;
|
||||
final Region? region;
|
||||
final String? psgcCode;
|
||||
final String? shortname;
|
||||
|
||||
factory Province.fromJson(Map<String, dynamic> json) => Province(
|
||||
code: json["code"],
|
||||
description: json["description"],
|
||||
region: Region.fromJson(json["region"]),
|
||||
region: json['region'] == null? null: Region.fromJson(json["region"]),
|
||||
psgcCode: json["psgc_code"],
|
||||
shortname: json["shortname"],
|
||||
);
|
||||
|
@ -91,7 +91,7 @@ class Province {
|
|||
Map<String, dynamic> toJson() => {
|
||||
"code": code,
|
||||
"description": description,
|
||||
"region": region.toJson(),
|
||||
"region": region!.toJson(),
|
||||
"psgc_code": psgcCode,
|
||||
"shortname": shortname,
|
||||
};
|
||||
|
@ -104,9 +104,9 @@ class Region {
|
|||
required this.psgcCode,
|
||||
});
|
||||
|
||||
final int code;
|
||||
final String description;
|
||||
final String psgcCode;
|
||||
final int? code;
|
||||
final String? description;
|
||||
final String? psgcCode;
|
||||
|
||||
factory Region.fromJson(Map<String, dynamic> json) => Region(
|
||||
code: json["code"],
|
||||
|
|
|
@ -18,16 +18,16 @@ class City {
|
|||
required this.zipcode,
|
||||
});
|
||||
|
||||
final String code;
|
||||
final String description;
|
||||
final Province province;
|
||||
final String psgcCode;
|
||||
final String zipcode;
|
||||
final String? code;
|
||||
final String? description;
|
||||
final Province? province;
|
||||
final String? psgcCode;
|
||||
final String? zipcode;
|
||||
|
||||
factory City.fromJson(Map<String, dynamic> json) => City(
|
||||
code: json["code"],
|
||||
description: json["description"],
|
||||
province: Province.fromJson(json["province"]),
|
||||
province: json['province'] == null? null : Province.fromJson(json["province"]),
|
||||
psgcCode: json["psgc_code"],
|
||||
zipcode: json["zipcode"],
|
||||
);
|
||||
|
@ -35,7 +35,7 @@ class City {
|
|||
Map<String, dynamic> toJson() => {
|
||||
"code": code,
|
||||
"description": description,
|
||||
"province": province.toJson(),
|
||||
"province": province!.toJson(),
|
||||
"psgc_code": psgcCode,
|
||||
"zipcode": zipcode,
|
||||
};
|
||||
|
@ -50,16 +50,16 @@ class Province {
|
|||
required this.shortname,
|
||||
});
|
||||
|
||||
final String code;
|
||||
final String description;
|
||||
final Region region;
|
||||
final String psgcCode;
|
||||
final String shortname;
|
||||
final String? code;
|
||||
final String? description;
|
||||
final Region? region;
|
||||
final String? psgcCode;
|
||||
final String? shortname;
|
||||
|
||||
factory Province.fromJson(Map<String, dynamic> json) => Province(
|
||||
code: json["code"],
|
||||
description: json["description"],
|
||||
region: Region.fromJson(json["region"]),
|
||||
region: json['region'] == null ? null : Region.fromJson(json["region"]),
|
||||
psgcCode: json["psgc_code"],
|
||||
shortname: json["shortname"],
|
||||
);
|
||||
|
@ -67,7 +67,7 @@ class Province {
|
|||
Map<String, dynamic> toJson() => {
|
||||
"code": code,
|
||||
"description": description,
|
||||
"region": region.toJson(),
|
||||
"region": region!.toJson(),
|
||||
"psgc_code": psgcCode,
|
||||
"shortname": shortname,
|
||||
};
|
||||
|
@ -80,9 +80,9 @@ class Region {
|
|||
required this.psgcCode,
|
||||
});
|
||||
|
||||
final int code;
|
||||
final String description;
|
||||
final String psgcCode;
|
||||
final int? code;
|
||||
final String? description;
|
||||
final String? psgcCode;
|
||||
|
||||
factory Region.fromJson(Map<String, dynamic> json) => Region(
|
||||
code: json["code"],
|
||||
|
|
|
@ -16,14 +16,14 @@ class Country {
|
|||
required this.code,
|
||||
});
|
||||
|
||||
final int id;
|
||||
final String name;
|
||||
final String code;
|
||||
final int? id;
|
||||
final String? name;
|
||||
final String? code;
|
||||
|
||||
factory Country.fromJson(Map<String, dynamic> json) => Country(
|
||||
id: json["id"],
|
||||
name: json["name"],
|
||||
code: json["code"],
|
||||
code: json["code"].toString(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
|
|
|
@ -18,16 +18,16 @@ class Province {
|
|||
required this.shortname,
|
||||
});
|
||||
|
||||
final String code;
|
||||
final String description;
|
||||
final Region region;
|
||||
final String psgcCode;
|
||||
final String shortname;
|
||||
final String? code;
|
||||
final String? description;
|
||||
final Region? region;
|
||||
final String? psgcCode;
|
||||
final String? shortname;
|
||||
|
||||
factory Province.fromJson(Map<String, dynamic> json) => Province(
|
||||
code: json["code"],
|
||||
description: json["description"],
|
||||
region: Region.fromJson(json["region"]),
|
||||
region: json['region'] == null? null: Region.fromJson(json["region"]),
|
||||
psgcCode: json["psgc_code"],
|
||||
shortname: json["shortname"],
|
||||
);
|
||||
|
@ -35,7 +35,7 @@ class Province {
|
|||
Map<String, dynamic> toJson() => {
|
||||
"code": code,
|
||||
"description": description,
|
||||
"region": region.toJson(),
|
||||
"region": region!.toJson(),
|
||||
"psgc_code": psgcCode,
|
||||
"shortname": shortname,
|
||||
};
|
||||
|
@ -48,9 +48,9 @@ class Region {
|
|||
required this.psgcCode,
|
||||
});
|
||||
|
||||
final int code;
|
||||
final String description;
|
||||
final String psgcCode;
|
||||
final int? code;
|
||||
final String? description;
|
||||
final String? psgcCode;
|
||||
|
||||
factory Region.fromJson(Map<String, dynamic> json) => Region(
|
||||
code: json["code"],
|
||||
|
|
|
@ -16,9 +16,9 @@ class Region {
|
|||
required this.psgcCode,
|
||||
});
|
||||
|
||||
final int code;
|
||||
final String description;
|
||||
final String psgcCode;
|
||||
final int? code;
|
||||
final String? description;
|
||||
final String? psgcCode;
|
||||
|
||||
factory Region.fromJson(Map<String, dynamic> json) => Region(
|
||||
code: json["code"],
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
import 'package:meta/meta.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
Eligibilities eligibilitiesFromJson(String str) => Eligibilities.fromJson(json.decode(str));
|
||||
EligibilityList eligibilitiesFromJson(String str) => EligibilityList.fromJson(json.decode(str));
|
||||
|
||||
String eligibilitiesToJson(Eligibilities data) => json.encode(data.toJson());
|
||||
String eligibilitiesToJson(EligibilityList data) => json.encode(data.toJson());
|
||||
|
||||
class Eligibilities {
|
||||
Eligibilities({
|
||||
class EligibilityList {
|
||||
EligibilityList({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.type,
|
||||
|
@ -20,7 +20,7 @@ class Eligibilities {
|
|||
final String title;
|
||||
final String type;
|
||||
|
||||
factory Eligibilities.fromJson(Map<String, dynamic> json) => Eligibilities(
|
||||
factory EligibilityList.fromJson(Map<String, dynamic> json) => EligibilityList(
|
||||
id: json["id"],
|
||||
title: json["title"],
|
||||
type: json["type"],
|
||||
|
|
|
@ -2,10 +2,13 @@ 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:intl/intl.dart';
|
||||
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||
import 'package:unit2/bloc/user/user_bloc.dart';
|
||||
import 'package:unit2/model/profile/eligibility.dart';
|
||||
|
||||
import '../../../../model/location/country.dart' as c;
|
||||
import '../../../../theme-data.dart/btn-style.dart';
|
||||
import '../../../../theme-data.dart/colors.dart';
|
||||
import '../../../../theme-data.dart/form-style.dart';
|
||||
|
@ -14,212 +17,246 @@ import '../../../../utils/text_container.dart';
|
|||
|
||||
class EditEligibilityScreen extends StatefulWidget {
|
||||
final EligibityCert eligibityCert;
|
||||
const EditEligibilityScreen({super.key,required this.eligibityCert});
|
||||
const EditEligibilityScreen({super.key, required this.eligibityCert});
|
||||
|
||||
@override
|
||||
State<EditEligibilityScreen> createState() => _EditEligibilityScreenState();
|
||||
}
|
||||
|
||||
class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||
final formKey = GlobalKey<FormBuilderState>();
|
||||
bool overseas =false;
|
||||
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
||||
final formKey = GlobalKey<FormBuilderState>();
|
||||
bool overseas = false;
|
||||
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
||||
c.Country? selectedCountry;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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: [
|
||||
FormBuilderTextField(
|
||||
name: "eligibility",
|
||||
initialValue: widget.eligibityCert.eligibility!.title!,
|
||||
decoration:
|
||||
normalTextFieldStyle("Eligibility", "Eligibility"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(
|
||||
return BlocBuilder<UserBloc, UserState>(
|
||||
builder: (context, state) {
|
||||
if (state is UserLoggedIn) {
|
||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||
builder: (context, state) {
|
||||
if (state is EditEligibilityState) {
|
||||
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: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderTextField(
|
||||
name: 'license number',
|
||||
initialValue:
|
||||
widget.eligibityCert.licenseNumber,
|
||||
decoration: normalTextFieldStyle(
|
||||
"license number", "license number"),
|
||||
),
|
||||
FormBuilderTextField(
|
||||
name: "eligibility",
|
||||
initialValue:
|
||||
widget.eligibityCert.eligibility!.title!,
|
||||
decoration: normalTextFieldStyle(
|
||||
"Eligibility", "Eligibility"),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
height: 20,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderTextField(
|
||||
name: 'rating',
|
||||
initialValue:
|
||||
widget.eligibityCert.rating.toString(),
|
||||
decoration:
|
||||
normalTextFieldStyle('rating', 'rating'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DateTimePicker(
|
||||
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,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DateTimePicker(
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2100),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Validity date", "Validity date"),
|
||||
initialValue:
|
||||
widget.eligibityCert.validityDate == null
|
||||
? ''
|
||||
: dteFormat2.format(
|
||||
widget.eligibityCert.validityDate!),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
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) {
|
||||
setState(() {
|
||||
overseas = value!;
|
||||
});
|
||||
},
|
||||
decoration: normalTextFieldStyle("", ''),
|
||||
name: 'overseas',
|
||||
title: const Text("Overseas Address?"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
child: overseas == true
|
||||
? FormBuilderTextField(
|
||||
name: 'country',
|
||||
decoration: normalTextFieldStyle(
|
||||
"Country", "Country"),
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
FormBuilderDropdown(
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderTextField(
|
||||
name: 'license number',
|
||||
initialValue:
|
||||
widget.eligibityCert.licenseNumber,
|
||||
decoration: normalTextFieldStyle(
|
||||
"Region", "Region"),
|
||||
name: 'region',
|
||||
items: [],
|
||||
initialValue: widget
|
||||
.eligibityCert
|
||||
.examAddress
|
||||
?.cityMunicipality
|
||||
?.province
|
||||
?.region
|
||||
?.description ==
|
||||
null
|
||||
? 'region'
|
||||
: 'region',
|
||||
"license number", "license number"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderTextField(
|
||||
name: 'rating',
|
||||
initialValue: widget.eligibityCert.rating
|
||||
.toString(),
|
||||
decoration: normalTextFieldStyle(
|
||||
'rating', 'rating'),
|
||||
),
|
||||
FormBuilderDropdown(
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DateTimePicker(
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2100),
|
||||
decoration: normalTextFieldStyle(
|
||||
'Province', "Province"),
|
||||
name: 'province',
|
||||
items: [],
|
||||
"Exam date", "Exam date"),
|
||||
initialValue: widget
|
||||
.eligibityCert
|
||||
.examAddress
|
||||
?.cityMunicipality
|
||||
?.province
|
||||
?.description ==
|
||||
.eligibityCert.examDate ==
|
||||
null
|
||||
? 'region'
|
||||
: 'pprovince'),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
FormBuilderDropdown(
|
||||
? ''
|
||||
: dteFormat2.format(
|
||||
widget.eligibityCert.examDate!),
|
||||
)),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DateTimePicker(
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2100),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Municipality", "Municipality"),
|
||||
name: 'municipality',
|
||||
items: [],
|
||||
initialValue: widget
|
||||
.eligibityCert
|
||||
.examAddress
|
||||
?.cityMunicipality
|
||||
?.description ==
|
||||
null
|
||||
? 'region'
|
||||
: 'municipality',
|
||||
"Validity date", "Validity date"),
|
||||
initialValue:
|
||||
widget.eligibityCert.validityDate ==
|
||||
null
|
||||
? ''
|
||||
: dteFormat2.format(widget
|
||||
.eligibityCert.validityDate!),
|
||||
),
|
||||
],
|
||||
)),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
height: 60,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(
|
||||
primary, Colors.transparent, second),
|
||||
onPressed: () {},
|
||||
child: const Text(submit)),
|
||||
),
|
||||
const SizedBox(height: 20,),
|
||||
|
||||
]),
|
||||
),
|
||||
),
|
||||
);;
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
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) {
|
||||
setState(() {
|
||||
overseas = value!;
|
||||
});
|
||||
},
|
||||
decoration: normalTextFieldStyle("", ''),
|
||||
name: 'overseas',
|
||||
title: const Text("Overseas Address?"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
child: overseas == true
|
||||
? FormBuilderDropdown<dynamic>(
|
||||
items: state.countries
|
||||
.map<DropdownMenuItem<c.Country>>(
|
||||
(c.Country country) {
|
||||
|
||||
return DropdownMenuItem<c.Country>(
|
||||
value: country,
|
||||
child: Text(country.name!));
|
||||
}).toList(),
|
||||
name: 'country',
|
||||
decoration: normalTextFieldStyle(
|
||||
"Country", "Country"),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
selectedCountry = value;
|
||||
});
|
||||
},
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
FormBuilderDropdown(
|
||||
decoration: normalTextFieldStyle(
|
||||
"Region", "Region"),
|
||||
name: 'region',
|
||||
items: [],
|
||||
initialValue: widget
|
||||
.eligibityCert
|
||||
.examAddress
|
||||
?.cityMunicipality
|
||||
?.province
|
||||
?.region
|
||||
?.description ==
|
||||
null
|
||||
? 'region'
|
||||
: 'region',
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
FormBuilderDropdown(
|
||||
decoration: normalTextFieldStyle(
|
||||
'Province', "Province"),
|
||||
name: 'province',
|
||||
items: [],
|
||||
initialValue: widget
|
||||
.eligibityCert
|
||||
.examAddress
|
||||
?.cityMunicipality
|
||||
?.province
|
||||
?.description ==
|
||||
null
|
||||
? 'region'
|
||||
: 'pprovince'),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
FormBuilderDropdown(
|
||||
decoration: normalTextFieldStyle(
|
||||
"Municipality", "Municipality"),
|
||||
name: 'municipality',
|
||||
items: [],
|
||||
initialValue: widget
|
||||
.eligibityCert
|
||||
.examAddress
|
||||
?.cityMunicipality
|
||||
?.description ==
|
||||
null
|
||||
? 'region'
|
||||
: 'municipality',
|
||||
),
|
||||
],
|
||||
)),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
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();
|
||||
},
|
||||
);
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ import 'package:unit2/widgets/empty_data.dart';
|
|||
import '../../../utils/alerts.dart';
|
||||
|
||||
class EligibiltyScreen extends StatelessWidget {
|
||||
const EligibiltyScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:unit2/model/location/country.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:unit2/utils/request.dart';
|
||||
import 'package:unit2/utils/urls.dart';
|
||||
|
||||
import '../model/location/region.dart';
|
||||
class LocationUtils {
|
||||
static final LocationUtils _instance = LocationUtils();
|
||||
static LocationUtils get instance => _instance;
|
||||
|
||||
Future<List<Country>>getCountries()async{
|
||||
List<Country> countries=[];
|
||||
String path = Url.instance.getCounties();
|
||||
|
||||
Map<String, String> headers = {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
};
|
||||
// try{
|
||||
http.Response response = await Request.instance.getRequest(path: path, param: {},headers: headers);
|
||||
if(response.statusCode == 200){
|
||||
Map data = jsonDecode(response.body);
|
||||
if(data['data'] != null){
|
||||
data['data'].forEach((var country){
|
||||
Country newCOuntry = Country.fromJson(country);
|
||||
countries.add(newCOuntry);
|
||||
});
|
||||
}
|
||||
}
|
||||
// }catch(e){
|
||||
// throw(e.toString());
|
||||
// }
|
||||
return countries;
|
||||
}
|
||||
|
||||
|
||||
Future<List<Region>>getRegions()async{
|
||||
List<Region> regions=[];
|
||||
String path = Url.instance.getRegions();
|
||||
|
||||
Map<String, String> headers = {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
};
|
||||
// try{
|
||||
http.Response response = await Request.instance.getRequest(path: path, param: {},headers: headers);
|
||||
if(response.statusCode == 200){
|
||||
Map data = jsonDecode(response.body);
|
||||
if(data['data'] != null){
|
||||
data['data'].forEach((var region){
|
||||
Region newRegion = Region.fromJson(region);
|
||||
regions.add(newRegion);
|
||||
});
|
||||
}
|
||||
}
|
||||
// }catch(e){
|
||||
// throw(e.toString());
|
||||
// }
|
||||
return regions;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:unit2/model/location/country.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:unit2/model/location/region.dart';
|
||||
import 'package:unit2/model/utils/eligibilities_choices.dart';
|
||||
import 'package:unit2/utils/request.dart';
|
||||
import 'package:unit2/utils/urls.dart';
|
||||
class ProfileUtilities {
|
||||
static final ProfileUtilities _instance = ProfileUtilities();
|
||||
static ProfileUtilities get instance => _instance;
|
||||
|
||||
Future<List<EligibilityList>>getEligibilities()async{
|
||||
List<EligibilityList> eligibilities=[];
|
||||
String path = Url.instance.eligibilities();
|
||||
|
||||
Map<String, String> headers = {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
};
|
||||
// try{
|
||||
http.Response response = await Request.instance.getRequest(path: path, param: {},headers: headers);
|
||||
if(response.statusCode == 200){
|
||||
Map data = jsonDecode(response.body);
|
||||
if(data['data'] != null){
|
||||
data['data'].forEach((var eligibility){
|
||||
EligibilityList newEligibilities = EligibilityList.fromJson(eligibility);
|
||||
eligibilities.add(newEligibilities);
|
||||
});
|
||||
}
|
||||
}
|
||||
// }catch(e){
|
||||
// throw(e.toString());
|
||||
// }
|
||||
return eligibilities;
|
||||
}
|
||||
|
||||
}
|
|
@ -15,4 +15,15 @@ class Url {
|
|||
String profileInformation(){
|
||||
return '/api/jobnet_app/profile/pds/';
|
||||
}
|
||||
|
||||
String eligibilities(){
|
||||
return "/api/jobnet_app/eligibilities/";
|
||||
}
|
||||
// location utils path
|
||||
String getCounties(){
|
||||
return "/api/jobnet_app/countries/";
|
||||
}
|
||||
String getRegions(){
|
||||
return "/api/web_app/location/region/";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue