bitwarden-android/src/Android/Renderers/ExtendedSliderRenderer.cs

34 lines
1.1 KiB
C#
Raw Normal View History

2019-05-13 22:24:38 +03:00
using Android.Content;
using Android.Graphics.Drawables;
using Android.Support.V4.Content.Res;
using Bit.App.Controls;
using Bit.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(ExtendedSlider), typeof(ExtendedSliderRenderer))]
namespace Bit.Droid.Renderers
{
public class ExtendedSliderRenderer : SliderRenderer
{
public ExtendedSliderRenderer(Context context)
: base(context)
{}
protected override void OnElementChanged(ElementChangedEventArgs<Slider> e)
{
base.OnElementChanged(e);
if(Control != null && Element is ExtendedSlider view)
{
var t = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.slider_thumb, null);
if(t is GradientDrawable thumb)
{
thumb.SetColor(view.ThumbColor.ToAndroid());
thumb.SetStroke(1, view.ThumbBorderColor.ToAndroid());
Control.SetThumb(thumb);
}
}
}
}
}