mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
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:
parent
a4db088eda
commit
6a979d0ff5
3 changed files with 55 additions and 30 deletions
|
@ -16,14 +16,21 @@
|
|||
<ContentPage.ToolbarItems>
|
||||
<ToolbarItem Text="{u:I18n Cancel}" Clicked="Close_Clicked" Order="Primary" Priority="-1"
|
||||
x:Name="_cancelItem" />
|
||||
<ToolbarItem Text="{u:I18n Continue}" Clicked="Continue_Clicked" Order="Primary"
|
||||
x:Name="_continueItem" />
|
||||
</ContentPage.ToolbarItems>
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<u:InverseBoolConverter x:Key="inverseBool" />
|
||||
<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>
|
||||
</ContentPage.Resources>
|
||||
|
||||
|
@ -45,7 +52,8 @@
|
|||
Keyboard="Numeric"
|
||||
StyleClass="box-value"
|
||||
ReturnType="Go"
|
||||
ReturnCommand="{Binding SubmitCommand}" />
|
||||
ReturnCommand="{Binding SubmitCommand}"
|
||||
TextChanged="Token_TextChanged"/>
|
||||
</StackLayout>
|
||||
<StackLayout StyleClass="box-row, box-row-switch">
|
||||
<Label
|
||||
|
@ -123,6 +131,12 @@
|
|||
Margin="10, 20, 10, 10"
|
||||
HorizontalTextAlignment="Center" />
|
||||
</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}"
|
||||
IsVisible="{Binding EmailMethod}"
|
||||
Clicked="ResendEmail_Clicked"
|
||||
|
@ -131,9 +145,6 @@
|
|||
IsVisible="{Binding ShowTryAgain}"
|
||||
Clicked="TryAgain_Clicked"
|
||||
Margin="10, 0"></Button>
|
||||
<Button Text="{u:I18n UseAnotherTwoStepMethod}"
|
||||
Clicked="Methods_Clicked"
|
||||
Margin="10, 0"></Button>
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue