Skip to content

Commit

Permalink
chore: add active icon to navigation drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
Grodien committed Oct 15, 2024
1 parent 8890805 commit 7c641da
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions das_client/lib/nav/das_navigation_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ class _DASNavigationDrawerState extends State<DASNavigationDrawer> {
title: context.l10n.w_navigation_drawer_settings_title,
route: const SettingsRoute(),
),
_navigationTile(
context,
icon: SBBIcons.user_small,
title: context.l10n.w_navigation_drawer_profile_title,
route: const ProfileRoute()
),
_navigationTile(context,
icon: SBBIcons.user_small,
title: context.l10n.w_navigation_drawer_profile_title,
route: const ProfileRoute()),
],
),
),
Expand All @@ -61,16 +59,29 @@ class _DASNavigationDrawerState extends State<DASNavigationDrawer> {
bool isActiveRoute = context.router.isRouteActive(route.routeName);

return ListTile(
leading: Icon(icon),
title: Text(title,
style: isActiveRoute ? SBBTextStyles.mediumBold : SBBTextStyles.mediumLight),
leading: isActiveRoute ? _activeIcon(icon) : _inactiveIcon(icon),
title: Text(title, style: isActiveRoute ? SBBTextStyles.mediumBold : SBBTextStyles.mediumLight),
onTap: () {
Navigator.pop(context);
context.router.replace(route);
},
);
}

Widget _activeIcon(IconData icon) {
return CircleAvatar(
backgroundColor: SBBColors.black,
child: Icon(icon),
);
}

Widget _inactiveIcon(IconData icon) {
return Padding(
padding: const EdgeInsets.fromLTRB(sbbDefaultSpacing / 2, 0, sbbDefaultSpacing / 2, 0),
child: Icon(icon),
);
}

Widget _versionFooter() {
return const Align(
alignment: Alignment.bottomCenter,
Expand Down

0 comments on commit 7c641da

Please sign in to comment.