2016-08-17 05:18:45 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using Bit.Android.Controls;
|
|
|
|
|
using Bit.App.Controls;
|
|
|
|
|
using Xamarin.Forms;
|
|
|
|
|
using Xamarin.Forms.Platform.Android;
|
|
|
|
|
|
|
|
|
|
[assembly: ExportRenderer(typeof(ExtendedButton), typeof(ExtendedButtonRenderer))]
|
|
|
|
|
namespace Bit.Android.Controls
|
|
|
|
|
{
|
|
|
|
|
public class ExtendedButtonRenderer : ButtonRenderer
|
|
|
|
|
{
|
|
|
|
|
protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
|
|
|
|
|
{
|
|
|
|
|
base.OnElementChanged(e);
|
|
|
|
|
SetPadding();
|
2016-08-18 07:20:21 +03:00
|
|
|
|
SetUppercase();
|
2016-08-17 05:18:45 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnElementPropertyChanged(sender, e);
|
|
|
|
|
if(e.PropertyName == ExtendedButton.PaddingProperty.PropertyName)
|
|
|
|
|
{
|
|
|
|
|
SetPadding();
|
|
|
|
|
}
|
2016-08-18 07:20:21 +03:00
|
|
|
|
else if(e.PropertyName == ExtendedButton.UppercaseProperty.PropertyName)
|
|
|
|
|
{
|
|
|
|
|
SetUppercase();
|
|
|
|
|
}
|
2016-08-17 05:18:45 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetPadding()
|
|
|
|
|
{
|
|
|
|
|
var element = Element as ExtendedButton;
|
|
|
|
|
if(element != null)
|
|
|
|
|
{
|
|
|
|
|
Control.SetPadding(
|
|
|
|
|
(int)element.Padding.Left,
|
|
|
|
|
(int)element.Padding.Top,
|
|
|
|
|
(int)element.Padding.Right,
|
|
|
|
|
(int)element.Padding.Bottom);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-18 07:20:21 +03:00
|
|
|
|
|
|
|
|
|
private void SetUppercase()
|
|
|
|
|
{
|
|
|
|
|
var element = Element as ExtendedButton;
|
|
|
|
|
if(element != null && !element.Uppercase)
|
|
|
|
|
{
|
|
|
|
|
Control.TransformationMethod = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-17 05:18:45 +03:00
|
|
|
|
}
|
|
|
|
|
}
|