This commit is contained in:
Jon Lipsky 2019-07-12 09:25:27 -05:00
Родитель 66562d873c
Коммит 0a3d82b4df
4 изменённых файлов: 19 добавлений и 5 удалений

Просмотреть файл

@ -2,7 +2,7 @@ using System;
namespace HotUI namespace HotUI
{ {
public class Binding<T> public class Binding<T> : IBinding
{ {
public Binding(Func<T> getValue, Action<T> setValue) public Binding(Func<T> getValue, Action<T> setValue)
{ {
@ -12,10 +12,11 @@ namespace HotUI
public Func<T> Get { get; } public Func<T> Get { get; }
public Action<T> Set { 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>( public static implicit operator Binding<T>(T value) => new Binding<T>(
getValue:() => value, getValue:() => value,
setValue: null) { Implicit = true }; setValue: null) { ImplicitFromValue = true };
} }
} }

Просмотреть файл

@ -9,7 +9,7 @@ namespace HotUI
float from = 0, float from = 0,
float through = 100, float through = 100,
float by = 1, float by = 1,
Action<float> onEditingChanged = null) : base(value?.Implicit ?? false) Action<float> onEditingChanged = null) : base(value)
{ {
ValueBinding = value?.Get; ValueBinding = value?.Get;
From = from; From = from;

Просмотреть файл

@ -40,6 +40,12 @@ namespace HotUI {
} }
public NavigationView Navigation { get; set; } public NavigationView Navigation { get; set; }
protected State State { get; set; } protected State State { get; set; }
protected View(IBinding binding) : this(binding?.ImplicitFromValue ?? false)
{
}
public View (bool hasConstructors) public View (bool hasConstructors)
{ {
ActiveViews.Add (this); ActiveViews.Add (this);

7
src/HotUI/IBinding.cs Normal file
Просмотреть файл

@ -0,0 +1,7 @@
namespace HotUI
{
public interface IBinding
{
bool ImplicitFromValue { get; set; }
}
}