2FA screen: move continue to a button (#1427)

* Move continue to a button

* Resolve pr comments

* Move use another two step method button

* Resolve code suggestions

* Resolve for iPhone

* Apply suggestions from code review

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
This commit is contained in:
Sang 2021-07-20 14:50:45 +10:00 committed by GitHub
parent a4db088eda
commit 6a979d0ff5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 30 deletions

View file

@ -16,14 +16,21 @@
<ContentPage.ToolbarItems> <ContentPage.ToolbarItems>
<ToolbarItem Text="{u:I18n Cancel}" Clicked="Close_Clicked" Order="Primary" Priority="-1" <ToolbarItem Text="{u:I18n Cancel}" Clicked="Close_Clicked" Order="Primary" Priority="-1"
x:Name="_cancelItem" /> x:Name="_cancelItem" />
<ToolbarItem Text="{u:I18n Continue}" Clicked="Continue_Clicked" Order="Primary"
x:Name="_continueItem" />
</ContentPage.ToolbarItems> </ContentPage.ToolbarItems>
<ContentPage.Resources> <ContentPage.Resources>
<ResourceDictionary> <ResourceDictionary>
<u:InverseBoolConverter x:Key="inverseBool" /> <u:InverseBoolConverter x:Key="inverseBool" />
<u:IsNullConverter x:Key="isNull" /> <u:IsNullConverter x:Key="isNull" />
<ToolbarItem Icon="more_vert.png" Clicked="More_Clicked" Order="Primary"
x:Name="_moreItem" x:Key="moreItem"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n Options}" />
<ToolbarItem Text="{u:I18n UseAnotherTwoStepMethod}"
Clicked="Methods_Clicked"
Order="Secondary"
x:Name="_useAnotherTwoStepMethod"
x:Key="useAnotherTwoStepMethod" />
</ResourceDictionary> </ResourceDictionary>
</ContentPage.Resources> </ContentPage.Resources>
@ -45,7 +52,8 @@
Keyboard="Numeric" Keyboard="Numeric"
StyleClass="box-value" StyleClass="box-value"
ReturnType="Go" ReturnType="Go"
ReturnCommand="{Binding SubmitCommand}" /> ReturnCommand="{Binding SubmitCommand}"
TextChanged="Token_TextChanged"/>
</StackLayout> </StackLayout>
<StackLayout StyleClass="box-row, box-row-switch"> <StackLayout StyleClass="box-row, box-row-switch">
<Label <Label
@ -123,6 +131,12 @@
Margin="10, 20, 10, 10" Margin="10, 20, 10, 10"
HorizontalTextAlignment="Center" /> HorizontalTextAlignment="Center" />
</StackLayout> </StackLayout>
<Button Text="{u:I18n Continue}"
IsEnabled="{Binding EnableContinue}"
IsVisible="{Binding ShowContinue}"
Clicked="Continue_Clicked"
Margin="10, 0"
x:Name="_continue"></Button>
<Button Text="{u:I18n SendVerificationCodeAgain}" <Button Text="{u:I18n SendVerificationCodeAgain}"
IsVisible="{Binding EmailMethod}" IsVisible="{Binding EmailMethod}"
Clicked="ResendEmail_Clicked" Clicked="ResendEmail_Clicked"
@ -131,9 +145,6 @@
IsVisible="{Binding ShowTryAgain}" IsVisible="{Binding ShowTryAgain}"
Clicked="TryAgain_Clicked" Clicked="TryAgain_Clicked"
Margin="10, 0"></Button> Margin="10, 0"></Button>
<Button Text="{u:I18n UseAnotherTwoStepMethod}"
Clicked="Methods_Clicked"
Margin="10, 0"></Button>
</StackLayout> </StackLayout>
</ScrollView> </ScrollView>

View file

@ -1,5 +1,6 @@
using Bit.App.Controls; using Bit.App.Controls;
using Bit.App.Models; using Bit.App.Models;
using Bit.App.Resources;
using Bit.Core.Abstractions; using Bit.Core.Abstractions;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using System; using System;
@ -45,26 +46,17 @@ namespace Bit.App.Pages
{ {
ToolbarItems.Remove(_cancelItem); ToolbarItems.Remove(_cancelItem);
} }
if (Device.RuntimePlatform == Device.iOS)
{
ToolbarItems.Add(_moreItem);
} else
{
ToolbarItems.Add(_useAnotherTwoStepMethod);
}
} }
public HybridWebView DuoWebView { get; set; } 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() protected async override void OnAppearing()
{ {
base.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) private async void ResendEmail_Clicked(object sender, EventArgs e)
{ {
if (DoOnce()) if (DoOnce())
@ -195,5 +202,10 @@ namespace Bit.App.Pages
Application.Current.MainPage = new TabsPage(_appOptions, previousPage); Application.Current.MainPage = new TabsPage(_appOptions, previousPage);
} }
} }
private void Token_TextChanged(object sender, TextChangedEventArgs e)
{
_vm.EnableContinue = !string.IsNullOrWhiteSpace(e.NewTextValue);
}
} }
} }

View file

@ -32,6 +32,7 @@ namespace Bit.App.Pages
private string _totpInstruction; private string _totpInstruction;
private string _webVaultUrl = "https://vault.bitwarden.com"; private string _webVaultUrl = "https://vault.bitwarden.com";
private bool _authingWithSso = false; private bool _authingWithSso = false;
private bool _enableContinue = false;
public TwoFactorPageViewModel() public TwoFactorPageViewModel()
{ {
@ -73,6 +74,14 @@ namespace Bit.App.Pages
public bool ShowTryAgain => YubikeyMethod && Device.RuntimePlatform == Device.iOS; 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 : public string YubikeyInstruction => Device.RuntimePlatform == Device.iOS ? AppResources.YubiKeyInstructionIos :
AppResources.YubiKeyInstruction; AppResources.YubiKeyInstruction;
@ -169,14 +178,7 @@ namespace Bit.App.Pages
{ {
_messagingService.Send("listenYubiKeyOTP", false); _messagingService.Send("listenYubiKeyOTP", false);
} }
if (SelectedProviderType == null || DuoMethod) ShowContinue = !(SelectedProviderType == null || DuoMethod);
{
page.RemoveContinueButton();
}
else
{
page.AddContinueButton();
}
} }
public async Task SubmitAsync() public async Task SubmitAsync()