Skip to content

Commit 7a43723

Browse files
committed
feat(app_shell): add sign out option
- Added sign out to appbar menu - Calls AppLogoutRequested event
1 parent d794adf commit 7a43723

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

lib/app/view/app_shell.dart

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
3+
import 'package:flutter_bloc/flutter_bloc.dart';
34
import 'package:go_router/go_router.dart';
5+
import 'package:ht_dashboard/app/bloc/app_bloc.dart';
46
import 'package:ht_dashboard/l10n/l10n.dart';
57
import 'package:ht_dashboard/router/routes.dart';
68
import 'package:ht_dashboard/shared/constants/app_spacing.dart';
@@ -34,10 +36,24 @@ class AppShell extends StatelessWidget {
3436
appBar: AppBar(
3537
title: Text(l10n.dashboard),
3638
actions: [
37-
InkWell(
38-
onTap: () {
39-
context.goNamed(Routes.settingsName);
39+
PopupMenuButton<String>(
40+
onSelected: (value) {
41+
if (value == 'settings') {
42+
context.goNamed(Routes.settingsName);
43+
} else if (value == 'signOut') {
44+
context.read<AppBloc>().add(const AppLogoutRequested());
45+
}
4046
},
47+
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
48+
PopupMenuItem<String>(
49+
value: 'settings',
50+
child: Text(l10n.settings),
51+
),
52+
PopupMenuItem<String>(
53+
value: 'signOut',
54+
child: Text(l10n.signOut),
55+
),
56+
],
4157
child: Padding(
4258
padding: const EdgeInsets.all(AppSpacing.sm),
4359
child: CircleAvatar(
@@ -49,7 +65,7 @@ class AppShell extends StatelessWidget {
4965
),
5066
),
5167
),
52-
SizedBox(width: AppSpacing.sm),
68+
const SizedBox(width: AppSpacing.sm),
5369
],
5470
),
5571
body: AdaptiveScaffold(

0 commit comments

Comments
 (0)