Skip to content

Commit

Permalink
feat: sign out confirmation step. Issue: #884 (#979)
Browse files Browse the repository at this point in the history
* feat: 馃幐 add a confirmation step to log out

* fix: 馃悰 Change the 'log out' term to 'sign out'

* refactor: 馃挕 Change the alert dialogue to smooth alert dialog

* refactor: 馃挕 removing unused variable 'theme'

* refactor: 馃挕 specifying widgets on SmoothAlertDialog actions

Co-authored-by: Moises Alonso <moises.alonso@codeminer42.com>
  • Loading branch information
mse-moises and Moises Alonso committed Jan 19, 2022
1 parent 6a166aa commit fe682a6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
40 changes: 36 additions & 4 deletions packages/smooth_app/lib/pages/user_preferences_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -153,4 +152,37 @@ class UserPreferencesProfile extends AbstractUserPreferences {

return result;
}

void _confirmLogout(BuildContext context) {
final AppLocalizations localizations = AppLocalizations.of(context)!;

showDialog<void>(
context: context,
builder: (BuildContext context) {
return SmoothAlertDialog(
close: false,
title: localizations.sign_out,
body: Text(
localizations.sign_out_confirmation,
),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
text: localizations.yes,
onPressed: () async {
UserManagementHelper.logout();
Navigator.pop(context);
setState(() {});
},
),
SmoothSimpleButton(
text: localizations.no,
onPressed: () {
Navigator.pop(context);
},
),
],
);
},
);
}
}

0 comments on commit fe682a6

Please sign in to comment.