1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-04 17:43:17 +00:00

[SG-471] Added text resources and arguments to Page.

This commit is contained in:
André Bispo
2022-07-27 15:29:23 +01:00
parent e52f527eea
commit 4e0da8fd96
5 changed files with 3835 additions and 5665 deletions

View File

@@ -22,67 +22,65 @@
<u:InverseBoolConverter x:Key="inverseBool" />
<u:StringHasValueConverter x:Key="stringHasValue" />
<u:IsNotNullConverter x:Key="notNull" />
<ToolbarItem Text="{u:I18n Cancel}" Clicked="Close_Clicked" Order="Primary" Priority="-1"
x:Key="closeItem" x:Name="_closeItem" />
</ResourceDictionary>
</ContentPage.Resources>
<ScrollView x:Name="_scrollView" Padding="7, 0, 7, 20">
<StackLayout>
<Label
Text="Are you trying to log in?"
Text="{u:I18n AreYouTryingToLogIn}"
FontSize="Title"
FontAttributes="Bold"
Margin="0,14,0,21"/>
<Label
Text="Log in attempt by jtouchstone@bitwarden on bitwaden.com"
Text="{Binding LogInAttempByLabel}"
FontSize="Small"
Margin="0,0,0,24"/>
<Label
Text="Fingerprint phrase"
Text="{u:I18n FingerprintPhrase}"
FontSize="Small"
FontAttributes="Bold"/>
<controls:MonoLabel
Text="longinus-spear-black-moon-scrolls"
FormattedText="{Binding FingerprintPhraseFormatted}"
FontSize="Medium"
Margin="0,0,0,27"/>
<Label
Text="Device Type"
Text="{u:I18n DeviceType}"
FontSize="Small"
FontAttributes="Bold"/>
<Label
Text="Intel Mac OS X 10_15_7"
Text="{Binding DeviceType}"
FontSize="Small"
Margin="0,0,0,21"/>
<Label
Text="IP Address"
Text="{u:I18n IpAddress}"
FontSize="Small"
FontAttributes="Bold"/>
<Label
Text="192.168. 1.1"
Text="{Binding IpAddress}"
FontSize="Small"
Margin="0,0,0,21"/>
<Label
Text="Near"
Text="{u:I18n Near}"
FontSize="Small"
FontAttributes="Bold"/>
<Label
Text="Panama City Beach, FL 32407 USA"
Text="{Binding NearLocation}"
FontSize="Small"
Margin="0,0,0,21"/>
<Label
Text="Time"
Text="{u:I18n Time}"
FontSize="Small"
FontAttributes="Bold"/>
<Label
Text="Just now"
Text="{Binding TimeOfRequest}"
FontSize="Small"
Margin="0,0,0,57"/>
<Button
Text="Confirm Log In"
Text="{u:I18n ConfirmLogIn}"
Margin="0,0,0,17"
StyleClass="btn-primary"/>
<Button
Text="Deny Log In"
Text="{u:I18n DenyLogIn}"
StyleClass="btn-secundary"/>
</StackLayout>
</ScrollView>

View File

@@ -1,16 +1,25 @@
using Bit.App.Models;
using Bit.App.Resources;
using Bit.App.Utilities;
using Bit.Core.Utilities;
using Xamarin.Forms;
namespace Bit.App.Pages
namespace Bit.App.Pages
{
public partial class LoginPasswordlessPage : Bit.App.Pages.BaseContentPage
public partial class LoginPasswordlessPage : BaseContentPage
{
public LoginPasswordlessPage()
private LoginPasswordlessViewModel _vm;
public LoginPasswordlessPage(string email, string deviceType, string ipAddress, string location, string fingerprintPhrase)
{
InitializeComponent();
_vm = BindingContext as LoginPasswordlessViewModel;
_vm.Page = this;
_vm.Email = email;
_vm.DeviceType = deviceType;
_vm.IpAddress = ipAddress;
_vm.NearLocation = location;
_vm.FingerprintPhrase = fingerprintPhrase;
}
protected override void OnAppearing()
{
_vm.InitAsync();
base.OnAppearing();
}
private async void Close_Clicked(object sender, System.EventArgs e)

View File

@@ -1,12 +1,94 @@
using System;
using System.Threading.Tasks;
using Bit.App.Resources;
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
using Xamarin.Forms;
using Bit.App.Utilities;
using System.Linq;
namespace Bit.App.Pages
{
public class LoginPasswordlessViewModel : BaseViewModel
{
private IStateService _stateService;
public string Email { get; set; }
public string LogInAttempByLabel { get; set; }
public string FingerprintPhrase { get; set; }
public FormattedString FingerprintPhraseFormatted { get; set; }
public string DeviceType { get; set; }
public string IpAddress { get; set; }
public string NearLocation { get; set; }
public string TimeOfRequest { get; set; }
public DateTime RequestDate { get; set; }
public LoginPasswordlessViewModel()
{
PageTitle = "Log In requested";
_stateService = ServiceContainer.Resolve<IStateService>("stateService");
PageTitle = AppResources.LogInRequested;
}
public async Task InitAsync()
{
LogInAttempByLabel = string.Format(AppResources.LogInAttemptByOn, Email, "bitwarden login test");
FingerprintPhraseFormatted = CreateFingerprintPhrase();
TimeOfRequest = CreateRequestDate();
UpdateScreen();
}
private FormattedString CreateFingerprintPhrase()
{
var fingerprintList = FingerprintPhrase.Split('-').ToList();
var fs = new FormattedString();
var lastFingerprint = fingerprintList.LastOrDefault();
foreach (var fingerprint in fingerprintList)
{
fs.Spans.Add(new Span
{
Text = fingerprint
});
if(fingerprint == lastFingerprint)
{
break;
}
fs.Spans.Add(new Span
{
Text = "-",
TextColor = ThemeManager.GetResourceColor("DangerColor")
});
}
return fs;
}
private string CreateRequestDate()
{
var minutesSinceRequest = RequestDate.ToUniversalTime().Minute - DateTime.UtcNow.Minute;
if(minutesSinceRequest < 5)
{
return AppResources.JustNow;
}
if(minutesSinceRequest < 59)
{
return $"{minutesSinceRequest} {AppResources.MinutesAgo}";
}
return RequestDate.ToShortTimeString();
}
public void UpdateScreen()
{
TriggerPropertyChanged(nameof(LogInAttempByLabel));
TriggerPropertyChanged(nameof(FingerprintPhraseFormatted));
TriggerPropertyChanged(nameof(DeviceType));
TriggerPropertyChanged(nameof(IpAddress));
TriggerPropertyChanged(nameof(NearLocation));
TriggerPropertyChanged(nameof(TimeOfRequest));
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -2269,4 +2269,40 @@
<data name="AreYouSureYouWantToEnableScreenCapture" xml:space="preserve">
<value>Are you sure you want to enable Screen Capture?</value>
</data>
<data name="LogInRequested" xml:space="preserve">
<value>Log in requested</value>
</data>
<data name="AreYouTryingToLogIn" xml:space="preserve">
<value>Are you trying to log in?</value>
</data>
<data name="LogInAttemptByOn" xml:space="preserve">
<value>Log in attempt by {0} on {1}</value>
</data>
<data name="FingerprintPhrase" xml:space="preserve">
<value>Fingerprint phrase</value>
</data>
<data name="DeviceType" xml:space="preserve">
<value>Device Type</value>
</data>
<data name="IpAddress" xml:space="preserve">
<value>IP Address</value>
</data>
<data name="Time" xml:space="preserve">
<value>Time</value>
</data>
<data name="Near" xml:space="preserve">
<value>Near</value>
</data>
<data name="ConfirmLogIn" xml:space="preserve">
<value>Confirm Log In</value>
</data>
<data name="DenyLogIn" xml:space="preserve">
<value>Deny Log In</value>
</data>
<data name="JustNow" xml:space="preserve">
<value>Just Now</value>
</data>
<data name="MinutesAgo" xml:space="preserve">
<value>minutes ago</value>
</data>
</root>