mirror of
https://github.com/bitwarden/android.git
synced 2025-01-01 05:48:34 +03:00
4aad34cd75
* Dynamic theme switching and visual tweaks * update action runner to use macos-11 for iOS 15 support * additional tweaks * refinements * refinements * formatting and tweaks
56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
using System.ComponentModel;
|
|
using Android.Content;
|
|
using Android.Graphics.Drawables;
|
|
using AndroidX.Core.Content.Resources;
|
|
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);
|
|
UpdateColor();
|
|
}
|
|
|
|
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
{
|
|
base.OnElementPropertyChanged(sender, e);
|
|
|
|
if (e.PropertyName == ExtendedSlider.ThumbBorderColorProperty.PropertyName)
|
|
{
|
|
UpdateColor();
|
|
}
|
|
}
|
|
|
|
private void UpdateColor()
|
|
{
|
|
if (Control != null && Element is ExtendedSlider view)
|
|
{
|
|
var t = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.slider_thumb, null);
|
|
if (t is GradientDrawable thumb)
|
|
{
|
|
if (view.ThumbColor == Color.Default)
|
|
{
|
|
thumb.SetColor(Color.White.ToAndroid());
|
|
}
|
|
else
|
|
{
|
|
thumb.SetColor(view.ThumbColor.ToAndroid());
|
|
}
|
|
thumb.SetStroke(3, view.ThumbBorderColor.ToAndroid());
|
|
Control.SetThumb(thumb);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|