Moved logic to view.
This commit is contained in:
Родитель
66562d873c
Коммит
0a3d82b4df
|
@ -2,7 +2,7 @@ using System;
|
|||
|
||||
namespace HotUI
|
||||
{
|
||||
public class Binding<T>
|
||||
public class Binding<T> : IBinding
|
||||
{
|
||||
public Binding(Func<T> getValue, Action<T> setValue)
|
||||
{
|
||||
|
@ -12,10 +12,11 @@ namespace HotUI
|
|||
|
||||
public Func<T> Get { get; }
|
||||
public Action<T> Set { get; }
|
||||
public bool Implicit { get; set; }
|
||||
|
||||
public bool ImplicitFromValue { get; set; }
|
||||
|
||||
public static implicit operator Binding<T>(T value) => new Binding<T>(
|
||||
getValue:() => value,
|
||||
setValue: null) { Implicit = true };
|
||||
setValue: null) { ImplicitFromValue = true };
|
||||
}
|
||||
}
|
|
@ -5,11 +5,11 @@ namespace HotUI
|
|||
public class Slider : View
|
||||
{
|
||||
public Slider (
|
||||
Binding<float> value = null,
|
||||
Binding<float> value = null,
|
||||
float from = 0,
|
||||
float through = 100,
|
||||
float by = 1,
|
||||
Action<float> onEditingChanged = null) : base(value?.Implicit ?? false)
|
||||
Action<float> onEditingChanged = null) : base(value)
|
||||
{
|
||||
ValueBinding = value?.Get;
|
||||
From = from;
|
||||
|
|
|
@ -40,6 +40,12 @@ namespace HotUI {
|
|||
}
|
||||
public NavigationView Navigation { get; set; }
|
||||
protected State State { get; set; }
|
||||
|
||||
protected View(IBinding binding) : this(binding?.ImplicitFromValue ?? false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public View (bool hasConstructors)
|
||||
{
|
||||
ActiveViews.Add (this);
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
namespace HotUI
|
||||
{
|
||||
public interface IBinding
|
||||
{
|
||||
bool ImplicitFromValue { get; set; }
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче