turn off uppercase for some android buttons

This commit is contained in:
Kyle Spearrin 2016-08-18 00:20:21 -04:00
parent a42c7a5198
commit 1ca4cceec8
4 changed files with 41 additions and 2 deletions

View file

@ -14,6 +14,7 @@ namespace Bit.Android.Controls
{
base.OnElementChanged(e);
SetPadding();
SetUppercase();
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
@ -23,6 +24,10 @@ namespace Bit.Android.Controls
{
SetPadding();
}
else if(e.PropertyName == ExtendedButton.UppercaseProperty.PropertyName)
{
SetUppercase();
}
}
private void SetPadding()
@ -37,5 +42,14 @@ namespace Bit.Android.Controls
(int)element.Padding.Bottom);
}
}
private void SetUppercase()
{
var element = Element as ExtendedButton;
if(element != null && !element.Uppercase)
{
Control.TransformationMethod = null;
}
}
}
}

View file

@ -8,11 +8,20 @@ namespace Bit.App.Controls
{
public static readonly BindableProperty PaddingProperty =
BindableProperty.Create(nameof(Padding), typeof(Thickness), typeof(ExtendedButton), default(Thickness));
public static readonly BindableProperty UppercaseProperty =
BindableProperty.Create(nameof(Padding), typeof(bool), typeof(ExtendedButton),
Device.OS == TargetPlatform.Android ? true : false);
public Thickness Padding
{
get { return (Thickness)GetValue(PaddingProperty); }
set { SetValue(PaddingProperty, value); }
}
public bool Uppercase
{
get { return (bool)GetValue(UppercaseProperty); }
set { SetValue(UppercaseProperty, value); }
}
}
}

View file

@ -90,12 +90,14 @@ namespace Bit.App.Pages
}
};
var forgotPasswordButton = new Button
var forgotPasswordButton = new ExtendedButton
{
Text = "Get your master password hint",
Style = (Style)Application.Current.Resources["btn-primaryAccent"],
Margin = new Thickness(15, 0, 15, 25),
Command = new Command(async () => await ForgotPasswordAsync())
Command = new Command(async () => await ForgotPasswordAsync()),
Uppercase = false,
BackgroundColor = Color.Transparent
};
var layout = new StackLayout

View file

@ -15,6 +15,7 @@ namespace Bit.iOS.Controls
{
base.OnElementChanged(e);
SetPadding();
SetUppercase();
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
@ -24,6 +25,10 @@ namespace Bit.iOS.Controls
{
SetPadding();
}
else if(e.PropertyName == ExtendedButton.UppercaseProperty.PropertyName)
{
SetUppercase();
}
}
private void SetPadding()
@ -38,5 +43,14 @@ namespace Bit.iOS.Controls
(int)element.Padding.Right);
}
}
private void SetUppercase()
{
var element = Element as ExtendedButton;
if(element != null && element.Uppercase)
{
Control.TitleLabel.Text = Control.TitleLabel.Text.ToUpper();
}
}
}
}