From d0ad8d6745bd9dafd231d58373d3d8fafb3f2b1e Mon Sep 17 00:00:00 2001 From: Rafael <1024481@stud.hs-mannheim.de> Date: Fri, 21 Jun 2024 02:42:45 +0200 Subject: [PATCH] Display of Sectors of Interest --- lib/constants.dart | 2 +- lib/enumerations.dart | 52 +++++++++++++++++++--- lib/models/user_profile.dart | 2 + lib/pages/user_matching_page.dart | 31 ++++++++++++-- lib/pages/user_profile_page.dart | 71 ++++++++++++++++++++++++++++++- lib/services/user_service.dart | 14 ++++++ lib/utils/helper.dart | 13 ++++++ lib/utils/list_utils.dart | 17 +++++++- 8 files changed, 190 insertions(+), 12 deletions(-) diff --git a/lib/constants.dart b/lib/constants.dart index 75f200c..0006156 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -4,7 +4,7 @@ class Constants { /// Title of the app static const String appTitle = 'Cofounderella'; static const String appVersion = '1.0.1'; - static const String appCompilationDate = '2024-06-19'; + static const String appCompilationDate = '2024-06-20'; static const String dbCollectionFeedbacks = 'feedbacks'; static const String dbCollectionUsers = 'Users'; diff --git a/lib/enumerations.dart b/lib/enumerations.dart index 4d0164b..0ae623a 100644 --- a/lib/enumerations.dart +++ b/lib/enumerations.dart @@ -256,33 +256,47 @@ enum RiskTolerance { enum SectorOption { agriculture, ai, - vr, + ar, automotive, + beauty, bigdata, blockchain, cloud, + construction, + consulting, crypto, cybersecurity, + ecommerce, education, energy, fashion, finance, food, gaming, + hardware, healthcare, home, industry, insurance, iot, + it, legal, ml, + marketing, media, + mobility, pharma, retail, robotics, saas, sports, - travel; + software, + telecommunication, + transport, + travel, + vr, + web, + other; String get displayName { switch (this) { @@ -290,20 +304,28 @@ enum SectorOption { return 'Agriculture'; case SectorOption.ai: return 'Artificial Intelligence'; - case SectorOption.vr: - return 'Augmented/Virtual Reality'; + case SectorOption.ar: + return 'Augmented Reality'; case SectorOption.automotive: return 'Automotive'; + case SectorOption.beauty: + return 'Beauty and Personal Care'; case SectorOption.bigdata: return 'Big Data'; case SectorOption.blockchain: return 'Blockchain'; case SectorOption.cloud: return 'Cloud Computing'; + case SectorOption.construction: + return 'Construction and Real Estate'; + case SectorOption.consulting: + return 'Consulting and Agency'; case SectorOption.crypto: - return 'Cryptocurrencies/Digital Assets'; + return 'Cryptocurrencies and Digital Assets'; case SectorOption.cybersecurity: return 'Cybersecurity'; + case SectorOption.ecommerce: + return 'E-Commerce'; case SectorOption.education: return 'Education'; case SectorOption.energy: @@ -316,6 +338,8 @@ enum SectorOption { return 'Food and Beverage'; case SectorOption.gaming: return 'Gaming'; + case SectorOption.hardware: + return 'Hardware'; case SectorOption.healthcare: return 'Healthcare'; case SectorOption.home: @@ -326,12 +350,18 @@ enum SectorOption { return 'Insurance'; case SectorOption.iot: return 'Internet of Things'; + case SectorOption.it: + return 'IT'; case SectorOption.legal: return 'Legal and Compliance'; case SectorOption.ml: return 'Machine Learning'; + case SectorOption.marketing: + return 'Marketing and Advertising'; case SectorOption.media: return 'Media and Entertainment'; + case SectorOption.mobility: + return 'Mobility'; case SectorOption.pharma: return 'Pharma'; case SectorOption.retail: @@ -342,8 +372,20 @@ enum SectorOption { return 'SaaS'; case SectorOption.sports: return 'Sports and Fitness'; + case SectorOption.software: + return 'Software'; + case SectorOption.telecommunication: + return 'Telecommunications'; + case SectorOption.transport: + return 'Transport and Logistics'; case SectorOption.travel: return 'Travel'; + case SectorOption.vr: + return 'Virtual Reality'; + case SectorOption.web: + return 'Web'; + case SectorOption.other: + return 'Other'; } } } diff --git a/lib/models/user_profile.dart b/lib/models/user_profile.dart index c55a196..0236972 100644 --- a/lib/models/user_profile.dart +++ b/lib/models/user_profile.dart @@ -19,6 +19,7 @@ class UserProfile { CommunicationPreference communication; List skills; List skillsSought; + List sectors; List visions; List workValues; List languages; @@ -41,6 +42,7 @@ class UserProfile { required this.communication, required this.skills, required this.skillsSought, + required this.sectors, required this.visions, required this.workValues, required this.languages, diff --git a/lib/pages/user_matching_page.dart b/lib/pages/user_matching_page.dart index 6eef91a..0de0d6d 100644 --- a/lib/pages/user_matching_page.dart +++ b/lib/pages/user_matching_page.dart @@ -14,6 +14,7 @@ import '../models/user_profile.dart'; import '../services/auth/auth_service.dart'; import '../services/user_service.dart'; import '../utils/helper.dart'; +import '../utils/list_utils.dart'; import '../utils/math.dart'; import 'chat_page.dart'; @@ -326,7 +327,7 @@ class UserMatchingPageState extends State { return Container( alignment: Alignment.center, decoration: BoxDecoration( - borderRadius: BorderRadius.circular(25.0), + borderRadius: BorderRadius.circular(16.0), color: Colors.blue, ), child: Stack( @@ -356,6 +357,7 @@ class UserMatchingPageState extends State { String? profileImageUrl = userProfile.profilePictureUrl; String pronoun = getPronoun(userProfile.gender); + String possAdjective = getPossessiveAdjective(userProfile.gender); String location = userProfile.locations[Constants.dbDocMainLocation]?.toString() ?? 'N/A'; @@ -445,10 +447,31 @@ class UserMatchingPageState extends State { '${userProfile.availability.commitmentText}.', ), const SizedBox(height: 8), - const Row( + Row( children: [ - Text('Spoken languages '), - Expanded(child: Divider()), + Text( + '$possAdjective Sectors of Interest ', + style: TextStyle( + color: Theme.of(context).colorScheme.primary, + ), + ), + const Expanded(child: Divider()), + ], + ), + const SizedBox(height: 4), + Text(sortSectorsList(userProfile.sectors) + .map((x) => x.displayName) + .join(' \u25CF ')), + const SizedBox(height: 8), + Row( + children: [ + Text( + 'Spoken languages ', + style: TextStyle( + color: Theme.of(context).colorScheme.primary, + ), + ), + const Expanded(child: Divider()), ], ), const SizedBox(height: 4), diff --git a/lib/pages/user_profile_page.dart b/lib/pages/user_profile_page.dart index 8d64b0a..ad3c78a 100644 --- a/lib/pages/user_profile_page.dart +++ b/lib/pages/user_profile_page.dart @@ -7,10 +7,12 @@ import '../constants.dart'; import '../enumerations.dart'; import '../forms/corporate_culture_form.dart'; import '../forms/risks_form.dart'; +import '../forms/sectors_form.dart'; import '../forms/skills_form.dart'; import '../models/user_profile.dart'; import '../services/user_service.dart'; import '../utils/helper.dart'; +import '../utils/list_utils.dart'; import '../utils/math.dart'; import 'edit_profile_page.dart'; import 'user_data_page.dart'; @@ -132,6 +134,27 @@ class _UserProfilePageState extends State { _editSkills(skillsSought: true); } + void editUserSectorsInfo() async { + final updatedUserData = await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => SectorsForm( + isRegProcess: false, + isEditMode: true, + ), + ), + ); + + if (updatedUserData != null) { + setState(() { + // above Type of updatedUserData is dynamic, so convert + List dynamicList = + updatedUserData[Constants.dbFieldUsersSectors]; + myData.sectors = dynamicList.map((e) => e as SectorOption).toList(); + }); + } + } + void editUserVisionInfo() async { final updatedUserData = await Navigator.push( context, @@ -227,6 +250,11 @@ class _UserProfilePageState extends State { if (isOwner) Divider(color: Theme.of(context).colorScheme.primary), if (isOwner) const SizedBox(height: 16), + _buildSectors(context), + const SizedBox(height: 16), + if (isOwner) + Divider(color: Theme.of(context).colorScheme.primary), + if (isOwner) const SizedBox(height: 16), _buildVision(context), const SizedBox(height: 16), if (isOwner) @@ -434,6 +462,47 @@ class _UserProfilePageState extends State { ); } + Widget _buildSectors(BuildContext context) { + return Column( + children: [ + Align( + alignment: Alignment.centerLeft, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Sectors of Interest', + style: TextStyle( + color: Theme.of(context).colorScheme.primary, + ), + ), + Text( + sortSectorsList(myData.sectors) + .map((x) => x.displayName) + .join('\n'), + style: const TextStyle(fontSize: 16)), + ], + ), + ), + if (isOwner) _editButton(context, editUserSectorsInfo), + ], + ), + const SizedBox(height: 16), + ], + ), + ), + ], + ); + } + Widget _buildSkills(BuildContext context) { return Column( children: [ @@ -511,7 +580,7 @@ class _UserProfilePageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Locations', + myData.locations.length > 1 ? 'Locations' : 'Location', style: TextStyle( color: Theme.of(context).colorScheme.primary, ), diff --git a/lib/services/user_service.dart b/lib/services/user_service.dart index 2ae9b8c..b35928d 100644 --- a/lib/services/user_service.dart +++ b/lib/services/user_service.dart @@ -70,6 +70,17 @@ class UserService { return []; } + static List convertSectorStringToEnum(List? sectors) { + if (sectors != null && sectors.isNotEmpty) { + List userSectors = sectors + .map((sector) => + SectorOption.values.firstWhere((x) => x.toString() == sector)) + .toList(); + return userSectors; + } + return []; + } + static List convertVisionStringToEnum(List? visions) { if (visions != null && visions.isNotEmpty) { List userVisions = visions @@ -126,6 +137,8 @@ class UserService { data[Constants.dbFieldUsersSkills]); List skillsSought = UserService.convertSkillStringToEnum( data[Constants.dbFieldUsersSkillsSought]); + List sectors = UserService.convertSectorStringToEnum( + data[Constants.dbFieldUsersSectors]); List visions = UserService.convertVisionStringToEnum( data[Constants.dbFieldUsersVisions]); List works = UserService.convertWorkValuesStringToEnum( @@ -178,6 +191,7 @@ class UserService { lastName: data[Constants.dbFieldUsersLastName] ?? '', skills: skillsOffered, skillsSought: skillsSought, + sectors: sectors, visions: visions, risk: risk, availability: availability, diff --git a/lib/utils/helper.dart b/lib/utils/helper.dart index 362261e..cc88bb8 100644 --- a/lib/utils/helper.dart +++ b/lib/utils/helper.dart @@ -75,6 +75,19 @@ String getPronoun(Gender? userGender) { } } +/// Get possessive adjective for given [userGender]. +/// Returns [His] if male, [Her] if female, else [His/Her]. +String getPossessiveAdjective(Gender? userGender) { + switch (userGender) { + case Gender.male: + return 'His'; + case Gender.female: + return 'Her'; + default: + return 'His/Her'; + } +} + /// Get the [displayName] of our own Enumerations. String getDisplayText(dynamic option) { // Check if the option is an enum and has a displayName property diff --git a/lib/utils/list_utils.dart b/lib/utils/list_utils.dart index 0dcdceb..f0781db 100644 --- a/lib/utils/list_utils.dart +++ b/lib/utils/list_utils.dart @@ -1,4 +1,5 @@ import 'package:collection/collection.dart'; +import '../enumerations.dart'; import '../models/language.dart'; /// Compare two lists by their content ignoring their elements order. @@ -6,7 +7,8 @@ bool equalContent(List list1, List list2) { return const DeepCollectionEquality.unordered().equals(list1, list2); } -/// Sort the given list of languages so that German appears first, English second, and all other languages follow in alphabetical order. +/// Sort the given list of languages so that German appears first, +/// English second, and all other languages follow in alphabetical order. List sortLanguageList(List langList) { List sortedLanguages = List.from(langList); sortedLanguages.sort((a, b) { @@ -21,3 +23,16 @@ List sortLanguageList(List langList) { }); return sortedLanguages; } + +/// Sort the given list of sectors of interest, placing [SectorOption.other] at the end. +List sortSectorsList(List sectorList) { + List sortedSectors = List.from(sectorList); + sortedSectors.sort((a, b) { + // other last + if (a.name == 'other') return 1; + if (b.name == 'other') return -1; + // All others by name ascending + return a.name.compareTo(b.name); + }); + return sortedSectors; +}