adjust font sizse for username/password if they are over certain lengths on vault view page.

This commit is contained in:
Kyle Spearrin 2016-10-30 00:02:07 -04:00
parent 428e35237f
commit 4a0e3227fc
2 changed files with 47 additions and 0 deletions

View File

@ -36,9 +36,31 @@ namespace Bit.App.Models.Page
_username = value;
PropertyChanged(this, new PropertyChangedEventArgs(nameof(Username)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(ShowUsername)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(UsernameFontSize)));
}
}
public bool ShowUsername => !string.IsNullOrWhiteSpace(Username);
public double UsernameFontSize
{
get
{
if(Device.OS == TargetPlatform.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
{
@ -48,9 +70,32 @@ namespace Bit.App.Models.Page
_password = value;
PropertyChanged(this, new PropertyChangedEventArgs(nameof(Password)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(MaskedPassword)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(ShowPassword)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(PasswordFontSize)));
}
}
public bool ShowPassword => !string.IsNullOrWhiteSpace(Password);
public double PasswordFontSize
{
get
{
if(Device.OS == TargetPlatform.Android)
{
var length = Password?.Length ?? 0;
if(length > 25)
{
return Device.GetNamedSize(NamedSize.Micro, typeof(Label));
}
else if(length > 15)
{
return Device.GetNamedSize(NamedSize.Small, typeof(Label));
}
}
return Device.GetNamedSize(NamedSize.Medium, typeof(Label));
}
}
public string Uri
{

View File

@ -49,12 +49,14 @@ namespace Bit.App.Pages
// Username
UsernameCell = new LabeledValueCell(AppResources.Username, button1Text: AppResources.Copy);
UsernameCell.Value.SetBinding<VaultViewSitePageModel>(Label.TextProperty, s => s.Username);
UsernameCell.Value.SetBinding<VaultViewSitePageModel>(Label.FontSizeProperty, s => s.UsernameFontSize);
UsernameCell.Button1.Command = new Command(() => Copy(Model.Username, AppResources.Username));
// Password
PasswordCell = new LabeledValueCell(AppResources.Password, button1Text: string.Empty,
button2Text: AppResources.Copy);
PasswordCell.Value.SetBinding<VaultViewSitePageModel>(Label.TextProperty, s => s.MaskedPassword);
PasswordCell.Value.SetBinding<VaultViewSitePageModel>(Label.FontSizeProperty, s => s.PasswordFontSize);
PasswordCell.Button1.SetBinding<VaultViewSitePageModel>(Button.ImageProperty, s => s.ShowHideImage);
if(Device.OS == TargetPlatform.iOS)
{