format BindableProperty & fix a tiny issue about rank page refreshing

This commit is contained in:
2022-03-11 13:17:00 +08:00
parent 71c1a7f0f1
commit f5f16d43f4
25 changed files with 256 additions and 108 deletions

View File

@ -7,24 +7,23 @@ namespace Billing.UI
{
public class WrapLayout : Layout<View>
{
public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create(nameof(ItemsSource), typeof(IList), typeof(WrapLayout), propertyChanged: OnItemsSourcePropertyChanged);
public static readonly BindableProperty ColumnSpacingProperty = BindableProperty.Create(nameof(ColumnSpacing), typeof(double), typeof(WrapLayout), defaultValue: 4d, propertyChanged: (obj, _, _) => ((WrapLayout)obj).InvalidateLayout());
public static readonly BindableProperty RowSpacingProperty = BindableProperty.Create(nameof(RowSpacing), typeof(double), typeof(WrapLayout), defaultValue: 4d, propertyChanged: (obj, _, _) => ((WrapLayout)obj).InvalidateLayout());
public static readonly BindableProperty ItemsSourceProperty = Helper.Create<IList, WrapLayout>(nameof(ItemsSource), propertyChanged: OnItemsSourcePropertyChanged);
public static readonly BindableProperty ColumnSpacingProperty = Helper.Create<double, WrapLayout>(nameof(ColumnSpacing), defaultValue: 4d, propertyChanged: (layout, _, _) => layout.InvalidateLayout());
public static readonly BindableProperty RowSpacingProperty = Helper.Create<double, WrapLayout>(nameof(RowSpacing), defaultValue: 4d, propertyChanged: (layout, _, _) => layout.InvalidateLayout());
private static void OnItemsSourcePropertyChanged(BindableObject obj, object old, object @new)
private static void OnItemsSourcePropertyChanged(WrapLayout layout, IList old, IList list)
{
var itemTemplate = BindableLayout.GetItemTemplate(obj);
var itemTemplate = BindableLayout.GetItemTemplate(layout);
if (itemTemplate == null)
{
return;
}
var layout = (WrapLayout)obj;
if (@new == null)
if (list == null)
{
layout.Children.Clear();
layout.InvalidateLayout();
}
else if (@new is IList list)
else
{
layout.freezed = true;
layout.Children.Clear();