passo_mobile_app/lib/screens/profile/profile.dart

389 lines
21 KiB
Dart
Raw Normal View History

2023-01-26 02:15:00 +00:00
import 'package:expandable_group/expandable_group_widget.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';
2023-01-26 02:15:00 +00:00
import 'package:fluttericon/brandico_icons.dart';
import 'package:fluttericon/elusive_icons.dart';
import 'package:fluttericon/entypo_icons.dart';
import 'package:fluttericon/font_awesome5_icons.dart';
import 'package:fluttericon/modern_pictograms_icons.dart';
import 'package:unit2/bloc/profile/primary_information/address/address_bloc.dart';
2023-06-06 06:54:51 +00:00
import 'package:unit2/bloc/profile/primary_information/citizenship/citizenship_bloc.dart';
import 'package:unit2/bloc/profile/primary_information/contact/contact_bloc.dart';
import 'package:unit2/bloc/profile/primary_information/identification/identification_bloc.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart';
2023-02-08 03:07:30 +00:00
import 'package:unit2/screens/profile/components/basic_information/address_screen.dart';
import 'package:unit2/screens/profile/components/basic_information/citizenship_screen.dart';
2023-02-09 08:48:19 +00:00
import 'package:unit2/screens/profile/components/basic_information/contact_information_screen.dart';
import 'package:unit2/screens/profile/components/basic_information/identification_information_screen.dart';
import 'package:unit2/screens/profile/components/basic_information/primary_information_screen.dart';
import 'package:unit2/screens/profile/components/education_screen.dart';
2023-02-09 08:48:19 +00:00
import 'package:unit2/screens/profile/components/eligibility_screen.dart';
2023-02-08 08:06:27 +00:00
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';
2023-02-09 08:48:19 +00:00
import 'package:unit2/screens/profile/components/other_information/non_academic_recognition_screen.dart';
import 'package:unit2/screens/profile/components/other_information/org_membership_screen.dart';
2023-02-07 06:17:49 +00:00
import 'package:unit2/screens/profile/components/other_information/skills_and_hobbies_screen.dart';
import 'package:unit2/screens/profile/components/references_screen.dart';
2023-02-07 01:29:38 +00:00
import 'package:unit2/screens/profile/components/work_history_screen.dart';
2023-02-09 08:48:19 +00:00
import 'package:unit2/screens/profile/components/voluntary_works_screen.dart';
2023-01-26 02:15:00 +00:00
import 'package:unit2/theme-data.dart/colors.dart';
2023-05-22 02:23:56 +00:00
import 'package:unit2/widgets/error_state.dart';
import '../../bloc/profile/eligibility/eligibility_bloc.dart';
import '../../bloc/profile/family/family_bloc.dart';
import '../../bloc/profile/education/education_bloc.dart';
import '../../bloc/profile/learningDevelopment/learning_development_bloc.dart';
import '../../bloc/profile/other_information/hobbies/hoobies_bloc.dart';
import '../../bloc/profile/other_information/non_academic_recognition.dart/non_academic_recognition_bloc.dart';
import '../../bloc/profile/other_information/org_membership/organization_membership_bloc.dart';
import '../../bloc/profile/references/references_bloc.dart';
import '../../bloc/profile/voluntary_works/voluntary_work_bloc.dart';
import '../../bloc/profile/workHistory/workHistory_bloc.dart';
import '../../bloc/user/user_bloc.dart';
2023-05-22 02:23:56 +00:00
import '../../model/profile/basic_information/primary-information.dart';
import '../unit2/homepage.dart/components/menu.dart';
2023-01-26 02:15:00 +00:00
import 'components/main_menu.dart';
import 'components/submenu.dart';
2023-03-16 07:53:42 +00:00
class ProfileInfo extends StatelessWidget {
2023-01-26 02:15:00 +00:00
const ProfileInfo({super.key});
@override
Widget build(BuildContext context) {
2023-03-16 07:53:42 +00:00
int? profileId;
String? token;
2023-05-22 02:23:56 +00:00
Profile profile;
2023-02-09 08:48:19 +00:00
return Scaffold(
appBar: AppBar(
backgroundColor: primary,
centerTitle: true,
title: const Text('Profile'),
),
body: ProgressHUD(
2023-03-16 07:53:42 +00:00
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
2023-02-15 03:40:12 +00:00
child: BlocBuilder<UserBloc, UserState>(builder: (context, state) {
2023-02-09 08:48:19 +00:00
if (state is UserLoggedIn) {
profileId = state.userData!.user!.login!.user!.profileId;
token = state.userData!.user!.login!.token!;
2023-05-22 02:23:56 +00:00
profile = state.userData!.employeeInfo!.profile!;
2023-02-09 08:48:19 +00:00
return BlocConsumer<ProfileBloc, ProfileState>(
2023-03-16 07:53:42 +00:00
listener: (context, state,){
2023-02-09 08:48:19 +00:00
if (state is ProfileLoading) {
final progress = ProgressHUD.of(context);
2023-03-16 07:53:42 +00:00
progress!.showWithText("Please wait...");
2023-02-09 08:48:19 +00:00
}
2023-05-22 02:23:56 +00:00
if (state is ProfileLoaded || state is ProfileErrorState || state is BasicInformationEditingState) {
2023-02-09 08:48:19 +00:00
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
},
builder: (context, state) {
if (state is ProfileLoaded) {
return Container(
padding: const EdgeInsets.symmetric(
vertical: 12, horizontal: 12),
child: ListView(
children: [
2023-02-15 03:40:12 +00:00
Text(
"View and Update your Profile Information",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyLarge,
),
2023-02-09 08:48:19 +00:00
ExpandableGroup(
collapsedIcon:
const Icon(Icons.keyboard_arrow_down),
2023-02-15 03:40:12 +00:00
expandedIcon: const Icon(Icons.keyboard_arrow_up),
2023-02-09 08:48:19 +00:00
header: const ListTile(
leading: Icon(
Elusive.address_book,
color: primary,
),
title: Text(
"Basic Information",
2023-02-15 03:40:12 +00:00
style: TextStyle(fontWeight: FontWeight.bold),
2023-02-09 08:48:19 +00:00
),
),
items: [
2023-02-15 03:40:12 +00:00
subMenu(Icons.person, "Primary", () {
2023-05-22 02:23:56 +00:00
2023-02-15 03:40:12 +00:00
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
2023-05-22 02:23:56 +00:00
return BlocProvider<ProfileBloc>.value(value: ProfileBloc()..add(GetPrimaryBasicInfo(primaryBasicInformation: profile)),child: PrimaryInfo(token: token!,profileId: profileId!,),);
2023-02-15 03:40:12 +00:00
}));
2023-02-09 08:48:19 +00:00
}),
2023-06-06 06:54:51 +00:00
subMenu(Icons.home, "Addresses", () {
2023-02-15 03:40:12 +00:00
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => AddressBloc()
..add(GetAddress(
addresses: state.profileInformation
.basicInfo.addresses)),
child: const AddressScreen(),
);
2023-02-15 03:40:12 +00:00
}));
}),
subMenu(Icons.contact_mail, "Identifications",
2023-02-15 03:40:12 +00:00
() {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => IdentificationBloc()
..add(GetIdentifications(
identificationInformation: state
.profileInformation
.basicInfo
.identifications)),
child: const IdentificationsScreen(),
2023-02-15 03:40:12 +00:00
);
}));
}),
subMenu(Icons.contact_phone, "Contact Info",
() {
2023-03-16 07:53:42 +00:00
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => ContactBloc()
..add(GetContacts(
contactInformations: state
.profileInformation
.basicInfo
.contactInformation)),
child: const ContactInformationScreen(),
);
}));
}),
2023-02-15 03:40:12 +00:00
subMenu(Icons.flag, "Citizenships", () {
2023-06-06 06:54:51 +00:00
Navigator.push(context, MaterialPageRoute(
2023-02-15 03:40:12 +00:00
builder: (BuildContext context) {
2023-06-06 06:54:51 +00:00
return BlocProvider(
create: (context) => CitizenshipBloc()
..add(GetCitizenship(
citizenship: state
.profileInformation
.basicInfo
.citizenships)),
child: CitizenShipScreen(profileId: profileId!,token: token!),
2023-02-15 03:40:12 +00:00
);
}));
2023-02-09 08:48:19 +00:00
}),
]),
const Divider(),
2023-02-15 03:40:12 +00:00
MainMenu(
2023-02-09 08:48:19 +00:00
icon: Elusive.group,
title: "Family",
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => FamilyBloc()
..add(GetFamilies(
profileId: profileId!, token: token!)),
child: const FamilyBackgroundScreen(),
);
}));
},
2023-02-09 08:48:19 +00:00
),
const Divider(),
2023-02-15 03:40:12 +00:00
MainMenu(
2023-02-09 08:48:19 +00:00
icon: FontAwesome5.graduation_cap,
title: "Education",
2023-02-15 03:40:12 +00:00
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => EducationBloc()
..add(GetEducationalBackground(
profileId: profileId!, token: token!)),
child: const EducationScreen(),
);
}));
2023-02-09 08:48:19 +00:00
},
),
const Divider(),
2023-02-15 03:40:12 +00:00
MainMenu(
2023-02-09 08:48:19 +00:00
icon: Icons.stars,
title: "Eligibility",
2023-02-15 03:40:12 +00:00
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => EligibilityBloc()
..add(GetEligibilities(
profileId: profileId!, token: token!)),
child: const EligibiltyScreen(),
2023-02-15 03:40:12 +00:00
);
2023-02-09 08:48:19 +00:00
}));
},
),
const Divider(),
2023-02-15 03:40:12 +00:00
MainMenu(
2023-02-09 08:48:19 +00:00
icon: FontAwesome5.shopping_bag,
title: "Work History",
2023-02-15 03:40:12 +00:00
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => WorkHistoryBloc()
..add(GetWorkHistories(
profileId: profileId!, token: token!)),
child: const WorkHistoryScreen(),
);
}));
2023-02-09 08:48:19 +00:00
},
),
const Divider(),
2023-02-15 03:40:12 +00:00
MainMenu(
2023-02-09 08:48:19 +00:00
icon: FontAwesome5.walking,
title: "Voluntary Work & Civic Services",
2023-02-15 03:40:12 +00:00
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => VoluntaryWorkBloc()
..add(GetVoluntarWorks(
profileId: profileId!, token: token!)),
child: const VolunataryWorkScreen(),
);
}));
2023-02-09 08:48:19 +00:00
},
),
const Divider(),
2023-02-15 03:40:12 +00:00
MainMenu(
2023-02-09 08:48:19 +00:00
icon: Elusive.lightbulb,
title: "Learning & Development",
2023-02-15 03:40:12 +00:00
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => LearningDevelopmentBloc()
..add(GetLearningDevelopments(
profileId: profileId!, token: token!)),
child: const LearningAndDevelopmentScreen(),
);
}));
2023-02-09 08:48:19 +00:00
},
),
const Divider(),
2023-02-15 03:40:12 +00:00
MainMenu(
2023-02-09 08:48:19 +00:00
icon: Brandico.codepen,
title: "Personal References",
2023-02-15 03:40:12 +00:00
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => ReferencesBloc()
..add(GetReferences(
profileId: profileId!, token: token!)),
child: const ReferencesScreen(),
);
}));
2023-02-09 08:48:19 +00:00
},
),
ExpandableGroup(
collapsedIcon:
const Icon(Icons.keyboard_arrow_down),
2023-02-15 03:40:12 +00:00
expandedIcon: const Icon(Icons.keyboard_arrow_up),
2023-02-09 08:48:19 +00:00
header: const ListTile(
leading: Icon(
Icons.info,
color: primary,
),
title: Text(
"Other Information",
2023-02-15 03:40:12 +00:00
style: TextStyle(fontWeight: FontWeight.bold),
2023-02-09 08:48:19 +00:00
),
),
2023-02-09 08:48:19 +00:00
items: [
2023-02-15 03:40:12 +00:00
subMenu(
Icons.fitness_center, "Skills & Hobbies",
() {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => HoobiesBloc()
..add(GetSkillsHobbies(
profileId: profileId!,
token: token!)),
child: const SkillHobbiesScreen(),
);
}));
2023-02-15 03:40:12 +00:00
}),
2023-02-09 08:48:19 +00:00
subMenu(FontAwesome5.certificate,
2023-02-15 03:40:12 +00:00
"Organization Memberships", () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) =>
OrganizationMembershipBloc()
..add(GetOrganizationMembership(
profileId: profileId!,
token: token!)),
child: const OrgMembershipsScreen(),
);
}));
2023-02-15 03:40:12 +00:00
}),
2023-02-09 08:48:19 +00:00
subMenu(Entypo.doc_text,
2023-02-15 03:40:12 +00:00
"Non-Academic Recognitions", () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) =>
NonAcademicRecognitionBloc()
..add(GetNonAcademicRecognition(
profileId: profileId!,
token: token!)),
child:
const NonAcademicRecognitionScreen(),
);
}));
2023-02-15 03:40:12 +00:00
}),
2023-02-09 08:48:19 +00:00
]),
ExpandableGroup(
collapsedIcon:
const Icon(Icons.keyboard_arrow_down),
2023-02-15 03:40:12 +00:00
expandedIcon: const Icon(Icons.keyboard_arrow_up),
2023-02-09 08:48:19 +00:00
header: const ListTile(
leading: Icon(
FontAwesome5.laptop_house,
color: primary,
),
title: Text(
"Assets",
2023-02-15 03:40:12 +00:00
style: TextStyle(fontWeight: FontWeight.bold),
2023-02-09 08:48:19 +00:00
),
),
items: [
subMenu(ModernPictograms.home,
2023-02-15 03:40:12 +00:00
"Real Property Tax", () {}),
2023-02-09 08:48:19 +00:00
]),
],
),
);
}
if (state is ProfileLoading) {
2023-03-16 07:53:42 +00:00
2023-02-09 08:48:19 +00:00
return const LoadingScreen();
}
if (state is ProfileErrorState) {
2023-05-22 02:23:56 +00:00
return SomethingWentWrong(message: state.mesage, onpressed: (){ BlocProvider.of<ProfileBloc>(
context)
.add(LoadProfile(token:token!, userID: profileId!));});
}
2023-02-09 08:48:19 +00:00
return Container();
},
);
}
return Container();
}),
));
2023-01-26 02:15:00 +00:00
}
}