Skip to content

Commit

Permalink
Merge pull request #148 from Solvro/feat/143-implement-deparments-lin…
Browse files Browse the repository at this point in the history
…ks-sorting

Feat/143 implement deparments links sorting
  • Loading branch information
mikolaj-jalocha authored Aug 9, 2024
2 parents 381f7a7 + b08c417 commit 07dcdba
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/config/contact_icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,16 @@ abstract class ContactIconsConfig {
"maps": Assets.contactIcons.compass,
"tel": Assets.contactIcons.phone,
};
static final iconsOrder = {
"maps": 1,
"tel": 2,
"mailto:": 3,
"linkedin": 5,
"facebook": 6,
"instagram": 7,
"youtu": 8,
"github": 9,
};
static const defaultIconOrder = 4;
static final defaultIcon = Assets.contactIcons.web;
}
13 changes: 13 additions & 0 deletions lib/utils/determine_contact_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ class ContactIconsModel {
final String icon;
final String? text;
final String? url;
final int order;

ContactIconsModel({
String? text,
this.url,
}) : icon = url.determineIcon(),
order = url.determineIconOrder(),
text = text ?? url;
}

Expand All @@ -27,4 +29,15 @@ extension IconDeterminerX on String? {
ContactIconsConfig.defaultIcon
: ContactIconsConfig.defaultIcon;
}

int determineIconOrder() {
return this != null
? ContactIconsConfig.iconsOrder.entries
.firstWhereOrNull(
(e) => this!.contains(e.key),
)
?.value ??
ContactIconsConfig.defaultIconOrder
: ContactIconsConfig.defaultIconOrder;
}
}
1 change: 1 addition & 0 deletions lib/widgets/detail_views/contact_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ContactSection extends StatelessWidget {

@override
Widget build(BuildContext context) {
list.sort((a, b) => a.order.compareTo(b.order));
return Container(
padding: const EdgeInsets.only(top: 24, left: 24, right: 24, bottom: 8),
color: context.colorTheme.greyLight,
Expand Down

0 comments on commit 07dcdba

Please sign in to comment.