1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-27 12:26:31 +01:00

wrap username and password at full font size

This commit is contained in:
Kyle Spearrin 2017-08-28 17:46:28 -04:00
parent 801829ccbf
commit 32a8676572
2 changed files with 2 additions and 46 deletions

View File

@ -39,31 +39,9 @@ namespace Bit.App.Models.Page
_username = value; _username = value;
PropertyChanged(this, new PropertyChangedEventArgs(nameof(Username))); PropertyChanged(this, new PropertyChangedEventArgs(nameof(Username)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(ShowUsername))); PropertyChanged(this, new PropertyChangedEventArgs(nameof(ShowUsername)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(UsernameFontSize)));
} }
} }
public bool ShowUsername => !string.IsNullOrWhiteSpace(Username); public bool ShowUsername => !string.IsNullOrWhiteSpace(Username);
public double UsernameFontSize
{
get
{
if(Device.RuntimePlatform == Device.Android)
{
var length = Username?.Length ?? 0;
if(length > 35)
{
return Device.GetNamedSize(NamedSize.Micro, typeof(Label));
}
else if(length > 25)
{
return Device.GetNamedSize(NamedSize.Small, typeof(Label));
}
}
return Device.GetNamedSize(NamedSize.Medium, typeof(Label));
}
}
public string Password public string Password
{ {
@ -74,31 +52,9 @@ namespace Bit.App.Models.Page
PropertyChanged(this, new PropertyChangedEventArgs(nameof(Password))); PropertyChanged(this, new PropertyChangedEventArgs(nameof(Password)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(MaskedPassword))); PropertyChanged(this, new PropertyChangedEventArgs(nameof(MaskedPassword)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(ShowPassword))); PropertyChanged(this, new PropertyChangedEventArgs(nameof(ShowPassword)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(PasswordFontSize)));
} }
} }
public bool ShowPassword => !string.IsNullOrWhiteSpace(Password); public bool ShowPassword => !string.IsNullOrWhiteSpace(Password);
public double PasswordFontSize
{
get
{
if(Device.RuntimePlatform == Device.Android)
{
var length = Password?.Length ?? 0;
if(length > 25)
{
return Device.GetNamedSize(NamedSize.Micro, typeof(Label));
}
else if(length > 20)
{
return Device.GetNamedSize(NamedSize.Small, typeof(Label));
}
}
return Device.GetNamedSize(NamedSize.Medium, typeof(Label));
}
}
public string Uri public string Uri
{ {

View File

@ -63,14 +63,13 @@ namespace Bit.App.Pages
// Username // Username
UsernameCell = new LabeledValueCell(AppResources.Username, button1Text: AppResources.Copy); UsernameCell = new LabeledValueCell(AppResources.Username, button1Text: AppResources.Copy);
UsernameCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.Username)); UsernameCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.Username));
UsernameCell.Value.SetBinding(Label.FontSizeProperty, nameof(VaultViewLoginPageModel.UsernameFontSize));
UsernameCell.Button1.Command = new Command(() => Copy(Model.Username, AppResources.Username)); UsernameCell.Button1.Command = new Command(() => Copy(Model.Username, AppResources.Username));
UsernameCell.Value.LineBreakMode = LineBreakMode.WordWrap;
// Password // Password
PasswordCell = new LabeledValueCell(AppResources.Password, button1Text: string.Empty, PasswordCell = new LabeledValueCell(AppResources.Password, button1Text: string.Empty,
button2Text: AppResources.Copy); button2Text: AppResources.Copy);
PasswordCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.MaskedPassword)); PasswordCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.MaskedPassword));
PasswordCell.Value.SetBinding(Label.FontSizeProperty, nameof(VaultViewLoginPageModel.PasswordFontSize));
PasswordCell.Button1.SetBinding(Button.ImageProperty, nameof(VaultViewLoginPageModel.ShowHideImage)); PasswordCell.Button1.SetBinding(Button.ImageProperty, nameof(VaultViewLoginPageModel.ShowHideImage));
if(Device.RuntimePlatform == Device.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
@ -79,6 +78,7 @@ namespace Bit.App.Pages
PasswordCell.Button1.Command = new Command(() => Model.RevealPassword = !Model.RevealPassword); PasswordCell.Button1.Command = new Command(() => Model.RevealPassword = !Model.RevealPassword);
PasswordCell.Button2.Command = new Command(() => Copy(Model.Password, AppResources.Password)); PasswordCell.Button2.Command = new Command(() => Copy(Model.Password, AppResources.Password));
PasswordCell.Value.FontFamily = Helpers.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier"); PasswordCell.Value.FontFamily = Helpers.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier");
PasswordCell.Value.LineBreakMode = LineBreakMode.WordWrap;
// URI // URI
UriCell = new LabeledValueCell(AppResources.Website, button1Text: AppResources.Launch); UriCell = new LabeledValueCell(AppResources.Website, button1Text: AppResources.Launch);