diff --git a/src/App/Pages/Accounts/TwoFactorPage.xaml b/src/App/Pages/Accounts/TwoFactorPage.xaml index e4feaf84b..c3235ec72 100644 --- a/src/App/Pages/Accounts/TwoFactorPage.xaml +++ b/src/App/Pages/Accounts/TwoFactorPage.xaml @@ -16,14 +16,21 @@ - + + @@ -45,7 +52,8 @@ Keyboard="Numeric" StyleClass="box-value" ReturnType="Go" - ReturnCommand="{Binding SubmitCommand}" /> + ReturnCommand="{Binding SubmitCommand}" + TextChanged="Token_TextChanged"/> + - diff --git a/src/App/Pages/Accounts/TwoFactorPage.xaml.cs b/src/App/Pages/Accounts/TwoFactorPage.xaml.cs index b0968daf7..4a5c2c39d 100644 --- a/src/App/Pages/Accounts/TwoFactorPage.xaml.cs +++ b/src/App/Pages/Accounts/TwoFactorPage.xaml.cs @@ -1,5 +1,6 @@ using Bit.App.Controls; using Bit.App.Models; +using Bit.App.Resources; using Bit.Core.Abstractions; using Bit.Core.Utilities; using System; @@ -45,26 +46,17 @@ namespace Bit.App.Pages { ToolbarItems.Remove(_cancelItem); } + if (Device.RuntimePlatform == Device.iOS) + { + ToolbarItems.Add(_moreItem); + } else + { + ToolbarItems.Add(_useAnotherTwoStepMethod); + } } public HybridWebView DuoWebView { get; set; } - public void AddContinueButton() - { - if (!ToolbarItems.Contains(_continueItem)) - { - ToolbarItems.Add(_continueItem); - } - } - - public void RemoveContinueButton() - { - if (ToolbarItems.Contains(_continueItem)) - { - ToolbarItems.Remove(_continueItem); - } - } - protected async override void OnAppearing() { base.OnAppearing(); @@ -145,6 +137,21 @@ namespace Bit.App.Pages } } + private async void More_Clicked(object sender, EventArgs e) + { + if (!DoOnce()) + { + return; + } + + var selection = await DisplayActionSheet(AppResources.Options, AppResources.Cancel, null, AppResources.UseAnotherTwoStepMethod); + + if (selection == AppResources.UseAnotherTwoStepMethod) + { + await _vm.AnotherMethodAsync(); + } + } + private async void ResendEmail_Clicked(object sender, EventArgs e) { if (DoOnce()) @@ -195,5 +202,10 @@ namespace Bit.App.Pages Application.Current.MainPage = new TabsPage(_appOptions, previousPage); } } + + private void Token_TextChanged(object sender, TextChangedEventArgs e) + { + _vm.EnableContinue = !string.IsNullOrWhiteSpace(e.NewTextValue); + } } } diff --git a/src/App/Pages/Accounts/TwoFactorPageViewModel.cs b/src/App/Pages/Accounts/TwoFactorPageViewModel.cs index 5a0815f10..335d7981e 100644 --- a/src/App/Pages/Accounts/TwoFactorPageViewModel.cs +++ b/src/App/Pages/Accounts/TwoFactorPageViewModel.cs @@ -32,6 +32,7 @@ namespace Bit.App.Pages private string _totpInstruction; private string _webVaultUrl = "https://vault.bitwarden.com"; private bool _authingWithSso = false; + private bool _enableContinue = false; public TwoFactorPageViewModel() { @@ -73,6 +74,14 @@ namespace Bit.App.Pages public bool ShowTryAgain => YubikeyMethod && Device.RuntimePlatform == Device.iOS; + public bool ShowContinue { get; set; } + + public bool EnableContinue + { + get => _enableContinue; + set => SetProperty(ref _enableContinue, value); + } + public string YubikeyInstruction => Device.RuntimePlatform == Device.iOS ? AppResources.YubiKeyInstructionIos : AppResources.YubiKeyInstruction; @@ -169,14 +178,7 @@ namespace Bit.App.Pages { _messagingService.Send("listenYubiKeyOTP", false); } - if (SelectedProviderType == null || DuoMethod) - { - page.RemoveContinueButton(); - } - else - { - page.AddContinueButton(); - } + ShowContinue = !(SelectedProviderType == null || DuoMethod); } public async Task SubmitAsync()