diff --git a/packages/smooth_app/lib/l10n/app_en.arb b/packages/smooth_app/lib/l10n/app_en.arb index 66d4c5ff88f..fdf8705bcce 100644 --- a/packages/smooth_app/lib/l10n/app_en.arb +++ b/packages/smooth_app/lib/l10n/app_en.arb @@ -92,6 +92,10 @@ "@sign_out": { "description": "Button label: For sign out" }, + "sign_out_confirmation": "Are you sure you want to sign out?", + "@sign_out_confirmation": { + "description": "Pop up title: Reassuring if the user really want to sign out" + }, "password": "Password", "forgot_password": "Forgot password", "@forgot_password": { diff --git a/packages/smooth_app/lib/pages/user_preferences_profile.dart b/packages/smooth_app/lib/pages/user_preferences_profile.dart index 93aa97f3e83..670431e31e8 100644 --- a/packages/smooth_app/lib/pages/user_preferences_profile.dart +++ b/packages/smooth_app/lib/pages/user_preferences_profile.dart @@ -7,6 +7,8 @@ import 'package:smooth_app/helpers/user_management_helper.dart'; import 'package:smooth_app/pages/abstract_user_preferences.dart'; import 'package:smooth_app/pages/onboarding/country_selector.dart'; import 'package:smooth_app/pages/user_management/login_page.dart'; +import 'package:smooth_ui_library/buttons/smooth_simple_button.dart'; +import 'package:smooth_ui_library/dialogs/smooth_alert_dialog.dart'; /// Collapsed/expanded display of profile for the preferences page. class UserPreferencesProfile extends AbstractUserPreferences { @@ -79,10 +81,7 @@ class UserPreferencesProfile extends AbstractUserPreferences { ), ), ElevatedButton( - onPressed: () { - UserManagementHelper.logout(); - setState(() {}); - }, + onPressed: () => _confirmLogout(context), child: Text( appLocalizations.sign_out, style: theme.textTheme.bodyText2?.copyWith( @@ -153,4 +152,37 @@ class UserPreferencesProfile extends AbstractUserPreferences { return result; } + + void _confirmLogout(BuildContext context) { + final AppLocalizations localizations = AppLocalizations.of(context)!; + + showDialog( + context: context, + builder: (BuildContext context) { + return SmoothAlertDialog( + close: false, + title: localizations.sign_out, + body: Text( + localizations.sign_out_confirmation, + ), + actions: [ + SmoothSimpleButton( + text: localizations.yes, + onPressed: () async { + UserManagementHelper.logout(); + Navigator.pop(context); + setState(() {}); + }, + ), + SmoothSimpleButton( + text: localizations.no, + onPressed: () { + Navigator.pop(context); + }, + ), + ], + ); + }, + ); + } }