From b9615e36666eef70e3632453c9893396411a1a42 Mon Sep 17 00:00:00 2001 From: PGAN-MIS Date: Wed, 15 Feb 2023 11:40:12 +0800 Subject: [PATCH] load eligibilities with profile bloc --- lib/bloc/profile/profile_bloc.dart | 6 + lib/bloc/profile/profile_event.dart | 7 + lib/bloc/profile/profile_state.dart | 7 + lib/model/location/barangay.dart | 122 ++++++++++ lib/model/location/city.dart | 98 ++++++++ lib/model/location/country.dart | 34 +++ lib/model/location/provinces.dart | 66 +++++ lib/model/location/purok.dart | 0 lib/model/location/region.dart | 34 +++ lib/model/utils/eligibilities_choices.dart | 34 +++ .../components/eligibility/edit_modal.dart | 225 +++++++++++++++++ .../eligibility/eligibility_screen.dart | 182 ++++++++++++++ lib/screens/profile/profile.dart | 228 +++++++++++------- lib/widgets/custom_switch.dart | 44 ++++ pubspec.lock | 8 + pubspec.yaml | 1 + 16 files changed, 1007 insertions(+), 89 deletions(-) create mode 100644 lib/model/location/barangay.dart create mode 100644 lib/model/location/city.dart create mode 100644 lib/model/location/country.dart create mode 100644 lib/model/location/provinces.dart create mode 100644 lib/model/location/purok.dart create mode 100644 lib/model/location/region.dart create mode 100644 lib/model/utils/eligibilities_choices.dart create mode 100644 lib/screens/profile/components/eligibility/edit_modal.dart create mode 100644 lib/screens/profile/components/eligibility/eligibility_screen.dart create mode 100644 lib/widgets/custom_switch.dart diff --git a/lib/bloc/profile/profile_bloc.dart b/lib/bloc/profile/profile_bloc.dart index 8368e9b..bd28a2e 100644 --- a/lib/bloc/profile/profile_bloc.dart +++ b/lib/bloc/profile/profile_bloc.dart @@ -2,6 +2,7 @@ import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:unit2/model/profile/basic_info.dart'; import 'package:unit2/model/profile/basic_information/primary-information.dart'; +import 'package:unit2/model/profile/eligibility.dart'; import 'package:unit2/model/profile/profileInfomation.dart'; import 'package:unit2/sevices/profile/profile_service.dart'; @@ -23,5 +24,10 @@ class ProfileBloc extends Bloc { // emit(ProfileErrorState(mesage: e.toString())); // } }); + + on((event,emit){ + emit(ProfileLoading()); + emit(EligibilityLoaded(eligibilities: event.eligibilities)); + }); } } diff --git a/lib/bloc/profile/profile_event.dart b/lib/bloc/profile/profile_event.dart index e978beb..83d1f28 100644 --- a/lib/bloc/profile/profile_event.dart +++ b/lib/bloc/profile/profile_event.dart @@ -21,3 +21,10 @@ class LoadProfileInformation extends ProfileEvent{ List get props => []; } +class LoadEligibility extends ProfileEvent{ + final List eligibilities; + const LoadEligibility({required this.eligibilities}); + @override + List get props => []; +} + diff --git a/lib/bloc/profile/profile_state.dart b/lib/bloc/profile/profile_state.dart index ae753d5..fd1f36a 100644 --- a/lib/bloc/profile/profile_state.dart +++ b/lib/bloc/profile/profile_state.dart @@ -27,3 +27,10 @@ class ProfileLoading extends ProfileState{ } +class EligibilityLoaded extends ProfileState{ + final List eligibilities; + const EligibilityLoaded({required this.eligibilities}); + @override + List get props => [eligibilities]; +} + diff --git a/lib/model/location/barangay.dart b/lib/model/location/barangay.dart new file mode 100644 index 0000000..a73735d --- /dev/null +++ b/lib/model/location/barangay.dart @@ -0,0 +1,122 @@ +// To parse this JSON data, do +// +// final barangay = barangayFromJson(jsonString); + +import 'package:meta/meta.dart'; +import 'dart:convert'; + +Barangay barangayFromJson(String str) => Barangay.fromJson(json.decode(str)); + +String barangayToJson(Barangay data) => json.encode(data.toJson()); + +class Barangay { + Barangay({ + required this.code, + required this.description, + required this.cityMunicipality, + }); + + final String code; + final String description; + final CityMunicipality cityMunicipality; + + factory Barangay.fromJson(Map json) => Barangay( + code: json["code"], + description: json["description"], + cityMunicipality: CityMunicipality.fromJson(json["city_municipality"]), + ); + + Map toJson() => { + "code": code, + "description": description, + "city_municipality": cityMunicipality.toJson(), + }; +} + +class CityMunicipality { + CityMunicipality({ + required this.code, + required this.description, + required this.province, + required this.psgcCode, + required this.zipcode, + }); + + final String code; + final String description; + final Province province; + final String psgcCode; + final String zipcode; + + factory CityMunicipality.fromJson(Map json) => CityMunicipality( + code: json["code"], + description: json["description"], + province: Province.fromJson(json["province"]), + psgcCode: json["psgc_code"], + zipcode: json["zipcode"], + ); + + Map toJson() => { + "code": code, + "description": description, + "province": province.toJson(), + "psgc_code": psgcCode, + "zipcode": zipcode, + }; +} + +class Province { + Province({ + required this.code, + required this.description, + required this.region, + required this.psgcCode, + required this.shortname, + }); + + final String code; + final String description; + final Region region; + final String psgcCode; + final String shortname; + + factory Province.fromJson(Map json) => Province( + code: json["code"], + description: json["description"], + region: Region.fromJson(json["region"]), + psgcCode: json["psgc_code"], + shortname: json["shortname"], + ); + + Map toJson() => { + "code": code, + "description": description, + "region": region.toJson(), + "psgc_code": psgcCode, + "shortname": shortname, + }; +} + +class Region { + Region({ + required this.code, + required this.description, + required this.psgcCode, + }); + + final int code; + final String description; + final String psgcCode; + + factory Region.fromJson(Map json) => Region( + code: json["code"], + description: json["description"], + psgcCode: json["psgc_code"], + ); + + Map toJson() => { + "code": code, + "description": description, + "psgc_code": psgcCode, + }; +} diff --git a/lib/model/location/city.dart b/lib/model/location/city.dart new file mode 100644 index 0000000..8d9014c --- /dev/null +++ b/lib/model/location/city.dart @@ -0,0 +1,98 @@ +// To parse this JSON data, do +// +// final city = cityFromJson(jsonString); + +import 'package:meta/meta.dart'; +import 'dart:convert'; + +City cityFromJson(String str) => City.fromJson(json.decode(str)); + +String cityToJson(City data) => json.encode(data.toJson()); + +class City { + City({ + required this.code, + required this.description, + required this.province, + required this.psgcCode, + required this.zipcode, + }); + + final String code; + final String description; + final Province province; + final String psgcCode; + final String zipcode; + + factory City.fromJson(Map json) => City( + code: json["code"], + description: json["description"], + province: Province.fromJson(json["province"]), + psgcCode: json["psgc_code"], + zipcode: json["zipcode"], + ); + + Map toJson() => { + "code": code, + "description": description, + "province": province.toJson(), + "psgc_code": psgcCode, + "zipcode": zipcode, + }; +} + +class Province { + Province({ + required this.code, + required this.description, + required this.region, + required this.psgcCode, + required this.shortname, + }); + + final String code; + final String description; + final Region region; + final String psgcCode; + final String shortname; + + factory Province.fromJson(Map json) => Province( + code: json["code"], + description: json["description"], + region: Region.fromJson(json["region"]), + psgcCode: json["psgc_code"], + shortname: json["shortname"], + ); + + Map toJson() => { + "code": code, + "description": description, + "region": region.toJson(), + "psgc_code": psgcCode, + "shortname": shortname, + }; +} + +class Region { + Region({ + required this.code, + required this.description, + required this.psgcCode, + }); + + final int code; + final String description; + final String psgcCode; + + factory Region.fromJson(Map json) => Region( + code: json["code"], + description: json["description"], + psgcCode: json["psgc_code"], + ); + + Map toJson() => { + "code": code, + "description": description, + "psgc_code": psgcCode, + }; +} diff --git a/lib/model/location/country.dart b/lib/model/location/country.dart new file mode 100644 index 0000000..c3a98ca --- /dev/null +++ b/lib/model/location/country.dart @@ -0,0 +1,34 @@ +// To parse this JSON data, do +// +// final country = countryFromJson(jsonString); + +import 'package:meta/meta.dart'; +import 'dart:convert'; + +Country countryFromJson(String str) => Country.fromJson(json.decode(str)); + +String countryToJson(Country data) => json.encode(data.toJson()); + +class Country { + Country({ + required this.id, + required this.name, + required this.code, + }); + + final int id; + final String name; + final String code; + + factory Country.fromJson(Map json) => Country( + id: json["id"], + name: json["name"], + code: json["code"], + ); + + Map toJson() => { + "id": id, + "name": name, + "code": code, + }; +} diff --git a/lib/model/location/provinces.dart b/lib/model/location/provinces.dart new file mode 100644 index 0000000..8d7ee19 --- /dev/null +++ b/lib/model/location/provinces.dart @@ -0,0 +1,66 @@ +// To parse this JSON data, do +// +// final province = provinceFromJson(jsonString); + +import 'package:meta/meta.dart'; +import 'dart:convert'; + +Province provinceFromJson(String str) => Province.fromJson(json.decode(str)); + +String provinceToJson(Province data) => json.encode(data.toJson()); + +class Province { + Province({ + required this.code, + required this.description, + required this.region, + required this.psgcCode, + required this.shortname, + }); + + final String code; + final String description; + final Region region; + final String psgcCode; + final String shortname; + + factory Province.fromJson(Map json) => Province( + code: json["code"], + description: json["description"], + region: Region.fromJson(json["region"]), + psgcCode: json["psgc_code"], + shortname: json["shortname"], + ); + + Map toJson() => { + "code": code, + "description": description, + "region": region.toJson(), + "psgc_code": psgcCode, + "shortname": shortname, + }; +} + +class Region { + Region({ + required this.code, + required this.description, + required this.psgcCode, + }); + + final int code; + final String description; + final String psgcCode; + + factory Region.fromJson(Map json) => Region( + code: json["code"], + description: json["description"], + psgcCode: json["psgc_code"], + ); + + Map toJson() => { + "code": code, + "description": description, + "psgc_code": psgcCode, + }; +} diff --git a/lib/model/location/purok.dart b/lib/model/location/purok.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/model/location/region.dart b/lib/model/location/region.dart new file mode 100644 index 0000000..718df02 --- /dev/null +++ b/lib/model/location/region.dart @@ -0,0 +1,34 @@ +// To parse this JSON data, do +// +// final region = regionFromJson(jsonString); + +import 'package:meta/meta.dart'; +import 'dart:convert'; + +Region regionFromJson(String str) => Region.fromJson(json.decode(str)); + +String regionToJson(Region data) => json.encode(data.toJson()); + +class Region { + Region({ + required this.code, + required this.description, + required this.psgcCode, + }); + + final int code; + final String description; + final String psgcCode; + + factory Region.fromJson(Map json) => Region( + code: json["code"], + description: json["description"], + psgcCode: json["psgc_code"], + ); + + Map toJson() => { + "code": code, + "description": description, + "psgc_code": psgcCode, + }; +} diff --git a/lib/model/utils/eligibilities_choices.dart b/lib/model/utils/eligibilities_choices.dart new file mode 100644 index 0000000..24b963d --- /dev/null +++ b/lib/model/utils/eligibilities_choices.dart @@ -0,0 +1,34 @@ +// To parse this JSON data, do +// +// final eligibilities = eligibilitiesFromJson(jsonString); + +import 'package:meta/meta.dart'; +import 'dart:convert'; + +Eligibilities eligibilitiesFromJson(String str) => Eligibilities.fromJson(json.decode(str)); + +String eligibilitiesToJson(Eligibilities data) => json.encode(data.toJson()); + +class Eligibilities { + Eligibilities({ + required this.id, + required this.title, + required this.type, + }); + + final int id; + final String title; + final String type; + + factory Eligibilities.fromJson(Map json) => Eligibilities( + id: json["id"], + title: json["title"], + type: json["type"], + ); + + Map toJson() => { + "id": id, + "title": title, + "type": type, + }; +} diff --git a/lib/screens/profile/components/eligibility/edit_modal.dart b/lib/screens/profile/components/eligibility/edit_modal.dart new file mode 100644 index 0000000..0a60f62 --- /dev/null +++ b/lib/screens/profile/components/eligibility/edit_modal.dart @@ -0,0 +1,225 @@ +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_form_builder/flutter_form_builder.dart'; +import 'package:intl/intl.dart'; +import 'package:unit2/model/profile/eligibility.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'; + +class EditEligibilityScreen extends StatefulWidget { + final EligibityCert eligibityCert; + const EditEligibilityScreen({super.key,required this.eligibityCert}); + + @override + State createState() => _EditEligibilityScreenState(); +} + +class _EditEligibilityScreenState extends State { + final formKey = GlobalKey(); + bool overseas =false; + DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); + @override + Widget build(BuildContext context) { + return Center( + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 18), + child: FormBuilder( + key: formKey, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + FormBuilderTextField( + name: "eligibility", + initialValue: widget.eligibityCert.eligibility!.title!, + decoration: + normalTextFieldStyle("Eligibility", "Eligibility"), + ), + const SizedBox( + height: 20, + ), + SizedBox( + width: screenWidth, + child: Row( + children: [ + Flexible( + flex: 1, + child: FormBuilderTextField( + name: 'license number', + initialValue: + widget.eligibityCert.licenseNumber, + decoration: normalTextFieldStyle( + "license number", "license number"), + ), + ), + const SizedBox( + width: 12, + ), + Flexible( + flex: 1, + child: FormBuilderTextField( + name: 'rating', + initialValue: + widget.eligibityCert.rating.toString(), + decoration: + normalTextFieldStyle('rating', 'rating'), + ), + ), + ], + ), + ), + const SizedBox( + height: 20, + ), + SizedBox( + width: screenWidth, + child: Row( + children: [ + Flexible( + flex: 1, + child: DateTimePicker( + firstDate: DateTime(2000), + lastDate: DateTime(2100), + decoration: normalTextFieldStyle( + "Exam date", "Exam date"), + initialValue: + widget.eligibityCert.examDate == null + ? '' + : dteFormat2.format( + widget.eligibityCert.examDate!), + )), + const SizedBox( + width: 12, + ), + Flexible( + flex: 1, + child: DateTimePicker( + firstDate: DateTime(2000), + lastDate: DateTime(2100), + decoration: normalTextFieldStyle( + "Validity date", "Validity date"), + initialValue: + widget.eligibityCert.validityDate == null + ? '' + : dteFormat2.format( + widget.eligibityCert.validityDate!), + ), + ), + ], + ), + ), + const SizedBox( + height: 20, + ), + Text( + "Placement of Examination/Confinement", + style: Theme.of(context) + .textTheme + .displaySmall! + .copyWith(fontSize: blockSizeVertical * 2), + ), + const SizedBox( + height: 12, + ), + FormBuilderSwitch( + initialValue: overseas, + activeColor: second, + onChanged: (value) { + setState(() { + overseas = value!; + }); + }, + decoration: normalTextFieldStyle("", ''), + name: 'overseas', + title: const Text("Overseas Address?"), + ), + const SizedBox( + height: 20, + ), + SizedBox( + child: overseas == true + ? FormBuilderTextField( + name: 'country', + decoration: normalTextFieldStyle( + "Country", "Country"), + ) + : Column( + children: [ + FormBuilderDropdown( + decoration: normalTextFieldStyle( + "Region", "Region"), + name: 'region', + items: [], + initialValue: widget + .eligibityCert + .examAddress + ?.cityMunicipality + ?.province + ?.region + ?.description == + null + ? 'region' + : 'region', + ), + const SizedBox( + height: 20, + ), + FormBuilderDropdown( + decoration: normalTextFieldStyle( + 'Province', "Province"), + name: 'province', + items: [], + initialValue: widget + .eligibityCert + .examAddress + ?.cityMunicipality + ?.province + ?.description == + null + ? 'region' + : 'pprovince'), + const SizedBox( + height: 20, + ), + FormBuilderDropdown( + decoration: normalTextFieldStyle( + "Municipality", "Municipality"), + name: 'municipality', + items: [], + initialValue: widget + .eligibityCert + .examAddress + ?.cityMunicipality + ?.description == + null + ? 'region' + : 'municipality', + ), + ], + )), + const SizedBox( + height: 20, + ), + SizedBox( + width: screenWidth, + height: 60, + child: ElevatedButton( + style: mainBtnStyle( + primary, Colors.transparent, second), + onPressed: () {}, + child: const Text(submit)), + ), + const SizedBox(height: 20,), + + ]), + ), + ), + );; + } +} \ No newline at end of file diff --git a/lib/screens/profile/components/eligibility/eligibility_screen.dart b/lib/screens/profile/components/eligibility/eligibility_screen.dart new file mode 100644 index 0000000..19f1d39 --- /dev/null +++ b/lib/screens/profile/components/eligibility/eligibility_screen.dart @@ -0,0 +1,182 @@ +import 'package:app_popup_menu/app_popup_menu.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:fluttericon/font_awesome_icons.dart'; +import 'package:unit2/bloc/profile/profile_bloc.dart'; +import 'package:unit2/bloc/user/user_bloc.dart'; +import 'package:unit2/model/profile/eligibility.dart'; +import 'package:unit2/screens/profile/components/eligibility/edit_modal.dart'; +import 'package:unit2/theme-data.dart/box_shadow.dart'; +import 'package:unit2/theme-data.dart/colors.dart'; +import 'package:unit2/utils/alerts.dart'; +import 'package:unit2/utils/global.dart'; +import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/add_leading.dart'; +import 'package:unit2/widgets/empty_data.dart'; + +class EligibiltyScreen extends StatefulWidget { + const EligibiltyScreen({super.key,}); + + @override + State createState() => _EligibiltyScreenState(); +} + +class _EligibiltyScreenState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text(elibilityScreenTitle), + centerTitle: true, + backgroundColor: primary, + actions: context.read()[AddLeading( + onPressed: () => () {}, + )], + ), + body: BlocBuilder( + builder: (context, state) { + return BlocBuilder( + builder: (context, state) { + if(state is EligibilityLoaded){ +return ListView.builder( + padding: + const EdgeInsets.symmetric(vertical: 8, horizontal: 10), + itemCount: state.eligibilities.length, + itemBuilder: (BuildContext context, int index) { + String title = + state.eligibilities[index].eligibility!.title!; + return Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: screenWidth, + padding: const EdgeInsets.symmetric( + horizontal: 12, vertical: 8), + decoration: box1(), + child: Row( + children: [ + Expanded( + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + title, + style: Theme.of(context) + .textTheme + .titleMedium! + .copyWith( + fontWeight: FontWeight.w500), + ), + const Divider(), + const SizedBox( + height: 5, + ), + Text( + "$licenseNumber: ${state.eligibilities[index].licenseNumber == null ? 'N/A' : state.eligibilities[index].licenseNumber.toString()}", + style: Theme.of(context) + .textTheme + .titleSmall), + const SizedBox( + height: 3, + ), + Text( + " : ${state.eligibilities[index].rating ?? 'N/A'}.", + style: Theme.of(context) + .textTheme + .titleSmall) + ]), + ), + AppPopupMenu( + offset: const Offset(-10, -10), + elevation: 3, + onSelected: (value) { + // if (value == 1) { + // confirmAlert(context, () => null, + // "Delete?", "Confirm Delete?"); + // } + // if (value == 2) { + // context.read().add( + // EditEligibility( + // eligibityCert: widget + // .eligibilities[index])); + // } + }, + menuItems: [ + PopupMenuItem( + value: 1, + child: Row( + children: const [ + Icon( + Icons.delete, + ), + SizedBox( + width: 10, + ), + Text( + 'Delete', + ), + ], + ), + ), + PopupMenuItem( + value: 2, + child: Row( + children: const [ + Icon( + Icons.edit, + ), + SizedBox( + width: 10, + ), + Text( + 'Edit', + ), + ], + ), + ), + PopupMenuItem( + value: 2, + child: Row( + children: const [ + Icon( + FontAwesome.attach, + ), + SizedBox( + width: 10, + ), + Text( + 'Attachment', + ), + ], + ), + ), + ], + icon: const Icon( + Icons.more_vert, + color: Colors.grey, + ), + tooltip: "Options", + ) + ], + ), + ), + const SizedBox( + height: 5, + ) + ], + ); + }); + } + return Container(); + }, + ); + }, + )); + } +} diff --git a/lib/screens/profile/profile.dart b/lib/screens/profile/profile.dart index ce97d91..db097ad 100644 --- a/lib/screens/profile/profile.dart +++ b/lib/screens/profile/profile.dart @@ -8,6 +8,7 @@ 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/profile_bloc.dart'; +import 'package:unit2/model/login_data/employee_info/employee_info.dart'; import 'package:unit2/screens/profile/components/basic_information/address_screen.dart'; import 'package:unit2/screens/profile/components/basic_information/citizenship_screen.dart'; import 'package:unit2/screens/profile/components/basic_information/contact_information_screen.dart'; @@ -46,8 +47,7 @@ class _ProfileInfoState extends State { title: const Text('Profile'), ), body: ProgressHUD( - child: - BlocBuilder(builder: (context, state) { + child: BlocBuilder(builder: (context, state) { if (state is UserLoggedIn) { return BlocConsumer( listener: (context, state) { @@ -64,20 +64,20 @@ class _ProfileInfoState extends State { }, builder: (context, state) { if (state is ProfileLoaded) { - return Container( padding: const EdgeInsets.symmetric( vertical: 12, horizontal: 12), child: ListView( children: [ - Text( - "View and Update your Profile Information",textAlign: TextAlign.center - ,style: Theme.of(context).textTheme.bodyLarge,), + Text( + "View and Update your Profile Information", + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.bodyLarge, + ), ExpandableGroup( collapsedIcon: const Icon(Icons.keyboard_arrow_down), - expandedIcon: - const Icon(Icons.keyboard_arrow_up), + expandedIcon: const Icon(Icons.keyboard_arrow_up), header: const ListTile( leading: Icon( Elusive.address_book, @@ -85,115 +85,157 @@ class _ProfileInfoState extends State { ), title: Text( "Basic Information", - style: TextStyle( - fontWeight: FontWeight.bold), + style: TextStyle(fontWeight: FontWeight.bold), ), ), items: [ - subMenu(Icons.person, "Primary",(){ - Navigator.push(context,MaterialPageRoute(builder: (BuildContext context){ - return PrimaryInfo(primaryInformation: state.profileInformation.basicInfo.primaryInformation!); - }) ); + subMenu(Icons.person, "Primary", () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return PrimaryInfo( + primaryInformation: state + .profileInformation + .basicInfo + .primaryInformation!); + })); }), - subMenu(Icons.home, "Home Addresses",(){ - Navigator.push(context,MaterialPageRoute(builder: (BuildContext context){ - return AddressScreen(addresses: state.profileInformation.basicInfo.addresses); - }) ); - + subMenu(Icons.home, "Home Addresses", () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return AddressScreen( + addresses: state.profileInformation + .basicInfo.addresses); + })); }), - subMenu( - Icons.contact_mail, "Identifications",(){ - Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){ - return IdentificationsScreen(identities: state.profileInformation.basicInfo.identifications); - })); - }), - subMenu( - Icons.contact_phone, "Contact Info",(){ - Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){ - return ContactInformationScreen(contacts: state.profileInformation.basicInfo.contactInformation,); - })); - }), - subMenu(Icons.flag, "Citizenships",(){ - Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){ - return CitizenShipScreen(citizenships: state.profileInformation.basicInfo.citizenships,); + subMenu(Icons.contact_mail, "Identifications", + () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return IdentificationsScreen( + identities: state.profileInformation + .basicInfo.identifications); + })); + }), + subMenu(Icons.contact_phone, "Contact Info", + () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return ContactInformationScreen( + contacts: state.profileInformation + .basicInfo.contactInformation, + ); + })); + }), + subMenu(Icons.flag, "Citizenships", () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return CitizenShipScreen( + citizenships: state.profileInformation + .basicInfo.citizenships, + ); })); }), ]), const Divider(), - MainMenu( + MainMenu( icon: Elusive.group, title: "Family", - onTap: (){ - Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){ - return FamilyBackgroundScreen(familyBackground: state.profileInformation.families); + onTap: () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return FamilyBackgroundScreen( + familyBackground: + state.profileInformation.families); })); }, ), const Divider(), - MainMenu( + MainMenu( icon: FontAwesome5.graduation_cap, title: "Education", - onTap: (){ - Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){ - return EducationScreen(educationBackgrounds: state.profileInformation.educationalBackgrounds); + onTap: () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return EducationScreen( + educationBackgrounds: state + .profileInformation + .educationalBackgrounds); })); }, ), const Divider(), - MainMenu( + MainMenu( icon: Icons.stars, title: "Eligibility", - onTap: (){ - Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){ - return EligibiltyScreen(eligibilities: state.profileInformation.eligibilities); + onTap: () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return BlocProvider.value(value: ProfileBloc()..add(LoadEligibility(eligibilities: state.profileInformation.eligibilities)), + + child: EligibiltyScreen( + eligibilities: state + .profileInformation.eligibilities), + ); })); }, ), const Divider(), - MainMenu( + MainMenu( icon: FontAwesome5.shopping_bag, title: "Work History", - onTap: (){ - Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){ - return WorkHistoryScreen(workExperiences: state.profileInformation.workExperiences); + onTap: () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return WorkHistoryScreen( + workExperiences: state + .profileInformation.workExperiences); })); }, ), const Divider(), - MainMenu( + MainMenu( icon: FontAwesome5.walking, title: "Voluntary Work & Civic Services", - onTap: (){ - Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){ - return VolunataryWorkScreen(voluntaryWorks: state.profileInformation.voluntaryWorks); + onTap: () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return VolunataryWorkScreen( + voluntaryWorks: state + .profileInformation.voluntaryWorks); })); }, ), const Divider(), - MainMenu( + MainMenu( icon: Elusive.lightbulb, title: "Learning & Development", - onTap: (){ - Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){ - return LearningAndDevelopmentScreen(learningDevelopments: state.profileInformation.learningsAndDevelopment); - })); + onTap: () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return LearningAndDevelopmentScreen( + learningDevelopments: state + .profileInformation + .learningsAndDevelopment); + })); }, ), const Divider(), - MainMenu( + MainMenu( icon: Brandico.codepen, title: "Personal References", - onTap: (){ - Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){ - return ReferencesScreen(references: state.profileInformation.references); + onTap: () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return ReferencesScreen( + references: + state.profileInformation.references); })); }, ), ExpandableGroup( collapsedIcon: const Icon(Icons.keyboard_arrow_down), - expandedIcon: - const Icon(Icons.keyboard_arrow_up), + expandedIcon: const Icon(Icons.keyboard_arrow_up), header: const ListTile( leading: Icon( Icons.info, @@ -201,36 +243,45 @@ class _ProfileInfoState extends State { ), title: Text( "Other Information", - style: TextStyle( - fontWeight: FontWeight.bold), + style: TextStyle(fontWeight: FontWeight.bold), ), ), items: [ - subMenu(Icons.fitness_center, - "Skills & Hobbies",(){ - Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){ - return SkillHobbiesScreen(skillsHobbies: state.profileInformation.otherInformation.skillsAndHobbies); - })); - }), + subMenu( + Icons.fitness_center, "Skills & Hobbies", + () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return SkillHobbiesScreen( + skillsHobbies: state.profileInformation + .otherInformation.skillsAndHobbies); + })); + }), subMenu(FontAwesome5.certificate, - "Organization Memberships",(){ - Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){ - return OrgMembershipsScreen(orgMemberships: state.profileInformation.otherInformation.orgMemberships); - })); - }), + "Organization Memberships", () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return OrgMembershipsScreen( + orgMemberships: state.profileInformation + .otherInformation.orgMemberships); + })); + }), subMenu(Entypo.doc_text, - "Non-Academic Recognitions",(){ - - Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){ - return NonAcademicRecognitionScreen(nonAcademicRecognitions: state.profileInformation.otherInformation.nonAcademicRecognition); - })); - }), + "Non-Academic Recognitions", () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return NonAcademicRecognitionScreen( + nonAcademicRecognitions: state + .profileInformation + .otherInformation + .nonAcademicRecognition); + })); + }), ]), ExpandableGroup( collapsedIcon: const Icon(Icons.keyboard_arrow_down), - expandedIcon: - const Icon(Icons.keyboard_arrow_up), + expandedIcon: const Icon(Icons.keyboard_arrow_up), header: const ListTile( leading: Icon( FontAwesome5.laptop_house, @@ -238,13 +289,12 @@ class _ProfileInfoState extends State { ), title: Text( "Assets", - style: TextStyle( - fontWeight: FontWeight.bold), + style: TextStyle(fontWeight: FontWeight.bold), ), ), items: [ subMenu(ModernPictograms.home, - "Real Property Tax",(){}), + "Real Property Tax", () {}), ]), ], ), diff --git a/lib/widgets/custom_switch.dart b/lib/widgets/custom_switch.dart new file mode 100644 index 0000000..907993f --- /dev/null +++ b/lib/widgets/custom_switch.dart @@ -0,0 +1,44 @@ +import 'package:flutter/material.dart'; +import 'package:toggle_switch/toggle_switch.dart'; + +class CostumToggleSwitch extends StatelessWidget { + final List activeBGColors; + final List icons; +final int initialLabelIndex; + final void Function(int?)? onToggle; + final List labels; + const CostumToggleSwitch( + {Key? key, + required this.activeBGColors, + required this.icons, + required this.onToggle, + required this.labels, + required this.initialLabelIndex + + }) + : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.all(15), + height: 80, + child: ToggleSwitch( + minWidth: 150.0, + cornerRadius: 25.0, + activeBgColors: [ + [Colors.green[800]!], + [Colors.red[800]!] + ], + activeFgColor: Colors.white, + inactiveBgColor: Colors.grey, + inactiveFgColor: Colors.white, + initialLabelIndex: initialLabelIndex, + totalSwitches: 2, + labels: labels, + icons: icons, + radiusStyle: false, + onToggle: onToggle), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 388b681..3f8450d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -9,6 +9,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" + app_popup_menu: + dependency: "direct main" + description: + name: app_popup_menu + sha256: e05b262b65289431603a84e04e53cb2f3aca6013d3ea61e3f24ddd48d49ef848 + url: "https://pub.dev" + source: hosted + version: "1.0.0" archive: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 698736c..85eecab 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -68,6 +68,7 @@ dependencies: permission_handler: ^10.2.0 expandable_group: ^0.0.8 badges: ^3.0.2 + app_popup_menu: ^1.0.0 dev_dependencies: flutter_test: