integrated organization membership

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
PGAN-MIS 2023-02-07 14:17:49 +08:00
parent 4e9b66051c
commit f74ad83667
9 changed files with 427 additions and 134 deletions

View File

@ -0,0 +1,8 @@
import 'package:unit2/model/profile/other_information/organization_memberships.dart';
import 'package:unit2/model/profile/other_information/skills_and_hobbies.dart';
class OtherInformation{
List<SkillsHobbies> skillsAndHobbies;
List<OrganizationMembership>orgMemberships;
OtherInformation({required this.skillsAndHobbies, required this.orgMemberships});
}

View File

@ -0,0 +1,101 @@
// To parse this JSON data, do
//
// final organizationMembership = organizationMembershipFromJson(jsonString);
import 'dart:convert';
OrganizationMembership organizationMembershipFromJson(String str) => OrganizationMembership.fromJson(json.decode(str));
String organizationMembershipToJson(OrganizationMembership data) => json.encode(data.toJson());
class OrganizationMembership {
OrganizationMembership({
this.agency,
});
final Agency? agency;
factory OrganizationMembership.fromJson(Map<String, dynamic> json) => OrganizationMembership(
agency: json["agency"] == null ? null : Agency.fromJson(json["agency"]),
);
Map<String, dynamic> toJson() => {
"agency": agency?.toJson(),
};
}
class Agency {
Agency({
this.id,
this.name,
this.category,
this.privateEntity,
});
final int? id;
final String? name;
final Category? category;
final bool? privateEntity;
factory Agency.fromJson(Map<String, dynamic> json) => Agency(
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 dynamic 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,
};
}

View File

@ -0,0 +1,29 @@
// To parse this JSON data, do
//
// final skillsHobbies = skillsHobbiesFromJson(jsonString);
import 'dart:convert';
SkillsHobbies skillsHobbiesFromJson(String str) => SkillsHobbies.fromJson(json.decode(str));
String skillsHobbiesToJson(SkillsHobbies data) => json.encode(data.toJson());
class SkillsHobbies {
SkillsHobbies({
this.id,
this.name,
});
final int? id;
final String? name;
factory SkillsHobbies.fromJson(Map<String, dynamic> json) => SkillsHobbies(
id: json["id"],
name: json["name"],
);
Map<String, dynamic> toJson() => {
"id": id,
"name": name,
};
}

View File

@ -3,17 +3,19 @@ import 'package:unit2/model/profile/basic_information/primary-information.dart';
import 'package:unit2/model/profile/educational_background.dart'; import 'package:unit2/model/profile/educational_background.dart';
import 'package:unit2/model/profile/eligibility.dart'; import 'package:unit2/model/profile/eligibility.dart';
import 'package:unit2/model/profile/learning_development.dart'; import 'package:unit2/model/profile/learning_development.dart';
import 'package:unit2/model/profile/other_info.dart';
import 'package:unit2/model/profile/references.dart'; import 'package:unit2/model/profile/references.dart';
import 'package:unit2/model/profile/voluntary_works.dart'; import 'package:unit2/model/profile/voluntary_works.dart';
import 'package:unit2/model/profile/work_history.dart'; import 'package:unit2/model/profile/work_history.dart';
class ProfileInformation{ class ProfileInformation{
BasicInfo basicInfo; BasicInfo basicInfo;
OtherInformation otherInformation;
List<EligibityCert> eligibilities; List<EligibityCert> eligibilities;
List<PersonalReference> references; List<PersonalReference> references;
List<LearningDevelopement> learningsAndDevelopment; List<LearningDevelopement> learningsAndDevelopment;
List<EducationalBackground> educationalBackgrounds; List<EducationalBackground> educationalBackgrounds;
List<WorkHistory>workExperiences; List<WorkHistory>workExperiences;
List<VoluntaryWork> voluntaryWorks; List<VoluntaryWork> voluntaryWorks;
ProfileInformation({required this.voluntaryWorks, required this.workExperiences, required this.basicInfo,required this.eligibilities,required this.references, required this.learningsAndDevelopment,required this.educationalBackgrounds}); 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});
} }

View File

@ -7,6 +7,7 @@ import 'package:fluttericon/font_awesome5_icons.dart';
import 'package:fluttericon/modern_pictograms_icons.dart'; import 'package:fluttericon/modern_pictograms_icons.dart';
import 'package:unit2/screens/profile/components/main_menu.dart'; import 'package:unit2/screens/profile/components/main_menu.dart';
import 'package:unit2/screens/profile/components/submenu.dart'; import 'package:unit2/screens/profile/components/submenu.dart';
import 'package:unit2/utils/global.dart';
import '../../../theme-data.dart/colors.dart'; import '../../../theme-data.dart/colors.dart';
@ -15,7 +16,10 @@ class LoadingScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Stack(
children: [
Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
vertical: 12, horizontal: 12), vertical: 12, horizontal: 12),
child: ListView( child: ListView(
@ -148,6 +152,13 @@ class LoadingScreen extends StatelessWidget {
]), ]),
], ],
), ),
),
Container(
width: screenWidth,
height: screenHeight,
color: Colors.white70,
),
],
); );
} }
} }

View File

@ -0,0 +1,63 @@
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:unit2/model/profile/other_information/organization_memberships.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import '../../../../utils/global.dart';
class OrgMembershipsScreen extends StatefulWidget {
final List<OrganizationMembership> orgMemberships;
const OrgMembershipsScreen({super.key, required this.orgMemberships});
@override
State<OrgMembershipsScreen> createState() => _OrgMembershipsScreenState();
}
class _OrgMembershipsScreenState extends State<OrgMembershipsScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Organization Memberships"),
backgroundColor: primary,
centerTitle: true,
),
body: ListView.builder(
itemCount: widget.orgMemberships.length,
itemBuilder: (BuildContext context, int index) {
String entity =
widget.orgMemberships[index].agency!.privateEntity == false
? "Government"
: "Private";
String agencyName = widget.orgMemberships[index].agency!.name!;
return Column(
children: [
Container(
width: screenWidth,
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius:
const BorderRadius.all(Radius.circular(12))),
padding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: Row(children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(entity),
Text(agencyName),
],
)),
IconButton(
onPressed: () {}, icon: const Icon(Icons.more_vert))
]),
)
],
);
}),
);
}
}

View File

@ -0,0 +1,49 @@
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:unit2/model/profile/other_information/skills_and_hobbies.dart';
import 'package:unit2/theme-data.dart/colors.dart';
class SkillHobbiesScreen extends StatefulWidget {
final List<SkillsHobbies>skillsHobbies;
const SkillHobbiesScreen({super.key,required this.skillsHobbies});
@override
State<SkillHobbiesScreen> createState() => _SkillHobbiesScreenState();
}
class _SkillHobbiesScreenState extends State<SkillHobbiesScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Skills and Hobbies"),
backgroundColor: primary,
centerTitle: true,
),
body: Wrap(
spacing: 5,
runSpacing: 5,
clipBehavior: Clip.none,
verticalDirection: VerticalDirection.down,
children:widget.skillsHobbies.map((SkillsHobbies sh){
return Badge(
padding: const EdgeInsets.all(8),
alignment: AlignmentDirectional.topStart,
backgroundColor: Colors.grey.shade300,
child: Row(
children: [
Text(sh.name!),
IconButton(
onPressed: () {},
icon: const Icon(Icons.close)),
],
),
);
}).toList()
),
);
}
}

View File

@ -16,6 +16,8 @@ import 'package:unit2/screens/profile/components/education_screen.dart';
import 'package:unit2/screens/profile/components/eligibility.dart'; import 'package:unit2/screens/profile/components/eligibility.dart';
import 'package:unit2/screens/profile/components/learning_and_development_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/loading_screen.dart';
import 'package:unit2/screens/profile/components/other_information/org_membership.dart';
import 'package:unit2/screens/profile/components/other_information/skills_and_hobbies_screen.dart';
import 'package:unit2/screens/profile/components/references_screen.dart'; import 'package:unit2/screens/profile/components/references_screen.dart';
import 'package:unit2/screens/profile/components/work_history_screen.dart'; import 'package:unit2/screens/profile/components/work_history_screen.dart';
import 'package:unit2/screens/profile/voluntary_works.dart'; import 'package:unit2/screens/profile/voluntary_works.dart';
@ -193,9 +195,17 @@ class _ProfileInfoState extends State<ProfileInfo> {
), ),
items: [ items: [
subMenu(Icons.fitness_center, subMenu(Icons.fitness_center,
"Skills & Hobbies",(){}), "Skills & Hobbies",(){
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){
return SkillHobbiesScreen(skillsHobbies: state.profileInformation.otherInformation.skillsAndHobbies);
}));
}),
subMenu(FontAwesome5.certificate, subMenu(FontAwesome5.certificate,
"Organization Memberships",(){}), "Organization Memberships",(){
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){
return OrgMembershipsScreen(orgMemberships: state.profileInformation.otherInformation.orgMemberships);
}));
}),
subMenu(Entypo.doc_text, subMenu(Entypo.doc_text,
"Non-Academic Recognitions",(){}), "Non-Academic Recognitions",(){}),
]), ]),

View File

@ -8,14 +8,17 @@ import 'package:unit2/model/profile/basic_information/identification_information
import 'package:unit2/model/profile/educational_background.dart'; import 'package:unit2/model/profile/educational_background.dart';
import 'package:unit2/model/profile/eligibility.dart'; import 'package:unit2/model/profile/eligibility.dart';
import 'package:unit2/model/profile/learning_development.dart'; import 'package:unit2/model/profile/learning_development.dart';
import 'package:unit2/model/profile/other_info.dart';
import 'package:unit2/model/profile/profileInfomation.dart'; import 'package:unit2/model/profile/profileInfomation.dart';
import 'package:unit2/model/profile/references.dart'; import 'package:unit2/model/profile/references.dart';
import 'package:unit2/model/profile/other_information/skills_and_hobbies.dart';
import 'package:unit2/model/profile/voluntary_works.dart'; import 'package:unit2/model/profile/voluntary_works.dart';
import 'package:unit2/model/profile/work_history.dart'; import 'package:unit2/model/profile/work_history.dart';
import 'package:unit2/utils/request.dart'; import 'package:unit2/utils/request.dart';
import 'package:unit2/utils/urls.dart'; import 'package:unit2/utils/urls.dart';
import '../../model/profile/basic_information/primary-information.dart'; import '../../model/profile/basic_information/primary-information.dart';
import '../../model/profile/other_information/organization_memberships.dart';
class ProfileService { class ProfileService {
static final ProfileService _instance = ProfileService(); static final ProfileService _instance = ProfileService();
@ -35,6 +38,8 @@ class ProfileService {
List<LearningDevelopement> learningsDevelopments = []; List<LearningDevelopement> learningsDevelopments = [];
List<EducationalBackground> educationalBackgrounds = []; List<EducationalBackground> educationalBackgrounds = [];
List<VoluntaryWork> voluntaryWorks =[]; List<VoluntaryWork> voluntaryWorks =[];
List<SkillsHobbies> skillsHobbies = [];
List<OrganizationMembership> orgMemberships = [];
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'Authorization': "Token $token" 'Authorization': "Token $token"
@ -105,13 +110,27 @@ class ProfileService {
voluntaryWorks.add(vwork); voluntaryWorks.add(vwork);
}); });
// get all hobbies
data['data']['other_information']['skills_hobbies'].forEach((var skills_hobbies){
SkillsHobbies skillsAndHobbies = SkillsHobbies.fromJson(skills_hobbies);
skillsHobbies.add(skillsAndHobbies);
});
data['data']['other_information']['organization_memberships'].forEach((var org) {
OrganizationMembership organization =
OrganizationMembership.fromJson(org);
orgMemberships.add(organization);
});
BasicInfo basicInfo = BasicInfo( BasicInfo basicInfo = BasicInfo(
contactInformation: contactInformation, contactInformation: contactInformation,
primaryInformation: primaryInformation, primaryInformation: primaryInformation,
identifications: identificationInformation, identifications: identificationInformation,
citizenships: citizenships); citizenships: citizenships);
OtherInformation otherInformation = OtherInformation(skillsAndHobbies: skillsHobbies,orgMemberships: orgMemberships);
ProfileInformation profileInformation = ProfileInformation( ProfileInformation profileInformation = ProfileInformation(
otherInformation: otherInformation,
workExperiences: workExperiences, workExperiences: workExperiences,
basicInfo: basicInfo, basicInfo: basicInfo,
eligibilities: eligibilities, eligibilities: eligibilities,
@ -119,6 +138,7 @@ class ProfileService {
learningsAndDevelopment: learningsDevelopments, learningsAndDevelopment: learningsDevelopments,
educationalBackgrounds: educationalBackgrounds, educationalBackgrounds: educationalBackgrounds,
voluntaryWorks: voluntaryWorks voluntaryWorks: voluntaryWorks
); );
profileInformation0 = profileInformation; profileInformation0 = profileInformation;
} }