diff --git a/lib/ui/app/menu_drawer.dart b/lib/ui/app/menu_drawer.dart index d22e3330c..57e3de03c 100644 --- a/lib/ui/app/menu_drawer.dart +++ b/lib/ui/app/menu_drawer.dart @@ -379,10 +379,11 @@ class _MenuDrawerState extends State { ), ), if (!state.account.accountSmsVerified && - state.isHosted) + state.isHosted && + state.company.displayName.isNotEmpty) if (state.isMenuCollapsed) Tooltip( - message: localization.verifyPhoneHelp, + message: localization.verifyPhoneNumberHelp, child: ListTile( contentPadding: const EdgeInsets.only(left: 12), @@ -404,7 +405,7 @@ class _MenuDrawerState extends State { child: ListTile( tileColor: Colors.orange.shade800, subtitle: Text( - localization.verifyPhoneHelp, + localization.verifyPhoneNumberHelp, style: TextStyle(color: Colors.white), ), onTap: () { diff --git a/lib/ui/settings/user_details.dart b/lib/ui/settings/user_details.dart index 88ee45f1e..ef49f6c2f 100644 --- a/lib/ui/settings/user_details.dart +++ b/lib/ui/settings/user_details.dart @@ -121,7 +121,7 @@ class _UserDetailsState extends State void _onChanged() { var phone = _phoneController.text.trim(); - if (!phone.startsWith('+')) { + if (phone.isNotEmpty && !phone.startsWith('+')) { phone = '+$phone'; } @@ -384,6 +384,38 @@ class _UserDetailsState extends State SizedBox(width: kTableColumnGap), ] ], + if (!state.account.accountSmsVerified) ...[ + Expanded( + child: OutlinedButton( + child: Text( + localization.verifyPhoneNumber.toUpperCase(), + ), + onPressed: () { + if (state.settingsUIState.isChanged) { + showMessageDialog( + context: context, + message: localization.errorUnsavedChanges); + return; + } + + if (state.user.phone.isEmpty || + user.phone.isEmpty) { + showMessageDialog( + context: context, + message: localization.enterPhoneNumber); + return; + } + + showDialog( + context: context, + builder: (BuildContext context) => + _SmsVerification(state: viewModel.state), + ); + }, + ), + ), + SizedBox(width: kTableColumnGap), + ], Expanded( child: OutlinedButton( child: Text((state.user.isTwoFactorEnabled @@ -681,3 +713,65 @@ class _EnableTwoFactorState extends State<_EnableTwoFactor> { ); } } + +class _SmsVerification extends StatefulWidget { + const _SmsVerification({@required this.state}); + + final AppState state; + + @override + State<_SmsVerification> createState() => __SmsVerificationState(); +} + +class __SmsVerificationState extends State<_SmsVerification> { + bool _isLoading = false; + + void _sendCode() { + // + } + + void _verifyCode() { + // + } + + @override + Widget build(BuildContext context) { + final localization = AppLocalization.of(context); + + return AlertDialog( + title: Text(localization.verifyPhoneNumber), + content: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text(localization.codeWasSent), + SizedBox(height: 8), + DecoratedFormField( + label: localization.code, + keyboardType: TextInputType.number, + ), + ], + ), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(), + child: Text( + localization.cancel.toUpperCase(), + ), + ), + TextButton( + onPressed: () => _sendCode(), + child: Text( + localization.resend.toUpperCase(), + ), + ), + TextButton( + onPressed: () => _verifyCode(), + child: Text( + localization.verify.toUpperCase(), + ), + ), + ], + ); + } +} diff --git a/lib/utils/i18n.dart b/lib/utils/i18n.dart index 3cd91a7ad..0e3b96ab6 100644 --- a/lib/utils/i18n.dart +++ b/lib/utils/i18n.dart @@ -16,8 +16,14 @@ mixin LocalizationsProvider on LocaleCodeAware { static final Map> _localizedValues = { 'en': { // STARTER: lang key - do not remove comment + 'code_was_sent': 'A code has been sent via SMS', + 'resend': 'Resend', + 'verify': 'Verify', + 'enter_phone_number': 'Please provide a phone number', 'invalid_phone_number': 'Invalid phone number', - 'verify_phone_help': 'Please verify your phone number to send emails', + 'verify_phone_number': 'Verify Phone Number', + 'verify_phone_number_help': + 'Please verify your phone number to send emails', 'merged_clients': 'Successfully merged clients', 'merge_into': 'Merge Into', 'merge': 'Merge', @@ -719,8 +725,7 @@ mixin LocalizationsProvider on LocaleCodeAware { 'capture_card': 'Capture Card', 'auto_bill_enabled': 'Auto Bill Enabled', 'total_taxes': 'Total Taxes', - 'line_taxes': 'Line Taxes', - 'total_fields': 'Total Fields', + 'line_taxes': 'Line Taxes', 'total_fields': 'Total Fields', 'stopped_recurring_invoice': 'Successfully stopped recurring invoice', 'started_recurring_invoice': 'Successfully started recurring invoice', 'resumed_recurring_invoice': 'Successfully resumed recurring invoice', @@ -85205,15 +85210,33 @@ mixin LocalizationsProvider on LocaleCodeAware { _localizedValues[localeCode]['merged_clients'] ?? _localizedValues['en']['merged_clients']; - String get verifyPhoneHelp => - _localizedValues[localeCode]['verify_phone_help'] ?? - _localizedValues['en']['verify_phone_help']; + String get verifyPhoneNumber => + _localizedValues[localeCode]['verify_phone_number'] ?? + _localizedValues['en']['verify_phone_number']; + + String get verifyPhoneNumberHelp => + _localizedValues[localeCode]['verify_phone_number_help'] ?? + _localizedValues['en']['verify_phone_number_help']; String get invalidPhoneNumber => _localizedValues[localeCode]['invalid_phone_number'] ?? _localizedValues['en']['invalid_phone_number']; + String get enterPhoneNumber => + _localizedValues[localeCode]['enter_phone_number'] ?? + _localizedValues['en']['enter_phone_number']; + String get resend => + _localizedValues[localeCode]['resend'] ?? + _localizedValues['en']['resend']; + + String get verify => + _localizedValues[localeCode]['verify'] ?? + _localizedValues['en']['verify']; + + String get codeWasSent => + _localizedValues[localeCode]['code_was_sent'] ?? + _localizedValues['en']['code_was_sent']; // STARTER: lang field - do not remove comment