Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jfversluis committed May 14, 2021
2 parents c885510 + 1f61a48 commit 140a051
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static readonly BindableProperty StateViewsProperty

internal static readonly BindableProperty LayoutControllerProperty
= BindableProperty.CreateAttached("LayoutController", typeof(StateLayoutController), typeof(Layout<View>), default(StateLayoutController),
defaultValueCreator: (b) => new StateLayoutController((Layout<View>)b) { StateViews = GetStateViews(b) ?? new List<StateView>() });
defaultValueCreator: LayoutControllerCreator);

internal static StateLayoutController? GetLayoutController(BindableObject b)
=> (StateLayoutController?)b.GetValue(LayoutControllerProperty);
Expand Down Expand Up @@ -96,5 +96,18 @@ static void OnCurrentCustomStateKeyChanged(BindableObject bindable, string oldVa
break;
}
}

static object LayoutControllerCreator(BindableObject bindable)
{
if (bindable is Layout<View> layoutView)
{
return new StateLayoutController(layoutView)
{
StateViews = GetStateViews(layoutView) ?? new List<StateView>()
};
}

throw new InvalidOperationException($"Cannot create the StateLayoutController. The specified view '{bindable.GetType().FullName}' does not inherit Layout<View>.");
}
}
}

0 comments on commit 140a051

Please sign in to comment.