From 82e8a6901c7a4ecff7ff4c2bfc4bfaf2e8c1cadc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9=20LARIVIERE?= Date: Thu, 2 Feb 2023 11:21:07 +0100 Subject: [PATCH] Add missing yields --- .../Views/Layouts/_CompatLayoutOfView.fs | 21 +++++++++++++++++++ .../Compatibility/Views/_CompatView.fs | 21 ++++++++++++++++++- .../Views/Controls/Partials/_ButtonStroke.fs | 2 -- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/Fabulous.Maui/Compatibility/Views/Layouts/_CompatLayoutOfView.fs b/src/Fabulous.Maui/Compatibility/Views/Layouts/_CompatLayoutOfView.fs index 4b6df7a..c7271b1 100644 --- a/src/Fabulous.Maui/Compatibility/Views/Layouts/_CompatLayoutOfView.fs +++ b/src/Fabulous.Maui/Compatibility/Views/Layouts/_CompatLayoutOfView.fs @@ -1,6 +1,9 @@ namespace Fabulous.Maui.Compatibility +open System.Runtime.CompilerServices open Fabulous +open Fabulous.StackAllocatedCollections +open Microsoft.Maui type IFabCompatLayoutOfView = inherit IFabCompatLayout @@ -8,3 +11,21 @@ type IFabCompatLayoutOfView = module CompatLayoutOfView = let Children = Attributes.defineListWidgetCollection "LayoutOfWidget_Children" (fun target -> (target :?> Microsoft.Maui.Controls.Layout).Children) + +[] +type CollectionBuilderExtensions = + [] + static member inline Yield + ( + _: CollectionBuilder<'msg, #IFabCompatLayoutOfView, IView>, + x: WidgetBuilder<'msg, 'itemType> + ) : Content<'msg> = + { Widgets = MutStackArray1.One(x.Compile()) } + + [] + static member inline Yield + ( + _: CollectionBuilder<'msg, #IFabCompatLayoutOfView, IView>, + x: WidgetBuilder<'msg, Memo.Memoized<#IView>> + ) : Content<'msg> = + { Widgets = MutStackArray1.One(x.Compile()) } \ No newline at end of file diff --git a/src/Fabulous.Maui/Compatibility/Views/_CompatView.fs b/src/Fabulous.Maui/Compatibility/Views/_CompatView.fs index 8eaba81..26b0a8c 100644 --- a/src/Fabulous.Maui/Compatibility/Views/_CompatView.fs +++ b/src/Fabulous.Maui/Compatibility/Views/_CompatView.fs @@ -3,6 +3,7 @@ namespace Fabulous.Maui.Compatibility open System.Runtime.CompilerServices open Fabulous open Fabulous.Maui +open Fabulous.StackAllocatedCollections open Microsoft.Maui open Microsoft.Maui.Controls @@ -84,4 +85,22 @@ type CompatViewModifiers = [] static member inline gestureRecognizers<'msg, 'marker when 'marker :> IFabCompatView>(this: WidgetBuilder<'msg, 'marker>) = - WidgetHelpers.buildAttributeCollection<'msg, 'marker, IGestureRecognizer> CompatView.GestureRecognizers this + WidgetHelpers.buildAttributeCollection<'msg, 'marker, IFabCompatGestureRecognizer> CompatView.GestureRecognizers this + +[] +type CompatViewYieldExtensions = + [] + static member inline Yield + ( + _: AttributeCollectionBuilder<'msg, #IFabCompatView, IFabCompatGestureRecognizer>, + x: WidgetBuilder<'msg, #IFabCompatGestureRecognizer> + ) : Content<'msg> = + { Widgets = MutStackArray1.One(x.Compile()) } + + [] + static member inline Yield + ( + _: AttributeCollectionBuilder<'msg, #IFabCompatView, IFabCompatGestureRecognizer>, + x: WidgetBuilder<'msg, Memo.Memoized<#IFabCompatGestureRecognizer>> + ) : Content<'msg> = + { Widgets = MutStackArray1.One(x.Compile()) } \ No newline at end of file diff --git a/src/Fabulous.Maui/Core/Views/Controls/Partials/_ButtonStroke.fs b/src/Fabulous.Maui/Core/Views/Controls/Partials/_ButtonStroke.fs index 1a9f580..37a8cf5 100644 --- a/src/Fabulous.Maui/Core/Views/Controls/Partials/_ButtonStroke.fs +++ b/src/Fabulous.Maui/Core/Views/Controls/Partials/_ButtonStroke.fs @@ -1,11 +1,9 @@ namespace Fabulous.Maui open System.Runtime.CompilerServices -open Microsoft.Maui open Microsoft.Maui.Graphics open Microsoft.Maui.Handlers.Defaults open Fabulous -open Fabulous.Maui.Controls module ButtonStroke = let CornerRadius =