diff --git a/src/App/Pages/Vault/ScanPage.xaml b/src/App/Pages/Vault/ScanPage.xaml
index d90c5a2b7..b7dd30ef0 100644
--- a/src/App/Pages/Vault/ScanPage.xaml
+++ b/src/App/Pages/Vault/ScanPage.xaml
@@ -1,14 +1,25 @@
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
@@ -24,7 +35,40 @@
AutomationId="zxingScannerView"
OnScanResult="OnScanResult">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+ Margin="0,15"
+ StyleClass="text-sm"
+ VerticalOptions="End"
+ HorizontalOptions="Center" >
+
+
+
+
-
-
-
+
\ No newline at end of file
diff --git a/src/App/Pages/Vault/ScanPage.xaml.cs b/src/App/Pages/Vault/ScanPage.xaml.cs
index 7ae607fe5..56148c14a 100644
--- a/src/App/Pages/Vault/ScanPage.xaml.cs
+++ b/src/App/Pages/Vault/ScanPage.xaml.cs
@@ -11,6 +11,7 @@ namespace Bit.App.Pages
{
public partial class ScanPage : BaseContentPage
{
+ private ScanPageViewModel ViewModel => BindingContext as ScanPageViewModel;
private readonly Action _callback;
private CancellationTokenSource _autofocusCts;
@@ -119,5 +120,10 @@ namespace Bit.App.Pages
await Navigation.PopModalAsync();
}
}
+
+ private void ToggleScanMode_OnTapped(object sender, EventArgs e)
+ {
+ ViewModel.ToggleScanModeCommand.Execute(null);
+ }
}
}
diff --git a/src/App/Pages/Vault/ScanPageViewModel.cs b/src/App/Pages/Vault/ScanPageViewModel.cs
new file mode 100644
index 000000000..d7b80067c
--- /dev/null
+++ b/src/App/Pages/Vault/ScanPageViewModel.cs
@@ -0,0 +1,64 @@
+using Bit.App.Resources;
+using Bit.App.Utilities;
+using Bit.Core.Abstractions;
+using Xamarin.Forms;
+
+namespace Bit.App.Pages
+{
+ public class ScanPageViewModel: BaseViewModel
+ {
+ private bool _showScanner;
+ private string _totpAuthenticationKey;
+
+ public ScanPageViewModel()
+ {
+ ShowScanner = true;
+ ToggleScanModeCommand = new Command(ToggleScanAsync);
+ }
+
+ public Command ToggleScanModeCommand { get; set; }
+
+ public string TotpAuthenticationKey
+ {
+ get => _totpAuthenticationKey;
+ set => SetProperty(ref _totpAuthenticationKey, value,
+ additionalPropertyNames: new string[]
+ {
+ nameof(ToggleScanModeLabel)
+ });
+ }
+ public bool ShowScanner
+ {
+ get => _showScanner;
+ set => SetProperty(ref _showScanner, value,
+ additionalPropertyNames: new string[]
+ {
+ nameof(ToggleScanModeLabel)
+ });
+ }
+
+ public FormattedString ToggleScanModeLabel
+ {
+ get
+ {
+ var fs = new FormattedString();
+ fs.Spans.Add(new Span
+ {
+ Text = ShowScanner ? AppResources.CannotScanQRCode : AppResources.CannotAddAuthenticatorKey,
+ TextColor = ThemeManager.GetResourceColor("BackgroundColor")
+ });
+ fs.Spans.Add(new Span
+ {
+ Text = ShowScanner ? AppResources.EnterCodeManually : AppResources.ScanQRCode,
+ TextColor = ThemeManager.GetResourceColor("PrimaryColor")
+ });
+ return fs;
+ }
+ }
+
+ private void ToggleScanAsync()
+ {
+ ShowScanner = !ShowScanner;
+ }
+ }
+}
diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs
index 4ce17e622..011964cc5 100644
--- a/src/App/Resources/AppResources.Designer.cs
+++ b/src/App/Resources/AppResources.Designer.cs
@@ -4040,5 +4040,35 @@ namespace Bit.App.Resources {
return ResourceManager.GetString("ToViewVerificationCodes", resourceCulture);
}
}
+
+ public static string CannotAddAuthenticatorKey {
+ get {
+ return ResourceManager.GetString("CannotAddAuthenticatorKey", resourceCulture);
+ }
+ }
+
+ public static string ScanQRCode {
+ get {
+ return ResourceManager.GetString("ScanQRCode", resourceCulture);
+ }
+ }
+
+ public static string CannotScanQRCode {
+ get {
+ return ResourceManager.GetString("CannotScanQRCode", resourceCulture);
+ }
+ }
+
+ public static string EnterCodeManually {
+ get {
+ return ResourceManager.GetString("EnterCodeManually", resourceCulture);
+ }
+ }
+
+ public static string AddTotp {
+ get {
+ return ResourceManager.GetString("AddTotp", resourceCulture);
+ }
+ }
}
}
diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx
index 75a400dd3..ca48379ef 100644
--- a/src/App/Resources/AppResources.resx
+++ b/src/App/Resources/AppResources.resx
@@ -2257,4 +2257,19 @@
to view verification codes
+
+ Cannot add authenticator key?
+
+
+ Scan QR Code
+
+
+ Cannot scan QR Code?
+
+
+ Enter code manually
+
+
+ Add TOTP
+