2021-10-08 15:47:40 +03:00
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using Android.Content;
|
2019-05-13 22:24:38 +03:00
|
|
|
|
using Android.Graphics.Drawables;
|
2020-03-21 00:54:23 +03:00
|
|
|
|
using AndroidX.Core.Content.Resources;
|
2019-05-13 22:24:38 +03:00
|
|
|
|
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);
|
2021-10-08 15:47:40 +03:00
|
|
|
|
UpdateColor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnElementPropertyChanged(sender, e);
|
|
|
|
|
|
|
|
|
|
if (e.PropertyName == ExtendedSlider.ThumbBorderColorProperty.PropertyName)
|
|
|
|
|
{
|
|
|
|
|
UpdateColor();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateColor()
|
|
|
|
|
{
|
2020-03-28 16:16:28 +03:00
|
|
|
|
if (Control != null && Element is ExtendedSlider view)
|
2019-05-13 22:24:38 +03:00
|
|
|
|
{
|
|
|
|
|
var t = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.slider_thumb, null);
|
2020-03-28 16:16:28 +03:00
|
|
|
|
if (t is GradientDrawable thumb)
|
2019-05-13 22:24:38 +03:00
|
|
|
|
{
|
2020-03-28 16:16:28 +03:00
|
|
|
|
if (view.ThumbColor == Color.Default)
|
2019-06-22 16:45:54 +03:00
|
|
|
|
{
|
|
|
|
|
thumb.SetColor(Color.White.ToAndroid());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
thumb.SetColor(view.ThumbColor.ToAndroid());
|
|
|
|
|
}
|
2019-05-31 18:03:32 +03:00
|
|
|
|
thumb.SetStroke(3, view.ThumbBorderColor.ToAndroid());
|
2019-05-13 22:24:38 +03:00
|
|
|
|
Control.SetThumb(thumb);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|