forked from cyrilaquismundo/passo_mobile_app
Implement Basic Information Identification API
parent
bfe1ee538b
commit
d8efeffd8c
|
@ -9,14 +9,110 @@ part 'family_state.dart';
|
|||
|
||||
class FamilyBloc extends Bloc<FamilyEvent, FamilyState> {
|
||||
FamilyBloc() : super(FamilyInitial()) {
|
||||
List<FamilyBackground> families = [];
|
||||
on<GetFamilies>((event, emit) async{
|
||||
List<FamilyBackground> families = [];
|
||||
on<GetFamilies>((event, emit) async {
|
||||
emit(FamilyLoadingState());
|
||||
try{
|
||||
List<FamilyBackground> family = await FamilyService.instance.getFamilies(event.profileId, event.token);
|
||||
try {
|
||||
emit(FamilyLoadingState());
|
||||
List<FamilyBackground> family = await FamilyService.instance
|
||||
.getFamilies(event.profileId, event.token);
|
||||
families = family;
|
||||
emit(FamilyLoaded(families: families));
|
||||
}catch(e){
|
||||
} catch (e) {
|
||||
emit(FamilyErrorState(message: e.toString()));
|
||||
}
|
||||
////Load
|
||||
on<LoadFamily>((event, emit) {
|
||||
emit(FamilyLoaded(families: families));
|
||||
});
|
||||
////Add Family
|
||||
});
|
||||
on<AddFamily>((event, emit) async {
|
||||
try {
|
||||
emit(FamilyLoadingState());
|
||||
Map<dynamic, dynamic> status = await FamilyService.instance.add(
|
||||
family: event.familyBackground,
|
||||
relationshipId: event.relationshipId,
|
||||
profileId: event.profileId,
|
||||
token: event.token);
|
||||
if (status['success']) {
|
||||
FamilyBackground familyBackground =
|
||||
FamilyBackground.fromJson(status['data']);
|
||||
families.add(familyBackground);
|
||||
emit(FamilyAddedState(response: status));
|
||||
} else {
|
||||
emit(FamilyAddedState(response: status));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(FamilyErrorState(message: e.toString()));
|
||||
}
|
||||
});
|
||||
//// Add Emergency
|
||||
on<AddEmergencyEvent>((event, emit) async {
|
||||
try {
|
||||
emit(FamilyLoadingState());
|
||||
Map<dynamic, dynamic> status = await FamilyService.instance
|
||||
.addEmergency(
|
||||
requestType: event.requestType,
|
||||
relatedPersonId: event.relatedPersonId,
|
||||
numberMail: event.numberMail,
|
||||
contactInfoId: event.contactInfoId,
|
||||
profileId: event.profileId,
|
||||
token: event.token);
|
||||
if (status['success']) {
|
||||
families.removeWhere(
|
||||
(element) => element.relatedPerson!.id == event.relatedPersonId);
|
||||
FamilyBackground familyBackground =
|
||||
FamilyBackground.fromJson(status['data']);
|
||||
families.add(familyBackground);
|
||||
emit(EmergencyContactEditedState(response: status));
|
||||
} else {
|
||||
emit(EmergencyContactEditedState(response: status));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(FamilyErrorState(message: e.toString()));
|
||||
}
|
||||
});
|
||||
////update
|
||||
on<Updatefamily>((event, emit) async {
|
||||
try {
|
||||
emit(FamilyLoadingState());
|
||||
Map<dynamic, dynamic> status = await FamilyService.instance.update(
|
||||
family: event.familyBackground,
|
||||
relationshipId: event.relationshipId,
|
||||
profileId: event.profileId,
|
||||
token: event.token);
|
||||
if (status['success']) {
|
||||
families.removeWhere((element) =>
|
||||
element.relatedPerson!.id ==
|
||||
event.familyBackground.relatedPerson!.id);
|
||||
FamilyBackground familyBackground =
|
||||
FamilyBackground.fromJson(status['data']);
|
||||
families.add(familyBackground);
|
||||
emit(FamilyEditedState(response: status));
|
||||
} else {
|
||||
emit(FamilyEditedState(response: status));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(FamilyErrorState(message: e.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
////Delete
|
||||
on<DeleteFamily>((event, emit) async {
|
||||
try {
|
||||
final bool success = await FamilyService.instance.delete(
|
||||
personRelatedId: event.id,
|
||||
profileId: event.profileId,
|
||||
token: event.token);
|
||||
if (success) {
|
||||
families
|
||||
.removeWhere((element) => element.relatedPerson!.id == event.id);
|
||||
emit(DeletedState(success: success));
|
||||
} else {
|
||||
emit(DeletedState(success: success));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(FamilyErrorState(message: e.toString()));
|
||||
}
|
||||
});
|
||||
|
|
|
@ -15,3 +15,52 @@ class GetFamilies extends FamilyEvent{
|
|||
@override
|
||||
List<Object> get props => [profileId,token];
|
||||
}
|
||||
|
||||
class LoadFamily extends FamilyEvent{
|
||||
|
||||
}
|
||||
|
||||
class ShowEditFamilyForm extends FamilyEvent{
|
||||
final FamilyBackground familyBackground;
|
||||
const ShowEditFamilyForm({required this.familyBackground});
|
||||
@override
|
||||
List<Object> get props => [familyBackground];
|
||||
|
||||
}
|
||||
class AddFamily extends FamilyEvent{
|
||||
final int profileId;
|
||||
final String token;
|
||||
final int relationshipId;
|
||||
final FamilyBackground familyBackground;
|
||||
const AddFamily({required this.familyBackground, required this.profileId, required this.token, required this.relationshipId});
|
||||
@override
|
||||
List<Object> get props => [profileId,token,familyBackground];
|
||||
}
|
||||
class Updatefamily extends FamilyEvent{
|
||||
final int profileId;
|
||||
final String token;
|
||||
final int relationshipId;
|
||||
|
||||
final FamilyBackground familyBackground;
|
||||
const Updatefamily({required this.familyBackground, required this.profileId, required this.token, required this.relationshipId,});
|
||||
@override
|
||||
List<Object> get props => [profileId,token,familyBackground];
|
||||
}
|
||||
|
||||
class DeleteFamily extends FamilyEvent{
|
||||
final int id;
|
||||
final int profileId;
|
||||
final String token;
|
||||
const DeleteFamily({required this.id, required this.profileId, required this.token});
|
||||
}
|
||||
class AddEmergencyEvent extends FamilyEvent{
|
||||
final int profileId;
|
||||
final int relatedPersonId;
|
||||
final int? contactInfoId;
|
||||
final String token;
|
||||
final String? numberMail;
|
||||
final String requestType;
|
||||
const AddEmergencyEvent({required this.contactInfoId, required this.numberMail, required this.profileId, required this.relatedPersonId, required this.token, required this.requestType});
|
||||
@override
|
||||
List<Object> get props => [profileId,token,relatedPersonId];
|
||||
}
|
||||
|
|
|
@ -10,13 +10,35 @@ abstract class FamilyState extends Equatable {
|
|||
class FamilyInitial extends FamilyState {}
|
||||
|
||||
class FamilyLoaded extends FamilyState{
|
||||
final List<FamilyBackground> families;
|
||||
final List<FamilyBackground>? families;
|
||||
const FamilyLoaded({required this.families});
|
||||
|
||||
@override
|
||||
List<Object> get props => [families];
|
||||
}
|
||||
|
||||
}
|
||||
class DeletedState extends FamilyState {
|
||||
final bool success;
|
||||
const DeletedState({required this.success});
|
||||
@override
|
||||
List<Object> get props => [success];
|
||||
}
|
||||
class FamilyAddedState extends FamilyState{
|
||||
final Map<dynamic,dynamic> response;
|
||||
const FamilyAddedState({required this.response});
|
||||
@override
|
||||
List<Object> get props => [response];
|
||||
}
|
||||
class EmergencyContactEditedState extends FamilyState{
|
||||
final Map<dynamic,dynamic> response;
|
||||
const EmergencyContactEditedState({required this.response});
|
||||
@override
|
||||
List<Object> get props => [response];
|
||||
}
|
||||
class FamilyEditedState extends FamilyState{
|
||||
final Map<dynamic,dynamic> response;
|
||||
const FamilyEditedState({required this.response});
|
||||
@override
|
||||
List<Object> get props => [response];
|
||||
}
|
||||
class FamilyErrorState extends FamilyState{
|
||||
final String message;
|
||||
const FamilyErrorState({required this.message});
|
||||
|
|
|
@ -1,21 +1,207 @@
|
|||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:unit2/bloc/profile/primary_information/contact/contact_bloc.dart';
|
||||
import 'package:unit2/screens/profile/components/basic_information/identification/edit_modal.dart';
|
||||
import 'package:unit2/sevices/profile/identification_services.dart';
|
||||
|
||||
import '../../../../model/location/city.dart';
|
||||
import '../../../../model/location/country.dart';
|
||||
import '../../../../model/location/provinces.dart';
|
||||
import '../../../../model/location/region.dart';
|
||||
import '../../../../model/profile/basic_information/identification_information.dart';
|
||||
import '../../../../model/utils/agency.dart';
|
||||
import '../../../../model/utils/category.dart';
|
||||
import '../../../../utils/location_utilities.dart';
|
||||
import '../../../../utils/profile_utilities.dart';
|
||||
|
||||
part 'identification_event.dart';
|
||||
part 'identification_state.dart';
|
||||
|
||||
class IdentificationBloc extends Bloc<IdentificationEvent, IdentificationState> {
|
||||
class IdentificationBloc
|
||||
extends Bloc<IdentificationEvent, IdentificationState> {
|
||||
IdentificationBloc() : super(IdentificationInitial()) {
|
||||
List<Identification> identificationInformations = [];
|
||||
List<Identification> identificationInformations = [];
|
||||
List<Agency> agencies = [];
|
||||
List<Agency> addedAgencies = [];
|
||||
List<Category> agencyCategory = [];
|
||||
List<Country> globalCountries = [];
|
||||
List<Region> globalRegions = [];
|
||||
List<Province> provinces = [];
|
||||
List<CityMunicipality> cities = [];
|
||||
Region? currentRegion;
|
||||
Country currentCountry;
|
||||
Province? currentProvince;
|
||||
CityMunicipality? currentCity;
|
||||
////get
|
||||
on<GetIdentifications>((event, emit) {
|
||||
try{
|
||||
try {
|
||||
identificationInformations = event.identificationInformation;
|
||||
emit(IdentificationLoadedState(identificationInformation: identificationInformations));
|
||||
}catch(e){
|
||||
emit(IdentificationLoadedState(
|
||||
identificationInformation: identificationInformations));
|
||||
} catch (e) {
|
||||
emit(IdenficationErrorState(message: e.toString()));
|
||||
}
|
||||
});
|
||||
////load
|
||||
on<LoadIdentifications>((event, emit) {
|
||||
emit(IdentificationLoadedState(
|
||||
identificationInformation: identificationInformations));
|
||||
});
|
||||
//// show add form
|
||||
on<ShowAddIdentificationForm>((event, emit) async {
|
||||
addedAgencies.clear();
|
||||
try {
|
||||
emit(IdentificationLoadingState());
|
||||
if (identificationInformations.isNotEmpty) {
|
||||
for (var element in identificationInformations) {
|
||||
addedAgencies.add(element.agency!);
|
||||
}
|
||||
}
|
||||
/////AGENCIES------------------------------------------
|
||||
if (agencies.isEmpty) {
|
||||
List<Agency> newAgencies =
|
||||
await ProfileUtilities.instance.getAgecies();
|
||||
agencies = newAgencies;
|
||||
}
|
||||
/////Category Agency------------------------------------------
|
||||
if (agencyCategory.isEmpty) {
|
||||
List<Category> categoryAgencies =
|
||||
await ProfileUtilities.instance.agencyCategory();
|
||||
agencyCategory = categoryAgencies;
|
||||
}
|
||||
////regions
|
||||
if (globalRegions.isEmpty) {
|
||||
List<Region> regions = await LocationUtils.instance.getRegions();
|
||||
globalRegions = regions;
|
||||
}
|
||||
//// country
|
||||
if (globalCountries.isEmpty) {
|
||||
List<Country> countries = await LocationUtils.instance.getCountries();
|
||||
globalCountries = countries;
|
||||
}
|
||||
emit(IdentificationAddingState(
|
||||
addedAgencies: addedAgencies,
|
||||
agencyCategory: agencyCategory,
|
||||
agencies: agencies,
|
||||
countries: globalCountries,
|
||||
regions: globalRegions));
|
||||
} catch (e) {
|
||||
emit(IdenficationErrorState(message: e.toString()));
|
||||
}
|
||||
});
|
||||
////show edit form
|
||||
on<ShowEditIdentificationForm>((event, emit) async {
|
||||
try {
|
||||
////regions
|
||||
if (globalRegions.isEmpty) {
|
||||
List<Region> regions = await LocationUtils.instance.getRegions();
|
||||
globalRegions = regions;
|
||||
}
|
||||
//// country
|
||||
if (globalCountries.isEmpty) {
|
||||
List<Country> countries = await LocationUtils.instance.getCountries();
|
||||
globalCountries = countries;
|
||||
}
|
||||
currentCountry = globalCountries.firstWhere((Country country) =>
|
||||
event.identification.issuedAt!.country!.code == country.code);
|
||||
if (!event.overseas) {
|
||||
currentRegion = globalRegions.firstWhere((Region region) =>
|
||||
event.identification.issuedAt!.cityMunicipality!.province!.region!
|
||||
.code ==
|
||||
region.code);
|
||||
provinces = await LocationUtils.instance
|
||||
.getProvinces(regionCode: currentRegion!.code.toString());
|
||||
currentProvince = provinces.firstWhere((Province province) =>
|
||||
event.identification.issuedAt!.cityMunicipality!.province!.code ==
|
||||
province.code);
|
||||
|
||||
cities = await LocationUtils.instance
|
||||
.getCities(code: currentProvince!.code.toString());
|
||||
|
||||
currentCity = cities.firstWhere((CityMunicipality cityMunicipality) =>
|
||||
event.identification.issuedAt!.cityMunicipality!.code ==
|
||||
cityMunicipality.code);
|
||||
}
|
||||
emit(IdentificationEditingState(
|
||||
cities: cities,
|
||||
countries: globalCountries,
|
||||
currentCity: currentCity,
|
||||
currentCountry: currentCountry,
|
||||
currentProvince: currentProvince,
|
||||
currentRegion: currentRegion,
|
||||
identification: event.identification,
|
||||
overseas: event.overseas,
|
||||
provinces: provinces,
|
||||
regions: globalRegions));
|
||||
} catch (e) {
|
||||
emit(IdenficationErrorState(message: e.toString()));
|
||||
}
|
||||
});
|
||||
////add
|
||||
on<AddIdentification>((event, emit) async {
|
||||
try {
|
||||
emit(IdentificationLoadingState());
|
||||
Map<dynamic, dynamic> status = await IdentificationServices.instance
|
||||
.add(
|
||||
identification: event.identification,
|
||||
profileId: event.profileId,
|
||||
token: event.token);
|
||||
if (status['success']) {
|
||||
Identification identification =
|
||||
Identification.fromJson(status['data']);
|
||||
identificationInformations.add(identification);
|
||||
emit(IdentificationAddedState(response: status));
|
||||
} else {
|
||||
emit(IdentificationAddedState(response: status));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(IdenficationErrorState(message: e.toString()));
|
||||
}
|
||||
});
|
||||
////update
|
||||
on<UpdateIdentifaction>((event, emit) async {
|
||||
try {
|
||||
emit(IdentificationLoadingState());
|
||||
Map<dynamic, dynamic> status = await IdentificationServices.instance
|
||||
.update(
|
||||
identification: event.identification,
|
||||
profileId: event.profileId,
|
||||
token: event.token);
|
||||
if (status['success']) {
|
||||
identificationInformations
|
||||
.removeWhere((element) => element.id == event.identification.id);
|
||||
Identification identification =
|
||||
Identification.fromJson(status['data']);
|
||||
identificationInformations.add(identification);
|
||||
emit(IdentificationEditedState(response: status));
|
||||
} else {
|
||||
emit(IdentificationEditedState(response: status));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(IdenficationErrorState(message: e.toString()));
|
||||
}
|
||||
});
|
||||
////delete
|
||||
on<DeleteIdentification>((event, emit) async {
|
||||
try {
|
||||
final bool success = await IdentificationServices.instance.delete(
|
||||
identificationId: event.identificationId,
|
||||
token: event.token,
|
||||
profileId: event.profileId);
|
||||
if (success) {
|
||||
identificationInformations.removeWhere(
|
||||
(Identification element) => element.id == event.identificationId);
|
||||
emit(IdentificationDeletedState(success: success));
|
||||
} else {
|
||||
emit(IdentificationDeletedState(success: success));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(IdenficationErrorState(message: e.toString()));
|
||||
}
|
||||
});
|
||||
////show error state
|
||||
on<ShowErrorState>((event, emit) {
|
||||
emit(IdenficationErrorState(message: event.message));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,63 @@ abstract class IdentificationEvent extends Equatable {
|
|||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
////get
|
||||
class GetIdentifications extends IdentificationEvent{
|
||||
final List<Identification> identificationInformation;
|
||||
const GetIdentifications({required this.identificationInformation});
|
||||
@override
|
||||
List<Object> get props => [identificationInformation];
|
||||
}
|
||||
////load
|
||||
class LoadIdentifications extends IdentificationEvent{
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
////show add form
|
||||
class ShowAddIdentificationForm extends IdentificationEvent{
|
||||
|
||||
}
|
||||
//// show edit form
|
||||
class ShowEditIdentificationForm extends IdentificationEvent{
|
||||
final bool overseas;
|
||||
final Identification identification;
|
||||
final int profileId;
|
||||
final String token;
|
||||
const ShowEditIdentificationForm({required this.identification, required this.profileId, required this.token, required this.overseas});
|
||||
@override
|
||||
List<Object> get props => [identification,profileId,token,overseas];
|
||||
}
|
||||
class DeleteIdentification extends IdentificationEvent{
|
||||
final int identificationId;
|
||||
final int profileId;
|
||||
final String token;
|
||||
const DeleteIdentification({required this.identificationId, required this.profileId, required this.token});
|
||||
|
||||
}
|
||||
|
||||
//// add
|
||||
class AddIdentification extends IdentificationEvent{
|
||||
final Identification identification;
|
||||
final int profileId;
|
||||
final String token;
|
||||
const AddIdentification({required this.identification, required this.profileId, required this.token});
|
||||
@override
|
||||
List<Object> get props => [identification,profileId,token];
|
||||
}
|
||||
|
||||
//// update
|
||||
class UpdateIdentifaction extends IdentificationEvent{
|
||||
final Identification identification;
|
||||
final int profileId;
|
||||
final String token;
|
||||
const UpdateIdentifaction({required this.identification, required this.profileId, required this.token});
|
||||
@override
|
||||
List<Object> get props => [identification,profileId,token];
|
||||
}
|
||||
|
||||
class ShowErrorState extends IdentificationEvent {
|
||||
final String message;
|
||||
const ShowErrorState({required this.message});
|
||||
}
|
||||
|
||||
|
|
|
@ -26,3 +26,49 @@ class IdenficationErrorState extends IdentificationState{
|
|||
class IdentificationLoadingState extends IdentificationState{
|
||||
|
||||
}
|
||||
class IdentificationDeletedState extends IdentificationState{
|
||||
final bool success;
|
||||
const IdentificationDeletedState({required this.success});
|
||||
@override
|
||||
List<Object> get props => [success];
|
||||
}
|
||||
|
||||
class IdentificationAddedState extends IdentificationState{
|
||||
final Map<dynamic,dynamic> response;
|
||||
const IdentificationAddedState({required this.response});
|
||||
@override
|
||||
List<Object> get props => [response];
|
||||
}
|
||||
|
||||
class IdentificationEditedState extends IdentificationState{
|
||||
final Map<dynamic,dynamic> response;
|
||||
const IdentificationEditedState({required this.response});
|
||||
@override
|
||||
List<Object> get props => [response];
|
||||
}
|
||||
|
||||
class IdentificationAddingState extends IdentificationState{
|
||||
final List<Agency> agencies;
|
||||
final List<Agency> addedAgencies;
|
||||
final List<Country> countries;
|
||||
final List<Region> regions;
|
||||
final List<Category> agencyCategory;
|
||||
const IdentificationAddingState({required this.agencies, required this.countries, required this.regions,required this.agencyCategory, required this.addedAgencies});
|
||||
@override
|
||||
List<Object> get props => [agencies,countries,regions,agencyCategory];
|
||||
}
|
||||
|
||||
class IdentificationEditingState extends IdentificationState{
|
||||
final Identification identification;
|
||||
final List<Country> countries;
|
||||
final List<Region> regions;
|
||||
final List<Province> provinces;
|
||||
final List<CityMunicipality> cities;
|
||||
final Region? currentRegion;
|
||||
final Country currentCountry;
|
||||
final Province? currentProvince;
|
||||
final CityMunicipality? currentCity;
|
||||
final bool overseas;
|
||||
const IdentificationEditingState({required this.cities,required this.countries, required this.currentCity, required this.currentCountry, required this.currentProvince, required this.currentRegion, required this.identification, required this.overseas, required this.provinces, required this.regions});
|
||||
|
||||
}
|
||||
|
|
|
@ -8,105 +8,122 @@ import 'dart:ffi';
|
|||
import '../utils/category.dart';
|
||||
import '../utils/position.dart';
|
||||
|
||||
FamilyBackground familyBackgroundFromJson(String str) => FamilyBackground.fromJson(json.decode(str));
|
||||
FamilyBackground familyBackgroundFromJson(String str) =>
|
||||
FamilyBackground.fromJson(json.decode(str));
|
||||
|
||||
String familyBackgroundToJson(FamilyBackground data) => json.encode(data.toJson());
|
||||
String familyBackgroundToJson(FamilyBackground data) =>
|
||||
json.encode(data.toJson());
|
||||
|
||||
class FamilyBackground {
|
||||
FamilyBackground({
|
||||
this.company,
|
||||
this.position,
|
||||
this.relationship,
|
||||
this.relatedPerson,
|
||||
this.companyAddress,
|
||||
this.emergencyContact,
|
||||
this.incaseOfEmergency,
|
||||
this.companyContactNumber,
|
||||
});
|
||||
FamilyBackground({
|
||||
this.company,
|
||||
this.position,
|
||||
this.relationship,
|
||||
this.relatedPerson,
|
||||
this.companyAddress,
|
||||
this.emergencyContact,
|
||||
this.incaseOfEmergency,
|
||||
this.companyContactNumber,
|
||||
});
|
||||
|
||||
final Company? company;
|
||||
final Position? position;
|
||||
final Relationship? relationship;
|
||||
final RelatedPerson? relatedPerson;
|
||||
final String? companyAddress;
|
||||
final List<EmergencyContact>? emergencyContact;
|
||||
final bool? incaseOfEmergency;
|
||||
final String? companyContactNumber;
|
||||
final Company? company;
|
||||
final Position? position;
|
||||
final Relationship? relationship;
|
||||
final RelatedPerson? relatedPerson;
|
||||
final String? companyAddress;
|
||||
final List<EmergencyContact>? emergencyContact;
|
||||
final bool? incaseOfEmergency;
|
||||
final String? companyContactNumber;
|
||||
|
||||
factory FamilyBackground.fromJson(Map<String, dynamic> json) => FamilyBackground(
|
||||
company: json["company"] == null ? null : Company.fromJson(json["company"]),
|
||||
position: json["position"] == null ? null : Position.fromJson(json["position"]),
|
||||
relationship: json["relationship"] == null ? null : Relationship.fromJson(json["relationship"]),
|
||||
relatedPerson: json["related_person"] == null ? null : RelatedPerson.fromJson(json["related_person"]),
|
||||
factory FamilyBackground.fromJson(Map<String, dynamic> json) =>
|
||||
FamilyBackground(
|
||||
company:
|
||||
json["company"] == null ? null : Company.fromJson(json["company"]),
|
||||
position: json["position"] == null
|
||||
? null
|
||||
: Position.fromJson(json["position"]),
|
||||
relationship: json["relationship"] == null
|
||||
? null
|
||||
: Relationship.fromJson(json["relationship"]),
|
||||
relatedPerson: json["related_person"] == null
|
||||
? null
|
||||
: RelatedPerson.fromJson(json["related_person"]),
|
||||
companyAddress: json["company_address"],
|
||||
emergencyContact: json["emergency_contact"] == null ? [] : List<EmergencyContact>.from(json["emergency_contact"]!.map((x) => EmergencyContact.fromJson(x))),
|
||||
emergencyContact: json["emergency_contact"] == null
|
||||
? []
|
||||
: List<EmergencyContact>.from(json["emergency_contact"]!
|
||||
.map((x) => EmergencyContact.fromJson(x))),
|
||||
incaseOfEmergency: json["incase_of_emergency"],
|
||||
companyContactNumber: json["company_contact_number"],
|
||||
);
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
Map<String, dynamic> toJson() => {
|
||||
"company": company?.toJson(),
|
||||
"position": position?.toJson(),
|
||||
"relationship": relationship?.toJson(),
|
||||
"related_person": relatedPerson?.toJson(),
|
||||
"company_address": companyAddress,
|
||||
"emergency_contact": emergencyContact == null ? [] : List<dynamic>.from(emergencyContact!.map((x) => x.toJson())),
|
||||
"emergency_contact": emergencyContact == null
|
||||
? []
|
||||
: List<dynamic>.from(emergencyContact!.map((x) => x.toJson())),
|
||||
"incase_of_emergency": incaseOfEmergency,
|
||||
"company_contact_number": companyContactNumber,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
class Company {
|
||||
Company({
|
||||
this.id,
|
||||
this.name,
|
||||
this.category,
|
||||
this.privateEntity,
|
||||
});
|
||||
Company({
|
||||
this.id,
|
||||
this.name,
|
||||
this.category,
|
||||
this.privateEntity,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final String? name;
|
||||
final Category? category;
|
||||
final bool? privateEntity;
|
||||
final int? id;
|
||||
final String? name;
|
||||
final Category? category;
|
||||
final bool? privateEntity;
|
||||
|
||||
factory Company.fromJson(Map<String, dynamic> json) => Company(
|
||||
factory Company.fromJson(Map<String, dynamic> json) => Company(
|
||||
id: json["id"],
|
||||
name: json["name"],
|
||||
category: json["category"] == null ? null : Category.fromJson(json["category"]),
|
||||
category: json["category"] == null
|
||||
? null
|
||||
: Category.fromJson(json["category"]),
|
||||
privateEntity: json["private_entity"],
|
||||
);
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"category": category?.toJson(),
|
||||
"private_entity": privateEntity,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
class EmergencyContact {
|
||||
EmergencyContact({
|
||||
this.telco,
|
||||
this.isactive,
|
||||
this.provider,
|
||||
this.isprimary,
|
||||
this.numbermail,
|
||||
this.serviceType,
|
||||
this.contactinfoid,
|
||||
this.commServiceId,
|
||||
});
|
||||
EmergencyContact({
|
||||
this.telco,
|
||||
this.isactive,
|
||||
this.provider,
|
||||
this.isprimary,
|
||||
this.numbermail,
|
||||
this.serviceType,
|
||||
this.contactinfoid,
|
||||
this.commServiceId,
|
||||
});
|
||||
|
||||
final String? telco;
|
||||
final bool? isactive;
|
||||
final int? provider;
|
||||
final bool? isprimary;
|
||||
final String? numbermail;
|
||||
final int? serviceType;
|
||||
final int? contactinfoid;
|
||||
final int? commServiceId;
|
||||
final String? telco;
|
||||
final bool? isactive;
|
||||
final int? provider;
|
||||
final bool? isprimary;
|
||||
final String? numbermail;
|
||||
final int? serviceType;
|
||||
final int? contactinfoid;
|
||||
final int? commServiceId;
|
||||
|
||||
factory EmergencyContact.fromJson(Map<String, dynamic> json) => EmergencyContact(
|
||||
factory EmergencyContact.fromJson(Map<String, dynamic> json) =>
|
||||
EmergencyContact(
|
||||
telco: json["telco"],
|
||||
isactive: json["isactive"],
|
||||
provider: json["provider"],
|
||||
|
@ -115,9 +132,9 @@ class EmergencyContact {
|
|||
serviceType: json["service_type"],
|
||||
contactinfoid: json["contactinfoid"],
|
||||
commServiceId: json["comm_service_id"],
|
||||
);
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
Map<String, dynamic> toJson() => {
|
||||
"telco": telco,
|
||||
"isactive": isactive,
|
||||
"provider": provider,
|
||||
|
@ -126,69 +143,76 @@ class EmergencyContact {
|
|||
"service_type": serviceType,
|
||||
"contactinfoid": contactinfoid,
|
||||
"comm_service_id": commServiceId,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
class RelatedPerson {
|
||||
RelatedPerson({
|
||||
this.id,
|
||||
this.sex,
|
||||
this.gender,
|
||||
this.deceased,
|
||||
this.heightM,
|
||||
this.birthdate,
|
||||
this.esigPath,
|
||||
this.lastName,
|
||||
this.weightKg,
|
||||
this.bloodType,
|
||||
this.firstName,
|
||||
this.photoPath,
|
||||
this.maidenName,
|
||||
this.middleName,
|
||||
this.uuidQrcode,
|
||||
this.civilStatus,
|
||||
this.titlePrefix,
|
||||
this.titleSuffix,
|
||||
this.showTitleId,
|
||||
this.nameExtension,
|
||||
});
|
||||
RelatedPerson({
|
||||
required this.id,
|
||||
required this.gender,
|
||||
required this.sex,
|
||||
required this.deceased,
|
||||
required this.heightM,
|
||||
required this.birthdate,
|
||||
required this.esigPath,
|
||||
required this.lastName,
|
||||
required this.weightKg,
|
||||
required this.bloodType,
|
||||
required this.firstName,
|
||||
required this.photoPath,
|
||||
required this.maidenName,
|
||||
required this.middleName,
|
||||
required this.uuidQrcode,
|
||||
required this.civilStatus,
|
||||
required this.titlePrefix,
|
||||
required this.titleSuffix,
|
||||
required this.showTitleId,
|
||||
required this.nameExtension,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final String? sex;
|
||||
final String? gender;
|
||||
final bool? deceased;
|
||||
final double? heightM;
|
||||
final DateTime? birthdate;
|
||||
final String? esigPath;
|
||||
final String? lastName;
|
||||
final double? weightKg;
|
||||
final String? bloodType;
|
||||
final String? firstName;
|
||||
final String? photoPath;
|
||||
final dynamic maidenName;
|
||||
final String? middleName;
|
||||
final String? uuidQrcode;
|
||||
final String? civilStatus;
|
||||
final String? titlePrefix;
|
||||
final String? titleSuffix;
|
||||
final bool? showTitleId;
|
||||
final String? nameExtension;
|
||||
final int? id;
|
||||
final String? sex;
|
||||
final bool? deceased;
|
||||
final String? gender;
|
||||
final double? heightM;
|
||||
final DateTime? birthdate;
|
||||
final String? esigPath;
|
||||
final String? lastName;
|
||||
final double? weightKg;
|
||||
final String? bloodType;
|
||||
final String? firstName;
|
||||
final String? photoPath;
|
||||
final MaidenName? maidenName;
|
||||
final String? middleName;
|
||||
final String? uuidQrcode;
|
||||
final String? civilStatus;
|
||||
final String? titlePrefix;
|
||||
final String? titleSuffix;
|
||||
final bool? showTitleId;
|
||||
final String? nameExtension;
|
||||
|
||||
factory RelatedPerson.fromJson(Map<String, dynamic> json) => RelatedPerson(
|
||||
factory RelatedPerson.fromJson(Map<String, dynamic> json) => RelatedPerson(
|
||||
id: json["id"],
|
||||
sex: json["sex"],
|
||||
gender: json["gender"],
|
||||
deceased: json["deceased"],
|
||||
heightM: json["height_m"] == null?null:double.parse(json["height_m"].toString()),
|
||||
birthdate: json["birthdate"] == null ? null : DateTime.parse(json["birthdate"]),
|
||||
heightM: json["height_m"] == null
|
||||
? null
|
||||
: double.parse(json["height_m"].toString()),
|
||||
birthdate: json["birthdate"] == null
|
||||
? null
|
||||
: DateTime.parse(json["birthdate"]),
|
||||
esigPath: json["esig_path"],
|
||||
lastName: json["last_name"],
|
||||
weightKg: json["weight_kg"] == null? null:double.parse(json["weight_kg"].toString()) ,
|
||||
weightKg: json["weight_kg"] == null
|
||||
? null
|
||||
: double.parse(json["weight_kg"].toString()),
|
||||
bloodType: json["blood_type"],
|
||||
firstName: json["first_name"],
|
||||
photoPath: json["photo_path"],
|
||||
maidenName: json["maiden_name"],
|
||||
maidenName: json["maiden_name"] == null
|
||||
? null
|
||||
: MaidenName.fromJson(json['maiden_name']),
|
||||
middleName: json["middle_name"],
|
||||
uuidQrcode: json["uuid_qrcode"],
|
||||
civilStatus: json["civil_status"],
|
||||
|
@ -196,15 +220,16 @@ class RelatedPerson {
|
|||
titleSuffix: json["title_suffix"],
|
||||
showTitleId: json["show_title_id"],
|
||||
nameExtension: json["name_extension"],
|
||||
);
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id,
|
||||
"sex": sex,
|
||||
"gender": gender,
|
||||
"deceased": deceased,
|
||||
"height_m": heightM,
|
||||
"birthdate": "${birthdate!.year.toString().padLeft(4, '0')}-${birthdate!.month.toString().padLeft(2, '0')}-${birthdate!.day.toString().padLeft(2, '0')}",
|
||||
"birthdate":
|
||||
"${birthdate!.year.toString().padLeft(4, '0')}-${birthdate!.month.toString().padLeft(2, '0')}-${birthdate!.day.toString().padLeft(2, '0')}",
|
||||
"esig_path": esigPath,
|
||||
"last_name": lastName,
|
||||
"weight_kg": weightKg,
|
||||
|
@ -219,29 +244,49 @@ class RelatedPerson {
|
|||
"title_suffix": titleSuffix,
|
||||
"show_title_id": showTitleId,
|
||||
"name_extension": nameExtension,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
class Relationship {
|
||||
Relationship({
|
||||
this.id,
|
||||
this.type,
|
||||
this.category,
|
||||
});
|
||||
Relationship({
|
||||
this.id,
|
||||
this.type,
|
||||
this.category,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final String? type;
|
||||
final String? category;
|
||||
final int? id;
|
||||
final String? type;
|
||||
final String? category;
|
||||
|
||||
factory Relationship.fromJson(Map<String, dynamic> json) => Relationship(
|
||||
factory Relationship.fromJson(Map<String, dynamic> json) => Relationship(
|
||||
id: json["id"],
|
||||
type: json["type"],
|
||||
category: json["category"],
|
||||
);
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id,
|
||||
"type": type,
|
||||
"category": category,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
class MaidenName {
|
||||
final String lastName;
|
||||
final String middleName;
|
||||
|
||||
MaidenName({
|
||||
required this.lastName,
|
||||
required this.middleName,
|
||||
});
|
||||
|
||||
factory MaidenName.fromJson(Map<String, dynamic> json) => MaidenName(
|
||||
lastName: json["last_name"],
|
||||
middleName: json["middle_name"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"last_name": lastName,
|
||||
"middle_name": middleName,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import 'package:unit2/theme-data.dart/form-style.dart';
|
|||
import 'package:unit2/utils/text_container.dart';
|
||||
|
||||
import '../../../../../theme-data.dart/colors.dart';
|
||||
import '../../../../../utils/formatters.dart';
|
||||
|
||||
class AddContactInformationScreen extends StatefulWidget {
|
||||
final int profileId;
|
||||
|
@ -37,17 +38,7 @@ class _AddContactInformationScreenState
|
|||
bool primaryaContact = false;
|
||||
bool active = false;
|
||||
String? numberMail;
|
||||
var mobileFormatter = MaskTextInputFormatter(
|
||||
mask: "+63 (###) ###-####",
|
||||
filter: {"#": RegExp(r"^[1-9][0-9]*$")},
|
||||
type: MaskAutoCompletionType.lazy,
|
||||
initialText: "0");
|
||||
|
||||
var landLineFormatter = MaskTextInputFormatter(
|
||||
mask: "(###) ###-###",
|
||||
filter: {"#": RegExp(r"^[0-9]")},
|
||||
type: MaskAutoCompletionType.lazy,
|
||||
initialText: "0");
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/src/widgets/framework.dart';
|
||||
import 'package:flutter/src/widgets/placeholder.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
|
||||
import '../../../../../bloc/profile/family/family_bloc.dart';
|
||||
import '../../../../../theme-data.dart/btn-style.dart';
|
||||
import '../../../../../theme-data.dart/colors.dart';
|
||||
import '../../../../../theme-data.dart/form-style.dart';
|
||||
import '../../../../../utils/formatters.dart';
|
||||
|
||||
class AddMobileNumber extends StatelessWidget {
|
||||
final Function onPressed;
|
||||
final GlobalKey<FormBuilderState> formKey;
|
||||
const AddMobileNumber({super.key, required this.onPressed,required this.formKey});
|
||||
|
||||
@override
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Emergency Contact Information"),
|
||||
content: FormBuilder(
|
||||
key: formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
FormBuilderTextField(
|
||||
name: 'number_mail',
|
||||
inputFormatters: [mobileFormatter],
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Mobile number *", "+63 (9xx) xxx - xxxx"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: 200,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(primary, Colors.transparent, second),
|
||||
child: const Text("Submit"),
|
||||
onPressed: () {
|
||||
if (formKey.currentState!.saveAndValidate()) {
|
||||
onPressed();
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,339 @@
|
|||
import 'package:date_time_picker/date_time_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
|
||||
import '../../../../../bloc/profile/family/family_bloc.dart';
|
||||
import '../../../../../model/profile/family_backround.dart';
|
||||
import '../../../../../model/utils/position.dart';
|
||||
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/text_container.dart';
|
||||
import '../../../../../utils/validators.dart';
|
||||
|
||||
class ChildAlert extends StatefulWidget {
|
||||
final List<String> nameExtensions;
|
||||
final List<String> gender;
|
||||
final List<String> sexes;
|
||||
final List<String> bloodType;
|
||||
final List<String> civilStatus;
|
||||
final String token;
|
||||
final int profileId;
|
||||
final FamilyBloc familyBloc;
|
||||
const ChildAlert(
|
||||
{super.key,
|
||||
required this.bloodType,
|
||||
required this.civilStatus,
|
||||
required this.gender,
|
||||
required this.nameExtensions,
|
||||
required this.sexes,required this.familyBloc, required this.profileId, required this.token});
|
||||
|
||||
@override
|
||||
State<ChildAlert> createState() => _ChildAlertState();
|
||||
}
|
||||
|
||||
class _ChildAlertState extends State<ChildAlert> {
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
final bdayController = TextEditingController();
|
||||
|
||||
////selected
|
||||
String? selectedExtension;
|
||||
String? selectedGender;
|
||||
String? selectedSex;
|
||||
String? selectedBloodType;
|
||||
String? selectedCivilStatus;
|
||||
bool deceased = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Family - Child"),
|
||||
contentPadding: const EdgeInsets.all(24),
|
||||
content: SingleChildScrollView(
|
||||
child: FormBuilder(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
////name
|
||||
FormBuilderTextField(
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "lastname",
|
||||
decoration: normalTextFieldStyle("Last name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// firstname
|
||||
FormBuilderTextField(
|
||||
name: "firstname",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
decoration: normalTextFieldStyle("First name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////middle name
|
||||
FormBuilderTextField(
|
||||
name: "middlename",
|
||||
decoration: normalTextFieldStyle("Middle name", ""),
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// extension
|
||||
FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Name extension", ""),
|
||||
name: "extension",
|
||||
items: widget.nameExtensions
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element,
|
||||
child: Text(element),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedExtension = e;
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
|
||||
////Bday
|
||||
DateTimePicker(
|
||||
controller: bdayController,
|
||||
use24HourFormat: false,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
timeHintText: "Birthdate",
|
||||
decoration:
|
||||
normalTextFieldStyle("Birthdate *", "*").copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
icon: const Icon(Icons.date_range),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// sex
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Sex", ""),
|
||||
name: "sex",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
items: widget.sexes
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedSex = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
////gender
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Gender", ""),
|
||||
name: "gender",
|
||||
items: widget.gender
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedGender = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
////Blood Type
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Blood type", ""),
|
||||
name: "bloodtype",
|
||||
items: widget.bloodType
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedBloodType = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
//// Civil Status
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Civil status", ""),
|
||||
name: "extension",
|
||||
items: widget.civilStatus
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedCivilStatus = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
////height
|
||||
child: FormBuilderTextField(
|
||||
name: "height",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Height", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// weight
|
||||
child: FormBuilderTextField(
|
||||
name: "weight",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Weight", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Deceased
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: StatefulBuilder(builder: (context, setState) {
|
||||
return FormBuilderSwitch(
|
||||
initialValue: deceased,
|
||||
title: Text(deceased ? "YES" : "NO"),
|
||||
decoration: normalTextFieldStyle("Deceased?", ""),
|
||||
////onvhange private sector
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
deceased = value!;
|
||||
});
|
||||
},
|
||||
|
||||
name: 'deceased',
|
||||
validator: FormBuilderValidators.required(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(second, Colors.transparent, primary),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.saveAndValidate()) {
|
||||
String fname =
|
||||
_formKey.currentState!.value['firstname'];
|
||||
String lastName =
|
||||
_formKey.currentState!.value['lastname'];
|
||||
String? mname =
|
||||
_formKey.currentState?.value['middlename'];
|
||||
String bday = bdayController.text;
|
||||
String? gender = selectedGender =="NONE"?null:selectedGender;
|
||||
String? extension = selectedExtension=="NONE"?null:selectedExtension;
|
||||
String? blood = selectedBloodType =="NONE"?null:selectedBloodType;
|
||||
String? civilStatus = selectedCivilStatus =="NONE"?null:selectedCivilStatus;
|
||||
String? sex = selectedSex;
|
||||
Company? company;
|
||||
Position? position;
|
||||
double? height =
|
||||
_formKey.currentState?.value['height']==null? null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['height']);
|
||||
double? weight =
|
||||
_formKey.currentState?.value['weight']==null?null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['weight']);
|
||||
Relationship relationship = Relationship(
|
||||
id: 1,
|
||||
type: "Paternal_Parent",
|
||||
category: "Family");
|
||||
List<EmergencyContact>? emergnecyContacts;
|
||||
bool incaseOfEmergency = false;
|
||||
String? companyAddress;
|
||||
RelatedPerson person = RelatedPerson(
|
||||
titlePrefix: null,
|
||||
firstName: fname,
|
||||
maidenName: null,
|
||||
middleName: mname,
|
||||
lastName: lastName,
|
||||
birthdate: DateTime.parse(bday),
|
||||
id: null,
|
||||
sex: sex,
|
||||
gender: gender,
|
||||
deceased: false,
|
||||
heightM: height,
|
||||
weightKg: weight,
|
||||
esigPath: null,
|
||||
bloodType: blood,
|
||||
photoPath: null,
|
||||
uuidQrcode: null,
|
||||
nameExtension: extension,
|
||||
civilStatus: civilStatus,
|
||||
titleSuffix: null,
|
||||
showTitleId: false,
|
||||
);
|
||||
FamilyBackground familyBackground =
|
||||
FamilyBackground(company: company,position: position,relatedPerson: person,relationship: relationship,companyAddress: companyAddress,emergencyContact: emergnecyContacts,incaseOfEmergency: incaseOfEmergency,companyContactNumber: null);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
widget.familyBloc.add(AddFamily(familyBackground: familyBackground, profileId: widget.profileId, token: widget.token,relationshipId: 4));
|
||||
}
|
||||
},
|
||||
child: const Text(submit)),
|
||||
),
|
||||
],
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,362 @@
|
|||
import 'package:date_time_picker/date_time_picker.dart';
|
||||
import 'package:flutter/material.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:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:unit2/bloc/profile/family/family_bloc.dart';
|
||||
import 'package:unit2/model/profile/family_backround.dart';
|
||||
|
||||
import '../../../../../model/utils/position.dart';
|
||||
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/text_container.dart';
|
||||
import '../../../../../utils/validators.dart';
|
||||
|
||||
class ChildEditAlert extends StatefulWidget {
|
||||
final FamilyBackground familyBackground;
|
||||
final List<String> nameExtensions;
|
||||
final List<String> gender;
|
||||
final List<String> sexes;
|
||||
final List<String> bloodType;
|
||||
final List<String> civilStatus;
|
||||
final String token;
|
||||
final int profileId;
|
||||
final FamilyBloc familyBloc;
|
||||
|
||||
const ChildEditAlert(
|
||||
{super.key,
|
||||
required this.familyBackground,
|
||||
required this.bloodType,
|
||||
required this.civilStatus,
|
||||
required this.gender,
|
||||
required this.nameExtensions,
|
||||
required this.sexes, required this.familyBloc, required this.profileId, required this.token});
|
||||
|
||||
@override
|
||||
State<ChildEditAlert> createState() => _ChildEditAlertState();
|
||||
}
|
||||
|
||||
class _ChildEditAlertState extends State<ChildEditAlert> {
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
final bdayController = TextEditingController();
|
||||
|
||||
////selected
|
||||
String? selectedExtension;
|
||||
String? selectedGender;
|
||||
String? selectedSex;
|
||||
String? selectedBloodType;
|
||||
String? selectedCivilStatus;
|
||||
bool deceased = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
selectedExtension = widget.familyBackground.relatedPerson?.nameExtension;
|
||||
selectedGender = widget.familyBackground.relatedPerson?.gender;
|
||||
selectedSex = widget.familyBackground.relatedPerson?.sex;
|
||||
selectedBloodType = widget.familyBackground.relatedPerson?.bloodType;
|
||||
selectedCivilStatus = widget.familyBackground.relatedPerson?.civilStatus;
|
||||
bdayController.text = widget.familyBackground.relatedPerson!.birthdate!.toString();
|
||||
deceased = widget.familyBackground.relatedPerson!.deceased!;
|
||||
return AlertDialog(
|
||||
title: const Text("Family - Parental Parent"),
|
||||
contentPadding: const EdgeInsets.all(24),
|
||||
content: SingleChildScrollView(
|
||||
child: FormBuilder(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
////name
|
||||
FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson!.lastName,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "lastname",
|
||||
decoration: normalTextFieldStyle("Last name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// firstname
|
||||
FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson!.firstName,
|
||||
name: "firstname",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
decoration: normalTextFieldStyle("First name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////middle name
|
||||
FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson?.middleName,
|
||||
name: "middlename",
|
||||
|
||||
decoration: normalTextFieldStyle("Middle name", ""),
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// extension
|
||||
DropdownButtonFormField<String>(
|
||||
value: selectedExtension,
|
||||
decoration: normalTextFieldStyle("Name extension", ""),
|
||||
|
||||
items: widget.nameExtensions
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element,
|
||||
child: Text(element),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedExtension = e;
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Bday
|
||||
DateTimePicker(
|
||||
controller: bdayController,
|
||||
use24HourFormat: false,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
timeHintText: "Birthdate",
|
||||
decoration:
|
||||
normalTextFieldStyle("Birthdate *", "*").copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
icon: const Icon(Icons.date_range),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// sex
|
||||
child: DropdownButtonFormField<String>(
|
||||
decoration: normalTextFieldStyle("Sex", ""),
|
||||
value: selectedSex,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
items: widget.sexes
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedSex = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
////gender
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle("Gender", ""),
|
||||
value: selectedGender,
|
||||
items: widget.gender
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedGender = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
////Blood Type
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle("Blood type", ""),
|
||||
value: selectedBloodType,
|
||||
items: widget.bloodType
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedBloodType = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
//// Civil Status
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle("Civil status", ""),
|
||||
value: selectedCivilStatus,
|
||||
items: widget.civilStatus
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedCivilStatus = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
////height
|
||||
child: FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson?.heightM == null? null:widget.familyBackground.relatedPerson?.heightM.toString(),
|
||||
name: "height",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Height", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// weight
|
||||
child: FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson?.weightKg == null? null:widget.familyBackground.relatedPerson?.weightKg.toString(),
|
||||
name: "weight",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Weight", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Deceased
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: StatefulBuilder(builder: (context, setState) {
|
||||
return FormBuilderSwitch(
|
||||
initialValue: deceased,
|
||||
title: Text(deceased ? "YES" : "NO"),
|
||||
decoration: normalTextFieldStyle("Deceased?", ""),
|
||||
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
deceased = value!;
|
||||
});
|
||||
},
|
||||
|
||||
name: 'deceased',
|
||||
validator: FormBuilderValidators.required(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style:
|
||||
mainBtnStyle(second, Colors.transparent, primary),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.saveAndValidate()) {
|
||||
String fname =
|
||||
_formKey.currentState!.value['firstname'];
|
||||
String lastName =
|
||||
_formKey.currentState!.value['lastname'];
|
||||
String? mname =
|
||||
_formKey.currentState?.value['middlename'];
|
||||
String bday = bdayController.text;
|
||||
String? gender = selectedGender =="NONE"?null:selectedGender;
|
||||
String? extension = selectedExtension=="NONE"?null:selectedExtension;
|
||||
String? blood = selectedBloodType =="NONE"?null:selectedBloodType;
|
||||
String? civilStatus = selectedCivilStatus =="NONE"?null:selectedCivilStatus;
|
||||
String? sex = selectedSex;
|
||||
Company? company;
|
||||
Position? position;
|
||||
double? height =
|
||||
_formKey.currentState?.value['height']==null? null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['height']);
|
||||
double? weight =
|
||||
_formKey.currentState?.value['weight']==null?null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['weight']);
|
||||
Relationship relationship = Relationship(
|
||||
id: 1,
|
||||
type: "Paternal_Parent",
|
||||
category: "Family");
|
||||
List<EmergencyContact>? emergnecyContacts;
|
||||
bool incaseOfEmergency = false;
|
||||
String? companyAddress;
|
||||
RelatedPerson person = RelatedPerson(
|
||||
titlePrefix: null,
|
||||
firstName: fname,
|
||||
maidenName: null,
|
||||
middleName: mname,
|
||||
lastName: lastName,
|
||||
birthdate: DateTime.parse(bday),
|
||||
id: widget.familyBackground.relatedPerson!.id,
|
||||
sex: sex,
|
||||
gender: gender,
|
||||
deceased: deceased,
|
||||
heightM: height,
|
||||
weightKg: weight,
|
||||
esigPath: null,
|
||||
bloodType: blood,
|
||||
photoPath: null,
|
||||
uuidQrcode: null,
|
||||
nameExtension: extension,
|
||||
civilStatus: civilStatus,
|
||||
titleSuffix: null,
|
||||
showTitleId: false,
|
||||
);
|
||||
FamilyBackground familyBackground =
|
||||
FamilyBackground(company: company,position: position,relatedPerson: person,relationship: relationship,companyAddress: companyAddress,emergencyContact: emergnecyContacts,incaseOfEmergency: incaseOfEmergency,companyContactNumber: null);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
widget.familyBloc.add(Updatefamily(familyBackground: familyBackground, profileId: widget.profileId, token: widget.token,relationshipId: 4));
|
||||
}
|
||||
},
|
||||
child: const Text(submit)),
|
||||
),
|
||||
],
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,344 @@
|
|||
import 'package:date_time_picker/date_time_picker.dart';
|
||||
import 'package:flutter/material.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:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:unit2/bloc/profile/family/family_bloc.dart';
|
||||
import 'package:unit2/model/profile/family_backround.dart';
|
||||
|
||||
import '../../../../../model/utils/position.dart';
|
||||
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/text_container.dart';
|
||||
import '../../../../../utils/validators.dart';
|
||||
|
||||
class FatherAlert extends StatefulWidget {
|
||||
final List<String> nameExtensions;
|
||||
final List<String> gender;
|
||||
final List<String> sexes;
|
||||
final List<String> bloodType;
|
||||
final List<String> civilStatus;
|
||||
final String token;
|
||||
final int profileId;
|
||||
final FamilyBloc familyBloc;
|
||||
|
||||
const FatherAlert(
|
||||
{super.key,
|
||||
required this.bloodType,
|
||||
required this.civilStatus,
|
||||
required this.gender,
|
||||
required this.nameExtensions,
|
||||
required this.sexes, required this.familyBloc, required this.profileId, required this.token});
|
||||
|
||||
@override
|
||||
State<FatherAlert> createState() => _FatherAlertState();
|
||||
}
|
||||
|
||||
class _FatherAlertState extends State<FatherAlert> {
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
final bdayController = TextEditingController();
|
||||
|
||||
////selected
|
||||
String? selectedExtension;
|
||||
String? selectedGender;
|
||||
String? selectedSex;
|
||||
String? selectedBloodType;
|
||||
String? selectedCivilStatus;
|
||||
bool deceased = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Family - Parental Parent"),
|
||||
contentPadding: const EdgeInsets.all(24),
|
||||
content: SingleChildScrollView(
|
||||
child: FormBuilder(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
////name
|
||||
FormBuilderTextField(
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "lastname",
|
||||
decoration: normalTextFieldStyle("Last name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// firstname
|
||||
FormBuilderTextField(
|
||||
name: "firstname",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
decoration: normalTextFieldStyle("First name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////middle name
|
||||
FormBuilderTextField(
|
||||
name: "middlename",
|
||||
|
||||
decoration: normalTextFieldStyle("Middle name", ""),
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// extension
|
||||
FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Name extension", ""),
|
||||
name: "extension",
|
||||
items: widget.nameExtensions
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element,
|
||||
child: Text(element),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedExtension = e;
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Bday
|
||||
DateTimePicker(
|
||||
controller: bdayController,
|
||||
use24HourFormat: false,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
timeHintText: "Birthdate",
|
||||
decoration:
|
||||
normalTextFieldStyle("Birthdate *", "*").copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
icon: const Icon(Icons.date_range),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// sex
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Sex", ""),
|
||||
name: "sex",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
items: widget.sexes
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedSex = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
////gender
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Gender", ""),
|
||||
name: "gender",
|
||||
items: widget.gender
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedGender = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
////Blood Type
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Blood type", ""),
|
||||
name: "bloodtype",
|
||||
items: widget.bloodType
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedBloodType = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
//// Civil Status
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Civil status", ""),
|
||||
name: "extension",
|
||||
items: widget.civilStatus
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedCivilStatus = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
////height
|
||||
child: FormBuilderTextField(
|
||||
name: "height",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Height", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// weight
|
||||
child: FormBuilderTextField(
|
||||
name: "weight",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Weight", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Deceased
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: StatefulBuilder(builder: (context, setState) {
|
||||
return FormBuilderSwitch(
|
||||
initialValue: deceased,
|
||||
title: Text(deceased ? "YES" : "NO"),
|
||||
decoration: normalTextFieldStyle("Deceased?", ""),
|
||||
////onvhange private sector
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
deceased = value!;
|
||||
});
|
||||
},
|
||||
|
||||
name: 'deceased',
|
||||
validator: FormBuilderValidators.required(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style:
|
||||
mainBtnStyle(second, Colors.transparent, primary),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.saveAndValidate()) {
|
||||
String fname =
|
||||
_formKey.currentState!.value['firstname'];
|
||||
String lastName =
|
||||
_formKey.currentState!.value['lastname'];
|
||||
String? mname =
|
||||
_formKey.currentState?.value['middlename'];
|
||||
String bday = bdayController.text;
|
||||
String? gender = selectedGender =="NONE"?null:selectedGender;
|
||||
String? extension = selectedExtension=="NONE"?null:selectedExtension;
|
||||
String? blood = selectedBloodType =="NONE"?null:selectedBloodType;
|
||||
String? civilStatus = selectedCivilStatus =="NONE"?null:selectedCivilStatus;
|
||||
String? sex = selectedSex;
|
||||
Company? company;
|
||||
Position? position;
|
||||
double? height =
|
||||
_formKey.currentState?.value['height']==null? null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['height']);
|
||||
double? weight =
|
||||
_formKey.currentState?.value['weight']==null?null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['weight']);
|
||||
Relationship relationship = Relationship(
|
||||
id: 1,
|
||||
type: "Paternal_Parent",
|
||||
category: "Family");
|
||||
List<EmergencyContact>? emergnecyContacts;
|
||||
bool incaseOfEmergency = false;
|
||||
String? companyAddress;
|
||||
RelatedPerson person = RelatedPerson(
|
||||
titlePrefix: null,
|
||||
firstName: fname,
|
||||
maidenName: null,
|
||||
middleName: mname,
|
||||
lastName: lastName,
|
||||
birthdate: DateTime.parse(bday),
|
||||
id: null,
|
||||
sex: sex,
|
||||
gender: gender,
|
||||
deceased: deceased,
|
||||
heightM: height,
|
||||
weightKg: weight,
|
||||
esigPath: null,
|
||||
bloodType: blood,
|
||||
photoPath: null,
|
||||
uuidQrcode: null,
|
||||
nameExtension: extension,
|
||||
civilStatus: civilStatus,
|
||||
titleSuffix: null,
|
||||
showTitleId: false,
|
||||
);
|
||||
FamilyBackground familyBackground =
|
||||
FamilyBackground(company: company,position: position,relatedPerson: person,relationship: relationship,companyAddress: companyAddress,emergencyContact: emergnecyContacts,incaseOfEmergency: incaseOfEmergency,companyContactNumber: null);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
widget.familyBloc.add(AddFamily(familyBackground: familyBackground, profileId: widget.profileId, token: widget.token,relationshipId: 1));
|
||||
}
|
||||
},
|
||||
child: const Text(submit)),
|
||||
),
|
||||
],
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,362 @@
|
|||
import 'package:date_time_picker/date_time_picker.dart';
|
||||
import 'package:flutter/material.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:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:unit2/bloc/profile/family/family_bloc.dart';
|
||||
import 'package:unit2/model/profile/family_backround.dart';
|
||||
|
||||
import '../../../../../model/utils/position.dart';
|
||||
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/text_container.dart';
|
||||
import '../../../../../utils/validators.dart';
|
||||
|
||||
class FatherEditAlert extends StatefulWidget {
|
||||
final FamilyBackground familyBackground;
|
||||
final List<String> nameExtensions;
|
||||
final List<String> gender;
|
||||
final List<String> sexes;
|
||||
final List<String> bloodType;
|
||||
final List<String> civilStatus;
|
||||
final String token;
|
||||
final int profileId;
|
||||
final FamilyBloc familyBloc;
|
||||
|
||||
const FatherEditAlert(
|
||||
{super.key,
|
||||
required this.familyBackground,
|
||||
required this.bloodType,
|
||||
required this.civilStatus,
|
||||
required this.gender,
|
||||
required this.nameExtensions,
|
||||
required this.sexes, required this.familyBloc, required this.profileId, required this.token});
|
||||
|
||||
@override
|
||||
State<FatherEditAlert> createState() => _FatherEditAlertState();
|
||||
}
|
||||
|
||||
class _FatherEditAlertState extends State<FatherEditAlert> {
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
final bdayController = TextEditingController();
|
||||
|
||||
////selected
|
||||
String? selectedExtension;
|
||||
String? selectedGender;
|
||||
String? selectedSex;
|
||||
String? selectedBloodType;
|
||||
String? selectedCivilStatus;
|
||||
bool deceased = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
selectedExtension = widget.familyBackground.relatedPerson?.nameExtension;
|
||||
selectedGender = widget.familyBackground.relatedPerson?.gender;
|
||||
selectedSex = widget.familyBackground.relatedPerson?.sex;
|
||||
selectedBloodType = widget.familyBackground.relatedPerson?.bloodType;
|
||||
selectedCivilStatus = widget.familyBackground.relatedPerson?.civilStatus;
|
||||
bdayController.text = widget.familyBackground.relatedPerson!.birthdate!.toString();
|
||||
deceased = widget.familyBackground.relatedPerson!.deceased!;
|
||||
return AlertDialog(
|
||||
title: const Text("Family - Parental Parent"),
|
||||
contentPadding: const EdgeInsets.all(24),
|
||||
content: SingleChildScrollView(
|
||||
child: FormBuilder(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
////name
|
||||
FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson!.lastName,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "lastname",
|
||||
decoration: normalTextFieldStyle("Last name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// firstname
|
||||
FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson!.firstName,
|
||||
name: "firstname",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
decoration: normalTextFieldStyle("First name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////middle name
|
||||
FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson?.middleName,
|
||||
name: "middlename",
|
||||
|
||||
decoration: normalTextFieldStyle("Middle name", ""),
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// extension
|
||||
DropdownButtonFormField<String>(
|
||||
value: selectedExtension,
|
||||
decoration: normalTextFieldStyle("Name extension", ""),
|
||||
|
||||
items: widget.nameExtensions
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element,
|
||||
child: Text(element),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedExtension = e;
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Bday
|
||||
DateTimePicker(
|
||||
controller: bdayController,
|
||||
use24HourFormat: false,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
timeHintText: "Birthdate",
|
||||
decoration:
|
||||
normalTextFieldStyle("Birthdate *", "*").copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
icon: const Icon(Icons.date_range),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// sex
|
||||
child: DropdownButtonFormField<String>(
|
||||
decoration: normalTextFieldStyle("Sex", ""),
|
||||
value: selectedSex,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
items: widget.sexes
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedSex = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
////gender
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle("Gender", ""),
|
||||
value: selectedGender,
|
||||
items: widget.gender
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedGender = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
////Blood Type
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle("Blood type", ""),
|
||||
value: selectedBloodType,
|
||||
items: widget.bloodType
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedBloodType = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
//// Civil Status
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle("Civil status", ""),
|
||||
value: selectedCivilStatus,
|
||||
items: widget.civilStatus
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedCivilStatus = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
////height
|
||||
child: FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson?.heightM == null? null:widget.familyBackground.relatedPerson?.heightM.toString(),
|
||||
name: "height",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Height", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// weight
|
||||
child: FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson?.weightKg == null? null:widget.familyBackground.relatedPerson?.weightKg.toString(),
|
||||
name: "weight",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Weight", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Deceased
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: StatefulBuilder(builder: (context, setState) {
|
||||
return FormBuilderSwitch(
|
||||
initialValue: deceased,
|
||||
title: Text(deceased ? "YES" : "NO"),
|
||||
decoration: normalTextFieldStyle("Deceased?", ""),
|
||||
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
deceased = value!;
|
||||
});
|
||||
},
|
||||
|
||||
name: 'deceased',
|
||||
validator: FormBuilderValidators.required(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style:
|
||||
mainBtnStyle(second, Colors.transparent, primary),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.saveAndValidate()) {
|
||||
String fname =
|
||||
_formKey.currentState!.value['firstname'];
|
||||
String lastName =
|
||||
_formKey.currentState!.value['lastname'];
|
||||
String? mname =
|
||||
_formKey.currentState?.value['middlename'];
|
||||
String bday = bdayController.text;
|
||||
String? gender = selectedGender =="NONE"?null:selectedGender;
|
||||
String? extension = selectedExtension=="NONE"?null:selectedExtension;
|
||||
String? blood = selectedBloodType =="NONE"?null:selectedBloodType;
|
||||
String? civilStatus = selectedCivilStatus =="NONE"?null:selectedCivilStatus;
|
||||
String? sex = selectedSex;
|
||||
Company? company;
|
||||
Position? position;
|
||||
double? height =
|
||||
_formKey.currentState?.value['height']==null? null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['height']);
|
||||
double? weight =
|
||||
_formKey.currentState?.value['weight']==null?null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['weight']);
|
||||
Relationship relationship = Relationship(
|
||||
id: 1,
|
||||
type: "Paternal_Parent",
|
||||
category: "Family");
|
||||
List<EmergencyContact>? emergnecyContacts;
|
||||
bool incaseOfEmergency = false;
|
||||
String? companyAddress;
|
||||
RelatedPerson person = RelatedPerson(
|
||||
titlePrefix: null,
|
||||
firstName: fname,
|
||||
maidenName: null,
|
||||
middleName: mname,
|
||||
lastName: lastName,
|
||||
birthdate: DateTime.parse(bday),
|
||||
id: widget.familyBackground.relatedPerson!.id,
|
||||
sex: sex,
|
||||
gender: gender,
|
||||
deceased: deceased,
|
||||
heightM: height,
|
||||
weightKg: weight,
|
||||
esigPath: null,
|
||||
bloodType: blood,
|
||||
photoPath: null,
|
||||
uuidQrcode: null,
|
||||
nameExtension: extension,
|
||||
civilStatus: civilStatus,
|
||||
titleSuffix: null,
|
||||
showTitleId: false,
|
||||
);
|
||||
FamilyBackground familyBackground =
|
||||
FamilyBackground(company: company,position: position,relatedPerson: person,relationship: relationship,companyAddress: companyAddress,emergencyContact: emergnecyContacts,incaseOfEmergency: incaseOfEmergency,companyContactNumber: null);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
widget.familyBloc.add(Updatefamily(familyBackground: familyBackground, profileId: widget.profileId, token: widget.token,relationshipId: 1));
|
||||
}
|
||||
},
|
||||
child: const Text(submit)),
|
||||
),
|
||||
],
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,372 @@
|
|||
import 'package:date_time_picker/date_time_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
|
||||
import '../../../../../bloc/profile/family/family_bloc.dart';
|
||||
import '../../../../../model/profile/family_backround.dart';
|
||||
import '../../../../../model/utils/position.dart';
|
||||
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/text_container.dart';
|
||||
import '../../../../../utils/validators.dart';
|
||||
|
||||
class MotherAlert extends StatefulWidget {
|
||||
final List<String> nameExtensions;
|
||||
final List<String> gender;
|
||||
final List<String> sexes;
|
||||
final List<String> bloodType;
|
||||
final List<String> civilStatus;
|
||||
final String token;
|
||||
final int profileId;
|
||||
final FamilyBloc familyBloc;
|
||||
const MotherAlert(
|
||||
{super.key,
|
||||
required this.familyBloc,
|
||||
required this.profileId,
|
||||
required this.token,
|
||||
required this.bloodType,
|
||||
required this.civilStatus,
|
||||
required this.gender,
|
||||
required this.nameExtensions,
|
||||
required this.sexes});
|
||||
|
||||
@override
|
||||
State<MotherAlert> createState() => _MotherAlertState();
|
||||
}
|
||||
|
||||
class _MotherAlertState extends State<MotherAlert> {
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
final bdayController = TextEditingController();
|
||||
////selected
|
||||
String? selectedExtension;
|
||||
String? selectedGender;
|
||||
String? selectedSex;
|
||||
String? selectedBloodType;
|
||||
String? selectedCivilStatus;
|
||||
bool deceased = false;
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Family - Maternal Parent"),
|
||||
contentPadding: const EdgeInsets.all(24),
|
||||
content: SingleChildScrollView(
|
||||
child: FormBuilder(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
////name
|
||||
FormBuilderTextField(
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "lastname",
|
||||
decoration: normalTextFieldStyle("Last name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// firstname
|
||||
FormBuilderTextField(
|
||||
name: "firstname",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
decoration: normalTextFieldStyle("First name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////middle name
|
||||
FormBuilderTextField(
|
||||
name: "middlename",
|
||||
|
||||
decoration: normalTextFieldStyle("Middle name", ""),
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// extension
|
||||
FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Name extension", ""),
|
||||
name: "extension",
|
||||
items: widget.nameExtensions
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element,
|
||||
child: Text(element),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedExtension = e;
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Bday
|
||||
DateTimePicker(
|
||||
controller: bdayController,
|
||||
use24HourFormat: false,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
timeHintText: "Birthdate",
|
||||
decoration:
|
||||
normalTextFieldStyle("Birthdate *", "*").copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
icon: const Icon(Icons.date_range),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// sex
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Sex", ""),
|
||||
name: "sex",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
items: widget.sexes
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedSex = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
////gender
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Gender", ""),
|
||||
name: "gender",
|
||||
items: widget.gender
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedGender = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
////Blood Type
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Blood type", ""),
|
||||
name: "bloodtype",
|
||||
items: widget.bloodType
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedBloodType = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
//// Civil Status
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Civil status", ""),
|
||||
name: "extension",
|
||||
items: widget.civilStatus
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedCivilStatus = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
|
||||
////height
|
||||
child: FormBuilderTextField(
|
||||
name: "height",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Height", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// weight
|
||||
child: FormBuilderTextField(
|
||||
name: "weight",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Weight", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Deceased
|
||||
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: StatefulBuilder(builder: (context, setState) {
|
||||
return FormBuilderSwitch(
|
||||
initialValue: deceased,
|
||||
title: Text(deceased ? "YES" : "NO"),
|
||||
decoration: normalTextFieldStyle("Deceased?", ""),
|
||||
////onvhange private sector
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
deceased = value!;
|
||||
});
|
||||
},
|
||||
|
||||
name: 'deceased',
|
||||
validator: FormBuilderValidators.required(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Text(
|
||||
"Maiden Name",
|
||||
style: Theme.of(context).textTheme.labelLarge,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////maiden lastname
|
||||
FormBuilderTextField(
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "maiden_lastname",
|
||||
decoration: normalTextFieldStyle("Last name", ""),
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////maiden middle name
|
||||
FormBuilderTextField(
|
||||
name: "maiden_middlename",
|
||||
decoration: normalTextFieldStyle("Middle name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style:
|
||||
mainBtnStyle(second, Colors.transparent, primary),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.saveAndValidate()) {
|
||||
String fname =
|
||||
_formKey.currentState!.value['firstname'];
|
||||
String lastName =
|
||||
_formKey.currentState!.value['lastname'];
|
||||
String? mname =
|
||||
_formKey.currentState?.value['middlename'];
|
||||
String maidenMiddleName = _formKey.currentState!.value['maiden_middlename'];
|
||||
String maidenLastName = _formKey.currentState!.value['maiden_lastname'];
|
||||
String bday = bdayController.text;
|
||||
String? gender = selectedGender =="NONE"?null:selectedGender;
|
||||
String? extension = selectedExtension=="NONE"?null:selectedExtension;
|
||||
String? blood = selectedBloodType =="NONE"?null:selectedBloodType;
|
||||
String? civilStatus = selectedCivilStatus =="NONE"?null:selectedCivilStatus;
|
||||
String? sex = selectedSex;
|
||||
Company? company;
|
||||
Position? position;
|
||||
double? height =
|
||||
_formKey.currentState?.value['height']==null? null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['height']);
|
||||
double? weight =
|
||||
_formKey.currentState?.value['weight']==null?null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['weight']);
|
||||
Relationship relationship = Relationship(
|
||||
id: 1,
|
||||
type: "Paternal_Parent",
|
||||
category: "Family");
|
||||
List<EmergencyContact>? emergnecyContacts;
|
||||
bool incaseOfEmergency = false;
|
||||
String? companyAddress;
|
||||
RelatedPerson person = RelatedPerson(
|
||||
titlePrefix: null,
|
||||
firstName: fname,
|
||||
maidenName: MaidenName(lastName: maidenLastName, middleName: maidenMiddleName),
|
||||
middleName: mname,
|
||||
lastName: lastName,
|
||||
birthdate: DateTime.parse(bday),
|
||||
id: null,
|
||||
sex: sex,
|
||||
gender: gender,
|
||||
deceased: deceased,
|
||||
heightM: height,
|
||||
weightKg: weight,
|
||||
esigPath: null,
|
||||
bloodType: blood,
|
||||
photoPath: null,
|
||||
uuidQrcode: null,
|
||||
nameExtension: extension,
|
||||
civilStatus: civilStatus,
|
||||
titleSuffix: null,
|
||||
showTitleId: false,
|
||||
);
|
||||
FamilyBackground familyBackground =
|
||||
FamilyBackground(company: company,position: position,relatedPerson: person,relationship: relationship,companyAddress: companyAddress,emergencyContact: emergnecyContacts,incaseOfEmergency: incaseOfEmergency,companyContactNumber: null);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
widget.familyBloc.add(AddFamily(familyBackground: familyBackground, profileId: widget.profileId, token: widget.token,relationshipId: 2));
|
||||
}
|
||||
},
|
||||
child: const Text(submit)),
|
||||
),
|
||||
],
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,390 @@
|
|||
import 'package:date_time_picker/date_time_picker.dart';
|
||||
import 'package:flutter/material.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:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:unit2/bloc/profile/family/family_bloc.dart';
|
||||
import 'package:unit2/model/profile/family_backround.dart';
|
||||
|
||||
import '../../../../../model/utils/position.dart';
|
||||
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/text_container.dart';
|
||||
import '../../../../../utils/validators.dart';
|
||||
|
||||
class MotherEditAlert extends StatefulWidget {
|
||||
final FamilyBackground familyBackground;
|
||||
final List<String> nameExtensions;
|
||||
final List<String> gender;
|
||||
final List<String> sexes;
|
||||
final List<String> bloodType;
|
||||
final List<String> civilStatus;
|
||||
final String token;
|
||||
final int profileId;
|
||||
final FamilyBloc familyBloc;
|
||||
|
||||
const MotherEditAlert(
|
||||
{super.key,
|
||||
required this.familyBackground,
|
||||
required this.bloodType,
|
||||
required this.civilStatus,
|
||||
required this.gender,
|
||||
required this.nameExtensions,
|
||||
required this.sexes, required this.familyBloc, required this.profileId, required this.token});
|
||||
|
||||
@override
|
||||
State<MotherEditAlert> createState() => _MotherEditAlertState();
|
||||
}
|
||||
|
||||
class _MotherEditAlertState extends State<MotherEditAlert> {
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
final bdayController = TextEditingController();
|
||||
|
||||
////selected
|
||||
String? selectedExtension;
|
||||
String? selectedGender;
|
||||
String? selectedSex;
|
||||
String? selectedBloodType;
|
||||
String? selectedCivilStatus;
|
||||
bool deceased = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
selectedExtension = widget.familyBackground.relatedPerson?.nameExtension;
|
||||
selectedGender = widget.familyBackground.relatedPerson?.gender;
|
||||
selectedSex = widget.familyBackground.relatedPerson?.sex;
|
||||
selectedBloodType = widget.familyBackground.relatedPerson?.bloodType;
|
||||
selectedCivilStatus = widget.familyBackground.relatedPerson?.civilStatus;
|
||||
bdayController.text = widget.familyBackground.relatedPerson!.birthdate!.toString();
|
||||
deceased = widget.familyBackground.relatedPerson!.deceased!;
|
||||
return AlertDialog(
|
||||
title: const Text("Family - Parental Parent"),
|
||||
contentPadding: const EdgeInsets.all(24),
|
||||
content: SingleChildScrollView(
|
||||
child: FormBuilder(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
////name
|
||||
FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson!.lastName,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "lastname",
|
||||
decoration: normalTextFieldStyle("Last name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// firstname
|
||||
FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson!.firstName,
|
||||
name: "firstname",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
decoration: normalTextFieldStyle("First name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////middle name
|
||||
FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson?.middleName,
|
||||
name: "middlename",
|
||||
|
||||
decoration: normalTextFieldStyle("Middle name", ""),
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// extension
|
||||
DropdownButtonFormField<String>(
|
||||
value: selectedExtension,
|
||||
decoration: normalTextFieldStyle("Name extension", ""),
|
||||
|
||||
items: widget.nameExtensions
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element,
|
||||
child: Text(element),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedExtension = e;
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Bday
|
||||
DateTimePicker(
|
||||
controller: bdayController,
|
||||
use24HourFormat: false,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
timeHintText: "Birthdate",
|
||||
decoration:
|
||||
normalTextFieldStyle("Birthdate *", "*").copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
icon: const Icon(Icons.date_range),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// sex
|
||||
child: DropdownButtonFormField<String>(
|
||||
decoration: normalTextFieldStyle("Sex", ""),
|
||||
value: selectedSex,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
items: widget.sexes
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedSex = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
////gender
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle("Gender", ""),
|
||||
value: selectedGender,
|
||||
items: widget.gender
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedGender = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
////Blood Type
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle("Blood type", ""),
|
||||
value: selectedBloodType,
|
||||
items: widget.bloodType
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedBloodType = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
//// Civil Status
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle("Civil status", ""),
|
||||
value: selectedCivilStatus,
|
||||
items: widget.civilStatus
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedCivilStatus = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
////height
|
||||
child: FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson?.heightM == null? null:widget.familyBackground.relatedPerson?.heightM.toString(),
|
||||
name: "height",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Height", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// weight
|
||||
child: FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson?.weightKg == null? null:widget.familyBackground.relatedPerson?.weightKg.toString(),
|
||||
name: "weight",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Weight", ""),
|
||||
),
|
||||
),
|
||||
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Deceased
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: StatefulBuilder(builder: (context, setState) {
|
||||
return FormBuilderSwitch(
|
||||
initialValue: deceased,
|
||||
title: Text(deceased ? "YES" : "NO"),
|
||||
decoration: normalTextFieldStyle("Deceased?", ""),
|
||||
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
deceased = value!;
|
||||
});
|
||||
},
|
||||
|
||||
name: 'deceased',
|
||||
validator: FormBuilderValidators.required(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Text(
|
||||
"Maiden Name",
|
||||
style: Theme.of(context).textTheme.labelLarge,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////maiden lastname
|
||||
FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson?.maidenName?.lastName,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "maiden_lastname",
|
||||
decoration: normalTextFieldStyle("Last name", ""),
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////maiden middle name
|
||||
FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson?.maidenName?.middleName,
|
||||
name: "maiden_middlename",
|
||||
decoration: normalTextFieldStyle("Middle name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style:
|
||||
mainBtnStyle(second, Colors.transparent, primary),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.saveAndValidate()) {
|
||||
String fname =
|
||||
_formKey.currentState!.value['firstname'];
|
||||
String lastName =
|
||||
_formKey.currentState!.value['lastname'];
|
||||
String? mname =
|
||||
_formKey.currentState?.value['middlename'];
|
||||
String maidenMiddleName = _formKey.currentState!.value['maiden_middlename'];
|
||||
String maidenLastName = _formKey.currentState!.value['maiden_lastname'];
|
||||
String bday = bdayController.text;
|
||||
String? gender = selectedGender =="NONE"?null:selectedGender;
|
||||
String? extension = selectedExtension=="NONE"?null:selectedExtension;
|
||||
String? blood = selectedBloodType =="NONE"?null:selectedBloodType;
|
||||
String? civilStatus = selectedCivilStatus =="NONE"?null:selectedCivilStatus;
|
||||
String? sex = selectedSex;
|
||||
Company? company;
|
||||
Position? position;
|
||||
double? height =
|
||||
_formKey.currentState?.value['height']==null? null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['height']);
|
||||
double? weight =
|
||||
_formKey.currentState?.value['weight']==null?null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['weight']);
|
||||
Relationship relationship = Relationship(
|
||||
id: 1,
|
||||
type: "Paternal_Parent",
|
||||
category: "Family");
|
||||
List<EmergencyContact>? emergnecyContacts;
|
||||
bool incaseOfEmergency = false;
|
||||
String? companyAddress;
|
||||
RelatedPerson person = RelatedPerson(
|
||||
titlePrefix: null,
|
||||
firstName: fname,
|
||||
maidenName: MaidenName(middleName: maidenMiddleName,lastName: maidenLastName),
|
||||
middleName: mname,
|
||||
lastName: lastName,
|
||||
birthdate: DateTime.parse(bday),
|
||||
id: widget.familyBackground.relatedPerson!.id,
|
||||
sex: sex,
|
||||
gender: gender,
|
||||
deceased: deceased,
|
||||
heightM: height,
|
||||
weightKg: weight,
|
||||
esigPath: null,
|
||||
bloodType: blood,
|
||||
photoPath: null,
|
||||
uuidQrcode: null,
|
||||
nameExtension: extension,
|
||||
civilStatus: civilStatus,
|
||||
titleSuffix: null,
|
||||
showTitleId: false,
|
||||
);
|
||||
FamilyBackground familyBackground =
|
||||
FamilyBackground(company: company,position: position,relatedPerson: person,relationship: relationship,companyAddress: companyAddress,emergencyContact: emergnecyContacts,incaseOfEmergency: incaseOfEmergency,companyContactNumber: null);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
widget.familyBloc.add(Updatefamily(familyBackground: familyBackground, profileId: widget.profileId, token: widget.token,relationshipId: 1));
|
||||
}
|
||||
},
|
||||
child: const Text(submit)),
|
||||
),
|
||||
],
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,381 @@
|
|||
import 'package:date_time_picker/date_time_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:unit2/model/utils/agency.dart';
|
||||
import 'package:unit2/model/utils/category.dart';
|
||||
|
||||
import '../../../../../bloc/profile/family/family_bloc.dart';
|
||||
import '../../../../../model/profile/family_backround.dart';
|
||||
import '../../../../../model/utils/position.dart';
|
||||
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/text_container.dart';
|
||||
import '../../../../../utils/validators.dart';
|
||||
|
||||
class RelatedAlert extends StatefulWidget {
|
||||
final List<String> nameExtensions;
|
||||
final List<String> gender;
|
||||
final List<String> sexes;
|
||||
final List<String> bloodType;
|
||||
final List<String> civilStatus;
|
||||
final List<Relationship> relationships;
|
||||
final String token;
|
||||
final int profileId;
|
||||
final FamilyBloc familyBloc;
|
||||
|
||||
|
||||
const RelatedAlert(
|
||||
{super.key,
|
||||
required this.bloodType,
|
||||
required this.token,
|
||||
required this.profileId,
|
||||
required this.familyBloc,
|
||||
required this.civilStatus,
|
||||
required this.relationships,
|
||||
required this.gender,
|
||||
required this.nameExtensions,
|
||||
required this.sexes,
|
||||
|
||||
});
|
||||
|
||||
@override
|
||||
State<RelatedAlert> createState() => _RelatedAlertState();
|
||||
}
|
||||
|
||||
class _RelatedAlertState extends State<RelatedAlert> {
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
final bdayController = TextEditingController();
|
||||
|
||||
////selected
|
||||
String? selectedExtension;
|
||||
String? selectedGender;
|
||||
String? selectedSex;
|
||||
String? selectedBloodType;
|
||||
String? selectedCivilStatus;
|
||||
Relationship? selectedRelationship;
|
||||
bool deceased = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Family - Other Related Person"),
|
||||
contentPadding: const EdgeInsets.all(24),
|
||||
content: SingleChildScrollView(
|
||||
child: FormBuilder(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
////Relationship
|
||||
FormBuilderDropdown<Relationship>(
|
||||
decoration: normalTextFieldStyle("Relationship", ""),
|
||||
name: "extension",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
items: widget.relationships
|
||||
.map((element){
|
||||
return DropdownMenuItem<Relationship>(
|
||||
value: element,
|
||||
child: Text(element.type!),
|
||||
);
|
||||
|
||||
},)
|
||||
.toList(),
|
||||
onChanged: (e){
|
||||
selectedRelationship = e;
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////name
|
||||
FormBuilderTextField(
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "lastname",
|
||||
decoration: normalTextFieldStyle("Last name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// firstname
|
||||
FormBuilderTextField(
|
||||
name: "firstname",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
decoration: normalTextFieldStyle("First name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////middle name
|
||||
FormBuilderTextField(
|
||||
name: "middlename",
|
||||
|
||||
decoration: normalTextFieldStyle("Middle name", ""),
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// extension
|
||||
FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Name extension", ""),
|
||||
name: "extension",
|
||||
items: widget.nameExtensions
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element,
|
||||
child: Text(element),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedExtension = e;
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
|
||||
////Bday
|
||||
DateTimePicker(
|
||||
controller: bdayController,
|
||||
use24HourFormat: false,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
timeHintText: "Birthdate",
|
||||
decoration:
|
||||
normalTextFieldStyle("Birthdate *", "*").copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
icon: const Icon(Icons.date_range),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// sex
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Sex", ""),
|
||||
name: "sex",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
items: widget.sexes
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedSex = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
////gender
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Gender", ""),
|
||||
name: "gender",
|
||||
items: widget.gender
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedGender = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
////Blood Type
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Blood type", ""),
|
||||
name: "bloodtype",
|
||||
items: widget.bloodType
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedBloodType = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
//// Civil Status
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Civil status", ""),
|
||||
name: "extension",
|
||||
items: widget.civilStatus
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedCivilStatus = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
////height
|
||||
child: FormBuilderTextField(
|
||||
name: "height",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Height", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// weight
|
||||
child: FormBuilderTextField(
|
||||
name: "weight",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Weight", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Deceased
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: StatefulBuilder(builder: (context, setState) {
|
||||
return FormBuilderSwitch(
|
||||
initialValue: deceased,
|
||||
title: Text(deceased ? "YES" : "NO"),
|
||||
decoration: normalTextFieldStyle("Deceased?", ""),
|
||||
////onvhange private sector
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
deceased = value!;
|
||||
});
|
||||
},
|
||||
|
||||
name: 'deceased',
|
||||
validator: FormBuilderValidators.required(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
|
||||
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style:
|
||||
mainBtnStyle(second, Colors.transparent, primary),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.saveAndValidate()) {
|
||||
String fname =
|
||||
_formKey.currentState!.value['firstname'];
|
||||
String lastName =
|
||||
_formKey.currentState!.value['lastname'];
|
||||
String? mname =
|
||||
_formKey.currentState?.value['middlename'];
|
||||
String bday = bdayController.text;
|
||||
String? gender = selectedGender =="NONE"?null:selectedGender;
|
||||
String? extension = selectedExtension=="NONE"?null:selectedExtension;
|
||||
String? blood = selectedBloodType =="NONE"?null:selectedBloodType;
|
||||
String? civilStatus = selectedCivilStatus =="NONE"?null:selectedCivilStatus;
|
||||
String? sex = selectedSex;
|
||||
Company? company;
|
||||
Position? position;
|
||||
double? height =
|
||||
_formKey.currentState?.value['height']==null? null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['height']);
|
||||
double? weight =
|
||||
_formKey.currentState?.value['weight']==null?null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['weight']);
|
||||
Relationship relationship = Relationship(
|
||||
id: 1,
|
||||
type: "Paternal_Parent",
|
||||
category: "Family");
|
||||
List<EmergencyContact>? emergnecyContacts;
|
||||
bool incaseOfEmergency = false;
|
||||
String? companyAddress;
|
||||
RelatedPerson person = RelatedPerson(
|
||||
titlePrefix: null,
|
||||
firstName: fname,
|
||||
maidenName: null,
|
||||
middleName: mname,
|
||||
lastName: lastName,
|
||||
birthdate: DateTime.parse(bday),
|
||||
id: null,
|
||||
sex: sex,
|
||||
gender: gender,
|
||||
deceased: deceased,
|
||||
heightM: height,
|
||||
weightKg: weight,
|
||||
esigPath: null,
|
||||
bloodType: blood,
|
||||
photoPath: null,
|
||||
uuidQrcode: null,
|
||||
nameExtension: extension,
|
||||
civilStatus: civilStatus,
|
||||
titleSuffix: null,
|
||||
showTitleId: false,
|
||||
);
|
||||
FamilyBackground familyBackground =
|
||||
FamilyBackground(company: company,position: position,relatedPerson: person,relationship: relationship,companyAddress: companyAddress,emergencyContact: emergnecyContacts,incaseOfEmergency: incaseOfEmergency,companyContactNumber: null);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
widget.familyBloc.add(AddFamily(familyBackground: familyBackground, profileId: widget.profileId, token: widget.token,relationshipId: selectedRelationship!.id!));
|
||||
}
|
||||
},
|
||||
child: const Text(submit)),
|
||||
),
|
||||
],
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,421 @@
|
|||
import 'package:date_time_picker/date_time_picker.dart';
|
||||
import 'package:flutter/material.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:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:unit2/bloc/profile/family/family_bloc.dart';
|
||||
import 'package:unit2/model/profile/family_backround.dart';
|
||||
|
||||
import '../../../../../model/utils/position.dart';
|
||||
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/text_container.dart';
|
||||
import '../../../../../utils/validators.dart';
|
||||
|
||||
class RelatedEditAlert extends StatefulWidget {
|
||||
final FamilyBackground familyBackground;
|
||||
final List<String> nameExtensions;
|
||||
final List<String> gender;
|
||||
final List<String> sexes;
|
||||
final List<String> bloodType;
|
||||
final List<String> civilStatus;
|
||||
final String token;
|
||||
final int profileId;
|
||||
final FamilyBloc familyBloc;
|
||||
final List<Relationship> relationships;
|
||||
|
||||
const RelatedEditAlert(
|
||||
{super.key,
|
||||
required this.familyBackground,
|
||||
required this.bloodType,
|
||||
required this.civilStatus,
|
||||
required this.gender,
|
||||
required this.nameExtensions,
|
||||
required this.relationships,
|
||||
required this.sexes,
|
||||
required this.familyBloc,
|
||||
required this.profileId,
|
||||
required this.token});
|
||||
|
||||
@override
|
||||
State<RelatedEditAlert> createState() => _RelatedEditAlertState();
|
||||
}
|
||||
|
||||
class _RelatedEditAlertState extends State<RelatedEditAlert> {
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
final bdayController = TextEditingController();
|
||||
|
||||
////selected
|
||||
String? selectedExtension;
|
||||
String? selectedGender;
|
||||
String? selectedSex;
|
||||
String? selectedBloodType;
|
||||
String? selectedCivilStatus;
|
||||
Relationship? selectedRelationship;
|
||||
bool deceased = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
selectedExtension = widget.familyBackground.relatedPerson?.nameExtension;
|
||||
selectedGender = widget.familyBackground.relatedPerson?.gender;
|
||||
selectedSex = widget.familyBackground.relatedPerson?.sex;
|
||||
selectedBloodType = widget.familyBackground.relatedPerson?.bloodType;
|
||||
selectedCivilStatus = widget.familyBackground.relatedPerson?.civilStatus;
|
||||
selectedRelationship = widget.relationships.firstWhere((element) => element.id == widget.familyBackground.relationship!.id);
|
||||
bdayController.text =
|
||||
widget.familyBackground.relatedPerson!.birthdate!.toString();
|
||||
deceased = widget.familyBackground.relatedPerson!.deceased!;
|
||||
return AlertDialog(
|
||||
title: const Text("Family - Other Related Person"),
|
||||
contentPadding: const EdgeInsets.all(24),
|
||||
content: SingleChildScrollView(
|
||||
child: FormBuilder(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
////Relationship
|
||||
DropdownButtonFormField<Relationship>(
|
||||
decoration: normalTextFieldStyle("Relationship", ""),
|
||||
value: selectedRelationship,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
items: widget.relationships.map(
|
||||
(element) {
|
||||
return DropdownMenuItem<Relationship>(
|
||||
value: element,
|
||||
child: Text(element.type!),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
onChanged: (e) {
|
||||
selectedRelationship = e;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8,),
|
||||
////name
|
||||
FormBuilderTextField(
|
||||
initialValue:
|
||||
widget.familyBackground.relatedPerson!.lastName,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "lastname",
|
||||
decoration: normalTextFieldStyle("Last name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// firstname
|
||||
FormBuilderTextField(
|
||||
initialValue:
|
||||
widget.familyBackground.relatedPerson!.firstName,
|
||||
name: "firstname",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
decoration: normalTextFieldStyle("First name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////middle name
|
||||
FormBuilderTextField(
|
||||
initialValue:
|
||||
widget.familyBackground.relatedPerson?.middleName,
|
||||
name: "middlename",
|
||||
|
||||
decoration: normalTextFieldStyle("Middle name", ""),
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// extension
|
||||
DropdownButtonFormField<String>(
|
||||
value: selectedExtension,
|
||||
decoration: normalTextFieldStyle("Name extension", ""),
|
||||
items: widget.nameExtensions
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element,
|
||||
child: Text(element),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedExtension = e;
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Bday
|
||||
DateTimePicker(
|
||||
controller: bdayController,
|
||||
use24HourFormat: false,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
timeHintText: "Birthdate",
|
||||
decoration:
|
||||
normalTextFieldStyle("Birthdate *", "*").copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
icon: const Icon(Icons.date_range),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// sex
|
||||
child: DropdownButtonFormField<String>(
|
||||
decoration: normalTextFieldStyle("Sex", ""),
|
||||
value: selectedSex,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
items: widget.sexes
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedSex = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
////gender
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle("Gender", ""),
|
||||
value: selectedGender,
|
||||
items: widget.gender
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedGender = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
////Blood Type
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle("Blood type", ""),
|
||||
value: selectedBloodType,
|
||||
items: widget.bloodType
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedBloodType = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
//// Civil Status
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle("Civil status", ""),
|
||||
value: selectedCivilStatus,
|
||||
items: widget.civilStatus
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedCivilStatus = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
////height
|
||||
child: FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson
|
||||
?.heightM ==
|
||||
null
|
||||
? null
|
||||
: widget.familyBackground.relatedPerson?.heightM
|
||||
.toString(),
|
||||
name: "height",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Height", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// weight
|
||||
child: FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson
|
||||
?.weightKg ==
|
||||
null
|
||||
? null
|
||||
: widget.familyBackground.relatedPerson?.weightKg
|
||||
.toString(),
|
||||
name: "weight",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Weight", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Deceased
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: StatefulBuilder(builder: (context, setState) {
|
||||
return FormBuilderSwitch(
|
||||
initialValue: deceased,
|
||||
title: Text(deceased ? "YES" : "NO"),
|
||||
decoration: normalTextFieldStyle("Deceased?", ""),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
deceased = value!;
|
||||
});
|
||||
},
|
||||
name: 'deceased',
|
||||
validator: FormBuilderValidators.required(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style:
|
||||
mainBtnStyle(second, Colors.transparent, primary),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.saveAndValidate()) {
|
||||
String fname =
|
||||
_formKey.currentState!.value['firstname'];
|
||||
String lastName =
|
||||
_formKey.currentState!.value['lastname'];
|
||||
String? mname =
|
||||
_formKey.currentState?.value['middlename'];
|
||||
String bday = bdayController.text;
|
||||
String? gender = selectedGender == "NONE"
|
||||
? null
|
||||
: selectedGender;
|
||||
String? extension = selectedExtension == "NONE"
|
||||
? null
|
||||
: selectedExtension;
|
||||
String? blood = selectedBloodType == "NONE"
|
||||
? null
|
||||
: selectedBloodType;
|
||||
String? civilStatus = selectedCivilStatus == "NONE"
|
||||
? null
|
||||
: selectedCivilStatus;
|
||||
String? sex = selectedSex;
|
||||
Company? company;
|
||||
Position? position;
|
||||
double? height =
|
||||
_formKey.currentState?.value['height'] == null
|
||||
? null
|
||||
: double.parse(
|
||||
_formKey.currentState?.value['height']);
|
||||
double? weight =
|
||||
_formKey.currentState?.value['weight'] == null
|
||||
? null
|
||||
: double.parse(
|
||||
_formKey.currentState?.value['weight']);
|
||||
Relationship relationship = Relationship(
|
||||
id: 1,
|
||||
type: "Paternal_Parent",
|
||||
category: "Family");
|
||||
List<EmergencyContact>? emergnecyContacts;
|
||||
bool incaseOfEmergency = false;
|
||||
String? companyAddress;
|
||||
RelatedPerson person = RelatedPerson(
|
||||
titlePrefix: null,
|
||||
firstName: fname,
|
||||
maidenName: null,
|
||||
middleName: mname,
|
||||
lastName: lastName,
|
||||
birthdate: DateTime.parse(bday),
|
||||
id: widget.familyBackground.relatedPerson!.id,
|
||||
sex: sex,
|
||||
gender: gender,
|
||||
deceased: deceased,
|
||||
heightM: height,
|
||||
weightKg: weight,
|
||||
esigPath: null,
|
||||
bloodType: blood,
|
||||
photoPath: null,
|
||||
uuidQrcode: null,
|
||||
nameExtension: extension,
|
||||
civilStatus: civilStatus,
|
||||
titleSuffix: null,
|
||||
showTitleId: false,
|
||||
);
|
||||
FamilyBackground familyBackground =
|
||||
FamilyBackground(
|
||||
company: company,
|
||||
position: position,
|
||||
relatedPerson: person,
|
||||
relationship: relationship,
|
||||
companyAddress: companyAddress,
|
||||
emergencyContact: emergnecyContacts,
|
||||
incaseOfEmergency: incaseOfEmergency,
|
||||
companyContactNumber: null);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
widget.familyBloc.add(Updatefamily(
|
||||
familyBackground: familyBackground,
|
||||
profileId: widget.profileId,
|
||||
token: widget.token,
|
||||
relationshipId: selectedRelationship!.id!));
|
||||
}
|
||||
},
|
||||
child: const Text(submit)),
|
||||
),
|
||||
],
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,722 @@
|
|||
import 'package:date_time_picker/date_time_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:fluttericon/font_awesome_icons.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:searchfield/searchfield.dart';
|
||||
|
||||
import '../../../../../bloc/profile/family/family_bloc.dart';
|
||||
import '../../../../../model/profile/family_backround.dart';
|
||||
import '../../../../../model/utils/agency.dart';
|
||||
import '../../../../../model/utils/category.dart';
|
||||
import '../../../../../model/utils/position.dart';
|
||||
import '../../../../../theme-data.dart/box_shadow.dart';
|
||||
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/text_container.dart';
|
||||
import '../../../../../utils/validators.dart';
|
||||
import '../../../shared/add_for_empty_search.dart';
|
||||
|
||||
class SpouseAlert extends StatefulWidget {
|
||||
final List<String> nameExtensions;
|
||||
final List<String> gender;
|
||||
final List<String> sexes;
|
||||
final List<String> bloodType;
|
||||
final List<String> civilStatus;
|
||||
final List<Position> positions;
|
||||
final List<Agency> agencies;
|
||||
final List<Category> category;
|
||||
final FamilyBloc familyBloc;
|
||||
final String token;
|
||||
final int profileId;
|
||||
|
||||
const SpouseAlert(
|
||||
{super.key,
|
||||
required this.token,
|
||||
required this.profileId,
|
||||
required this.familyBloc,
|
||||
required this.bloodType,
|
||||
required this.civilStatus,
|
||||
required this.agencies,
|
||||
required this.category,
|
||||
required this.positions,
|
||||
required this.gender,
|
||||
required this.nameExtensions,
|
||||
required this.sexes});
|
||||
|
||||
@override
|
||||
State<SpouseAlert> createState() => _SpouseAlertState();
|
||||
}
|
||||
|
||||
class _SpouseAlertState extends State<SpouseAlert> {
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
final bdayController = TextEditingController();
|
||||
|
||||
////selected
|
||||
String? selectedExtension;
|
||||
String? selectedGender;
|
||||
String? selectedSex;
|
||||
String? selectedBloodType;
|
||||
String? selectedCivilStatus; Position? selectedPosition;
|
||||
Category? selectedAgencyCategory;
|
||||
Agency? selectedAgency;
|
||||
bool deceased = false;
|
||||
|
||||
final agencyFocusNode = FocusNode();
|
||||
final positionFocusNode = FocusNode();
|
||||
final appointmentStatusNode = FocusNode();
|
||||
final agencyCategoryFocusNode = FocusNode();
|
||||
|
||||
final addAgencyController = TextEditingController();
|
||||
final addPositionController = TextEditingController();
|
||||
|
||||
bool hasOccupation = false;
|
||||
bool showAgency = false;
|
||||
bool? isPrivate = false;
|
||||
bool showIsPrivateRadio = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Family - Spouse"),
|
||||
contentPadding: const EdgeInsets.all(24),
|
||||
content: SingleChildScrollView(
|
||||
child: FormBuilder(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
////name
|
||||
FormBuilderTextField(
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "lastname",
|
||||
decoration: normalTextFieldStyle("Last name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// firstname
|
||||
FormBuilderTextField(
|
||||
name: "firstname",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
decoration: normalTextFieldStyle("First name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////middle name
|
||||
FormBuilderTextField(
|
||||
name: "middlename",
|
||||
decoration: normalTextFieldStyle("Middle name", ""),
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// extension
|
||||
FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Name extension", ""),
|
||||
name: "extension",
|
||||
|
||||
items: widget.nameExtensions
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element,
|
||||
child: Text(element),
|
||||
))
|
||||
.toList()),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
|
||||
////Bday
|
||||
DateTimePicker(
|
||||
controller: bdayController,
|
||||
use24HourFormat: false,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
timeHintText: "Birthdate",
|
||||
decoration:
|
||||
normalTextFieldStyle("Birthdate *", "*").copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
icon: const Icon(Icons.date_range),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// sex
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Sex", ""),
|
||||
name: "sex",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
items: widget.sexes
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedSex = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
////gender
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Gender", ""),
|
||||
name: "gender",
|
||||
items: widget.gender
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedGender = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
////Blood Type
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Blood type", ""),
|
||||
name: "bloodtype",
|
||||
items: widget.bloodType
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedBloodType = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
//// Civil Status
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
decoration: normalTextFieldStyle("Civil status", ""),
|
||||
name: "civil_status",
|
||||
items: widget.civilStatus
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedCivilStatus = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
////height
|
||||
child: FormBuilderTextField(
|
||||
name: "height",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Height", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// weight
|
||||
child: FormBuilderTextField(
|
||||
name: "weight",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Weight", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Deceased
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: StatefulBuilder(builder: (context, setState) {
|
||||
return FormBuilderSwitch(
|
||||
initialValue: deceased,
|
||||
title: Text(deceased ? "YES" : "NO"),
|
||||
decoration: normalTextFieldStyle("Deceased?", ""),
|
||||
////onvhange private sector
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
deceased = value!;
|
||||
});
|
||||
},
|
||||
|
||||
name: 'deceased',
|
||||
validator: FormBuilderValidators.required(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Has Occupation
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: StatefulBuilder(builder: (context, setState) {
|
||||
return Column(
|
||||
children: [
|
||||
FormBuilderSwitch(
|
||||
initialValue: hasOccupation,
|
||||
title: Text(hasOccupation ? "YES" : "NO"),
|
||||
decoration:
|
||||
normalTextFieldStyle("Has Occupation?", ""),
|
||||
////onvhange private sector
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
hasOccupation = value!;
|
||||
});
|
||||
},
|
||||
|
||||
name: 'hasOccupation',
|
||||
validator: FormBuilderValidators.required(),
|
||||
),
|
||||
Container(
|
||||
child: hasOccupation
|
||||
? Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
////Position
|
||||
return SearchField(
|
||||
itemHeight: 50,
|
||||
suggestionsDecoration: box1(),
|
||||
suggestions: widget.positions
|
||||
.map((Position position) =>
|
||||
SearchFieldListItem(
|
||||
position.title!,
|
||||
item: position,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets
|
||||
.symmetric(
|
||||
horizontal:
|
||||
10),
|
||||
child: ListTile(
|
||||
title: Text(position
|
||||
.title!),
|
||||
))))
|
||||
.toList(),
|
||||
focusNode: positionFocusNode,
|
||||
searchInputDecoration:
|
||||
normalTextFieldStyle(
|
||||
"Position *", "")
|
||||
.copyWith(
|
||||
suffixIcon: IconButton(
|
||||
icon: const Icon(
|
||||
Icons.arrow_drop_down),
|
||||
onPressed: () {
|
||||
positionFocusNode.unfocus();
|
||||
},
|
||||
)),
|
||||
onSuggestionTap: (position) {
|
||||
setState(() {
|
||||
selectedPosition = position.item;
|
||||
positionFocusNode.unfocus();
|
||||
});
|
||||
},
|
||||
////EMPTY WIDGET
|
||||
emptyWidget: EmptyWidget(
|
||||
title: "Add Position",
|
||||
controller: addPositionController,
|
||||
onpressed: () {
|
||||
setState(() {
|
||||
Position newAgencyPosition =
|
||||
Position(
|
||||
id: null,
|
||||
title:
|
||||
addPositionController
|
||||
.text
|
||||
.toUpperCase());
|
||||
|
||||
widget.positions.insert(
|
||||
0, newAgencyPosition);
|
||||
|
||||
addPositionController.text =
|
||||
"";
|
||||
Navigator.pop(context);
|
||||
});
|
||||
}),
|
||||
validator: (position) {
|
||||
if (position!.isEmpty) {
|
||||
return "This field is required";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
);
|
||||
}),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
return Column(
|
||||
children: [
|
||||
SearchField(
|
||||
itemHeight: 70,
|
||||
focusNode: agencyFocusNode,
|
||||
suggestions: widget.agencies
|
||||
.map((Agency agency) =>
|
||||
SearchFieldListItem(
|
||||
agency.name!,
|
||||
item: agency,
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
agency.name!,
|
||||
overflow:
|
||||
TextOverflow
|
||||
.ellipsis,
|
||||
),
|
||||
subtitle: Text(agency
|
||||
.privateEntity ==
|
||||
true
|
||||
? "Private"
|
||||
: agency.privateEntity ==
|
||||
false
|
||||
? "Government"
|
||||
: ""),
|
||||
)))
|
||||
.toList(),
|
||||
searchInputDecoration:
|
||||
normalTextFieldStyle(
|
||||
"Agency *", "")
|
||||
.copyWith(
|
||||
suffixIcon:
|
||||
const Icon(Icons
|
||||
.arrow_drop_down)),
|
||||
onSuggestionTap: (agency) {
|
||||
setState(() {
|
||||
selectedAgency =
|
||||
agency.item;
|
||||
|
||||
if (selectedAgency!
|
||||
.privateEntity ==
|
||||
null) {
|
||||
showIsPrivateRadio = true;
|
||||
} else {
|
||||
showIsPrivateRadio =
|
||||
false;
|
||||
}
|
||||
|
||||
agencyFocusNode.unfocus();
|
||||
});
|
||||
},
|
||||
validator: (agency) {
|
||||
if (agency!.isEmpty) {
|
||||
return "This field is required";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
emptyWidget: EmptyWidget(
|
||||
controller:
|
||||
addAgencyController,
|
||||
onpressed: () {
|
||||
setState(() {
|
||||
Agency newAgency = Agency(
|
||||
id: null,
|
||||
name: addAgencyController
|
||||
.text
|
||||
.toUpperCase(),
|
||||
category: null,
|
||||
privateEntity:
|
||||
null);
|
||||
|
||||
widget.agencies.insert(
|
||||
0, newAgency);
|
||||
selectedAgency =
|
||||
newAgency;
|
||||
addAgencyController
|
||||
.text = "";
|
||||
showAgency = true;
|
||||
|
||||
showIsPrivateRadio =
|
||||
true;
|
||||
|
||||
Navigator.pop(context);
|
||||
});
|
||||
},
|
||||
title: "Add Agency")),
|
||||
|
||||
SizedBox(
|
||||
height: showAgency ? 12 : 0,
|
||||
),
|
||||
////SHOW CATEGORY AGENCY
|
||||
SizedBox(
|
||||
child: showAgency
|
||||
? SearchField(
|
||||
focusNode:
|
||||
agencyCategoryFocusNode,
|
||||
itemHeight: 70,
|
||||
suggestions: widget
|
||||
.category
|
||||
.map((Category
|
||||
category) =>
|
||||
SearchFieldListItem(
|
||||
category
|
||||
.name!,
|
||||
item:
|
||||
category,
|
||||
child:
|
||||
ListTile(
|
||||
title: Text(
|
||||
category
|
||||
.name!),
|
||||
subtitle: Text(category
|
||||
.industryClass!
|
||||
.name!),
|
||||
)))
|
||||
.toList(),
|
||||
emptyWidget: Container(
|
||||
height: 100,
|
||||
decoration: box1(),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"No result found ...")),
|
||||
),
|
||||
onSuggestionTap:
|
||||
(agencyCategory) {
|
||||
setState(() {
|
||||
selectedAgencyCategory =
|
||||
agencyCategory
|
||||
.item;
|
||||
agencyCategoryFocusNode
|
||||
.unfocus();
|
||||
selectedAgency = Agency(
|
||||
id: null,
|
||||
name:
|
||||
selectedAgency!
|
||||
.name,
|
||||
category:
|
||||
selectedAgencyCategory,
|
||||
privateEntity:
|
||||
null);
|
||||
});
|
||||
},
|
||||
searchInputDecoration:
|
||||
normalTextFieldStyle(
|
||||
"Category *",
|
||||
"")
|
||||
.copyWith(
|
||||
suffixIcon:
|
||||
const Icon(
|
||||
Icons
|
||||
.arrow_drop_down)),
|
||||
validator: (value) {
|
||||
if (value!.isEmpty) {
|
||||
return "This field is required";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////PRVIATE SECTOR
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: showIsPrivateRadio
|
||||
? FormBuilderSwitch(
|
||||
initialValue: isPrivate,
|
||||
title: Text(isPrivate!
|
||||
? "YES"
|
||||
: "NO"),
|
||||
decoration:
|
||||
normalTextFieldStyle(
|
||||
"Private Entity?",
|
||||
""),
|
||||
////onvhange private sector
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
isPrivate = value;
|
||||
selectedAgency = Agency(
|
||||
id: null,
|
||||
name:
|
||||
selectedAgency!
|
||||
.name,
|
||||
category:
|
||||
selectedAgencyCategory,
|
||||
privateEntity:
|
||||
isPrivate);
|
||||
agencyFocusNode
|
||||
.unfocus();
|
||||
agencyCategoryFocusNode
|
||||
.unfocus();
|
||||
});
|
||||
},
|
||||
|
||||
name: 'isPrivate',
|
||||
validator:
|
||||
FormBuilderValidators
|
||||
.required(),
|
||||
)
|
||||
: const SizedBox()),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Company Address
|
||||
FormBuilderTextField(
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
name: "company_address",
|
||||
decoration: normalTextFieldStyle(
|
||||
"Company Address/Business Address *",
|
||||
"Company Address/Business Address *"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Company Tel Number
|
||||
FormBuilderTextField(
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
name: "company_tel",
|
||||
decoration: normalTextFieldStyle(
|
||||
"Company /Business Tel./Mobile # *",
|
||||
"Company /Business Tel./Mobile # *"),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
],
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style:
|
||||
mainBtnStyle(second, Colors.transparent, primary),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.saveAndValidate()) {
|
||||
|
||||
if (_formKey.currentState!.saveAndValidate()) {
|
||||
String fname =
|
||||
_formKey.currentState!.value['firstname'];
|
||||
String lastName =
|
||||
_formKey.currentState!.value['lastname'];
|
||||
String? mname =
|
||||
_formKey.currentState?.value['middlename'];
|
||||
String bday = bdayController.text;
|
||||
String? gender = selectedGender =="NONE"?null:selectedGender;
|
||||
String? extension = selectedExtension=="NONE"?null:selectedExtension;
|
||||
String? blood = selectedBloodType =="NONE"?null:selectedBloodType;
|
||||
String? civilStatus = selectedCivilStatus =="NONE"?null:selectedCivilStatus;
|
||||
String? sex = selectedSex;
|
||||
String? companyAddress = _formKey.currentState?.value['company_address'];
|
||||
String? companyContactNumber= _formKey.currentState?.value['company_tel'];
|
||||
Company? company = selectedAgency == null? null:Company(id: selectedAgency?.id,name: selectedAgency?.name,category: selectedAgencyCategory,privateEntity: isPrivate);
|
||||
Position? position = selectedPosition;
|
||||
double? height =
|
||||
_formKey.currentState?.value['height']==null? null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['height']);
|
||||
double? weight =
|
||||
_formKey.currentState?.value['weight']==null?null:
|
||||
double.parse(
|
||||
_formKey.currentState?.value['weight']);
|
||||
Relationship relationship = Relationship(
|
||||
id: 1,
|
||||
type: "Paternal_Parent",
|
||||
category: "Family");
|
||||
List<EmergencyContact>? emergnecyContacts;
|
||||
bool incaseOfEmergency = false;
|
||||
RelatedPerson person = RelatedPerson(
|
||||
titlePrefix: null,
|
||||
firstName: fname,
|
||||
maidenName: null,
|
||||
middleName: mname,
|
||||
lastName: lastName,
|
||||
birthdate: DateTime.parse(bday),
|
||||
id: null,
|
||||
sex: sex,
|
||||
gender: gender,
|
||||
deceased: deceased,
|
||||
heightM: height,
|
||||
weightKg: weight,
|
||||
esigPath: null,
|
||||
bloodType: blood,
|
||||
photoPath: null,
|
||||
uuidQrcode: null,
|
||||
nameExtension: extension,
|
||||
civilStatus: civilStatus,
|
||||
titleSuffix: null,
|
||||
showTitleId: false,
|
||||
);
|
||||
FamilyBackground familyBackground =
|
||||
FamilyBackground(company: company,position: position,relatedPerson: person,relationship: relationship,companyAddress: companyAddress,emergencyContact: emergnecyContacts,incaseOfEmergency: incaseOfEmergency,companyContactNumber: companyContactNumber);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
widget.familyBloc.add(AddFamily(familyBackground: familyBackground, profileId: widget.profileId, token: widget.token,relationshipId: 3));
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
child: const Text(submit)),
|
||||
),
|
||||
],
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,800 @@
|
|||
import 'package:date_time_picker/date_time_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:fluttericon/font_awesome_icons.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:searchfield/searchfield.dart';
|
||||
|
||||
import '../../../../../bloc/profile/family/family_bloc.dart';
|
||||
import '../../../../../model/profile/family_backround.dart';
|
||||
import '../../../../../model/utils/agency.dart';
|
||||
import '../../../../../model/utils/category.dart';
|
||||
import '../../../../../model/utils/position.dart';
|
||||
import '../../../../../theme-data.dart/box_shadow.dart';
|
||||
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/text_container.dart';
|
||||
import '../../../../../utils/validators.dart';
|
||||
import '../../../shared/add_for_empty_search.dart';
|
||||
|
||||
class SpouseEditAlert extends StatefulWidget {
|
||||
final List<String> nameExtensions;
|
||||
final List<String> gender;
|
||||
final List<String> sexes;
|
||||
final List<String> bloodType;
|
||||
final List<String> civilStatus;
|
||||
final List<Position> positions;
|
||||
final List<Agency> agencies;
|
||||
final List<Category> category;
|
||||
final FamilyBloc familyBloc;
|
||||
final String token;
|
||||
final int profileId;
|
||||
final FamilyBackground familyBackground;
|
||||
|
||||
const SpouseEditAlert(
|
||||
{super.key,
|
||||
required this.familyBackground,
|
||||
required this.token,
|
||||
required this.profileId,
|
||||
required this.familyBloc,
|
||||
required this.bloodType,
|
||||
required this.civilStatus,
|
||||
required this.agencies,
|
||||
required this.category,
|
||||
required this.positions,
|
||||
required this.gender,
|
||||
required this.nameExtensions,
|
||||
required this.sexes});
|
||||
|
||||
@override
|
||||
State<SpouseEditAlert> createState() => _SpouseEditAlertState();
|
||||
}
|
||||
|
||||
class _SpouseEditAlertState extends State<SpouseEditAlert> {
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
final bdayController = TextEditingController();
|
||||
|
||||
////selected
|
||||
String? selectedExtension;
|
||||
String? selectedGender;
|
||||
String? selectedSex;
|
||||
String? selectedBloodType;
|
||||
String? selectedCivilStatus;
|
||||
Position? selectedPosition;
|
||||
Category? selectedAgencyCategory;
|
||||
Agency? selectedAgency;
|
||||
bool deceased = false;
|
||||
|
||||
final agencyFocusNode = FocusNode();
|
||||
final positionFocusNode = FocusNode();
|
||||
final appointmentStatusNode = FocusNode();
|
||||
final agencyCategoryFocusNode = FocusNode();
|
||||
|
||||
final addAgencyController = TextEditingController();
|
||||
final addPositionController = TextEditingController();
|
||||
final oldPositionController = TextEditingController();
|
||||
final oldAppointmentStatusController = TextEditingController();
|
||||
final oldAgencyController = TextEditingController();
|
||||
bool hasOccupation = false;
|
||||
bool showAgency = false;
|
||||
bool? isPrivate = false;
|
||||
bool showIsPrivateRadio = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
selectedExtension = widget.familyBackground.relatedPerson?.nameExtension;
|
||||
selectedGender = widget.familyBackground.relatedPerson?.gender;
|
||||
selectedSex = widget.familyBackground.relatedPerson?.sex;
|
||||
selectedBloodType = widget.familyBackground.relatedPerson?.bloodType;
|
||||
selectedCivilStatus = widget.familyBackground.relatedPerson?.civilStatus;
|
||||
bdayController.text =
|
||||
widget.familyBackground.relatedPerson!.birthdate!.toString();
|
||||
deceased = widget.familyBackground.relatedPerson!.deceased!;
|
||||
hasOccupation = widget.familyBackground.position != null;
|
||||
oldPositionController.text = widget.familyBackground.position == null?"":widget.familyBackground.position!.title!;
|
||||
oldAgencyController.text = widget.familyBackground.company == null?"":widget.familyBackground.company!.name!;
|
||||
selectedAgency = widget.familyBackground.company==null?null:Agency(id: widget.familyBackground.company!.id, name: widget.familyBackground.company!.name,category: widget.familyBackground.company!.category,privateEntity: widget.familyBackground.company!.privateEntity);
|
||||
return AlertDialog(
|
||||
title: const Text("Family - Spouse"),
|
||||
contentPadding: const EdgeInsets.all(24),
|
||||
content: SingleChildScrollView(
|
||||
child: FormBuilder(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
////name
|
||||
FormBuilderTextField(
|
||||
initialValue:
|
||||
widget.familyBackground.relatedPerson!.lastName,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "lastname",
|
||||
decoration: normalTextFieldStyle("Last name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// firstname
|
||||
FormBuilderTextField(
|
||||
initialValue:
|
||||
widget.familyBackground.relatedPerson!.firstName,
|
||||
name: "firstname",
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
decoration: normalTextFieldStyle("First name", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////middle name
|
||||
FormBuilderTextField(
|
||||
initialValue:
|
||||
widget.familyBackground.relatedPerson?.middleName,
|
||||
name: "middlename",
|
||||
decoration: normalTextFieldStyle("Middle name", ""),
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// extension
|
||||
DropdownButtonFormField<String>(
|
||||
value: selectedExtension,
|
||||
decoration: normalTextFieldStyle("Name extension", ""),
|
||||
items: widget.nameExtensions
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element,
|
||||
child: Text(element),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedExtension = e;
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Bday
|
||||
DateTimePicker(
|
||||
controller: bdayController,
|
||||
use24HourFormat: false,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
timeHintText: "Birthdate",
|
||||
decoration:
|
||||
normalTextFieldStyle("Birthdate *", "*").copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
icon: const Icon(Icons.date_range),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// sex
|
||||
child: DropdownButtonFormField<String>(
|
||||
decoration: normalTextFieldStyle("Sex", ""),
|
||||
value: selectedSex,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
items: widget.sexes
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedSex = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
////gender
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle("Gender", ""),
|
||||
value: selectedGender,
|
||||
items: widget.gender
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedGender = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
////Blood Type
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle("Blood type", ""),
|
||||
value: selectedBloodType,
|
||||
items: widget.bloodType
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedBloodType = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
//// Civil Status
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle("Civil status", ""),
|
||||
value: selectedCivilStatus,
|
||||
items: widget.civilStatus
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
selectedCivilStatus = e;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: Row(children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
////height
|
||||
child: FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson
|
||||
?.heightM ==
|
||||
null
|
||||
? null
|
||||
: widget.familyBackground.relatedPerson?.heightM
|
||||
.toString(),
|
||||
name: "height",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Height", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
//// weight
|
||||
child: FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.relatedPerson
|
||||
?.weightKg ==
|
||||
null
|
||||
? null
|
||||
: widget.familyBackground.relatedPerson?.weightKg
|
||||
.toString(),
|
||||
name: "weight",
|
||||
validator: integerAndNumeric,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: normalTextFieldStyle("Weight", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Deceased
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: StatefulBuilder(builder: (context, setState) {
|
||||
return FormBuilderSwitch(
|
||||
initialValue: deceased,
|
||||
title: Text(deceased ? "YES" : "NO"),
|
||||
decoration: normalTextFieldStyle("Deceased?", ""),
|
||||
////onvhange private sector
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
deceased = value!;
|
||||
});
|
||||
},
|
||||
|
||||
name: 'deceased',
|
||||
validator: FormBuilderValidators.required(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Has Occupation
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: StatefulBuilder(builder: (context, setState) {
|
||||
return Column(
|
||||
children: [
|
||||
FormBuilderSwitch(
|
||||
initialValue: hasOccupation,
|
||||
title: Text(hasOccupation ? "YES" : "NO"),
|
||||
decoration:
|
||||
normalTextFieldStyle("Has Occupation?", ""),
|
||||
////onvhange private sector
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
hasOccupation = value!;
|
||||
});
|
||||
},
|
||||
|
||||
name: 'hasOccupation',
|
||||
validator: FormBuilderValidators.required(),
|
||||
),
|
||||
Container(
|
||||
child: hasOccupation
|
||||
? Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
////Position
|
||||
return SearchField(
|
||||
controller: oldPositionController,
|
||||
itemHeight: 50,
|
||||
suggestionsDecoration: box1(),
|
||||
suggestions: widget.positions
|
||||
.map((Position position) =>
|
||||
SearchFieldListItem(
|
||||
position.title!,
|
||||
item: position,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets
|
||||
.symmetric(
|
||||
horizontal:
|
||||
10),
|
||||
child: ListTile(
|
||||
title: Text(position
|
||||
.title!),
|
||||
))))
|
||||
.toList(),
|
||||
focusNode: positionFocusNode,
|
||||
searchInputDecoration:
|
||||
normalTextFieldStyle(
|
||||
"Position *", "")
|
||||
.copyWith(
|
||||
suffixIcon: IconButton(
|
||||
icon: const Icon(
|
||||
Icons.arrow_drop_down),
|
||||
onPressed: () {
|
||||
positionFocusNode.unfocus();
|
||||
},
|
||||
)),
|
||||
onSuggestionTap: (position) {
|
||||
setState(() {
|
||||
selectedPosition = position.item;
|
||||
positionFocusNode.unfocus();
|
||||
});
|
||||
},
|
||||
////EMPTY WIDGET
|
||||
emptyWidget: EmptyWidget(
|
||||
title: "Add Position",
|
||||
controller: addPositionController,
|
||||
onpressed: () {
|
||||
setState(() {
|
||||
Position newAgencyPosition =
|
||||
Position(
|
||||
id: null,
|
||||
title:
|
||||
addPositionController
|
||||
.text
|
||||
.toUpperCase());
|
||||
|
||||
widget.positions.insert(
|
||||
0, newAgencyPosition);
|
||||
|
||||
addPositionController.text =
|
||||
"";
|
||||
Navigator.pop(context);
|
||||
});
|
||||
}),
|
||||
validator: (position) {
|
||||
if (position!.isEmpty) {
|
||||
return "This field is required";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
);
|
||||
}),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
return Column(
|
||||
children: [
|
||||
////Company
|
||||
SearchField(
|
||||
controller: oldAgencyController,
|
||||
itemHeight: 70,
|
||||
focusNode: agencyFocusNode,
|
||||
suggestions: widget.agencies
|
||||
.map((Agency agency) =>
|
||||
SearchFieldListItem(
|
||||
agency.name!,
|
||||
item: agency,
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
agency.name!,
|
||||
overflow:
|
||||
TextOverflow
|
||||
.ellipsis,
|
||||
),
|
||||
subtitle: Text(agency
|
||||
.privateEntity ==
|
||||
true
|
||||
? "Private"
|
||||
: agency.privateEntity ==
|
||||
false
|
||||
? "Government"
|
||||
: ""),
|
||||
)))
|
||||
.toList(),
|
||||
searchInputDecoration:
|
||||
normalTextFieldStyle(
|
||||
"Agency *", "")
|
||||
.copyWith(
|
||||
suffixIcon:
|
||||
const Icon(Icons
|
||||
.arrow_drop_down)),
|
||||
onSuggestionTap: (agency) {
|
||||
setState(() {
|
||||
selectedAgency =
|
||||
agency.item;
|
||||
|
||||
if (selectedAgency!
|
||||
.privateEntity ==
|
||||
null) {
|
||||
showIsPrivateRadio = true;
|
||||
} else {
|
||||
showIsPrivateRadio =
|
||||
false;
|
||||
}
|
||||
|
||||
agencyFocusNode.unfocus();
|
||||
});
|
||||
},
|
||||
validator: (agency) {
|
||||
if (agency!.isEmpty) {
|
||||
return "This field is required";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
emptyWidget: EmptyWidget(
|
||||
controller:
|
||||
addAgencyController,
|
||||
onpressed: () {
|
||||
setState(() {
|
||||
Agency newAgency = Agency(
|
||||
id: null,
|
||||
name: addAgencyController
|
||||
.text
|
||||
.toUpperCase(),
|
||||
category: null,
|
||||
privateEntity:
|
||||
null);
|
||||
|
||||
widget.agencies.insert(
|
||||
0, newAgency);
|
||||
selectedAgency =
|
||||
newAgency;
|
||||
addAgencyController
|
||||
.text = "";
|
||||
showAgency = true;
|
||||
|
||||
showIsPrivateRadio =
|
||||
true;
|
||||
|
||||
Navigator.pop(context);
|
||||
});
|
||||
},
|
||||
title: "Add Agency")),
|
||||
|
||||
SizedBox(
|
||||
height: showAgency ? 12 : 0,
|
||||
),
|
||||
////SHOW CATEGORY AGENCY
|
||||
SizedBox(
|
||||
child: showAgency
|
||||
? SearchField(
|
||||
focusNode:
|
||||
agencyCategoryFocusNode,
|
||||
itemHeight: 70,
|
||||
suggestions: widget
|
||||
.category
|
||||
.map((Category
|
||||
category) =>
|
||||
SearchFieldListItem(
|
||||
category
|
||||
.name!,
|
||||
item:
|
||||
category,
|
||||
child:
|
||||
ListTile(
|
||||
title: Text(
|
||||
category
|
||||
.name!),
|
||||
subtitle: Text(category
|
||||
.industryClass!
|
||||
.name!),
|
||||
)))
|
||||
.toList(),
|
||||
emptyWidget: Container(
|
||||
height: 100,
|
||||
decoration: box1(),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"No result found ...")),
|
||||
),
|
||||
onSuggestionTap:
|
||||
(agencyCategory) {
|
||||
setState(() {
|
||||
selectedAgencyCategory =
|
||||
agencyCategory
|
||||
.item;
|
||||
agencyCategoryFocusNode
|
||||
.unfocus();
|
||||
selectedAgency = Agency(
|
||||
id: null,
|
||||
name:
|
||||
selectedAgency!
|
||||
.name,
|
||||
category:
|
||||
selectedAgencyCategory,
|
||||
privateEntity:
|
||||
null);
|
||||
});
|
||||
},
|
||||
searchInputDecoration:
|
||||
normalTextFieldStyle(
|
||||
"Category *",
|
||||
"")
|
||||
.copyWith(
|
||||
suffixIcon:
|
||||
const Icon(
|
||||
Icons
|
||||
.arrow_drop_down)),
|
||||
validator: (value) {
|
||||
if (value!.isEmpty) {
|
||||
return "This field is required";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////PRVIATE SECTOR
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: showIsPrivateRadio
|
||||
? FormBuilderSwitch(
|
||||
initialValue: isPrivate,
|
||||
title: Text(isPrivate!
|
||||
? "YES"
|
||||
: "NO"),
|
||||
decoration:
|
||||
normalTextFieldStyle(
|
||||
"Private Entity?",
|
||||
""),
|
||||
////onvhange private sector
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
isPrivate = value;
|
||||
selectedAgency = Agency(
|
||||
id: null,
|
||||
name:
|
||||
selectedAgency!
|
||||
.name,
|
||||
category:
|
||||
selectedAgencyCategory,
|
||||
privateEntity:
|
||||
isPrivate);
|
||||
agencyFocusNode
|
||||
.unfocus();
|
||||
agencyCategoryFocusNode
|
||||
.unfocus();
|
||||
});
|
||||
},
|
||||
|
||||
name: 'isPrivate',
|
||||
validator:
|
||||
FormBuilderValidators
|
||||
.required(),
|
||||
)
|
||||
: const SizedBox()),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Company Address
|
||||
FormBuilderTextField(
|
||||
initialValue: widget.familyBackground.companyAddress,
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
name: "company_address",
|
||||
decoration: normalTextFieldStyle(
|
||||
"Company Address/Business Address *",
|
||||
"Company Address/Business Address *"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////Company Tel Number
|
||||
FormBuilderTextField(
|
||||
initialValue:
|
||||
widget.familyBackground.companyContactNumber,
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
name: "company_tel",
|
||||
decoration: normalTextFieldStyle(
|
||||
"Company /Business Tel./Mobile # *",
|
||||
"Company /Business Tel./Mobile # *"),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
],
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style:
|
||||
mainBtnStyle(second, Colors.transparent, primary),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.saveAndValidate()) {
|
||||
if (_formKey.currentState!.saveAndValidate()) {
|
||||
String fname =
|
||||
_formKey.currentState!.value['firstname'];
|
||||
String lastName =
|
||||
_formKey.currentState!.value['lastname'];
|
||||
String? mname =
|
||||
_formKey.currentState?.value['middlename'];
|
||||
String bday = bdayController.text;
|
||||
String? gender = selectedGender == "NONE"
|
||||
? null
|
||||
: selectedGender;
|
||||
String? extension = selectedExtension == "NONE"
|
||||
? null
|
||||
: selectedExtension;
|
||||
String? blood = selectedBloodType == "NONE"
|
||||
? null
|
||||
: selectedBloodType;
|
||||
String? civilStatus =
|
||||
selectedCivilStatus == "NONE"
|
||||
? null
|
||||
: selectedCivilStatus;
|
||||
String? sex = selectedSex;
|
||||
String? companyAddress = _formKey
|
||||
.currentState?.value['company_address'];
|
||||
String? companyContactNumber =
|
||||
_formKey.currentState?.value['company_tel'];
|
||||
Company? company = selectedAgency == null
|
||||
? null
|
||||
: Company(
|
||||
id: selectedAgency?.id,
|
||||
name: selectedAgency?.name,
|
||||
category: selectedAgencyCategory,
|
||||
privateEntity: isPrivate);
|
||||
Position? position = selectedPosition;
|
||||
double? height = _formKey
|
||||
.currentState?.value['height'] ==
|
||||
null
|
||||
? null
|
||||
: double.parse(
|
||||
_formKey.currentState?.value['height']);
|
||||
double? weight = _formKey
|
||||
.currentState?.value['weight'] ==
|
||||
null
|
||||
? null
|
||||
: double.parse(
|
||||
_formKey.currentState?.value['weight']);
|
||||
Relationship relationship = Relationship(
|
||||
id: 1,
|
||||
type: "Paternal_Parent",
|
||||
category: "Family");
|
||||
List<EmergencyContact>? emergnecyContacts;
|
||||
bool incaseOfEmergency = false;
|
||||
RelatedPerson person = RelatedPerson(
|
||||
titlePrefix: null,
|
||||
firstName: fname,
|
||||
maidenName: null,
|
||||
middleName: mname,
|
||||
lastName: lastName,
|
||||
birthdate: DateTime.parse(bday),
|
||||
id: widget.familyBackground.relatedPerson!.id,
|
||||
sex: sex,
|
||||
gender: gender,
|
||||
deceased: deceased,
|
||||
heightM: height,
|
||||
weightKg: weight,
|
||||
esigPath: null,
|
||||
bloodType: blood,
|
||||
photoPath: null,
|
||||
uuidQrcode: null,
|
||||
nameExtension: extension,
|
||||
civilStatus: civilStatus,
|
||||
titleSuffix: null,
|
||||
showTitleId: false,
|
||||
);
|
||||
FamilyBackground familyBackground =
|
||||
FamilyBackground(
|
||||
company: hasOccupation?company:null,
|
||||
position: hasOccupation? position:null,
|
||||
relatedPerson: person,
|
||||
relationship: relationship,
|
||||
companyAddress: hasOccupation? companyAddress:null,
|
||||
emergencyContact: emergnecyContacts,
|
||||
incaseOfEmergency: incaseOfEmergency,
|
||||
companyContactNumber:hasOccupation?
|
||||
companyContactNumber:null);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
widget.familyBloc.add(Updatefamily(
|
||||
familyBackground: familyBackground,
|
||||
profileId: widget.profileId,
|
||||
token: widget.token,
|
||||
relationshipId: 3));
|
||||
}
|
||||
}
|
||||
},
|
||||
child: const Text(submit)),
|
||||
),
|
||||
],
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,826 @@
|
|||
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:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
import 'package:searchfield/searchfield.dart';
|
||||
import 'package:unit2/bloc/profile/primary_information/identification/identification_bloc.dart';
|
||||
import 'package:unit2/model/utils/industry_class.dart';
|
||||
import 'package:unit2/theme-data.dart/btn-style.dart';
|
||||
import 'package:unit2/utils/text_container.dart';
|
||||
|
||||
import '../../../../../model/location/city.dart';
|
||||
import '../../../../../model/location/country.dart';
|
||||
import '../../../../../model/location/provinces.dart';
|
||||
import '../../../../../model/location/region.dart';
|
||||
import '../../../../../model/profile/basic_information/identification_information.dart';
|
||||
import '../../../../../model/profile/voluntary_works.dart';
|
||||
import '../../../../../model/utils/agency.dart';
|
||||
import '../../../../../model/utils/category.dart';
|
||||
import '../../../../../theme-data.dart/box_shadow.dart';
|
||||
import '../../../../../theme-data.dart/colors.dart';
|
||||
import '../../../../../theme-data.dart/form-style.dart';
|
||||
import '../../../../../utils/global.dart';
|
||||
import '../../../../../utils/global_context.dart';
|
||||
import '../../../../../utils/location_utilities.dart';
|
||||
import '../../../shared/add_for_empty_search.dart';
|
||||
|
||||
class AddIdentificationScreen extends StatefulWidget {
|
||||
final int profileId;
|
||||
final String token;
|
||||
const AddIdentificationScreen(
|
||||
{super.key, required this.profileId, required this.token});
|
||||
|
||||
@override
|
||||
State<AddIdentificationScreen> createState() =>
|
||||
_AddIdentificationScreenState();
|
||||
}
|
||||
|
||||
class _AddIdentificationScreenState extends State<AddIdentificationScreen> {
|
||||
final addAgencyController = TextEditingController();
|
||||
final dateIssuedController = TextEditingController();
|
||||
final expirationController = TextEditingController();
|
||||
final agencyFocusNode = FocusNode();
|
||||
final agencyCategoryFocusNode = FocusNode();
|
||||
bool showAgency = false;
|
||||
bool showIsPrivateRadio = false;
|
||||
bool asPdfReference = false;
|
||||
bool isPrivate = false;
|
||||
bool overseas = false;
|
||||
bool provinceCall = false;
|
||||
bool cityCall = false;
|
||||
bool otherAgency = false;
|
||||
////selected
|
||||
Agency? selectedAgency;
|
||||
Category? selectedCategoty;
|
||||
Region? selectedRegion;
|
||||
Province? selectedProvince;
|
||||
CityMunicipality? selectedMunicipality;
|
||||
Country? selectedCountry;
|
||||
List<Province>? provinces;
|
||||
List<CityMunicipality>? citymuns;
|
||||
|
||||
final formKey = GlobalKey<FormBuilderState>();
|
||||
List<Agency>? requiredAgency = [
|
||||
Agency(
|
||||
id: 173,
|
||||
name: "GOVERNMENT SERVICE INSURANCE SYSTEM (GSIS)",
|
||||
category: Category(
|
||||
id: 16,
|
||||
name: "Government-Owned and Controlled Corporations (GOCC)",
|
||||
industryClass: IndustryClass(
|
||||
description: null, name: "Public Governance", id: 16)),
|
||||
privateEntity: false),
|
||||
Agency(
|
||||
id: 2,
|
||||
name: "SOCIAL SECURITY SYSTEM (SSS)",
|
||||
category: Category(
|
||||
id: 202,
|
||||
name: "Government-Owned and Controlled Corporations (GOCC)",
|
||||
industryClass: IndustryClass(
|
||||
id: 16, name: "Public Governance", description: null)),
|
||||
privateEntity: false),
|
||||
Agency(
|
||||
id: 3,
|
||||
name: "HOME DEVELOPMENT MUTUAL FUND (PAG-IBIG FUND)",
|
||||
category: Category(
|
||||
id: 202,
|
||||
name: "Government-Owned and Controlled Corporations (GOCC)",
|
||||
industryClass: IndustryClass(
|
||||
name: "Public Governance", id: 16, description: null)),
|
||||
privateEntity: false),
|
||||
Agency(
|
||||
id: 4,
|
||||
name: "BUREAU OF INTERNAL REVENUE (BIR)",
|
||||
category: Category(
|
||||
id: 201,
|
||||
name: "National Government Agency",
|
||||
industryClass: IndustryClass(
|
||||
id: 16, name: "Public Governance", description: null),
|
||||
),
|
||||
privateEntity: false),
|
||||
Agency(
|
||||
id: 165,
|
||||
name: "PHILIPPINE HEALTH INSURANCE CORPORATION (PHILHEALTH)",
|
||||
category: Category(
|
||||
id: 202,
|
||||
name: "Government-Owned and Controlled Corporations (GOCC)",
|
||||
industryClass: IndustryClass(
|
||||
id: 16, name: "Public Governance", description: null)),
|
||||
privateEntity: false),
|
||||
Agency(id: 0, name: "OTHERS"),
|
||||
];
|
||||
List<int> requiredIds = [173, 2, 3, 4, 165];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<IdentificationBloc, IdentificationState>(
|
||||
buildWhen: (previous, current) {
|
||||
return false;
|
||||
},
|
||||
builder: (context, state) {
|
||||
|
||||
if (state is IdentificationAddingState) {
|
||||
|
||||
for (var agency in state.addedAgencies) {
|
||||
if (requiredIds.contains(agency.id)) {
|
||||
Agency? newAgency = requiredAgency
|
||||
?.firstWhere((element) => element.id == agency.id);
|
||||
if (newAgency != null) {
|
||||
requiredAgency!.remove(newAgency);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 24),
|
||||
child: FormBuilder(
|
||||
key: formKey,
|
||||
child: SizedBox(
|
||||
height: screenHeight * 90,
|
||||
child: ListView(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
StatefulBuilder(builder: (context, setState) {
|
||||
return Column(
|
||||
children: [
|
||||
FormBuilderDropdown<Agency>(
|
||||
isExpanded: true,
|
||||
decoration: normalTextFieldStyle(
|
||||
"Select Agency", "Select Agency"),
|
||||
name: "requiredAgency",
|
||||
items: requiredAgency!
|
||||
.map<DropdownMenuItem<Agency>>(
|
||||
(Agency agency) {
|
||||
return DropdownMenuItem(
|
||||
value: agency,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
decoration:
|
||||
box1().copyWith(boxShadow: []),
|
||||
child: Text(agency.name!)),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
selectedAgency = value;
|
||||
|
||||
if (value!.id == 0) {
|
||||
setState(() {
|
||||
otherAgency = true;
|
||||
});
|
||||
} else {
|
||||
isPrivate = value.privateEntity!;
|
||||
setState(() {
|
||||
otherAgency = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
////Other agency
|
||||
SizedBox(
|
||||
child: otherAgency
|
||||
? StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
return Column(
|
||||
children: [
|
||||
////Company
|
||||
SizedBox(
|
||||
child: SearchField(
|
||||
itemHeight: 70,
|
||||
focusNode: agencyFocusNode,
|
||||
suggestions: state.agencies
|
||||
.map((Agency agency) =>
|
||||
SearchFieldListItem(
|
||||
agency.name!,
|
||||
item: agency,
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
agency
|
||||
.name!,
|
||||
overflow:
|
||||
TextOverflow
|
||||
.ellipsis,
|
||||
),
|
||||
subtitle: Text(agency
|
||||
.privateEntity ==
|
||||
true
|
||||
? "Private"
|
||||
: agency.privateEntity ==
|
||||
false
|
||||
? "Government"
|
||||
: ""),
|
||||
)))
|
||||
.toList(),
|
||||
searchInputDecoration:
|
||||
normalTextFieldStyle(
|
||||
"Agency *", "")
|
||||
.copyWith(
|
||||
suffixIcon:
|
||||
const Icon(Icons
|
||||
.arrow_drop_down)),
|
||||
onSuggestionTap: (agency) {
|
||||
setState(() {
|
||||
selectedAgency =
|
||||
agency.item;
|
||||
|
||||
if (selectedAgency!
|
||||
.privateEntity ==
|
||||
null) {
|
||||
showIsPrivateRadio =
|
||||
true;
|
||||
} else {
|
||||
showIsPrivateRadio =
|
||||
false;
|
||||
}
|
||||
|
||||
agencyFocusNode
|
||||
.unfocus();
|
||||
});
|
||||
},
|
||||
validator: (agency) {
|
||||
if (agency!.isEmpty) {
|
||||
return "This field is required";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
emptyWidget: EmptyWidget(
|
||||
controller:
|
||||
addAgencyController,
|
||||
onpressed: () {
|
||||
setState(() {
|
||||
Agency newAgency = Agency(
|
||||
id: null,
|
||||
name: addAgencyController
|
||||
.text
|
||||
.toUpperCase(),
|
||||
category: null,
|
||||
privateEntity:
|
||||
null);
|
||||
|
||||
state.agencies
|
||||
.insert(0,
|
||||
newAgency);
|
||||
selectedAgency =
|
||||
newAgency;
|
||||
addAgencyController
|
||||
.text = "";
|
||||
showAgency = true;
|
||||
|
||||
showIsPrivateRadio =
|
||||
true;
|
||||
|
||||
Navigator.pop(
|
||||
context);
|
||||
});
|
||||
},
|
||||
title: "Add Agency")),
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
height: showAgency ? 8 : 0,
|
||||
),
|
||||
////SHOW CATEGORY AGENCY
|
||||
SizedBox(
|
||||
child: showAgency
|
||||
? SearchField(
|
||||
focusNode:
|
||||
agencyCategoryFocusNode,
|
||||
itemHeight: 70,
|
||||
suggestions: state
|
||||
.agencyCategory
|
||||
.map((Category
|
||||
category) =>
|
||||
SearchFieldListItem(
|
||||
category
|
||||
.name!,
|
||||
item:
|
||||
category,
|
||||
child:
|
||||
ListTile(
|
||||
title: Text(
|
||||
category
|
||||
.name!),
|
||||
subtitle: Text(category
|
||||
.industryClass!
|
||||
.name!),
|
||||
)))
|
||||
.toList(),
|
||||
emptyWidget: Container(
|
||||
height: 100,
|
||||
decoration: box1(),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"No result found ...")),
|
||||
),
|
||||
onSuggestionTap:
|
||||
(agencyCategory) {
|
||||
setState(() {
|
||||
selectedCategoty =
|
||||
agencyCategory
|
||||
.item;
|
||||
agencyCategoryFocusNode
|
||||
.unfocus();
|
||||
selectedAgency = Agency(
|
||||
id: null,
|
||||
name:
|
||||
selectedAgency!
|
||||
.name,
|
||||
category:
|
||||
selectedCategoty,
|
||||
privateEntity:
|
||||
null);
|
||||
});
|
||||
},
|
||||
searchInputDecoration:
|
||||
normalTextFieldStyle(
|
||||
"Category *",
|
||||
"")
|
||||
.copyWith(
|
||||
suffixIcon:
|
||||
const Icon(
|
||||
Icons.arrow_drop_down)),
|
||||
validator: (value) {
|
||||
if (value!.isEmpty) {
|
||||
return "This field is required";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
////PRVIATE SECTOR
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
child: showIsPrivateRadio
|
||||
? FormBuilderSwitch(
|
||||
initialValue:
|
||||
isPrivate,
|
||||
title: Text(isPrivate
|
||||
? "YES"
|
||||
: "NO"),
|
||||
decoration:
|
||||
normalTextFieldStyle(
|
||||
"Private Entity?",
|
||||
""),
|
||||
////onvhange private sector
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
isPrivate =
|
||||
value!;
|
||||
selectedAgency = Agency(
|
||||
id: null,
|
||||
name:
|
||||
selectedAgency!
|
||||
.name,
|
||||
category:
|
||||
selectedCategoty,
|
||||
privateEntity:
|
||||
isPrivate);
|
||||
agencyFocusNode
|
||||
.unfocus();
|
||||
agencyCategoryFocusNode
|
||||
.unfocus();
|
||||
});
|
||||
},
|
||||
|
||||
name: 'isPrivate',
|
||||
validator:
|
||||
FormBuilderValidators
|
||||
.required(),
|
||||
)
|
||||
: const SizedBox()),
|
||||
],
|
||||
);
|
||||
})
|
||||
: const SizedBox(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
SizedBox(
|
||||
height: otherAgency ? 8 : 0,
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// Identification numner
|
||||
FormBuilderTextField(
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "identification_number",
|
||||
decoration: normalTextFieldStyle(
|
||||
"Identification Number *", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
//// Date Issued
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DateTimePicker(
|
||||
controller: dateIssuedController,
|
||||
use24HourFormat: false,
|
||||
icon: const Icon(Icons.date_range),
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
timeHintText: "Date Issued",
|
||||
decoration: normalTextFieldStyle(
|
||||
"Date Issued *", "Date Issued *")
|
||||
.copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
initialValue: null,
|
||||
)),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
//// Expiration Date
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DateTimePicker(
|
||||
controller: expirationController,
|
||||
use24HourFormat: false,
|
||||
icon: const Icon(Icons.date_range),
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
timeHintText: "Expiration date",
|
||||
decoration: normalTextFieldStyle(
|
||||
"Expiration Date *",
|
||||
"Expiration Date *")
|
||||
.copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
initialValue: null,
|
||||
)),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// as pdf reference
|
||||
StatefulBuilder(builder: (context, setState) {
|
||||
return FormBuilderSwitch(
|
||||
initialValue: asPdfReference,
|
||||
activeColor: second,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
asPdfReference = value!;
|
||||
});
|
||||
},
|
||||
decoration:
|
||||
normalTextFieldStyle("As PDF Reference?", ''),
|
||||
name: 'pdf_reference',
|
||||
title: Text(asPdfReference ? "YES" : "NO"),
|
||||
);
|
||||
}),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// OVERSEAS
|
||||
//// OVERSEAS
|
||||
StatefulBuilder(builder: (context, setState) {
|
||||
return Column(
|
||||
children: [
|
||||
FormBuilderSwitch(
|
||||
initialValue: overseas,
|
||||
activeColor: second,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
overseas = value!;
|
||||
});
|
||||
},
|
||||
decoration: normalTextFieldStyle(
|
||||
"Overseas Address?", ''),
|
||||
name: 'overseas',
|
||||
title: Text(overseas ? "YES" : "NO"),
|
||||
),
|
||||
SizedBox(
|
||||
height: overseas == true ? 8 : 0,
|
||||
),
|
||||
SizedBox(
|
||||
child: overseas == false
|
||||
? Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
////REGION DROPDOWN
|
||||
DropdownButtonFormField<Region?>(
|
||||
isExpanded: true,
|
||||
autovalidateMode: AutovalidateMode
|
||||
.onUserInteraction,
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
onChanged:
|
||||
(Region? region) async {
|
||||
if (selectedRegion != region) {
|
||||
setState(() {
|
||||
provinceCall = true;
|
||||
});
|
||||
selectedRegion = region;
|
||||
try {
|
||||
provinces = await LocationUtils
|
||||
.instance
|
||||
.getProvinces(
|
||||
regionCode:
|
||||
selectedRegion!
|
||||
.code
|
||||
.toString());
|
||||
selectedProvince =
|
||||
provinces![0];
|
||||
setState(() {
|
||||
provinceCall = false;
|
||||
cityCall = true;
|
||||
});
|
||||
try {
|
||||
citymuns = await LocationUtils
|
||||
.instance
|
||||
.getCities(
|
||||
code: selectedProvince!
|
||||
.code
|
||||
.toString());
|
||||
selectedMunicipality =
|
||||
citymuns![0];
|
||||
setState(() {
|
||||
cityCall = false;
|
||||
});
|
||||
} catch (e) {
|
||||
NavigationService
|
||||
.navigatorKey
|
||||
.currentContext
|
||||
?.read<
|
||||
IdentificationBloc>()
|
||||
.add(ShowErrorState(
|
||||
message: e
|
||||
.toString()));
|
||||
}
|
||||
} catch (e) {
|
||||
context
|
||||
.read<
|
||||
IdentificationBloc>()
|
||||
.add(ShowErrorState(
|
||||
message:
|
||||
e.toString()));
|
||||
}
|
||||
}
|
||||
},
|
||||
value: selectedRegion,
|
||||
decoration: normalTextFieldStyle(
|
||||
"Region*", "Region"),
|
||||
items: state.regions.map<
|
||||
DropdownMenuItem<Region>>(
|
||||
(Region region) {
|
||||
return DropdownMenuItem<Region>(
|
||||
value: region,
|
||||
child: Text(
|
||||
region.description!));
|
||||
}).toList(),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// PROVINCE DROPDOWN
|
||||
SizedBox(
|
||||
height: 60,
|
||||
child: ModalProgressHUD(
|
||||
color: Colors.transparent,
|
||||
inAsyncCall: provinceCall,
|
||||
child: DropdownButtonFormField<
|
||||
Province?>(
|
||||
autovalidateMode:
|
||||
AutovalidateMode
|
||||
.onUserInteraction,
|
||||
validator: (value) =>
|
||||
value == null
|
||||
? 'required'
|
||||
: null,
|
||||
isExpanded: true,
|
||||
value: selectedProvince,
|
||||
onChanged: (Province?
|
||||
province) async {
|
||||
if (selectedProvince !=
|
||||
province) {
|
||||
setState(() {
|
||||
cityCall = true;
|
||||
});
|
||||
selectedProvince =
|
||||
province;
|
||||
try {
|
||||
citymuns = await LocationUtils
|
||||
.instance
|
||||
.getCities(
|
||||
code: selectedProvince!
|
||||
.code
|
||||
.toString());
|
||||
selectedMunicipality =
|
||||
citymuns![0];
|
||||
setState(() {
|
||||
cityCall = false;
|
||||
});
|
||||
} catch (e) {
|
||||
context
|
||||
.read<
|
||||
IdentificationBloc>()
|
||||
.add(ShowErrorState(
|
||||
message: e
|
||||
.toString()));
|
||||
}
|
||||
}
|
||||
},
|
||||
items: provinces == null
|
||||
? []
|
||||
: provinces!.map<
|
||||
DropdownMenuItem<
|
||||
Province>>(
|
||||
(Province
|
||||
province) {
|
||||
return DropdownMenuItem(
|
||||
value: province,
|
||||
child:
|
||||
FittedBox(
|
||||
child: Text(
|
||||
province
|
||||
.description!),
|
||||
));
|
||||
}).toList(),
|
||||
decoration:
|
||||
normalTextFieldStyle(
|
||||
"Province*",
|
||||
"Province")),
|
||||
),
|
||||
),
|
||||
////CITY MUNICIPALITY
|
||||
SizedBox(
|
||||
height: 60,
|
||||
child: ModalProgressHUD(
|
||||
color: Colors.white,
|
||||
inAsyncCall: cityCall,
|
||||
child: DropdownButtonFormField<
|
||||
CityMunicipality>(
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
isExpanded: true,
|
||||
onChanged:
|
||||
(CityMunicipality? city) {
|
||||
if (selectedMunicipality !=
|
||||
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(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
//// COUNTRY DROPDOWN
|
||||
: SizedBox(
|
||||
height: 60,
|
||||
child:
|
||||
DropdownButtonFormField<Country>(
|
||||
isExpanded: true,
|
||||
validator:
|
||||
FormBuilderValidators.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
items: state.countries
|
||||
.map<DropdownMenuItem<Country>>(
|
||||
(Country country) {
|
||||
return DropdownMenuItem<Country>(
|
||||
value: country,
|
||||
child: FittedBox(
|
||||
child:
|
||||
Text(country.name!)));
|
||||
}).toList(),
|
||||
value: selectedCountry,
|
||||
decoration: normalTextFieldStyle(
|
||||
"Country*", "Country"),
|
||||
onChanged: (Country? value) {
|
||||
selectedCountry = value;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 60,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(
|
||||
primary, Colors.transparent, second),
|
||||
onPressed: () {
|
||||
if (formKey.currentState!
|
||||
.saveAndValidate()) {
|
||||
Country country = selectedCountry ??=
|
||||
Country(
|
||||
id: 175,
|
||||
name: 'Philippines',
|
||||
code: 'PH');
|
||||
IssuedAt issuedAt = IssuedAt(
|
||||
id:null,
|
||||
barangay: null,
|
||||
|
||||
addressCategory: null,
|
||||
issuedAtClass: null,
|
||||
cityMunicipality: overseas?null:selectedMunicipality
|
||||
,
|
||||
country: country);
|
||||
if (selectedCategoty != null) {
|
||||
selectedAgency = Agency(
|
||||
id: selectedAgency?.id,
|
||||
name: selectedAgency!.name,
|
||||
category: selectedCategoty,
|
||||
privateEntity: isPrivate);
|
||||
}
|
||||
Identification identification = Identification(id: null, agency: selectedAgency, issuedAt: issuedAt, asPdfReference: asPdfReference, identificationNumber: formKey.currentState!.value['identification_number'],dateIssued: dateIssuedController.text.isEmpty?null:DateTime.parse(dateIssuedController.text),expirationDate: expirationController.text.isEmpty?null:DateTime.tryParse(expirationController.text));
|
||||
final progress = ProgressHUD.of(context);
|
||||
progress!.showWithText("Loading...");
|
||||
context.read<IdentificationBloc>().add(AddIdentification(identification: identification, profileId: widget.profileId, token: widget.token));
|
||||
}
|
||||
|
||||
},
|
||||
child: const Text(submit)),
|
||||
)
|
||||
|
||||
],
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getProvinces() async {
|
||||
try {
|
||||
List<Province> newProvinces = await LocationUtils.instance
|
||||
.getProvinces(regionCode: selectedRegion!.code.toString());
|
||||
setState(() {
|
||||
provinces = newProvinces;
|
||||
selectedProvince = provinces![0];
|
||||
provinceCall = false;
|
||||
cityCall = true;
|
||||
getCities();
|
||||
});
|
||||
} catch (e) {
|
||||
context
|
||||
.read<IdentificationBloc>()
|
||||
.add(ShowErrorState(message: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getCities() async {
|
||||
try {
|
||||
List<CityMunicipality> newCities = await LocationUtils.instance
|
||||
.getCities(code: selectedProvince!.code.toString());
|
||||
citymuns = newCities;
|
||||
setState(() {
|
||||
selectedMunicipality = newCities[0];
|
||||
cityCall = false;
|
||||
});
|
||||
} catch (e) {
|
||||
context
|
||||
.read<IdentificationBloc>()
|
||||
.add(ShowErrorState(message: e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,528 @@
|
|||
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:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
|
||||
import 'package:searchfield/searchfield.dart';
|
||||
import 'package:unit2/bloc/profile/primary_information/identification/identification_bloc.dart';
|
||||
import 'package:unit2/model/utils/industry_class.dart';
|
||||
import 'package:unit2/theme-data.dart/btn-style.dart';
|
||||
import 'package:unit2/utils/text_container.dart';
|
||||
|
||||
import '../../../../../model/location/city.dart';
|
||||
import '../../../../../model/location/country.dart';
|
||||
import '../../../../../model/location/provinces.dart';
|
||||
import '../../../../../model/location/region.dart';
|
||||
import '../../../../../model/profile/basic_information/identification_information.dart';
|
||||
import '../../../../../model/profile/voluntary_works.dart';
|
||||
import '../../../../../model/utils/agency.dart';
|
||||
import '../../../../../model/utils/category.dart';
|
||||
import '../../../../../theme-data.dart/box_shadow.dart';
|
||||
import '../../../../../theme-data.dart/colors.dart';
|
||||
import '../../../../../theme-data.dart/form-style.dart';
|
||||
import '../../../../../utils/global.dart';
|
||||
import '../../../../../utils/global_context.dart';
|
||||
import '../../../../../utils/location_utilities.dart';
|
||||
import '../../../shared/add_for_empty_search.dart';
|
||||
|
||||
class EditIdentificationScreen extends StatefulWidget {
|
||||
final int profileId;
|
||||
final String token;
|
||||
const EditIdentificationScreen(
|
||||
{super.key, required this.profileId, required this.token});
|
||||
|
||||
@override
|
||||
State<EditIdentificationScreen> createState() =>
|
||||
_EditIdentificationScreenState();
|
||||
}
|
||||
|
||||
class _EditIdentificationScreenState extends State<EditIdentificationScreen> {
|
||||
final addAgencyController = TextEditingController();
|
||||
final dateIssuedController = TextEditingController();
|
||||
final expirationController = TextEditingController();
|
||||
final agencyFocusNode = FocusNode();
|
||||
final agencyCategoryFocusNode = FocusNode();
|
||||
bool asPdfReference = false;
|
||||
bool overseas = false;
|
||||
bool provinceCall = false;
|
||||
bool cityCall = false;
|
||||
bool otherAgency = false;
|
||||
////selected
|
||||
Agency? selectedAgency;
|
||||
Category? selectedCategoty;
|
||||
Region? selectedRegion;
|
||||
Province? selectedProvince;
|
||||
CityMunicipality? selectedMunicipality;
|
||||
Country? selectedCountry;
|
||||
List<Province>? provinces;
|
||||
List<CityMunicipality>? citymuns;
|
||||
|
||||
final formKey = GlobalKey<FormBuilderState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<IdentificationBloc, IdentificationState>(
|
||||
builder: (context, state) {
|
||||
if (state is IdentificationEditingState) {
|
||||
String? issuedDate = state.identification.dateIssued.toString();
|
||||
String? expDate = state.identification.expirationDate.toString();
|
||||
provinces = state.provinces;
|
||||
citymuns = state.cities;
|
||||
selectedCountry = state.currentCountry;
|
||||
dateIssuedController.text =
|
||||
issuedDate.isEmpty || issuedDate == "null" ? "" : issuedDate;
|
||||
expirationController.text =
|
||||
expDate.isEmpty || expDate == "null" ? "" : expDate;
|
||||
selectedRegion = state.currentRegion;
|
||||
selectedProvince = state.currentProvince;
|
||||
selectedMunicipality = state.currentCity;
|
||||
overseas = state.overseas;
|
||||
asPdfReference = state.identification.asPdfReference!;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 24),
|
||||
child: FormBuilder(
|
||||
key: formKey,
|
||||
child: SizedBox(
|
||||
height: screenHeight * 90,
|
||||
child: ListView(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
FormBuilderTextField(
|
||||
initialValue: state.identification.agency!.name,
|
||||
enabled: false,
|
||||
name: "",
|
||||
decoration: normalTextFieldStyle("", "").copyWith(
|
||||
filled: true, fillColor: Colors.black12),
|
||||
),
|
||||
SizedBox(
|
||||
height: otherAgency ? 8 : 0,
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
//// Identification numner
|
||||
FormBuilderTextField(
|
||||
initialValue:
|
||||
state.identification.identificationNumber,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "identification_number",
|
||||
decoration: normalTextFieldStyle(
|
||||
"Identification Number *", ""),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
//// Date Issued
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DateTimePicker(
|
||||
controller: dateIssuedController,
|
||||
use24HourFormat: false,
|
||||
icon: const Icon(Icons.date_range),
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
timeHintText: "Date Issued",
|
||||
decoration: normalTextFieldStyle(
|
||||
"Date Issued *", "Date Issued *")
|
||||
.copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
initialValue: null,
|
||||
)),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
//// Expiration Date
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: DateTimePicker(
|
||||
controller: expirationController,
|
||||
use24HourFormat: false,
|
||||
icon: const Icon(Icons.date_range),
|
||||
firstDate: DateTime(1970),
|
||||
lastDate: DateTime(2100),
|
||||
timeHintText: "Expiration date",
|
||||
decoration: normalTextFieldStyle(
|
||||
"Expiration Date *",
|
||||
"Expiration Date *")
|
||||
.copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
)),
|
||||
initialValue: null,
|
||||
)),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
|
||||
//// OVERSEAS
|
||||
StatefulBuilder(builder: (context, setState) {
|
||||
return Column(
|
||||
children: [
|
||||
FormBuilderSwitch(
|
||||
initialValue: overseas,
|
||||
activeColor: second,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
overseas = value!;
|
||||
});
|
||||
},
|
||||
decoration: normalTextFieldStyle(
|
||||
"Overseas Address?", ''),
|
||||
name: 'overseas',
|
||||
title: Text(overseas ? "YES" : "NO"),
|
||||
),
|
||||
SizedBox(
|
||||
height: overseas == true ? 8 : 0,
|
||||
),
|
||||
SizedBox(
|
||||
child: overseas == false
|
||||
? Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
////REGION DROPDOWN
|
||||
DropdownButtonFormField<Region?>(
|
||||
isExpanded: true,
|
||||
autovalidateMode: AutovalidateMode
|
||||
.onUserInteraction,
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
onChanged:
|
||||
(Region? region) async {
|
||||
if (selectedRegion != region) {
|
||||
setState(() {
|
||||
provinceCall = true;
|
||||
});
|
||||
selectedRegion = region;
|
||||
try {
|
||||
provinces = await LocationUtils
|
||||
.instance
|
||||
.getProvinces(
|
||||
regionCode:
|
||||
selectedRegion!
|
||||
.code
|
||||
.toString());
|
||||
selectedProvince =
|
||||
provinces![0];
|
||||
setState(() {
|
||||
provinceCall = false;
|
||||
cityCall = true;
|
||||
});
|
||||
try {
|
||||
citymuns = await LocationUtils
|
||||
.instance
|
||||
.getCities(
|
||||
code: selectedProvince!
|
||||
.code
|
||||
.toString());
|
||||
selectedMunicipality =
|
||||
citymuns![0];
|
||||
setState(() {
|
||||
cityCall = false;
|
||||
});
|
||||
} catch (e) {
|
||||
NavigationService
|
||||
.navigatorKey
|
||||
.currentContext
|
||||
?.read<
|
||||
IdentificationBloc>()
|
||||
.add(ShowErrorState(
|
||||
message: e
|
||||
.toString()));
|
||||
}
|
||||
} catch (e) {
|
||||
context
|
||||
.read<
|
||||
IdentificationBloc>()
|
||||
.add(ShowErrorState(
|
||||
message:
|
||||
e.toString()));
|
||||
}
|
||||
}
|
||||
},
|
||||
value: selectedRegion,
|
||||
decoration: normalTextFieldStyle(
|
||||
"Region*", "Region"),
|
||||
items: state.regions.map<
|
||||
DropdownMenuItem<Region>>(
|
||||
(Region region) {
|
||||
return DropdownMenuItem<Region>(
|
||||
value: region,
|
||||
child: Text(
|
||||
region.description!));
|
||||
}).toList(),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
//// PROVINCE DROPDOWN
|
||||
SizedBox(
|
||||
height: 60,
|
||||
child: ModalProgressHUD(
|
||||
color: Colors.transparent,
|
||||
inAsyncCall: provinceCall,
|
||||
child: DropdownButtonFormField<
|
||||
Province?>(
|
||||
value: selectedProvince,
|
||||
autovalidateMode:
|
||||
AutovalidateMode
|
||||
.onUserInteraction,
|
||||
validator: (value) =>
|
||||
value == null
|
||||
? 'required'
|
||||
: null,
|
||||
isExpanded: true,
|
||||
onChanged: (Province?
|
||||
province) async {
|
||||
if (selectedProvince !=
|
||||
province) {
|
||||
setState(() {
|
||||
cityCall = true;
|
||||
});
|
||||
selectedProvince =
|
||||
province;
|
||||
try {
|
||||
citymuns = await LocationUtils
|
||||
.instance
|
||||
.getCities(
|
||||
code: selectedProvince!
|
||||
.code
|
||||
.toString());
|
||||
selectedMunicipality =
|
||||
citymuns![0];
|
||||
setState(() {
|
||||
cityCall = false;
|
||||
});
|
||||
} catch (e) {
|
||||
context
|
||||
.read<
|
||||
IdentificationBloc>()
|
||||
.add(ShowErrorState(
|
||||
message: e
|
||||
.toString()));
|
||||
}
|
||||
}
|
||||
},
|
||||
items: provinces == null
|
||||
? []
|
||||
: provinces!.map<
|
||||
DropdownMenuItem<
|
||||
Province>>(
|
||||
(Province
|
||||
province) {
|
||||
return DropdownMenuItem(
|
||||
value: province,
|
||||
child:
|
||||
FittedBox(
|
||||
child: Text(
|
||||
province
|
||||
.description!),
|
||||
));
|
||||
}).toList(),
|
||||
decoration:
|
||||
normalTextFieldStyle(
|
||||
"Province*",
|
||||
"Province")),
|
||||
),
|
||||
),
|
||||
////CITY MUNICIPALITY
|
||||
SizedBox(
|
||||
height: 60,
|
||||
child: ModalProgressHUD(
|
||||
color: Colors.white,
|
||||
inAsyncCall: cityCall,
|
||||
child: DropdownButtonFormField<
|
||||
CityMunicipality>(
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
isExpanded: true,
|
||||
onChanged:
|
||||
(CityMunicipality? city) {
|
||||
if (selectedMunicipality !=
|
||||
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(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
//// COUNTRY DROPDOWN
|
||||
: SizedBox(
|
||||
height: 60,
|
||||
child:
|
||||
DropdownButtonFormField<Country>(
|
||||
isExpanded: true,
|
||||
validator:
|
||||
FormBuilderValidators.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
items: state.countries
|
||||
.map<DropdownMenuItem<Country>>(
|
||||
(Country country) {
|
||||
return DropdownMenuItem<Country>(
|
||||
value: country,
|
||||
child: FittedBox(
|
||||
child:
|
||||
Text(country.name!)));
|
||||
}).toList(),
|
||||
value: selectedCountry,
|
||||
decoration: normalTextFieldStyle(
|
||||
"Country*", "Country"),
|
||||
onChanged: (Country? value) {
|
||||
selectedCountry = value;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 60,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(
|
||||
primary, Colors.transparent, second),
|
||||
onPressed: () {
|
||||
if (formKey.currentState!.saveAndValidate()) {
|
||||
IssuedAt? issuedAt;
|
||||
if (!overseas) {
|
||||
issuedAt = IssuedAt(
|
||||
id: state.identification.issuedAt!.id,
|
||||
barangay: null,
|
||||
addressCategory: state.identification.issuedAt?.addressCategory,
|
||||
issuedAtClass: null,
|
||||
cityMunicipality: selectedMunicipality,
|
||||
country: selectedCountry);
|
||||
}else{
|
||||
issuedAt = IssuedAt(
|
||||
id: state.identification.issuedAt!.id,
|
||||
barangay: null,
|
||||
addressCategory: state.identification.issuedAt?.addressCategory,
|
||||
issuedAtClass: null,
|
||||
cityMunicipality: null,
|
||||
country: selectedCountry);
|
||||
}
|
||||
|
||||
Identification identification =
|
||||
Identification(
|
||||
id: state.identification.id,
|
||||
agency: state.identification.agency,
|
||||
issuedAt: issuedAt,
|
||||
asPdfReference: asPdfReference,
|
||||
identificationNumber:
|
||||
formKey
|
||||
.currentState!.value[
|
||||
'identification_number'],
|
||||
dateIssued:
|
||||
dateIssuedController
|
||||
.text.isEmpty
|
||||
? null
|
||||
: DateTime
|
||||
.parse(
|
||||
dateIssuedController
|
||||
.text),
|
||||
expirationDate: expirationController
|
||||
.text.isEmpty
|
||||
? null
|
||||
: DateTime.tryParse(
|
||||
expirationController.text));
|
||||
final progress = ProgressHUD.of(context);
|
||||
progress!.showWithText("Loading...");
|
||||
context.read<IdentificationBloc>().add(
|
||||
UpdateIdentifaction(
|
||||
identification: identification,
|
||||
profileId: widget.profileId,
|
||||
token: widget.token));
|
||||
}
|
||||
},
|
||||
child: const Text(submit)),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getProvinces() async {
|
||||
try {
|
||||
List<Province> newProvinces = await LocationUtils.instance
|
||||
.getProvinces(regionCode: selectedRegion!.code.toString());
|
||||
setState(() {
|
||||
provinces = newProvinces;
|
||||
selectedProvince = provinces![0];
|
||||
provinceCall = false;
|
||||
cityCall = true;
|
||||
getCities();
|
||||
});
|
||||
} catch (e) {
|
||||
context
|
||||
.read<IdentificationBloc>()
|
||||
.add(ShowErrorState(message: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getCities() async {
|
||||
try {
|
||||
List<CityMunicipality> newCities = await LocationUtils.instance
|
||||
.getCities(code: selectedProvince!.code.toString());
|
||||
citymuns = newCities;
|
||||
setState(() {
|
||||
selectedMunicipality = newCities[0];
|
||||
cityCall = false;
|
||||
});
|
||||
} catch (e) {
|
||||
context
|
||||
.read<IdentificationBloc>()
|
||||
.add(ShowErrorState(message: e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,149 +1,366 @@
|
|||
import 'package:app_popup_menu/app_popup_menu.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:fluttericon/font_awesome_icons.dart';
|
||||
import 'package:unit2/bloc/profile/primary_information/identification/identification_bloc.dart';
|
||||
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||
import 'package:unit2/model/profile/basic_information/identification_information.dart';
|
||||
import 'package:unit2/screens/profile/components/basic_information/identification/add_modal.dart';
|
||||
import 'package:unit2/screens/profile/components/basic_information/identification/edit_modal.dart';
|
||||
import 'package:unit2/theme-data.dart/box_shadow.dart';
|
||||
import 'package:unit2/theme-data.dart/colors.dart';
|
||||
import 'package:unit2/utils/global.dart';
|
||||
import 'package:unit2/utils/text_container.dart';
|
||||
import 'package:unit2/widgets/Leadings/add_leading.dart';
|
||||
import 'package:unit2/widgets/empty_data.dart';
|
||||
import 'package:unit2/widgets/error_state.dart';
|
||||
|
||||
import '../../../../bloc/user/user_bloc.dart';
|
||||
import '../../../../utils/alerts.dart';
|
||||
|
||||
class IdentificationsScreen extends StatelessWidget {
|
||||
const IdentificationsScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String? token;
|
||||
int? profileId;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text(identificationScreenTitle),
|
||||
centerTitle: true,
|
||||
backgroundColor: primary,
|
||||
actions: [AddLeading(onPressed: () {})],
|
||||
actions: [
|
||||
AddLeading(onPressed: () {
|
||||
context
|
||||
.read<IdentificationBloc>()
|
||||
.add(ShowAddIdentificationForm());
|
||||
})
|
||||
],
|
||||
),
|
||||
body: BlocBuilder<UserBloc, UserState>(
|
||||
builder: (context, state) {
|
||||
if (state is UserLoggedIn) {
|
||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||
builder: (context, state) {
|
||||
if (state is ProfileLoaded) {
|
||||
return BlocConsumer<IdentificationBloc,
|
||||
IdentificationState>(
|
||||
listener: (context, state) {},
|
||||
builder: (context, state) {
|
||||
if (state is IdentificationLoadedState) {
|
||||
if (state.identificationInformation.isNotEmpty) {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8, horizontal: 10),
|
||||
itemCount: state.identificationInformation.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
String agency =
|
||||
state.identificationInformation[index].agency!.name!;
|
||||
String idNumber =
|
||||
state.identificationInformation[index].identificationNumber!;
|
||||
bool government =
|
||||
state.identificationInformation[index].agency!.privateEntity!;
|
||||
String issuedAt =
|
||||
"${state.identificationInformation[index].issuedAt!.cityMunicipality!.description!} ${state.identificationInformation[index].issuedAt!.cityMunicipality!.province!.description}";
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
decoration: box1(),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(agency,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium!
|
||||
.copyWith(
|
||||
fontWeight:
|
||||
FontWeight
|
||||
.w400)),
|
||||
const Divider(),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Row(children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"$idNumberText : $idNumber",
|
||||
style:
|
||||
Theme.of(context)
|
||||
.textTheme
|
||||
.titleSmall,
|
||||
),
|
||||
body: ProgressHUD(
|
||||
padding: const EdgeInsets.all(24),
|
||||
backgroundColor: Colors.black87,
|
||||
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
|
||||
child: BlocBuilder<UserBloc, UserState>(
|
||||
builder: (context, state) {
|
||||
if (state is UserLoggedIn) {
|
||||
token = state.userData!.user!.login!.token;
|
||||
profileId = state.userData!.user!.login!.user!.profileId;
|
||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||
builder: (context, state) {
|
||||
if (state is ProfileLoaded) {
|
||||
return BlocConsumer<IdentificationBloc,
|
||||
IdentificationState>(
|
||||
listener: (context, state) {
|
||||
if (state is IdentificationLoadingState) {
|
||||
final progress = ProgressHUD.of(context);
|
||||
progress!.showWithText("Please wait...");
|
||||
}
|
||||
if (state is IdentificationLoadedState ||
|
||||
state is IdentificationAddingState ||
|
||||
state is IdentificationEditingState ||
|
||||
state is IdenficationErrorState ||
|
||||
state is IdentificationAddedState ||
|
||||
state is IdentificationDeletedState ||
|
||||
state is IdentificationEditedState) {
|
||||
final progress = ProgressHUD.of(context);
|
||||
progress!.dismiss();
|
||||
}
|
||||
//// Added State
|
||||
if (state is IdentificationAddedState) {
|
||||
if (state.response['success']) {
|
||||
successAlert(context, "Adding Successfull!",
|
||||
state.response['message'], () {
|
||||
Navigator.of(context).pop();
|
||||
context
|
||||
.read<IdentificationBloc>()
|
||||
.add(LoadIdentifications());
|
||||
});
|
||||
} else {
|
||||
errorAlert(context, "Adding Failed",
|
||||
"Something went wrong. Please try again.",
|
||||
() {
|
||||
Navigator.of(context).pop();
|
||||
context
|
||||
.read<IdentificationBloc>()
|
||||
.add(LoadIdentifications());
|
||||
});
|
||||
}
|
||||
}
|
||||
//// Updated State
|
||||
if (state is IdentificationEditedState) {
|
||||
if (state.response['success']) {
|
||||
successAlert(context, "Update Successfull!",
|
||||
state.response['message'], () {
|
||||
Navigator.of(context).pop();
|
||||
context
|
||||
.read<IdentificationBloc>()
|
||||
.add(LoadIdentifications());
|
||||
});
|
||||
} else {
|
||||
errorAlert(context, "Update Failed",
|
||||
"Something went wrong. Please try again.",
|
||||
() {
|
||||
Navigator.of(context).pop();
|
||||
context
|
||||
.read<IdentificationBloc>()
|
||||
.add(LoadIdentifications());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
////Deleted State
|
||||
if (state is IdentificationDeletedState) {
|
||||
if (state.success) {
|
||||
successAlert(context, "Deletion Successfull!",
|
||||
"Deleted Successfully", () {
|
||||
Navigator.of(context).pop();
|
||||
context
|
||||
.read<IdentificationBloc>()
|
||||
.add(LoadIdentifications());
|
||||
});
|
||||
} else {
|
||||
errorAlert(context, "Deletion Failed",
|
||||
"Something went wrong. Please try again.",
|
||||
() {
|
||||
Navigator.of(context).pop();
|
||||
context
|
||||
.read<IdentificationBloc>()
|
||||
.add(LoadIdentifications());
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
if (state is IdentificationLoadedState) {
|
||||
if (state.identificationInformation.isNotEmpty) {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8, horizontal: 10),
|
||||
itemCount:
|
||||
state.identificationInformation.length,
|
||||
itemBuilder:
|
||||
(BuildContext context, int index) {
|
||||
String agency = state
|
||||
.identificationInformation[index]
|
||||
.agency!
|
||||
.name!;
|
||||
String idNumber = state
|
||||
.identificationInformation[index]
|
||||
.identificationNumber!;
|
||||
bool government = state
|
||||
.identificationInformation[index]
|
||||
.agency!
|
||||
.privateEntity!;
|
||||
String issuedAt =
|
||||
"${state.identificationInformation[index].issuedAt!.cityMunicipality?.description!} ${state.identificationInformation[index].issuedAt!.cityMunicipality?.province!.description}";
|
||||
return Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
decoration: box1(),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment
|
||||
.start,
|
||||
children: [
|
||||
Text(agency,
|
||||
style: Theme.of(
|
||||
context)
|
||||
.textTheme
|
||||
.titleMedium!
|
||||
.copyWith(
|
||||
fontWeight:
|
||||
FontWeight
|
||||
.w400)),
|
||||
const Divider(),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Badge(
|
||||
backgroundColor:
|
||||
success2,
|
||||
label: Text(
|
||||
government == true
|
||||
? privateText
|
||||
.toUpperCase()
|
||||
: governmentText
|
||||
.toUpperCase(),
|
||||
Row(children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"$idNumberText : $idNumber",
|
||||
style: Theme.of(
|
||||
context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(
|
||||
color: Colors
|
||||
.white),
|
||||
))
|
||||
.titleSmall,
|
||||
),
|
||||
),
|
||||
Badge(
|
||||
backgroundColor:
|
||||
success2,
|
||||
label: Text(
|
||||
government == true
|
||||
? privateText
|
||||
.toUpperCase()
|
||||
: governmentText
|
||||
.toUpperCase(),
|
||||
style: Theme.of(
|
||||
context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(
|
||||
color: Colors
|
||||
.white),
|
||||
))
|
||||
]),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Text(issuedAt),
|
||||
]),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Text(issuedAt),
|
||||
]),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {},
|
||||
),
|
||||
AppPopupMenu<int>(
|
||||
offset: const Offset(-10, -10),
|
||||
elevation: 3,
|
||||
onSelected: (value) {
|
||||
////delete identification-= = = = = = = = =>>
|
||||
if (value == 2) {
|
||||
confirmAlert(context, () {
|
||||
final progress =
|
||||
ProgressHUD.of(
|
||||
context);
|
||||
progress!.showWithText(
|
||||
"Loading...");
|
||||
BlocProvider.of<IdentificationBloc>(
|
||||
context)
|
||||
.add(DeleteIdentification(
|
||||
identificationId:
|
||||
state
|
||||
.identificationInformation[
|
||||
index]
|
||||
.id!,
|
||||
profileId:
|
||||
profileId!,
|
||||
token: token!));
|
||||
}, "Delete?",
|
||||
"Confirm Delete?");
|
||||
}
|
||||
if (value == 1) {
|
||||
bool isOverseas;
|
||||
////edit voluntary work-= = = = = = = = =>>
|
||||
final progress =
|
||||
ProgressHUD.of(context);
|
||||
progress!.showWithText(
|
||||
"Loading...");
|
||||
|
||||
if (state
|
||||
.identificationInformation[
|
||||
index]
|
||||
.issuedAt
|
||||
?.country!.id == 175) {
|
||||
isOverseas = false;
|
||||
} else {
|
||||
isOverseas = true;
|
||||
}
|
||||
context
|
||||
.read<
|
||||
IdentificationBloc>()
|
||||
.add(ShowEditIdentificationForm(
|
||||
identification:
|
||||
state.identificationInformation[
|
||||
index],
|
||||
profileId:
|
||||
profileId!,
|
||||
token: token!,
|
||||
overseas:
|
||||
isOverseas));
|
||||
}
|
||||
},
|
||||
menuItems: [
|
||||
popMenuItem(
|
||||
text: "Edit",
|
||||
value: 1,
|
||||
icon: Icons.edit),
|
||||
popMenuItem(
|
||||
text: "Delete",
|
||||
value: 2,
|
||||
icon: Icons.delete),
|
||||
popMenuItem(
|
||||
text: "Attachment",
|
||||
value: 3,
|
||||
icon: FontAwesome.attach)
|
||||
],
|
||||
icon: const Icon(
|
||||
Icons.more_vert,
|
||||
color: Colors.grey,
|
||||
))
|
||||
],
|
||||
),
|
||||
tooltip: "Options",
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
} else {
|
||||
const EmptyData(
|
||||
message:
|
||||
"You don't have identifications added. Please click + to add.");
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
} else {
|
||||
return const EmptyData(
|
||||
message:
|
||||
"You don't have identifications added. Please click + to add.");
|
||||
}
|
||||
}
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
if (state is IdentificationAddingState) {
|
||||
return AddIdentificationScreen(
|
||||
token: token!,
|
||||
profileId: profileId!,
|
||||
);
|
||||
}
|
||||
if (state is IdenficationErrorState) {
|
||||
return SomethingWentWrong(
|
||||
message: state.message, onpressed: () {});
|
||||
}
|
||||
if (state is IdentificationEditingState) {
|
||||
return EditIdentificationScreen(
|
||||
profileId: profileId!, token: token!);
|
||||
}
|
||||
|
||||
return Container();
|
||||
},
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
PopupMenuItem<int> popMenuItem({String? text, int? value, IconData? icon}) {
|
||||
return PopupMenuItem(
|
||||
value: value,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
text!,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,11 +63,11 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
|
|||
if (state is AddEligibilityState) {
|
||||
return SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
height: screenHeight * .95,
|
||||
height: screenHeight * .90,
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 25, horizontal: 18),
|
||||
vertical: 25, horizontal: 25),
|
||||
child: FormBuilder(
|
||||
key: formKey,
|
||||
child: Column(
|
||||
|
@ -291,7 +291,7 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
|
|||
),
|
||||
////PROVINCE DROPDOWN
|
||||
SizedBox(
|
||||
height: 70,
|
||||
height: 60,
|
||||
child: ModalProgressHUD(
|
||||
color: Colors.transparent,
|
||||
inAsyncCall: provinceCall,
|
||||
|
|
|
@ -84,13 +84,14 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
|||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 25, horizontal: 18),
|
||||
vertical: 25, horizontal: 24),
|
||||
child: FormBuilder(
|
||||
key: formKey,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 24,),
|
||||
////ELIGIBILITIES DROPDOWN
|
||||
DropdownButtonFormField<Eligibility>(
|
||||
validator: (value) =>
|
||||
|
@ -110,7 +111,7 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
|||
decoration: normalTextFieldStyle(
|
||||
"Eligibility", "")),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
height: 12,
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
|
@ -155,7 +156,7 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
|||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
height: 12,
|
||||
),
|
||||
SizedBox(
|
||||
width: screenWidth,
|
||||
|
@ -236,7 +237,7 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
|||
title: const Text("Overseas Address?"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
height: 12,
|
||||
),
|
||||
//COUNTRY DROPDOWN
|
||||
SizedBox(
|
||||
|
@ -328,7 +329,7 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
|||
}).toList(),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
height: 12,
|
||||
),
|
||||
////PROVINCE DROPDOWN
|
||||
SizedBox(
|
||||
|
@ -392,7 +393,7 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
|||
|
||||
//// City municipality
|
||||
SizedBox(
|
||||
height: 70,
|
||||
height: 60,
|
||||
child: ModalProgressHUD(
|
||||
color:
|
||||
Colors.transparent,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -33,6 +33,9 @@ class _MainScreenState extends State<MainScreen> {
|
|||
},
|
||||
child: BlocBuilder<UserBloc, UserState>(builder: (context, state) {
|
||||
if (state is UserLoggedIn) {
|
||||
for (var element in roles) {
|
||||
element.roles.clear();
|
||||
}
|
||||
for (var role in state.userData!.user!.login!.user!.roles!) {
|
||||
Role? getRole = role;
|
||||
for (var module in role!.modules!) {
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:unit2/utils/request.dart';
|
||||
|
@ -8,31 +5,203 @@ import 'package:unit2/utils/request.dart';
|
|||
import '../../model/profile/family_backround.dart';
|
||||
import '../../utils/urls.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
class FamilyService{
|
||||
|
||||
class FamilyService {
|
||||
static final FamilyService _instance = FamilyService();
|
||||
static FamilyService get instance => _instance;
|
||||
Future< List<FamilyBackground>> getFamilies(int profileId, String token)async{
|
||||
List<FamilyBackground> families = [];
|
||||
String authToken = "Token $token";
|
||||
|
||||
Future<List<FamilyBackground>> getFamilies(
|
||||
int profileId, String token) async {
|
||||
List<FamilyBackground> families = [];
|
||||
String authToken = "Token $token";
|
||||
String path = "${Url.instance.getFamilies()}$profileId/";
|
||||
Map<String, String> headers = {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': authToken
|
||||
};
|
||||
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 family){
|
||||
FamilyBackground familyBackground = FamilyBackground.fromJson(family);
|
||||
families.add(familyBackground);
|
||||
});
|
||||
}
|
||||
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 family) {
|
||||
FamilyBackground familyBackground =
|
||||
FamilyBackground.fromJson(family);
|
||||
families.add(familyBackground);
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
throw e.toString();
|
||||
}
|
||||
}catch(e){
|
||||
throw e.toString();
|
||||
}
|
||||
return families;
|
||||
return families;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<dynamic, dynamic>> add(
|
||||
{required int profileId,
|
||||
required String token,
|
||||
required int relationshipId,
|
||||
required FamilyBackground? family}) async {
|
||||
Map<dynamic, dynamic>? _response = {};
|
||||
String authtoken = "Token $token";
|
||||
String path = "${Url.instance.getFamilies()}$profileId/";
|
||||
Map<String, String> headers = {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': authtoken
|
||||
};
|
||||
Map body = {
|
||||
"relation_type_id": relationshipId,
|
||||
"company_address": family?.companyAddress,
|
||||
"company_contact_number": family?.companyContactNumber,
|
||||
"first_name": family!.relatedPerson!.firstName,
|
||||
"middle_name": family.relatedPerson!.middleName,
|
||||
"last_name": family.relatedPerson!.lastName,
|
||||
"name_extension": family.relatedPerson?.nameExtension,
|
||||
"birthdate": family.relatedPerson!.birthdate.toString(),
|
||||
"sex": family.relatedPerson!.sex,
|
||||
"blood_type": family.relatedPerson?.bloodType,
|
||||
"civil_status": family.relatedPerson?.civilStatus,
|
||||
"height": family.relatedPerson?.heightM,
|
||||
"weight": family.relatedPerson?.weightKg,
|
||||
"position_id": family.position?.id,
|
||||
"agency_id": family.company?.id,
|
||||
"_positionName": family.position?.title,
|
||||
"_agencyName": family.company?.name,
|
||||
"_agencyCatId": family.company?.category?.id,
|
||||
"_privateEntity": family.company?.privateEntity,
|
||||
"maidenMiddleName": family.relatedPerson?.maidenName?.middleName,
|
||||
"maidenLastName": family.relatedPerson?.maidenName?.lastName,
|
||||
"gender": family.relatedPerson!.gender,
|
||||
"deceased": family.relatedPerson!.deceased,
|
||||
};
|
||||
try {
|
||||
http.Response response = await Request.instance
|
||||
.postRequest(param: {}, path: path, body: body, headers: headers);
|
||||
if (response.statusCode == 201) {
|
||||
Map data = jsonDecode(response.body);
|
||||
_response = data;
|
||||
} else {
|
||||
_response.addAll({'success': false});
|
||||
}
|
||||
} catch (e) {
|
||||
throw (e.toString());
|
||||
}
|
||||
return _response;
|
||||
}
|
||||
//// Add Emergency
|
||||
Future<Map<dynamic, dynamic>> addEmergency(
|
||||
{required int profileId,
|
||||
required String token,
|
||||
required int relatedPersonId,
|
||||
required String? numberMail,
|
||||
required int? contactInfoId,
|
||||
required String requestType,
|
||||
}) async {
|
||||
Map<dynamic, dynamic>? _response = {};
|
||||
String authtoken = "Token $token";
|
||||
String path = Url.instance.addEmergency();
|
||||
Map<String, String> headers = {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': authtoken
|
||||
};
|
||||
Map body = { "personid": profileId, "related_personid": relatedPersonId, "request_type": requestType, "number_mail": numberMail, "contactinfoid": contactInfoId };
|
||||
try {
|
||||
http.Response response = await Request.instance
|
||||
.postRequest(param: {}, path: path, body: body, headers: headers);
|
||||
if (response.statusCode == 200) {
|
||||
Map data = jsonDecode(response.body);
|
||||
_response = data;
|
||||
print(_response.toString());
|
||||
} else {
|
||||
_response.addAll({'success': false});
|
||||
}
|
||||
} catch (e) {
|
||||
throw (e.toString());
|
||||
}
|
||||
return _response;
|
||||
}
|
||||
////Update
|
||||
Future<Map<dynamic, dynamic>> update(
|
||||
{required int profileId,
|
||||
required String token,
|
||||
required int relationshipId,
|
||||
required FamilyBackground family}) async {
|
||||
Map<dynamic, dynamic>? _response = {};
|
||||
String authtoken = "Token $token";
|
||||
String path = "${Url.instance.getFamilies()}$profileId/";
|
||||
Map<String, String> headers = {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': authtoken
|
||||
};
|
||||
Map body = {
|
||||
"relation_type_id": relationshipId,
|
||||
"related_person_id": family.relatedPerson!.id,
|
||||
"company_address": family.companyAddress,
|
||||
"company_contact_number": family.companyContactNumber,
|
||||
"first_name": family.relatedPerson!.firstName,
|
||||
"middle_name": family.relatedPerson!.middleName,
|
||||
"last_name": family.relatedPerson!.lastName,
|
||||
"name_extension": family.relatedPerson?.nameExtension,
|
||||
"birthdate": family.relatedPerson!.birthdate.toString(),
|
||||
"sex": family.relatedPerson!.sex,
|
||||
"blood_type": family.relatedPerson?.bloodType,
|
||||
"civil_status": family.relatedPerson?.civilStatus,
|
||||
"height": family.relatedPerson!.heightM,
|
||||
"weight": family.relatedPerson!.weightKg,
|
||||
"position_id": family.position?.id,
|
||||
"agency_id": family.company?.id,
|
||||
"_positionName": family.position?.title,
|
||||
"_agencyName": family.company?.name,
|
||||
"_agencyCatId": family.company?.category?.id,
|
||||
"_privateEntity": family.company?.privateEntity,
|
||||
"maidenMiddleName": family.relatedPerson?.maidenName?.middleName,
|
||||
"maidenLastName": family.relatedPerson?.maidenName?.lastName,
|
||||
"gender": family.relatedPerson!.gender,
|
||||
"deceased": family.relatedPerson!.deceased,
|
||||
};
|
||||
try {
|
||||
http.Response response = await Request.instance
|
||||
.putRequest(param: {}, path: path, body: body, headers: headers);
|
||||
if (response.statusCode == 200) {
|
||||
Map data = jsonDecode(response.body);
|
||||
_response = data;
|
||||
} else {
|
||||
_response.addAll({'success': false});
|
||||
}
|
||||
} catch (e) {
|
||||
throw (e.toString());
|
||||
}
|
||||
return _response;
|
||||
}
|
||||
|
||||
Future<bool> delete(
|
||||
{required int personRelatedId,
|
||||
required int profileId,
|
||||
required String token}) async {
|
||||
bool? success;
|
||||
String authtoken = "Token $token";
|
||||
String path = "${Url.instance.getFamilies()}$profileId/";
|
||||
Map body = {"related_person_id": personRelatedId};
|
||||
Map<String, dynamic> params = {"force_mode": "true"};
|
||||
Map<String, String> headers = {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': authtoken
|
||||
};
|
||||
try {
|
||||
http.Response response = await Request.instance.deleteRequest(
|
||||
path: path, headers: headers, body: body, param: params);
|
||||
if (response.statusCode == 200) {
|
||||
Map data = jsonDecode(response.body);
|
||||
success = data['success'];
|
||||
} else {
|
||||
success = false;
|
||||
}
|
||||
} catch (e) {
|
||||
throw (e.toString());
|
||||
}
|
||||
return success!;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,125 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:unit2/model/profile/basic_information/identification_information.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../../utils/request.dart';
|
||||
import '../../utils/urls.dart';
|
||||
|
||||
class IdentificationServices {
|
||||
static final IdentificationServices _instance = IdentificationServices();
|
||||
static IdentificationServices get instance => _instance;
|
||||
|
||||
Future<Map<dynamic, dynamic>> add(
|
||||
{required Identification identification,
|
||||
required int profileId,
|
||||
required String token}) async {
|
||||
Map<dynamic, dynamic>? responseData = {};
|
||||
String authToken = "Token $token";
|
||||
String path = "${Url.instance.identifications()}$profileId/";
|
||||
Map<String, String> headers = {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': authToken
|
||||
};
|
||||
Map body = {
|
||||
"agency_id": identification.agency!.id,
|
||||
"identification_number": identification.identificationNumber,
|
||||
"date_issued": identification.dateIssued == null
|
||||
? null
|
||||
: identification.dateIssued.toString(),
|
||||
"expiration_date": identification.expirationDate == null
|
||||
? null
|
||||
: identification.expirationDate.toString(),
|
||||
"as_pdf_reference": identification.asPdfReference,
|
||||
"_agencyName": identification.agency!.name,
|
||||
"_agencyCatId": identification.agency!.category!.id,
|
||||
"_privateEntity": identification.agency!.privateEntity,
|
||||
"_citymunCode": identification.issuedAt?.cityMunicipality?.code,
|
||||
"_countryId": identification.issuedAt!.country!.id
|
||||
};
|
||||
try {
|
||||
http.Response response = await Request.instance
|
||||
.postRequest(param: {}, path: path, body: body, headers: headers);
|
||||
if (response.statusCode == 201) {
|
||||
Map data = jsonDecode(response.body);
|
||||
responseData = data;
|
||||
} else {
|
||||
responseData.addAll({'success': false});
|
||||
}
|
||||
} catch (e) {
|
||||
throw e.toString();
|
||||
}
|
||||
return responseData;
|
||||
}
|
||||
|
||||
////delete
|
||||
Future<bool> delete(
|
||||
{required int identificationId,
|
||||
required String token,
|
||||
required int profileId}) async {
|
||||
bool success = false;
|
||||
String authToken = "Token $token";
|
||||
String path = "${Url.instance.identifications()}$profileId/";
|
||||
Map<String, String> headers = {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': authToken
|
||||
};
|
||||
Map<String, dynamic> params = {"force_mode": "true"};
|
||||
Map body = {
|
||||
"id": identificationId,
|
||||
};
|
||||
try {
|
||||
http.Response response = await Request.instance.deleteRequest(
|
||||
path: path, headers: headers, body: body, param: params);
|
||||
if (response.statusCode == 200) {
|
||||
Map data = jsonDecode(response.body);
|
||||
success = data['success'];
|
||||
}
|
||||
} catch (e) {
|
||||
throw (e.toString());
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
Future<Map<dynamic, dynamic>> update(
|
||||
{required Identification identification,
|
||||
required int profileId,
|
||||
required String token}) async {
|
||||
Map<dynamic, dynamic>? responseData = {};
|
||||
String authToken = "Token $token";
|
||||
String path = "${Url.instance.identifications()}$profileId/";
|
||||
Map<String, String> headers = {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': authToken
|
||||
};
|
||||
Map body = {
|
||||
"id":identification.id,
|
||||
"agency_id": identification.agency!.id,
|
||||
"identification_number": identification.identificationNumber,
|
||||
"date_issued": identification.dateIssued == null
|
||||
? null
|
||||
: identification.dateIssued.toString(),
|
||||
"expiration_date": identification.expirationDate == null
|
||||
? null
|
||||
: identification.expirationDate.toString(),
|
||||
"as_pdf_reference": identification.asPdfReference,
|
||||
"_agencyName": identification.agency!.name,
|
||||
"_agencyCatId": identification.agency!.category!.id,
|
||||
"_privateEntity": identification.agency!.privateEntity,
|
||||
"_citymunCode": identification.issuedAt?.cityMunicipality?.code,
|
||||
"_countryId": identification.issuedAt!.country!.id
|
||||
};
|
||||
try {
|
||||
http.Response response = await Request.instance
|
||||
.putRequest(param: {}, path: path, body: body, headers: headers);
|
||||
if (response.statusCode == 200) {
|
||||
Map data = jsonDecode(response.body);
|
||||
responseData = data;
|
||||
} else {
|
||||
responseData.addAll({'success': false});
|
||||
}
|
||||
} catch (e) {
|
||||
throw e.toString();
|
||||
}
|
||||
return responseData;
|
||||
}
|
||||
}
|
|
@ -37,7 +37,7 @@ confirmAlert(context, Function() yes,String title, String subtitle) {
|
|||
).show();
|
||||
}
|
||||
|
||||
confirmAlertWithCancel(context, Function() yes,Function() no,String title, String subtitle) {
|
||||
confirmAlertWithCancel(context, Function() yes,Function() no,String title, String subtitle,) {
|
||||
AwesomeDialog(
|
||||
context: context,
|
||||
dialogType: DialogType.question,
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
import 'package:mask_text_input_formatter/mask_text_input_formatter.dart';
|
||||
|
||||
var mobileFormatter = MaskTextInputFormatter(
|
||||
mask: "+63 (###) ###-####",
|
||||
filter: {"#": RegExp(r"^[1-9][0-9]*$")},
|
||||
type: MaskAutoCompletionType.lazy,
|
||||
initialText: "0");
|
||||
|
||||
var landLineFormatter = MaskTextInputFormatter(
|
||||
mask: "(###) ###-###",
|
||||
filter: {"#": RegExp(r"^[0-9]")},
|
||||
type: MaskAutoCompletionType.lazy,
|
||||
initialText: "0");
|
|
@ -8,6 +8,7 @@ import 'package:unit2/utils/request.dart';
|
|||
import 'package:unit2/utils/urls.dart';
|
||||
|
||||
import '../model/profile/basic_information/contact_information.dart';
|
||||
import '../model/profile/family_backround.dart';
|
||||
import '../model/utils/agency.dart';
|
||||
import '../model/utils/category.dart';
|
||||
import '../model/utils/position.dart';
|
||||
|
@ -141,4 +142,33 @@ class ProfileUtilities {
|
|||
}
|
||||
return serviceTypes;
|
||||
}
|
||||
|
||||
//// get relationship type
|
||||
Future<List<Relationship>> getRelationshipType() async {
|
||||
List<Relationship> relationshipTypes= [];
|
||||
Map<String, String> headers = {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
};
|
||||
String path = Url.instance.getRelationshipTypes();
|
||||
|
||||
try {
|
||||
http.Response response = await Request.instance
|
||||
.getRequest(param: {}, path: path, headers: headers);
|
||||
if (response.statusCode == 200) {
|
||||
Map data = jsonDecode(response.body);
|
||||
if (data['data'] != null) {
|
||||
for (var element in data['data']) {
|
||||
Relationship relationship = Relationship.fromJson(element);
|
||||
if(relationship.category=="personal reference"){
|
||||
relationshipTypes.add(relationship);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
throw e.toString();
|
||||
}
|
||||
return relationshipTypes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ class Url {
|
|||
// return '192.168.10.183:3000';
|
||||
// return 'agusandelnorte.gov.ph';
|
||||
// return "192.168.10.219:3000";
|
||||
return "devweb.agusandelnorte.gov.ph";
|
||||
return "playweb.agusandelnorte.gov.ph";
|
||||
// return 'devapi.agusandelnorte.gov.ph:3004';
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,10 @@ String getAgencyCategory(){
|
|||
return "api/jobnet_app/agency_categories/";
|
||||
}
|
||||
|
||||
String identifications(){
|
||||
return "/api/jobnet_app/profile/pds/basic/identification/";
|
||||
}
|
||||
|
||||
|
||||
////educational background paths
|
||||
String educationalBackground(){
|
||||
|
@ -119,6 +123,13 @@ String getNonAcademicRecognition(){
|
|||
String getFamilies(){
|
||||
return "/api/jobnet_app/profile/pds/family/";
|
||||
}
|
||||
String addEmergency(){
|
||||
return "/api/profile_app/person_emergency/";
|
||||
}
|
||||
String getRelationshipTypes(){
|
||||
return "/api/jobnet_app/relationship_types";
|
||||
}
|
||||
|
||||
|
||||
//// contacts path
|
||||
String getServiceTypes(){
|
||||
|
|
Loading…
Reference in New Issue