This commit is contained in:
Hillel Coren 2021-03-07 21:48:09 +02:00
parent ebdafb84b7
commit 7c51840f07
3 changed files with 39 additions and 5 deletions

View File

@ -218,7 +218,7 @@ class _UserDetailsState extends State<UserDetails>
Expanded(
child: OutlineButton(
child: Text((user.isTwoFactorEnabled
? localization.disableTwoFacor
? localization.disableTwoFactor
: localization.enableTwoFactor)
.toUpperCase()),
shape: RoundedRectangleBorder(

View File

@ -50,6 +50,18 @@ class UserDetailsVM {
user: state.uiState.settingsUIState.user,
onChanged: (user) => store.dispatch(UpdateUserSettings(user: user)),
onDisableTwoFactorPressed: (context) {
final completer = snackBarCompleter<Null>(
context, AppLocalization.of(context).disabledTwoFactor);
completer.future.then((_) {
AppBuilder.of(context).rebuild();
}).catchError((Object error) {
showDialog<ErrorDialog>(
context: context,
builder: (BuildContext context) {
return ErrorDialog(error);
});
});
passwordCallback(
context: context,
callback: (password, idToken) {
@ -64,6 +76,18 @@ class UserDetailsVM {
});
},
onDisconnectGooglePressed: (context) {
final completer = snackBarCompleter<Null>(
context, AppLocalization.of(context).disconnectGoogle);
completer.future.then((_) {
AppBuilder.of(context).rebuild();
}).catchError((Object error) {
showDialog<ErrorDialog>(
context: context,
builder: (BuildContext context) {
return ErrorDialog(error);
});
});
passwordCallback(
context: context,
callback: (password, idToken) {
@ -72,13 +96,14 @@ class UserDetailsVM {
user: state.user.rebuild((b) => b..oauthProvider = ''),
password: password,
idToken: idToken,
completer: completer,
),
);
});
},
onConnectGooglePressed: (context) {
final completer = snackBarCompleter<Null>(
context, AppLocalization.of(context).connectedOauth);
context, AppLocalization.of(context).connectedGoogle);
completer.future.catchError((Object error) {
showDialog<ErrorDialog>(
context: context,

View File

@ -15,7 +15,9 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = {
'en': {
// STARTER: lang key - do not remove comment
'connected_oauth': 'Successfully connected account',
'disabled_two_factor': 'Successfully disabled 2FA',
'connected_google': 'Successfully connected account',
'disconnected_google': 'Successfully disconnected account',
'delivered': 'Delivered',
'bounced': 'Bounced',
'spam': 'Spam',
@ -55560,9 +55562,12 @@ mixin LocalizationsProvider on LocaleCodeAware {
String get enableTwoFactor =>
_localizedValues[localeCode]['enable_two_factor'] ?? '';
String get disableTwoFacor =>
String get disableTwoFactor =>
_localizedValues[localeCode]['disable_two_factor'] ?? '';
String get disabledTwoFactor =>
_localizedValues[localeCode]['disabled_two_factor'] ?? '';
String get connectGoogle =>
_localizedValues[localeCode]['connect_google'] ?? '';
@ -55590,7 +55595,11 @@ mixin LocalizationsProvider on LocaleCodeAware {
String get spam => _localizedValues[localeCode]['spam'] ?? '';
String get connectedOauth => _localizedValues[localeCode]['connected_oauth'] ?? '';
String get connectedGoogle =>
_localizedValues[localeCode]['connected_google'] ?? '';
String get disconnectedGoogle =>
_localizedValues[localeCode]['disconnected_google'] ?? '';
String lookup(String key) {
final lookupKey = toSnakeCase(key);