[Tizen] Fix material style slider issue (#12708)
This commit is contained in:
Родитель
defad083c7
Коммит
3a47d0f7b4
|
@ -8,13 +8,22 @@ namespace Xamarin.Forms.Material.Tizen
|
|||
{
|
||||
public class MaterialSliderRenderer : SliderRenderer
|
||||
{
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<Slider> e)
|
||||
protected override ElmSharp.Slider CreateNativeControl()
|
||||
{
|
||||
if (Control == null)
|
||||
{
|
||||
SetNativeControl(new MSlider(Forms.NativeParent));
|
||||
}
|
||||
base.OnElementChanged(e);
|
||||
return new MSlider(Forms.NativeParent);
|
||||
}
|
||||
|
||||
protected override void UpdateMinimumTrackColor()
|
||||
{
|
||||
var color = Element.MinimumTrackColor.IsDefault ? MColors.Current.PrimaryColor : Element.MinimumTrackColor.ToNative();
|
||||
Control.SetPartColor(Parts.Slider.Bar, color);
|
||||
Control.SetPartColor(Parts.Slider.BarPressed, color);
|
||||
}
|
||||
|
||||
protected override void UpdateMaximumTrackColor()
|
||||
{
|
||||
var color = Element.MaximumTrackColor.IsDefault ? MColors.Current.PrimaryColor.WithAlpha(0.5) : Element.MaximumTrackColor.ToNative();
|
||||
Control.SetPartColor(Parts.Widget.Background, color);
|
||||
}
|
||||
|
||||
protected override void UpdateThumbColor()
|
||||
|
@ -22,6 +31,8 @@ namespace Xamarin.Forms.Material.Tizen
|
|||
var color = Element.ThumbColor.IsDefault ? MColors.Current.PrimaryColor : Element.ThumbColor.ToNative();
|
||||
Control.SetPartColor(Parts.Slider.Handler, color);
|
||||
Control.SetPartColor(Parts.Slider.HandlerPressed, color);
|
||||
Control.SetPartColor(Parts.Slider.Handler2, color.WithAlpha(0.32));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Xamarin.Forms.Platform.Tizen
|
|||
{
|
||||
if (Control == null)
|
||||
{
|
||||
SetNativeControl(new ESlider(Forms.NativeParent));
|
||||
SetNativeControl(CreateNativeControl());
|
||||
Control.ValueChanged += OnValueChanged;
|
||||
Control.DragStarted += OnDragStarted;
|
||||
Control.DragStopped += OnDragStopped;
|
||||
|
@ -24,6 +24,7 @@ namespace Xamarin.Forms.Platform.Tizen
|
|||
_defaultMaxColor = Control.GetBackgroundColor();
|
||||
_defaultThumbColor = Control.GetHandlerColor();
|
||||
}
|
||||
|
||||
UpdateMinimum();
|
||||
UpdateMaximum();
|
||||
UpdateValue();
|
||||
|
@ -31,6 +32,11 @@ namespace Xamarin.Forms.Platform.Tizen
|
|||
base.OnElementChanged(e);
|
||||
}
|
||||
|
||||
protected virtual ESlider CreateNativeControl()
|
||||
{
|
||||
return new ESlider(Forms.NativeParent);
|
||||
}
|
||||
|
||||
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == Slider.MinimumProperty.PropertyName)
|
||||
|
@ -109,13 +115,13 @@ namespace Xamarin.Forms.Platform.Tizen
|
|||
Control.Maximum = Element.Maximum;
|
||||
}
|
||||
|
||||
protected void UpdateMinimumTrackColor()
|
||||
protected virtual void UpdateMinimumTrackColor()
|
||||
{
|
||||
var color = Element.MinimumTrackColor.IsDefault ? _defaultMinColor : Element.MinimumTrackColor.ToNative();
|
||||
Control.SetBarColor(color);
|
||||
}
|
||||
|
||||
protected void UpdateMaximumTrackColor()
|
||||
protected virtual void UpdateMaximumTrackColor()
|
||||
{
|
||||
Control.SetBackgroundColor(Element.MaximumTrackColor.IsDefault ? _defaultMaxColor : Element.MaximumTrackColor.ToNative());
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче