Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat - #238 sort links on about us team #249

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions lib/config/contact_icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class ContactIconsConfig {
"tiktok": Assets.svg.contactIcons.tiktok,
"discord": Assets.svg.contactIcons.discord,
};
static final iconsOrder = {
static final iconsOrderAtSciClubs = {
"maps": 1,
"tel": 2,
"mailto:": 3,
Expand All @@ -27,6 +27,20 @@ abstract class ContactIconsConfig {
"youtu": 11,
"tiktok": 12,
};
static const defaultIconOrder = 2;
static final iconsOrderAtAboutUs = {
"github": 1,
"linkedin": 2,
"facebook": 4,
"mailto:": 5,
"instagram": 6,
"https://x.com": 7,
"discord": 8,
"youtu": 9,
"tiktok": 10,
"maps": 11,
"tel": 12,
};
static const defaultIconOrderAtSciClubs = 2;
static const defaultIconOrderAtAboutUs = 3;
static final defaultIcon = Assets.svg.contactIcons.web;
}
6 changes: 3 additions & 3 deletions lib/features/about_us_view/about_us_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ class _AboutUsView extends ConsumerWidget {
),
],
),
_ => const _AboustUsLoading(),
_ => const _AboutUsLoading(),
};
}
}

class _AboustUsLoading extends StatelessWidget {
const _AboustUsLoading();
class _AboutUsLoading extends StatelessWidget {
const _AboutUsLoading();

@override
Widget build(BuildContext context) {
Expand Down
3 changes: 2 additions & 1 deletion lib/features/about_us_view/models/about_us_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class AboutUsDetails {
.map(
(e) => ContactIconsModel(url: e.url),
)
.toIList();
.toIList()
.sort((a, b) => a.order.compareTo(b.order));
}
}
5 changes: 4 additions & 1 deletion lib/features/about_us_view/models/member_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ class MemberData {
}) : links = _determineLinksIcons(socialLinks);

static IList<ContactIconsModel> _determineLinksIcons(IList<String> urls) {
return urls.map((url) => ContactIconsModel(url: url)).toIList();
return urls
.map((url) => ContactIconsModel(url: url, isTeamMember: true))
.toIList()
.sort((a, b) => a.order.compareTo(b.order));
}

@override
Expand Down
25 changes: 20 additions & 5 deletions lib/utils/determine_contact_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ class ContactIconsModel {
final String? text;
final String? url;
final int order;
final bool isTeamMember;

ContactIconsModel({
String? text,
this.url,
this.isTeamMember = false,
}) : icon = url.determineIcon(),
order = url.determineIconOrder(),
order = !isTeamMember
? url.determineIconOrderForSciClubs()
: url.determineIconOrderForAboutUs(),
text = text ?? url;
}

Expand All @@ -30,14 +34,25 @@ extension IconDeterminerX on String? {
: ContactIconsConfig.defaultIcon;
}

int determineIconOrder() {
int determineIconOrderForSciClubs() {
return this != null
? ContactIconsConfig.iconsOrder.entries
? ContactIconsConfig.iconsOrderAtSciClubs.entries
.firstWhereOrNull(
(e) => this!.contains(e.key),
)
?.value ??
ContactIconsConfig.defaultIconOrder
: ContactIconsConfig.defaultIconOrder;
ContactIconsConfig.defaultIconOrderAtSciClubs
: ContactIconsConfig.defaultIconOrderAtSciClubs;
}

int determineIconOrderForAboutUs() {
return this != null
? ContactIconsConfig.iconsOrderAtAboutUs.entries
.firstWhereOrNull(
(e) => this!.contains(e.key),
)
?.value ??
ContactIconsConfig.defaultIconOrderAtAboutUs
: ContactIconsConfig.defaultIconOrderAtAboutUs;
}
}