Code formating
This commit is contained in:
Родитель
f47aab436c
Коммит
631f58b2bf
|
@ -43,7 +43,7 @@ namespace HotUI.Forms {
|
|||
|
||||
public static Xamarin.Forms.WebViewSource ToWebViewSource (this string source)
|
||||
{
|
||||
|
||||
|
||||
if (string.IsNullOrWhiteSpace (source)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ namespace HotUI.Forms {
|
|||
return fView.UpdateBaseProperty (property, value);
|
||||
}
|
||||
|
||||
public static Xamarin.Forms.ImageSource ToImageSource(this string source)
|
||||
public static Xamarin.Forms.ImageSource ToImageSource (this string source)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace (source)) {
|
||||
return null;
|
||||
|
@ -96,12 +96,12 @@ namespace HotUI.Forms {
|
|||
public static bool UpdateProperty (this Xamarin.Forms.Entry fView, string property, object value)
|
||||
{
|
||||
switch (property) {
|
||||
case nameof (Entry.Text):
|
||||
fView.Text = (string)value;
|
||||
return true;
|
||||
case nameof (Entry.Placeholder):
|
||||
fView.Placeholder = (string)value;
|
||||
return true;
|
||||
case nameof (Entry.Text):
|
||||
fView.Text = (string)value;
|
||||
return true;
|
||||
case nameof (Entry.Placeholder):
|
||||
fView.Placeholder = (string)value;
|
||||
return true;
|
||||
}
|
||||
return fView.UpdateBaseProperty (property, value);
|
||||
}
|
||||
|
@ -115,9 +115,9 @@ namespace HotUI.Forms {
|
|||
public static bool UpdateProperty (this Xamarin.Forms.Button fView, string property, object value)
|
||||
{
|
||||
switch (property) {
|
||||
case nameof (Button.Text):
|
||||
fView.Text = (string)value;
|
||||
return true;
|
||||
case nameof (Button.Text):
|
||||
fView.Text = (string)value;
|
||||
return true;
|
||||
}
|
||||
return fView.UpdateBaseProperty (property, value);
|
||||
}
|
||||
|
@ -132,9 +132,9 @@ namespace HotUI.Forms {
|
|||
public static bool UpdateProperty (this Xamarin.Forms.Label fView, string property, object value)
|
||||
{
|
||||
switch (property) {
|
||||
case nameof (Label.Text):
|
||||
fView.Text = (string)value;
|
||||
return true;
|
||||
case nameof (Label.Text):
|
||||
fView.Text = (string)value;
|
||||
return true;
|
||||
}
|
||||
return fView.UpdateBaseProperty (property, value);
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@ namespace HotUI.Forms {
|
|||
if (hotPage == null)
|
||||
return null;
|
||||
var handler = hotPage.ViewHandler;
|
||||
if(handler == null) {
|
||||
if (handler == null) {
|
||||
|
||||
handler = Registrar.Pages.GetRenderer (hotPage.GetType ()) as IViewBuilderHandler ;
|
||||
handler = Registrar.Pages.GetRenderer (hotPage.GetType ()) as IViewBuilderHandler;
|
||||
hotPage.ViewHandler = handler;
|
||||
hotPage.ReBuildView ();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace HotUI.Forms {
|
|||
if (button == null)
|
||||
return;
|
||||
Command = new Command ((s) => button.OnClick?.Invoke ());
|
||||
this.UpdateProperties (button) ;
|
||||
this.UpdateProperties (button);
|
||||
}
|
||||
|
||||
public void UpdateValue (string property, object value)
|
||||
|
|
|
@ -5,7 +5,7 @@ using FEntry = Xamarin.Forms.Entry;
|
|||
using HEntry = HotUI.Entry;
|
||||
using HView = HotUI.View;
|
||||
namespace HotUI.Forms {
|
||||
public class EntryHandler : FEntry , HotUI.IViewHandler, IFormsView{
|
||||
public class EntryHandler : FEntry, HotUI.IViewHandler, IFormsView {
|
||||
public EntryHandler ()
|
||||
{
|
||||
this.Focused += FormsControl_Focused;
|
||||
|
|
|
@ -3,7 +3,7 @@ using HotUI;
|
|||
using Xamarin.Forms;
|
||||
|
||||
namespace HotUI.Forms {
|
||||
public class HotPageHandler : ContentPage , IFormsPage, IViewBuilderHandler {
|
||||
public class HotPageHandler : ContentPage, IFormsPage, IViewBuilderHandler {
|
||||
|
||||
public Xamarin.Forms.Page Page => this;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ using FImage = Xamarin.Forms.Image;
|
|||
using HImage = HotUI.Image;
|
||||
using HView = HotUI.View;
|
||||
namespace HotUI.Forms {
|
||||
public class ImageHandler : FImage, IViewHandler, IFormsView {
|
||||
public class ImageHandler : FImage, IViewHandler, IFormsView {
|
||||
public Xamarin.Forms.View View => this;
|
||||
|
||||
public void Remove (HView view)
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace HotUI {
|
|||
|
||||
internal Action StateChanged;
|
||||
|
||||
internal protected Action<BindingObject,List<(string property, object value)>> UpdateParentValueChanged;
|
||||
internal protected Action<BindingObject, List<(string property, object value)>> UpdateParentValueChanged;
|
||||
internal protected string ParentProperty { get; set; }
|
||||
|
||||
BindingState bindingState = new BindingState ();
|
||||
|
@ -27,11 +27,11 @@ namespace HotUI {
|
|||
if (bindingState == value)
|
||||
return;
|
||||
bindingState = value;
|
||||
foreach(var child in bindableChildren) {
|
||||
foreach (var child in bindableChildren) {
|
||||
child.BindingState = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<KeyValuePair<string, object>> ChangedProperties => changeDictionary;
|
||||
|
||||
|
@ -63,7 +63,7 @@ namespace HotUI {
|
|||
|
||||
bool hasChecked = false;
|
||||
static Assembly HotUIAssembly = typeof (BindingObject).Assembly;
|
||||
void CheckForStateAttributes()
|
||||
void CheckForStateAttributes ()
|
||||
{
|
||||
if (hasChecked)
|
||||
return;
|
||||
|
@ -72,7 +72,7 @@ namespace HotUI {
|
|||
// Where (x => Attribute.IsDefined (x, typeof (StateAttribute))).ToList ();
|
||||
var fields = type.GetFields (BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).
|
||||
//ToList ();
|
||||
Where (x => (x.FieldType.Assembly == HotUIAssembly && x.FieldType.Name == "State`1")|| Attribute.IsDefined (x, typeof (StateAttribute))).ToList ();
|
||||
Where (x => (x.FieldType.Assembly == HotUIAssembly && x.FieldType.Name == "State`1") || Attribute.IsDefined (x, typeof (StateAttribute))).ToList ();
|
||||
//if (properties.Any()) {
|
||||
// foreach(var prop in properties) {
|
||||
// var child = prop.GetValue (this) as BindingObject;
|
||||
|
@ -117,7 +117,7 @@ namespace HotUI {
|
|||
internal string [] EndProperty (bool includeParent = false)
|
||||
{
|
||||
var children = bindableChildren.SelectMany (x => x.EndProperty (true));
|
||||
var props = listProperties.Select(x=> includeParent ? $"{ParentProperty}.{x}" : x).Union(children).Distinct ().ToArray ();
|
||||
var props = listProperties.Select (x => includeParent ? $"{ParentProperty}.{x}" : x).Union (children).Distinct ().ToArray ();
|
||||
listProperties.Clear ();
|
||||
return props;
|
||||
|
||||
|
@ -148,7 +148,7 @@ namespace HotUI {
|
|||
|
||||
if (pendingUpdates.Any ()) {
|
||||
if (UpdateParentValueChanged != null) {
|
||||
UpdateParentValueChanged (this,pendingUpdates);
|
||||
UpdateParentValueChanged (this, pendingUpdates);
|
||||
} else if (!BindingState.UpdateValues (pendingUpdates)) {
|
||||
pendingUpdates.Clear ();
|
||||
StateChanged?.Invoke ();
|
||||
|
@ -194,7 +194,7 @@ namespace HotUI {
|
|||
dictionary [propertyName] = value;
|
||||
changeDictionary [propertyName] = value;
|
||||
//If this is tied to a parent, we need to send that notification as well
|
||||
if(!string.IsNullOrWhiteSpace(ParentProperty))
|
||||
if (!string.IsNullOrWhiteSpace (ParentProperty))
|
||||
pendingUpdates.Add (($"{ParentProperty}.{propertyName}", value));
|
||||
pendingUpdates.Add ((propertyName, value));
|
||||
if (!isUpdating) {
|
||||
|
@ -209,7 +209,7 @@ namespace HotUI {
|
|||
void TrackChild (string propertyName, BindingObject child)
|
||||
{
|
||||
//This should fail if there are two properties with the same binding object as it's value. But that should never happen!
|
||||
child.ParentProperty = propertyName;
|
||||
child.ParentProperty = propertyName;
|
||||
child.UpdateParentValueChanged = Child_PropertiesChanged;
|
||||
child.BindingState = this.BindingState;
|
||||
bindableChildren.Add (child);
|
||||
|
|
|
@ -9,6 +9,6 @@ namespace HotUI {
|
|||
}
|
||||
|
||||
public Action OnClick { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Runtime.CompilerServices;
|
|||
|
||||
namespace HotUI {
|
||||
public static class DatabindingExtensions {
|
||||
public static void SetValue<T> (this State state, ref T currentValue, T newValue, Action<string,object> onUpdate, [CallerMemberName] string propertyName = "")
|
||||
public static void SetValue<T> (this State state, ref T currentValue, T newValue, Action<string, object> onUpdate, [CallerMemberName] string propertyName = "")
|
||||
{
|
||||
if (state?.IsBuilding ?? false) {
|
||||
var props = state.EndProperty ();
|
||||
|
@ -16,7 +16,7 @@ namespace HotUI {
|
|||
bool isGlobal = propCount > 1;
|
||||
if (propCount == 1) {
|
||||
var prop = props [0];
|
||||
var stateValue = (T)state.GetValue(prop);
|
||||
var stateValue = (T)state.GetValue (prop);
|
||||
//1 to 1 binding!
|
||||
if (EqualityComparer<T>.Default.Equals (stateValue, newValue)) {
|
||||
state.BindingState.AddViewProperty (prop, onUpdate);
|
||||
|
@ -36,7 +36,7 @@ namespace HotUI {
|
|||
}
|
||||
}
|
||||
currentValue = newValue;
|
||||
onUpdate (propertyName,newValue);
|
||||
onUpdate (propertyName, newValue);
|
||||
}
|
||||
|
||||
public static void SetValue<T> (this View view, State state, ref T currentValue, T newValue, Action<string, object> onUpdate, [CallerMemberName] string propertyName = "")
|
||||
|
@ -54,11 +54,11 @@ namespace HotUI {
|
|||
//Yes if one is IContainer, the other is too!
|
||||
if (newView is IContainerView newContainer && oldView is IContainerView oldContainer) {
|
||||
var newChildren = newContainer.GetChildren ();
|
||||
var oldChildren = oldContainer.GetChildren ().ToList () ;
|
||||
var oldChildren = oldContainer.GetChildren ().ToList ();
|
||||
for (var i = 0; i < Math.Max (newChildren.Count, oldChildren.Count); i++) {
|
||||
var n = newChildren.GetViewAtIndex (i);
|
||||
var o = oldChildren.GetViewAtIndex (i);
|
||||
if(n.AreSameType(o)) {
|
||||
if (n.AreSameType (o)) {
|
||||
Debug.WriteLine ("The controls are the same!");
|
||||
DiffUpdate (n, o);
|
||||
continue;
|
||||
|
@ -84,7 +84,7 @@ namespace HotUI {
|
|||
oldChildren.RemoveAt (i);
|
||||
continue;
|
||||
}
|
||||
if (n1.AreSameType (o)){
|
||||
if (n1.AreSameType (o)) {
|
||||
//The next ones line up, so this was just a new one being inserted!
|
||||
//Lets add an empty one to make them line up
|
||||
|
||||
|
@ -93,7 +93,7 @@ namespace HotUI {
|
|||
oldChildren.Insert (i, null);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//They don't line up. Maybe we check if 2 were inserted? But for now we are just going to say oh well.
|
||||
//The view will jsut be recreated for the restof these!
|
||||
Debug.WriteLine ("Oh WEll");
|
||||
|
@ -108,7 +108,7 @@ namespace HotUI {
|
|||
|
||||
}
|
||||
|
||||
static View GetViewAtIndex(this IReadOnlyList<View> list, int index)
|
||||
static View GetViewAtIndex (this IReadOnlyList<View> list, int index)
|
||||
{
|
||||
if (index >= list.Count)
|
||||
return null;
|
||||
|
@ -119,7 +119,7 @@ namespace HotUI {
|
|||
|
||||
public static bool AreSameType (this View view, View compareView)
|
||||
{
|
||||
|
||||
|
||||
//Add in more edge cases
|
||||
return view?.GetType () == compareView?.GetType ();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace HotUI {
|
|||
string title;
|
||||
public string Title {
|
||||
get => title;
|
||||
set => this.SetValue ( ref title, value, ViewPropertyChanged);
|
||||
set => this.SetValue (ref title, value, ViewPropertyChanged);
|
||||
}
|
||||
|
||||
//public HotPage()
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace HotUI {
|
|||
}
|
||||
|
||||
public class State<T> : BindingObject {
|
||||
public State(T value)
|
||||
public State (T value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace HotUI {
|
|||
public class StateBuilder : IDisposable {
|
||||
static List<State> currentStates = new List<State> ();
|
||||
public static State CurrentState => currentStates.LastOrDefault ();
|
||||
public StateBuilder(State state)
|
||||
public StateBuilder (State state)
|
||||
{
|
||||
State = state;
|
||||
state.StartBuildingView ();
|
||||
|
@ -47,16 +47,17 @@ namespace HotUI {
|
|||
|
||||
[Serializable]
|
||||
public class State : BindingObject {
|
||||
internal object GetValue (string property) {
|
||||
internal object GetValue (string property)
|
||||
{
|
||||
var bindingParts = property.Split ('.');
|
||||
var dict = dictionary;
|
||||
for(var i = 0; i < bindingParts.Length - 1; i++) {
|
||||
for (var i = 0; i < bindingParts.Length - 1; i++) {
|
||||
var part = bindingParts [i];
|
||||
dict.TryGetValue (part, out var val);
|
||||
var child = val as BindingObject;
|
||||
dict = child.dictionary;
|
||||
}
|
||||
dict.TryGetValue (bindingParts.Last(), out var value);
|
||||
dict.TryGetValue (bindingParts.Last (), out var value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче