Skip to content

Commit 657623e

Browse files
committed
feat(app_shell): refactor navigation rail and add settings/logout tiles
- Replace UserNavigationRailFooter with custom settings and sign-out tiles - Add expanded row for app name in extended state - Implement consistent styling for nav rail items - Add Bloc listener for app logout functionality - Update imports to include necessary packages and routes
1 parent 6f87789 commit 657623e

File tree

1 file changed

+100
-20
lines changed

1 file changed

+100
-20
lines changed

lib/app/view/app_shell.dart

Lines changed: 100 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
3+
import 'package:flutter_bloc/flutter_bloc.dart';
4+
import 'package:flutter_news_app_web_dashboard_full_source_code/app/bloc/app_bloc.dart';
35
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
4-
import 'package:flutter_news_app_web_dashboard_full_source_code/shared/widgets/user_navigation_rail_footer.dart';
6+
import 'package:flutter_news_app_web_dashboard_full_source_code/router/routes.dart';
57
import 'package:go_router/go_router.dart';
68
import 'package:ui_kit/ui_kit.dart';
79

@@ -23,6 +25,11 @@ class AppShell extends StatelessWidget {
2325
@override
2426
Widget build(BuildContext context) {
2527
final l10n = AppLocalizationsX(context).l10n;
28+
final theme = Theme.of(context);
29+
30+
// Use the same text style as the NavigationRail labels for consistency.
31+
final navRailLabelStyle = theme.textTheme.labelMedium;
32+
2633
return Scaffold(
2734
body: AdaptiveScaffold(
2835
selectedIndex: navigationShell.currentIndex,
@@ -49,29 +56,102 @@ class AppShell extends StatelessWidget {
4956
label: l10n.appConfiguration,
5057
),
5158
],
52-
// App name at the top of the navigation rail for both extended and unextended states.
53-
leadingUnextendedNavRail: Padding(
54-
padding: const EdgeInsets.symmetric(vertical: AppSpacing.lg),
55-
child: Text(
56-
l10n.dashboardTitle,
57-
style: Theme.of(context).textTheme.titleLarge?.copyWith(
58-
color: Theme.of(context).colorScheme.primary,
59-
),
60-
),
59+
leadingUnextendedNavRail: const Padding(
60+
padding: EdgeInsets.symmetric(vertical: AppSpacing.lg),
61+
child: Icon(Icons.newspaper_outlined),
6162
),
6263
leadingExtendedNavRail: Padding(
63-
padding: const EdgeInsets.symmetric(vertical: AppSpacing.lg),
64-
child: Text(
65-
l10n.dashboardTitle,
66-
style: Theme.of(context).textTheme.titleLarge?.copyWith(
67-
color: Theme.of(context).colorScheme.primary,
68-
),
64+
padding: const EdgeInsets.all(AppSpacing.lg),
65+
child: Row(
66+
children: [
67+
const Icon(Icons.newspaper_outlined),
68+
const SizedBox(width: AppSpacing.md),
69+
Text(
70+
l10n.dashboardTitle,
71+
style: theme.textTheme.titleLarge?.copyWith(
72+
color: theme.colorScheme.primary,
73+
),
74+
),
75+
],
6976
),
7077
),
71-
// UserNavigationRailFooter pinned to the bottom of the navigation rail.
72-
trailingNavRail: const UserNavigationRailFooter(),
73-
// Ensure the navigation rail items are aligned to the start, pushing the footer to the end.
74-
groupAlignment: 1,
78+
trailingNavRail: Builder(
79+
builder: (context) {
80+
final isExtended = Breakpoints.mediumLarge.isActive(context);
81+
return Expanded(
82+
child: Padding(
83+
padding: const EdgeInsets.only(bottom: AppSpacing.lg),
84+
child: Column(
85+
mainAxisAlignment: MainAxisAlignment.end,
86+
children: [
87+
// Settings Tile
88+
InkWell(
89+
onTap: () => context.goNamed(Routes.settingsName),
90+
child: Padding(
91+
padding: EdgeInsets.symmetric(
92+
vertical: AppSpacing.md,
93+
horizontal: isExtended ? 24 : 16,
94+
),
95+
child: Row(
96+
mainAxisAlignment: isExtended
97+
? MainAxisAlignment.start
98+
: MainAxisAlignment.center,
99+
children: [
100+
Icon(
101+
Icons.settings_outlined,
102+
color: theme.colorScheme.onSurfaceVariant,
103+
size: 24,
104+
),
105+
if (isExtended) ...[
106+
const SizedBox(width: AppSpacing.lg),
107+
Text(
108+
l10n.settings,
109+
style: navRailLabelStyle,
110+
),
111+
],
112+
],
113+
),
114+
),
115+
),
116+
// Sign Out Tile
117+
InkWell(
118+
onTap: () => context.read<AppBloc>().add(
119+
const AppLogoutRequested(),
120+
),
121+
child: Padding(
122+
padding: EdgeInsets.symmetric(
123+
vertical: AppSpacing.md,
124+
horizontal: isExtended ? 24 : 16,
125+
),
126+
child: Row(
127+
mainAxisAlignment: isExtended
128+
? MainAxisAlignment.start
129+
: MainAxisAlignment.center,
130+
children: [
131+
Icon(
132+
Icons.logout,
133+
color: theme.colorScheme.error,
134+
size: 24,
135+
),
136+
if (isExtended) ...[
137+
const SizedBox(width: AppSpacing.lg),
138+
Text(
139+
l10n.signOut,
140+
style: navRailLabelStyle?.copyWith(
141+
color: theme.colorScheme.error,
142+
),
143+
),
144+
],
145+
],
146+
),
147+
),
148+
),
149+
],
150+
),
151+
),
152+
);
153+
},
154+
),
75155
body: (_) => Padding(
76156
padding: const EdgeInsets.fromLTRB(
77157
0,

0 commit comments

Comments
 (0)