feat: Add sign out confirmation dialog and success snackbar

Introduces a confirmation dialog before signing out in the client settings page and displays a snackbar upon successful sign out. Also updates a slivers list to use explicit type annotation for consistency.
This commit is contained in:
Achintha Isuru
2026-01-22 13:43:04 -05:00
parent b73abc5487
commit 5da56eb769
3 changed files with 46 additions and 4 deletions

View File

@@ -59,7 +59,7 @@ class ClientHubsPage extends StatelessWidget {
body: Stack(
children: <Widget>[
CustomScrollView(
slivers: [
slivers: <Widget>[
_buildAppBar(context),
SliverPadding(
padding: const EdgeInsets.symmetric(

View File

@@ -23,6 +23,9 @@ class ClientSettingsPage extends StatelessWidget {
child: BlocListener<ClientSettingsBloc, ClientSettingsState>(
listener: (context, state) {
if (state is ClientSettingsSignOutSuccess) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Signed out successfully')),
);
Modular.to.navigate('/');
}
if (state is ClientSettingsError) {

View File

@@ -28,9 +28,7 @@ class SettingsActions extends StatelessWidget {
text: labels.log_out,
onPressed: state is ClientSettingsLoading
? null
: () => BlocProvider.of<ClientSettingsBloc>(
context,
).add(const ClientSettingsSignOutRequested()),
: () => _showSignOutDialog(context),
);
},
),
@@ -38,4 +36,45 @@ class SettingsActions extends StatelessWidget {
),
);
}
/// Shows a confirmation dialog for signing out.
Future<void> _showSignOutDialog(BuildContext context) {
return showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
backgroundColor: UiColors.bgPopup,
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: UiConstants.radiusLg),
title: Text(
t.client_settings.profile.log_out,
style: UiTypography.headline3m.textPrimary,
),
content: Text(
'Are you sure you want to log out?',
style: UiTypography.body2r.textSecondary,
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(
t.common.cancel,
style: UiTypography.buttonM.textSecondary,
),
),
TextButton(
onPressed: () {
Navigator.of(context).pop();
BlocProvider.of<ClientSettingsBloc>(
context,
).add(const ClientSettingsSignOutRequested());
},
child: Text(
t.client_settings.profile.log_out,
style: UiTypography.buttonM.textError,
),
),
],
),
);
}
}