integrated family background API

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
PGAN-MIS 2023-02-08 16:06:27 +08:00
parent d2a34d8e22
commit 7795b5883b
7 changed files with 584 additions and 70 deletions

View File

@ -0,0 +1,310 @@
// To parse this JSON data, do
//
// final familyBackground = familyBackgroundFromJson(jsonString);
import 'dart:convert';
import 'dart:ffi';
FamilyBackground familyBackgroundFromJson(String str) => FamilyBackground.fromJson(json.decode(str));
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,
});
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"]),
companyAddress: json["company_address"],
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() => {
"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())),
"incase_of_emergency": incaseOfEmergency,
"company_contact_number": companyContactNumber,
};
}
class Company {
Company({
this.id,
this.name,
this.category,
this.privateEntity,
});
final int? id;
final String? name;
final Category? category;
final bool? privateEntity;
factory Company.fromJson(Map<String, dynamic> json) => Company(
id: json["id"],
name: json["name"],
category: json["category"] == null ? null : Category.fromJson(json["category"]),
privateEntity: json["private_entity"],
);
Map<String, dynamic> toJson() => {
"id": id,
"name": name,
"category": category?.toJson(),
"private_entity": privateEntity,
};
}
class Category {
Category({
this.id,
this.name,
this.industryClass,
});
final int? id;
final String? name;
final IndustryClass? industryClass;
factory Category.fromJson(Map<String, dynamic> json) => Category(
id: json["id"],
name: json["name"],
industryClass: json["industry_class"] == null ? null : IndustryClass.fromJson(json["industry_class"]),
);
Map<String, dynamic> toJson() => {
"id": id,
"name": name,
"industry_class": industryClass?.toJson(),
};
}
class IndustryClass {
IndustryClass({
this.id,
this.name,
this.description,
});
final int? id;
final String? name;
final String? description;
factory IndustryClass.fromJson(Map<String, dynamic> json) => IndustryClass(
id: json["id"],
name: json["name"],
description: json["description"],
);
Map<String, dynamic> toJson() => {
"id": id,
"name": name,
"description": description,
};
}
class EmergencyContact {
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;
factory EmergencyContact.fromJson(Map<String, dynamic> json) => EmergencyContact(
telco: json["telco"],
isactive: json["isactive"],
provider: json["provider"],
isprimary: json["isprimary"],
numbermail: json["numbermail"],
serviceType: json["service_type"],
contactinfoid: json["contactinfoid"],
commServiceId: json["comm_service_id"],
);
Map<String, dynamic> toJson() => {
"telco": telco,
"isactive": isactive,
"provider": provider,
"isprimary": isprimary,
"numbermail": numbermail,
"service_type": serviceType,
"contactinfoid": contactinfoid,
"comm_service_id": commServiceId,
};
}
class Position {
Position({
this.id,
this.title,
});
final int? id;
final String? title;
factory Position.fromJson(Map<String, dynamic> json) => Position(
id: json["id"],
title: json["title"],
);
Map<String, dynamic> toJson() => {
"id": id,
"title": title,
};
}
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,
});
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;
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"]),
esigPath: json["esig_path"],
lastName: json["last_name"],
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"],
middleName: json["middle_name"],
uuidQrcode: json["uuid_qrcode"],
civilStatus: json["civil_status"],
titlePrefix: json["title_prefix"],
titleSuffix: json["title_suffix"],
showTitleId: json["show_title_id"],
nameExtension: json["name_extension"],
);
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')}",
"esig_path": esigPath,
"last_name": lastName,
"weight_kg": weightKg,
"blood_type": bloodType,
"first_name": firstName,
"photo_path": photoPath,
"maiden_name": maidenName,
"middle_name": middleName,
"uuid_qrcode": uuidQrcode,
"civil_status": civilStatus,
"title_prefix": titlePrefix,
"title_suffix": titleSuffix,
"show_title_id": showTitleId,
"name_extension": nameExtension,
};
}
class Relationship {
Relationship({
this.id,
this.type,
this.category,
});
final int? id;
final String? type;
final String? category;
factory Relationship.fromJson(Map<String, dynamic> json) => Relationship(
id: json["id"],
type: json["type"],
category: json["category"],
);
Map<String, dynamic> toJson() => {
"id": id,
"type": type,
"category": category,
};
}

View File

@ -2,6 +2,7 @@ import 'package:unit2/model/profile/basic_info.dart';
import 'package:unit2/model/profile/basic_information/primary-information.dart';
import 'package:unit2/model/profile/educational_background.dart';
import 'package:unit2/model/profile/eligibility.dart';
import 'package:unit2/model/profile/family_backround.dart';
import 'package:unit2/model/profile/learning_development.dart';
import 'package:unit2/model/profile/other_info.dart';
import 'package:unit2/model/profile/references.dart';
@ -15,7 +16,8 @@ class ProfileInformation{
List<PersonalReference> references;
List<LearningDevelopement> learningsAndDevelopment;
List<EducationalBackground> educationalBackgrounds;
List<FamilyBackground> families;
List<WorkHistory>workExperiences;
List<VoluntaryWork> voluntaryWorks;
ProfileInformation({required this.otherInformation, required this.voluntaryWorks, required this.workExperiences, required this.basicInfo,required this.eligibilities,required this.references, required this.learningsAndDevelopment,required this.educationalBackgrounds});
ProfileInformation({required this.families, required this.otherInformation, required this.voluntaryWorks, required this.workExperiences, required this.basicInfo,required this.eligibilities,required this.references, required this.learningsAndDevelopment,required this.educationalBackgrounds});
}

View File

@ -0,0 +1,189 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:unit2/model/profile/family_backround.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/utils/global.dart';
class FamilyBackgroundScreen extends StatefulWidget {
final List<FamilyBackground> familyBackground;
const FamilyBackgroundScreen({super.key, required this.familyBackground});
@override
State<FamilyBackgroundScreen> createState() => _FamilyBackgroundScreenState();
}
class _FamilyBackgroundScreenState extends State<FamilyBackgroundScreen> {
FamilyBackground? father;
FamilyBackground? mother;
FamilyBackground? spouse;
List<FamilyBackground> children = [];
List<FamilyBackground> otherRelated = [];
@override
Widget build(BuildContext context) {
father = widget.familyBackground.firstWhere((element) => element.relationship!.id==1);
mother = widget.familyBackground.firstWhere((element) => element.relationship!.id==2);
spouse = widget.familyBackground.firstWhere((element) => element.relationship!.id==3);
var childs = widget.familyBackground.where((element) => element.relationship!.id==4);
if(childs.isNotEmpty){
for (var element in childs) {
children.add(element);
}
}
var relateds = widget.familyBackground.where((element) => element.relationship!.id! < 4);
if(relateds.isNotEmpty){
for (var element in childs) {
otherRelated.add(element);
}
}
return Scaffold(
appBar: AppBar(title: const Text("Addresses"), centerTitle: true, backgroundColor: primary,),
body: Column(
children: [
//Father
Container(
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: const BorderRadius.all(Radius.circular(12))),
padding: const EdgeInsets.symmetric(horizontal: 12,vertical: 8),
width: screenWidth,
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text("Father"),
Text("${father!.relatedPerson!.firstName} ${father!.relatedPerson!.middleName} ${father!.relatedPerson!.lastName} ${father!.relatedPerson!.nameExtension??''}"),
const Text("Full Name"),
Row(children: [
Checkbox(value: false, onChanged: (value){}),
const Text("Incase of emergency")
],)
]),
),
IconButton(onPressed: (){}, icon: const Icon(Icons.more_vert))
],
),),
const SizedBox(height: 5,),
//Mother
Container(
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: const BorderRadius.all(Radius.circular(12))),
padding: const EdgeInsets.symmetric(horizontal: 12,vertical: 8),
width: screenWidth,
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text("Mother"),
Text("${mother!.relatedPerson!.firstName} ${mother!.relatedPerson!.middleName} ${mother!.relatedPerson!.lastName} ${mother!.relatedPerson!.nameExtension??''}"),
const Text("Full Name"),
Row(children: [
Checkbox(value: false, onChanged: (value){}),
const Text("Incase of emergency")
],)
]),
),
IconButton(onPressed: (){}, icon: const Icon(Icons.more_vert))
],
),),
const SizedBox(height: 5,),
//Spouse
spouse != null?
Container(
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: const BorderRadius.all(Radius.circular(12))),
padding: const EdgeInsets.symmetric(horizontal: 12,vertical: 8),
width: screenWidth,
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text("Spouse"),
Text("${spouse!.relatedPerson!.firstName} ${spouse!.relatedPerson!.middleName} ${spouse!.relatedPerson!.lastName} ${spouse!.relatedPerson!.nameExtension??''}"),
const Text("Full Name"),
Row(children: [
Checkbox(value: false, onChanged: (value){}),
const Text("Incase of emergency")
],)
]),
),
IconButton(onPressed: (){}, icon: const Icon(Icons.more_vert))
],
),):const SizedBox(),
const SizedBox(height: 5,),
// Childrens
children.isNotEmpty?Expanded(
child: ListView(
children: children.map((child) => Container(
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: const BorderRadius.all(Radius.circular(12))),
padding: const EdgeInsets.symmetric(horizontal: 12,vertical: 8),
width: screenWidth,
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text("Children"),
Text("${child.relatedPerson!.firstName} ${child.relatedPerson!.middleName} ${child.relatedPerson!.lastName} ${child.relatedPerson!.nameExtension??''}"),
const Text("Full Name"),
Row(children: [
Checkbox(value: false, onChanged: (value){}),
const Text("Incase of emergency")
],)
]),
),
IconButton(onPressed: (){}, icon: const Icon(Icons.more_vert))
],
),),).toList()),
):const SizedBox(),
otherRelated.isNotEmpty?Expanded(
child: ListView(
children: otherRelated.map((relative) => Container(
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: const BorderRadius.all(Radius.circular(12))),
padding: const EdgeInsets.symmetric(horizontal: 12,vertical: 8),
width: screenWidth,
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text("Other related Person(s)"),
Text("${relative.relatedPerson!.firstName} ${relative!.relatedPerson!.middleName} ${relative!.relatedPerson!.lastName} ${relative!.relatedPerson!.nameExtension??''}"),
const Text("Full Name"),
Row(children: [
Checkbox(value: false, onChanged: (value){}),
const Text("Incase of emergency")
],)
]),
),
IconButton(onPressed: (){}, icon: const Icon(Icons.more_vert))
],
),),).toList()),
):const SizedBox()
]),
);
}
}

View File

@ -15,6 +15,7 @@ import 'package:unit2/screens/profile/components/basic_information/identificatio
import 'package:unit2/screens/profile/components/basic_information/primary_information.dart';
import 'package:unit2/screens/profile/components/education_screen.dart';
import 'package:unit2/screens/profile/components/eligibility.dart';
import 'package:unit2/screens/profile/components/family_background_screen.dart';
import 'package:unit2/screens/profile/components/learning_and_development_screen.dart';
import 'package:unit2/screens/profile/components/loading_screen.dart';
import 'package:unit2/screens/profile/components/other_information/non_academic_recognition.dart';
@ -122,7 +123,11 @@ class _ProfileInfoState extends State<ProfileInfo> {
MainMenu(
icon: Elusive.group,
title: "Family",
onTap: (){},
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){
return FamilyBackgroundScreen(familyBackground: state.profileInformation.families);
}));
},
),
const Divider(),
MainMenu(

View File

@ -21,8 +21,7 @@ class _MenuScreenState extends State<MenuScreen> {
widget.userData!.user!.login!.user!.firstName!.toUpperCase();
final String lastname =
widget.userData!.user!.login!.user!.lastName!.toUpperCase();
return SafeArea(
child: Drawer(
return Drawer(
child: SingleChildScrollView(
child: SizedBox(
height: blockSizeVertical * 96,
@ -70,7 +69,6 @@ class _MenuScreenState extends State<MenuScreen> {
),
),
),
),
);
}
}

View File

@ -47,8 +47,7 @@ class _MainScreenState extends State<MainScreen> {
}
});
});
return SafeArea(
child: Scaffold(
return Scaffold(
appBar: AppBar(
backgroundColor: primary,
leading: IconButton(
@ -74,7 +73,7 @@ class _MainScreenState extends State<MainScreen> {
roles: roles,
)
: const NoModule(),
));
);
}
return Container();
}),

View File

@ -8,6 +8,7 @@ import 'package:unit2/model/profile/basic_information/contact_information.dart';
import 'package:unit2/model/profile/basic_information/identification_information.dart';
import 'package:unit2/model/profile/educational_background.dart';
import 'package:unit2/model/profile/eligibility.dart';
import 'package:unit2/model/profile/family_backround.dart';
import 'package:unit2/model/profile/learning_development.dart';
import 'package:unit2/model/profile/other_info.dart';
import 'package:unit2/model/profile/other_information/non_acedimic_recognition.dart';
@ -37,6 +38,7 @@ class ProfileService {
List<Identification> identificationInformation = [];
List<ContactInfo> contactInformation = [];
List<EligibityCert> eligibilities = [];
List<FamilyBackground> families = [];
List<Citizenship> citizenships = [];
List<LearningDevelopement> learningsDevelopments = [];
List<EducationalBackground> educationalBackgrounds = [];
@ -89,6 +91,14 @@ class ProfileService {
});
}
// get all family background
if(data['data']['family_background'] != null){
data['data']['family_background'].forEach((var family){
FamilyBackground familyBackground = FamilyBackground.fromJson(family);
families.add(familyBackground);
});
}
//get all eligibilities
if (data['data']['eligibilities'] != null) {
data['data']['eligibilities']!.forEach((var cert) {
@ -188,6 +198,7 @@ class ProfileService {
orgMemberships: orgMemberships,
nonAcademicRecognition: nonAcademicRecognitions);
ProfileInformation profileInformation = ProfileInformation(
families: families,
otherInformation: otherInformation,
workExperiences: workExperiences,
basicInfo: basicInfo,