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/basic_information/primary-information.dart';
|
||||||
import 'package:unit2/model/profile/eligibility.dart';
|
import 'package:unit2/model/profile/eligibility.dart';
|
||||||
import 'package:unit2/model/profile/profileInfomation.dart';
|
import 'package:unit2/model/profile/profileInfomation.dart';
|
||||||
|
import 'package:unit2/model/utils/eligibilities_choices.dart';
|
||||||
import 'package:unit2/sevices/profile/profile_service.dart';
|
import 'package:unit2/sevices/profile/profile_service.dart';
|
||||||
|
import 'package:unit2/utils/location_utilities.dart';
|
||||||
|
import 'package:unit2/utils/profile_utilities.dart';
|
||||||
|
import '../../model/location/country.dart' as country;
|
||||||
|
import '../../model/location/region.dart' as region;
|
||||||
|
|
||||||
part 'profile_event.dart';
|
part 'profile_event.dart';
|
||||||
part 'profile_state.dart';
|
part 'profile_state.dart';
|
||||||
|
@ -28,8 +33,16 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
||||||
emit(ProfileLoading());
|
emit(ProfileLoading());
|
||||||
emit(EligibilityLoaded(eligibilities: event.eligibilities));
|
emit(EligibilityLoaded(eligibilities: event.eligibilities));
|
||||||
});
|
});
|
||||||
on<EditEligibility>((event, emit) {
|
on<EditEligibility>((event, emit) async{
|
||||||
emit(EditEligibilityState(eligibityCert: event.eligibityCert));
|
// 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{
|
class EditEligibilityState extends ProfileState{
|
||||||
final EligibityCert eligibityCert;
|
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
|
@override
|
||||||
List<Object> get props => [eligibityCert];
|
List<Object> get props => [eligibityCert];
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,20 +16,20 @@ class Barangay {
|
||||||
required this.cityMunicipality,
|
required this.cityMunicipality,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String code;
|
final String? code;
|
||||||
final String description;
|
final String? description;
|
||||||
final CityMunicipality cityMunicipality;
|
final CityMunicipality? cityMunicipality;
|
||||||
|
|
||||||
factory Barangay.fromJson(Map<String, dynamic> json) => Barangay(
|
factory Barangay.fromJson(Map<String, dynamic> json) => Barangay(
|
||||||
code: json["code"],
|
code: json["code"],
|
||||||
description: json["description"],
|
description: json["description"],
|
||||||
cityMunicipality: CityMunicipality.fromJson(json["city_municipality"]),
|
cityMunicipality: json['city_municipality'] == null? null: CityMunicipality.fromJson(json["city_municipality"]),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
"code": code,
|
"code": code,
|
||||||
"description": description,
|
"description": description,
|
||||||
"city_municipality": cityMunicipality.toJson(),
|
"city_municipality": cityMunicipality!.toJson(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,16 +42,16 @@ class CityMunicipality {
|
||||||
required this.zipcode,
|
required this.zipcode,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String code;
|
final String? code;
|
||||||
final String description;
|
final String? description;
|
||||||
final Province province;
|
final Province? province;
|
||||||
final String psgcCode;
|
final String? psgcCode;
|
||||||
final String zipcode;
|
final String? zipcode;
|
||||||
|
|
||||||
factory CityMunicipality.fromJson(Map<String, dynamic> json) => CityMunicipality(
|
factory CityMunicipality.fromJson(Map<String, dynamic> json) => CityMunicipality(
|
||||||
code: json["code"],
|
code: json["code"],
|
||||||
description: json["description"],
|
description: json["description"],
|
||||||
province: Province.fromJson(json["province"]),
|
province: json['province'] == null? null:Province.fromJson(json["province"]),
|
||||||
psgcCode: json["psgc_code"],
|
psgcCode: json["psgc_code"],
|
||||||
zipcode: json["zipcode"],
|
zipcode: json["zipcode"],
|
||||||
);
|
);
|
||||||
|
@ -59,7 +59,7 @@ class CityMunicipality {
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
"code": code,
|
"code": code,
|
||||||
"description": description,
|
"description": description,
|
||||||
"province": province.toJson(),
|
"province": province!.toJson(),
|
||||||
"psgc_code": psgcCode,
|
"psgc_code": psgcCode,
|
||||||
"zipcode": zipcode,
|
"zipcode": zipcode,
|
||||||
};
|
};
|
||||||
|
@ -74,16 +74,16 @@ class Province {
|
||||||
required this.shortname,
|
required this.shortname,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String code;
|
final String? code;
|
||||||
final String description;
|
final String? description;
|
||||||
final Region region;
|
final Region? region;
|
||||||
final String psgcCode;
|
final String? psgcCode;
|
||||||
final String shortname;
|
final String? shortname;
|
||||||
|
|
||||||
factory Province.fromJson(Map<String, dynamic> json) => Province(
|
factory Province.fromJson(Map<String, dynamic> json) => Province(
|
||||||
code: json["code"],
|
code: json["code"],
|
||||||
description: json["description"],
|
description: json["description"],
|
||||||
region: Region.fromJson(json["region"]),
|
region: json['region'] == null? null: Region.fromJson(json["region"]),
|
||||||
psgcCode: json["psgc_code"],
|
psgcCode: json["psgc_code"],
|
||||||
shortname: json["shortname"],
|
shortname: json["shortname"],
|
||||||
);
|
);
|
||||||
|
@ -91,7 +91,7 @@ class Province {
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
"code": code,
|
"code": code,
|
||||||
"description": description,
|
"description": description,
|
||||||
"region": region.toJson(),
|
"region": region!.toJson(),
|
||||||
"psgc_code": psgcCode,
|
"psgc_code": psgcCode,
|
||||||
"shortname": shortname,
|
"shortname": shortname,
|
||||||
};
|
};
|
||||||
|
@ -104,9 +104,9 @@ class Region {
|
||||||
required this.psgcCode,
|
required this.psgcCode,
|
||||||
});
|
});
|
||||||
|
|
||||||
final int code;
|
final int? code;
|
||||||
final String description;
|
final String? description;
|
||||||
final String psgcCode;
|
final String? psgcCode;
|
||||||
|
|
||||||
factory Region.fromJson(Map<String, dynamic> json) => Region(
|
factory Region.fromJson(Map<String, dynamic> json) => Region(
|
||||||
code: json["code"],
|
code: json["code"],
|
||||||
|
|
|
@ -18,16 +18,16 @@ class City {
|
||||||
required this.zipcode,
|
required this.zipcode,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String code;
|
final String? code;
|
||||||
final String description;
|
final String? description;
|
||||||
final Province province;
|
final Province? province;
|
||||||
final String psgcCode;
|
final String? psgcCode;
|
||||||
final String zipcode;
|
final String? zipcode;
|
||||||
|
|
||||||
factory City.fromJson(Map<String, dynamic> json) => City(
|
factory City.fromJson(Map<String, dynamic> json) => City(
|
||||||
code: json["code"],
|
code: json["code"],
|
||||||
description: json["description"],
|
description: json["description"],
|
||||||
province: Province.fromJson(json["province"]),
|
province: json['province'] == null? null : Province.fromJson(json["province"]),
|
||||||
psgcCode: json["psgc_code"],
|
psgcCode: json["psgc_code"],
|
||||||
zipcode: json["zipcode"],
|
zipcode: json["zipcode"],
|
||||||
);
|
);
|
||||||
|
@ -35,7 +35,7 @@ class City {
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
"code": code,
|
"code": code,
|
||||||
"description": description,
|
"description": description,
|
||||||
"province": province.toJson(),
|
"province": province!.toJson(),
|
||||||
"psgc_code": psgcCode,
|
"psgc_code": psgcCode,
|
||||||
"zipcode": zipcode,
|
"zipcode": zipcode,
|
||||||
};
|
};
|
||||||
|
@ -50,16 +50,16 @@ class Province {
|
||||||
required this.shortname,
|
required this.shortname,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String code;
|
final String? code;
|
||||||
final String description;
|
final String? description;
|
||||||
final Region region;
|
final Region? region;
|
||||||
final String psgcCode;
|
final String? psgcCode;
|
||||||
final String shortname;
|
final String? shortname;
|
||||||
|
|
||||||
factory Province.fromJson(Map<String, dynamic> json) => Province(
|
factory Province.fromJson(Map<String, dynamic> json) => Province(
|
||||||
code: json["code"],
|
code: json["code"],
|
||||||
description: json["description"],
|
description: json["description"],
|
||||||
region: Region.fromJson(json["region"]),
|
region: json['region'] == null ? null : Region.fromJson(json["region"]),
|
||||||
psgcCode: json["psgc_code"],
|
psgcCode: json["psgc_code"],
|
||||||
shortname: json["shortname"],
|
shortname: json["shortname"],
|
||||||
);
|
);
|
||||||
|
@ -67,7 +67,7 @@ class Province {
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
"code": code,
|
"code": code,
|
||||||
"description": description,
|
"description": description,
|
||||||
"region": region.toJson(),
|
"region": region!.toJson(),
|
||||||
"psgc_code": psgcCode,
|
"psgc_code": psgcCode,
|
||||||
"shortname": shortname,
|
"shortname": shortname,
|
||||||
};
|
};
|
||||||
|
@ -80,9 +80,9 @@ class Region {
|
||||||
required this.psgcCode,
|
required this.psgcCode,
|
||||||
});
|
});
|
||||||
|
|
||||||
final int code;
|
final int? code;
|
||||||
final String description;
|
final String? description;
|
||||||
final String psgcCode;
|
final String? psgcCode;
|
||||||
|
|
||||||
factory Region.fromJson(Map<String, dynamic> json) => Region(
|
factory Region.fromJson(Map<String, dynamic> json) => Region(
|
||||||
code: json["code"],
|
code: json["code"],
|
||||||
|
|
|
@ -16,14 +16,14 @@ class Country {
|
||||||
required this.code,
|
required this.code,
|
||||||
});
|
});
|
||||||
|
|
||||||
final int id;
|
final int? id;
|
||||||
final String name;
|
final String? name;
|
||||||
final String code;
|
final String? code;
|
||||||
|
|
||||||
factory Country.fromJson(Map<String, dynamic> json) => Country(
|
factory Country.fromJson(Map<String, dynamic> json) => Country(
|
||||||
id: json["id"],
|
id: json["id"],
|
||||||
name: json["name"],
|
name: json["name"],
|
||||||
code: json["code"],
|
code: json["code"].toString(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
|
|
|
@ -18,16 +18,16 @@ class Province {
|
||||||
required this.shortname,
|
required this.shortname,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String code;
|
final String? code;
|
||||||
final String description;
|
final String? description;
|
||||||
final Region region;
|
final Region? region;
|
||||||
final String psgcCode;
|
final String? psgcCode;
|
||||||
final String shortname;
|
final String? shortname;
|
||||||
|
|
||||||
factory Province.fromJson(Map<String, dynamic> json) => Province(
|
factory Province.fromJson(Map<String, dynamic> json) => Province(
|
||||||
code: json["code"],
|
code: json["code"],
|
||||||
description: json["description"],
|
description: json["description"],
|
||||||
region: Region.fromJson(json["region"]),
|
region: json['region'] == null? null: Region.fromJson(json["region"]),
|
||||||
psgcCode: json["psgc_code"],
|
psgcCode: json["psgc_code"],
|
||||||
shortname: json["shortname"],
|
shortname: json["shortname"],
|
||||||
);
|
);
|
||||||
|
@ -35,7 +35,7 @@ class Province {
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
"code": code,
|
"code": code,
|
||||||
"description": description,
|
"description": description,
|
||||||
"region": region.toJson(),
|
"region": region!.toJson(),
|
||||||
"psgc_code": psgcCode,
|
"psgc_code": psgcCode,
|
||||||
"shortname": shortname,
|
"shortname": shortname,
|
||||||
};
|
};
|
||||||
|
@ -48,9 +48,9 @@ class Region {
|
||||||
required this.psgcCode,
|
required this.psgcCode,
|
||||||
});
|
});
|
||||||
|
|
||||||
final int code;
|
final int? code;
|
||||||
final String description;
|
final String? description;
|
||||||
final String psgcCode;
|
final String? psgcCode;
|
||||||
|
|
||||||
factory Region.fromJson(Map<String, dynamic> json) => Region(
|
factory Region.fromJson(Map<String, dynamic> json) => Region(
|
||||||
code: json["code"],
|
code: json["code"],
|
||||||
|
|
|
@ -16,9 +16,9 @@ class Region {
|
||||||
required this.psgcCode,
|
required this.psgcCode,
|
||||||
});
|
});
|
||||||
|
|
||||||
final int code;
|
final int? code;
|
||||||
final String description;
|
final String? description;
|
||||||
final String psgcCode;
|
final String? psgcCode;
|
||||||
|
|
||||||
factory Region.fromJson(Map<String, dynamic> json) => Region(
|
factory Region.fromJson(Map<String, dynamic> json) => Region(
|
||||||
code: json["code"],
|
code: json["code"],
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
import 'dart:convert';
|
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 {
|
class EligibilityList {
|
||||||
Eligibilities({
|
EligibilityList({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.type,
|
required this.type,
|
||||||
|
@ -20,7 +20,7 @@ class Eligibilities {
|
||||||
final String title;
|
final String title;
|
||||||
final String type;
|
final String type;
|
||||||
|
|
||||||
factory Eligibilities.fromJson(Map<String, dynamic> json) => Eligibilities(
|
factory EligibilityList.fromJson(Map<String, dynamic> json) => EligibilityList(
|
||||||
id: json["id"],
|
id: json["id"],
|
||||||
title: json["title"],
|
title: json["title"],
|
||||||
type: json["type"],
|
type: json["type"],
|
||||||
|
|
|
@ -2,10 +2,13 @@ import 'package:date_time_picker/date_time_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/src/widgets/framework.dart';
|
import 'package:flutter/src/widgets/framework.dart';
|
||||||
import 'package:flutter/src/widgets/placeholder.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_form_builder/flutter_form_builder.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||||
|
import 'package:unit2/bloc/user/user_bloc.dart';
|
||||||
import 'package:unit2/model/profile/eligibility.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/btn-style.dart';
|
||||||
import '../../../../theme-data.dart/colors.dart';
|
import '../../../../theme-data.dart/colors.dart';
|
||||||
import '../../../../theme-data.dart/form-style.dart';
|
import '../../../../theme-data.dart/form-style.dart';
|
||||||
|
@ -24,11 +27,19 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
final formKey = GlobalKey<FormBuilderState>();
|
final formKey = GlobalKey<FormBuilderState>();
|
||||||
bool overseas = false;
|
bool overseas = false;
|
||||||
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
||||||
|
c.Country? selectedCountry;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return BlocBuilder<UserBloc, UserState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
if (state is UserLoggedIn) {
|
||||||
|
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
if (state is EditEligibilityState) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 18),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 25, horizontal: 18),
|
||||||
child: FormBuilder(
|
child: FormBuilder(
|
||||||
key: formKey,
|
key: formKey,
|
||||||
child: Column(
|
child: Column(
|
||||||
|
@ -37,9 +48,10 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
children: [
|
children: [
|
||||||
FormBuilderTextField(
|
FormBuilderTextField(
|
||||||
name: "eligibility",
|
name: "eligibility",
|
||||||
initialValue: widget.eligibityCert.eligibility!.title!,
|
initialValue:
|
||||||
decoration:
|
widget.eligibityCert.eligibility!.title!,
|
||||||
normalTextFieldStyle("Eligibility", "Eligibility"),
|
decoration: normalTextFieldStyle(
|
||||||
|
"Eligibility", "Eligibility"),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
|
@ -65,10 +77,10 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: FormBuilderTextField(
|
child: FormBuilderTextField(
|
||||||
name: 'rating',
|
name: 'rating',
|
||||||
initialValue:
|
initialValue: widget.eligibityCert.rating
|
||||||
widget.eligibityCert.rating.toString(),
|
.toString(),
|
||||||
decoration:
|
decoration: normalTextFieldStyle(
|
||||||
normalTextFieldStyle('rating', 'rating'),
|
'rating', 'rating'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -88,8 +100,9 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
lastDate: DateTime(2100),
|
lastDate: DateTime(2100),
|
||||||
decoration: normalTextFieldStyle(
|
decoration: normalTextFieldStyle(
|
||||||
"Exam date", "Exam date"),
|
"Exam date", "Exam date"),
|
||||||
initialValue:
|
initialValue: widget
|
||||||
widget.eligibityCert.examDate == null
|
.eligibityCert.examDate ==
|
||||||
|
null
|
||||||
? ''
|
? ''
|
||||||
: dteFormat2.format(
|
: dteFormat2.format(
|
||||||
widget.eligibityCert.examDate!),
|
widget.eligibityCert.examDate!),
|
||||||
|
@ -105,10 +118,11 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
decoration: normalTextFieldStyle(
|
decoration: normalTextFieldStyle(
|
||||||
"Validity date", "Validity date"),
|
"Validity date", "Validity date"),
|
||||||
initialValue:
|
initialValue:
|
||||||
widget.eligibityCert.validityDate == null
|
widget.eligibityCert.validityDate ==
|
||||||
|
null
|
||||||
? ''
|
? ''
|
||||||
: dteFormat2.format(
|
: dteFormat2.format(widget
|
||||||
widget.eligibityCert.validityDate!),
|
.eligibityCert.validityDate!),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -144,10 +158,23 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
child: overseas == true
|
child: overseas == true
|
||||||
? FormBuilderTextField(
|
? 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',
|
name: 'country',
|
||||||
decoration: normalTextFieldStyle(
|
decoration: normalTextFieldStyle(
|
||||||
"Country", "Country"),
|
"Country", "Country"),
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
selectedCountry = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
)
|
)
|
||||||
: Column(
|
: Column(
|
||||||
children: [
|
children: [
|
||||||
|
@ -215,11 +242,21 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
child: const Text(submit)),
|
child: const Text(submit)),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20,),
|
const SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);;
|
);
|
||||||
|
}
|
||||||
|
return Container();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Container();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,6 +18,8 @@ import 'package:unit2/widgets/empty_data.dart';
|
||||||
import '../../../utils/alerts.dart';
|
import '../../../utils/alerts.dart';
|
||||||
|
|
||||||
class EligibiltyScreen extends StatelessWidget {
|
class EligibiltyScreen extends StatelessWidget {
|
||||||
|
const EligibiltyScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
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(){
|
String profileInformation(){
|
||||||
return '/api/jobnet_app/profile/pds/';
|
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