From 74ad1b6d7f954de7edabec705aec67d4a91bb7e8 Mon Sep 17 00:00:00 2001 From: Adolfo Marinucci Date: Sat, 6 Jan 2024 01:25:48 +0100 Subject: [PATCH] Fixing bugs with the new pattern + Inline component simplification --- .github/workflows/build-deploy.yml | 2 +- .../Pages/InlineComponentsPage.cs | 3 +- src/MauiReactor.Scaffold/TypeGenerator.cs | 45 ++++++++++++++++++- src/MauiReactor.Scaffold/TypeGenerator.tt | 8 +++- src/MauiReactor/BaseShellItem.cs | 4 ++ src/MauiReactor/Button.cs | 6 +++ src/MauiReactor/CarouselView.cs | 4 ++ src/MauiReactor/Cell.cs | 6 +++ src/MauiReactor/CheckBox.cs | 2 + src/MauiReactor/Compatibility/Layout.cs | 2 + src/MauiReactor/Component.cs | 18 ++++++-- src/MauiReactor/ContentPage.partial.cs | 13 +++++- src/MauiReactor/DatePicker.cs | 2 + src/MauiReactor/DragGestureRecognizer.cs | 4 ++ src/MauiReactor/DropGestureRecognizer.cs | 6 +++ src/MauiReactor/Editor.cs | 2 + src/MauiReactor/Element.cs | 16 +++++++ src/MauiReactor/Entry.cs | 2 + src/MauiReactor/EntryCell.cs | 2 + src/MauiReactor/FlyoutPage.cs | 2 + src/MauiReactor/GraphicsView.cs | 14 ++++++ src/MauiReactor/ImageButton.cs | 6 +++ src/MauiReactor/ImageButton.partial.cs | 12 +++++ src/MauiReactor/InlineComponent.cs | 42 ++++++++--------- src/MauiReactor/InputView.cs | 2 + src/MauiReactor/ItemsView.cs | 6 +++ src/MauiReactor/ListView.cs | 12 +++++ src/MauiReactor/MenuItem.cs | 2 + src/MauiReactor/MultiPage`1.cs | 4 ++ src/MauiReactor/NavigationPage.cs | 6 +++ src/MauiReactor/Page.cs | 12 +++++ src/MauiReactor/PanGestureRecognizer.cs | 2 + src/MauiReactor/Picker.cs | 2 + src/MauiReactor/PinchGestureRecognizer.cs | 3 ++ src/MauiReactor/PointerGestureRecognizer.cs | 11 +++++ src/MauiReactor/RadioButton.cs | 2 + src/MauiReactor/RefreshView.cs | 2 + src/MauiReactor/ReorderableItemsView.cs | 2 + src/MauiReactor/ScrollView.cs | 2 + src/MauiReactor/SearchBar.cs | 2 + src/MauiReactor/SelectableItemsView.cs | 2 + src/MauiReactor/Shapes/GeometryGroup.cs | 2 + src/MauiReactor/Shell.cs | 4 ++ src/MauiReactor/Slider.cs | 6 +++ src/MauiReactor/Stepper.cs | 2 + src/MauiReactor/SwipeGestureRecognizer.cs | 2 + src/MauiReactor/SwipeItem.cs | 2 + src/MauiReactor/SwipeItems.cs | 2 + src/MauiReactor/SwipeView.cs | 6 +++ src/MauiReactor/Switch.cs | 2 + src/MauiReactor/SwitchCell.cs | 2 + src/MauiReactor/TapGestureRecognizer.cs | 2 + src/MauiReactor/View.partial.cs | 25 ----------- src/MauiReactor/VisualElement.cs | 14 ++++++ src/MauiReactor/VisualElement.partial.cs | 32 ++++++++++++- src/MauiReactor/WebView.cs | 4 ++ src/MauiReactor/Window.cs | 28 ++++++++++++ 57 files changed, 376 insertions(+), 56 deletions(-) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 35e362e1..b02c886a 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -15,7 +15,7 @@ jobs: env: Solution_Name: ./src/MauiReactor.Build.sln TemplatePack_Name: ./src/MauiReactor.TemplatePack/MauiReactor.TemplatePack.csproj - Version: 2.0.14-beta + Version: 2.0.15-beta steps: - name: Checkout diff --git a/samples/MauiReactor.TestApp/Pages/InlineComponentsPage.cs b/samples/MauiReactor.TestApp/Pages/InlineComponentsPage.cs index b5052164..cc24e75d 100644 --- a/samples/MauiReactor.TestApp/Pages/InlineComponentsPage.cs +++ b/samples/MauiReactor.TestApp/Pages/InlineComponentsPage.cs @@ -27,9 +27,8 @@ static class Buttons { public static VisualNode IncrementButton() { - return Component.Render(context => + return Component.Render(state => { - var state = context.UseState(); return new Button( state.Value == 0 ? "Click me!" : $"Counter is {state.Value}", () => state.Set(s => ++s)); diff --git a/src/MauiReactor.Scaffold/TypeGenerator.cs b/src/MauiReactor.Scaffold/TypeGenerator.cs index 4a08e051..6c45dfa4 100644 --- a/src/MauiReactor.Scaffold/TypeGenerator.cs +++ b/src/MauiReactor.Scaffold/TypeGenerator.cs @@ -506,7 +506,7 @@ public virtual string TransformText() " "); #line 1 "C:\Source\github\reactorui-maui\src\MauiReactor.Scaffold\TypeGenerator.tt" - if (Properties.Length > 0) { + if (Properties.Length > 0 || Events.Length > 0) { #line default #line hidden @@ -554,6 +554,49 @@ public virtual string TransformText() #line hidden this.Write("\n "); + #line 1 "C:\Source\github\reactorui-maui\src\MauiReactor.Scaffold\TypeGenerator.tt" + foreach (var ev in Events) { + var genericArgs = ev.EventHandlerType.GetGenericArguments(); + + #line default + #line hidden + this.Write("\n thisAs"); + + #line 1 "C:\Source\github\reactorui-maui\src\MauiReactor.Scaffold\TypeGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(InterfaceName())); + + #line default + #line hidden + this.Write("."); + + #line 1 "C:\Source\github\reactorui-maui\src\MauiReactor.Scaffold\TypeGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ev.Name)); + + #line default + #line hidden + this.Write("Action = null;\n thisAs"); + + #line 1 "C:\Source\github\reactorui-maui\src\MauiReactor.Scaffold\TypeGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(InterfaceName())); + + #line default + #line hidden + this.Write("."); + + #line 1 "C:\Source\github\reactorui-maui\src\MauiReactor.Scaffold\TypeGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ev.Name)); + + #line default + #line hidden + this.Write("ActionWithArgs = null;\n "); + + #line 1 "C:\Source\github\reactorui-maui\src\MauiReactor.Scaffold\TypeGenerator.tt" + } + + #line default + #line hidden + this.Write("\n\n "); + #line 1 "C:\Source\github\reactorui-maui\src\MauiReactor.Scaffold\TypeGenerator.tt" } diff --git a/src/MauiReactor.Scaffold/TypeGenerator.tt b/src/MauiReactor.Scaffold/TypeGenerator.tt index 0031caee..765699cf 100644 --- a/src/MauiReactor.Scaffold/TypeGenerator.tt +++ b/src/MauiReactor.Scaffold/TypeGenerator.tt @@ -118,11 +118,17 @@ public abstract partial class <#= TypeName() #> : <#= BaseTypeName() #>, < { base.Reset(); - <# if (Properties.Length > 0) { #> + <# if (Properties.Length > 0 || Events.Length > 0) { #> var thisAs<#= InterfaceName() #> = (<#= InterfaceName() #>)this; <# foreach (var property in Properties) { #> thisAs<#= InterfaceName() #>.<#= property.Name #> = null; <# } #> + <# foreach (var ev in Events) { + var genericArgs = ev.EventHandlerType.GetGenericArguments(); #> + thisAs<#= InterfaceName() #>.<#= ev.Name #>Action = null; + thisAs<#= InterfaceName() #>.<#= ev.Name #>ActionWithArgs = null; + <# } #> + <# } #> OnReset(); diff --git a/src/MauiReactor/BaseShellItem.cs b/src/MauiReactor/BaseShellItem.cs index 4e88f33d..8c392477 100644 --- a/src/MauiReactor/BaseShellItem.cs +++ b/src/MauiReactor/BaseShellItem.cs @@ -68,6 +68,10 @@ internal override void Reset() thisAsIBaseShellItem.IsEnabled = null; thisAsIBaseShellItem.Title = null; thisAsIBaseShellItem.IsVisible = null; + thisAsIBaseShellItem.AppearingAction = null; + thisAsIBaseShellItem.AppearingActionWithArgs = null; + thisAsIBaseShellItem.DisappearingAction = null; + thisAsIBaseShellItem.DisappearingActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/Button.cs b/src/MauiReactor/Button.cs index eab80f65..b14d8bcb 100644 --- a/src/MauiReactor/Button.cs +++ b/src/MauiReactor/Button.cs @@ -126,6 +126,12 @@ internal override void Reset() thisAsIButton.ImageSource = null; thisAsIButton.Padding = null; thisAsIButton.LineBreakMode = null; + thisAsIButton.ClickedAction = null; + thisAsIButton.ClickedActionWithArgs = null; + thisAsIButton.PressedAction = null; + thisAsIButton.PressedActionWithArgs = null; + thisAsIButton.ReleasedAction = null; + thisAsIButton.ReleasedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/CarouselView.cs b/src/MauiReactor/CarouselView.cs index fe89af07..65b21ef4 100644 --- a/src/MauiReactor/CarouselView.cs +++ b/src/MauiReactor/CarouselView.cs @@ -78,6 +78,10 @@ internal override void Reset() thisAsICarouselView.IsScrollAnimated = null; thisAsICarouselView.CurrentItem = null; thisAsICarouselView.Position = null; + thisAsICarouselView.CurrentItemChangedAction = null; + thisAsICarouselView.CurrentItemChangedActionWithArgs = null; + thisAsICarouselView.PositionChangedAction = null; + thisAsICarouselView.PositionChangedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/Cell.cs b/src/MauiReactor/Cell.cs index 4512e4cf..38408de3 100644 --- a/src/MauiReactor/Cell.cs +++ b/src/MauiReactor/Cell.cs @@ -56,6 +56,12 @@ internal override void Reset() base.Reset(); var thisAsICell = (ICell)this; thisAsICell.IsEnabled = null; + thisAsICell.AppearingAction = null; + thisAsICell.AppearingActionWithArgs = null; + thisAsICell.DisappearingAction = null; + thisAsICell.DisappearingActionWithArgs = null; + thisAsICell.TappedAction = null; + thisAsICell.TappedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/CheckBox.cs b/src/MauiReactor/CheckBox.cs index cf6e0d1c..a4ce1ea8 100644 --- a/src/MauiReactor/CheckBox.cs +++ b/src/MauiReactor/CheckBox.cs @@ -45,6 +45,8 @@ internal override void Reset() var thisAsICheckBox = (ICheckBox)this; thisAsICheckBox.IsChecked = null; thisAsICheckBox.Color = null; + thisAsICheckBox.CheckedChangedAction = null; + thisAsICheckBox.CheckedChangedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/Compatibility/Layout.cs b/src/MauiReactor/Compatibility/Layout.cs index 0b7d2c89..f9ac1432 100644 --- a/src/MauiReactor/Compatibility/Layout.cs +++ b/src/MauiReactor/Compatibility/Layout.cs @@ -50,6 +50,8 @@ internal override void Reset() thisAsILayout.IsClippedToBounds = null; thisAsILayout.CascadeInputTransparent = null; thisAsILayout.Padding = null; + thisAsILayout.LayoutChangedAction = null; + thisAsILayout.LayoutChangedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/Component.cs b/src/MauiReactor/Component.cs index e44700b0..bf1a73bc 100644 --- a/src/MauiReactor/Component.cs +++ b/src/MauiReactor/Component.cs @@ -216,11 +216,21 @@ public static IServiceProvider Services { var parameterContext = new ParameterContext(this); return parameterContext.Get(name) ?? throw new InvalidOperationException($"Unable to find parameter with name '{name ?? typeof(T).FullName}'"); - } - - public static VisualNode Render(Func renderFunc) + } + protected IParameter GetOrCreateParameter(string? name = null) where T : new() + { + var parameterContext = new ParameterContext(this); + return parameterContext.Get(name) ?? parameterContext.Create(name); + } + + //public static VisualNode Render(Func renderFunc) + //{ + // return new InlineComponent(renderFunc); + //} + + public static VisualNode Render(Func, VisualNode> renderFunc, S? defaultValue = default) { - return new InlineComponent(renderFunc); + return new InlineComponent(renderFunc, defaultValue); } } diff --git a/src/MauiReactor/ContentPage.partial.cs b/src/MauiReactor/ContentPage.partial.cs index a3431ef7..bcb71409 100644 --- a/src/MauiReactor/ContentPage.partial.cs +++ b/src/MauiReactor/ContentPage.partial.cs @@ -55,5 +55,16 @@ public static ContentPage ContentPage(string title) => GetNodeFromPool().Title(title); public static ContentPage ContentPage(string title, params VisualNode?[]? children) - => ContentPage(children).Title(title); + => ContentPage(children).Title(title); +} + +public static partial class ContentPageExtensions +{ + public static T HasNavigationBar(this T contentPage, bool hasNavigationBar) + where T : IContentPage, IVisualNodeWithAttachedProperties + { + contentPage.Set(Microsoft.Maui.Controls.NavigationPage.HasNavigationBarProperty, hasNavigationBar); + return contentPage; + } + } diff --git a/src/MauiReactor/DatePicker.cs b/src/MauiReactor/DatePicker.cs index 4e7437ec..2e033b01 100644 --- a/src/MauiReactor/DatePicker.cs +++ b/src/MauiReactor/DatePicker.cs @@ -85,6 +85,8 @@ internal override void Reset() thisAsIDatePicker.FontSize = null; thisAsIDatePicker.FontAttributes = null; thisAsIDatePicker.FontAutoScalingEnabled = null; + thisAsIDatePicker.DateSelectedAction = null; + thisAsIDatePicker.DateSelectedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/DragGestureRecognizer.cs b/src/MauiReactor/DragGestureRecognizer.cs index 10b17f46..cc6f3cf8 100644 --- a/src/MauiReactor/DragGestureRecognizer.cs +++ b/src/MauiReactor/DragGestureRecognizer.cs @@ -48,6 +48,10 @@ internal override void Reset() base.Reset(); var thisAsIDragGestureRecognizer = (IDragGestureRecognizer)this; thisAsIDragGestureRecognizer.CanDrag = null; + thisAsIDragGestureRecognizer.DropCompletedAction = null; + thisAsIDragGestureRecognizer.DropCompletedActionWithArgs = null; + thisAsIDragGestureRecognizer.DragStartingAction = null; + thisAsIDragGestureRecognizer.DragStartingActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/DropGestureRecognizer.cs b/src/MauiReactor/DropGestureRecognizer.cs index b3d9d08b..14b12c2a 100644 --- a/src/MauiReactor/DropGestureRecognizer.cs +++ b/src/MauiReactor/DropGestureRecognizer.cs @@ -56,6 +56,12 @@ internal override void Reset() base.Reset(); var thisAsIDropGestureRecognizer = (IDropGestureRecognizer)this; thisAsIDropGestureRecognizer.AllowDrop = null; + thisAsIDropGestureRecognizer.DragLeaveAction = null; + thisAsIDropGestureRecognizer.DragLeaveActionWithArgs = null; + thisAsIDropGestureRecognizer.DragOverAction = null; + thisAsIDropGestureRecognizer.DragOverActionWithArgs = null; + thisAsIDropGestureRecognizer.DropAction = null; + thisAsIDropGestureRecognizer.DropActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/Editor.cs b/src/MauiReactor/Editor.cs index da4a0d70..f04e5250 100644 --- a/src/MauiReactor/Editor.cs +++ b/src/MauiReactor/Editor.cs @@ -50,6 +50,8 @@ internal override void Reset() thisAsIEditor.AutoSize = null; thisAsIEditor.HorizontalTextAlignment = null; thisAsIEditor.VerticalTextAlignment = null; + thisAsIEditor.CompletedAction = null; + thisAsIEditor.CompletedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/Element.cs b/src/MauiReactor/Element.cs index 5a982b47..f7b72501 100644 --- a/src/MauiReactor/Element.cs +++ b/src/MauiReactor/Element.cs @@ -101,6 +101,22 @@ internal override void Reset() var thisAsIElement = (IElement)this; thisAsIElement.AutomationId = null; thisAsIElement.ClassId = null; + thisAsIElement.ChildAddedAction = null; + thisAsIElement.ChildAddedActionWithArgs = null; + thisAsIElement.ChildRemovedAction = null; + thisAsIElement.ChildRemovedActionWithArgs = null; + thisAsIElement.DescendantAddedAction = null; + thisAsIElement.DescendantAddedActionWithArgs = null; + thisAsIElement.DescendantRemovedAction = null; + thisAsIElement.DescendantRemovedActionWithArgs = null; + thisAsIElement.ParentChangingAction = null; + thisAsIElement.ParentChangingActionWithArgs = null; + thisAsIElement.ParentChangedAction = null; + thisAsIElement.ParentChangedActionWithArgs = null; + thisAsIElement.HandlerChangingAction = null; + thisAsIElement.HandlerChangingActionWithArgs = null; + thisAsIElement.HandlerChangedAction = null; + thisAsIElement.HandlerChangedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/Entry.cs b/src/MauiReactor/Entry.cs index bbc83e8d..34c82894 100644 --- a/src/MauiReactor/Entry.cs +++ b/src/MauiReactor/Entry.cs @@ -60,6 +60,8 @@ internal override void Reset() thisAsIEntry.HorizontalTextAlignment = null; thisAsIEntry.VerticalTextAlignment = null; thisAsIEntry.ClearButtonVisibility = null; + thisAsIEntry.CompletedAction = null; + thisAsIEntry.CompletedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/EntryCell.cs b/src/MauiReactor/EntryCell.cs index 8d72e71e..8ef55a1a 100644 --- a/src/MauiReactor/EntryCell.cs +++ b/src/MauiReactor/EntryCell.cs @@ -70,6 +70,8 @@ internal override void Reset() thisAsIEntryCell.Keyboard = null; thisAsIEntryCell.HorizontalTextAlignment = null; thisAsIEntryCell.VerticalTextAlignment = null; + thisAsIEntryCell.CompletedAction = null; + thisAsIEntryCell.CompletedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/FlyoutPage.cs b/src/MauiReactor/FlyoutPage.cs index 69d451d7..eeffed7b 100644 --- a/src/MauiReactor/FlyoutPage.cs +++ b/src/MauiReactor/FlyoutPage.cs @@ -50,6 +50,8 @@ internal override void Reset() thisAsIFlyoutPage.IsGestureEnabled = null; thisAsIFlyoutPage.IsPresented = null; thisAsIFlyoutPage.FlyoutLayoutBehavior = null; + thisAsIFlyoutPage.IsPresentedChangedAction = null; + thisAsIFlyoutPage.IsPresentedChangedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/GraphicsView.cs b/src/MauiReactor/GraphicsView.cs index 9fdb515a..f6af87a3 100644 --- a/src/MauiReactor/GraphicsView.cs +++ b/src/MauiReactor/GraphicsView.cs @@ -88,6 +88,20 @@ internal override void Reset() base.Reset(); var thisAsIGraphicsView = (IGraphicsView)this; thisAsIGraphicsView.Drawable = null; + thisAsIGraphicsView.StartHoverInteractionAction = null; + thisAsIGraphicsView.StartHoverInteractionActionWithArgs = null; + thisAsIGraphicsView.MoveHoverInteractionAction = null; + thisAsIGraphicsView.MoveHoverInteractionActionWithArgs = null; + thisAsIGraphicsView.EndHoverInteractionAction = null; + thisAsIGraphicsView.EndHoverInteractionActionWithArgs = null; + thisAsIGraphicsView.StartInteractionAction = null; + thisAsIGraphicsView.StartInteractionActionWithArgs = null; + thisAsIGraphicsView.DragInteractionAction = null; + thisAsIGraphicsView.DragInteractionActionWithArgs = null; + thisAsIGraphicsView.EndInteractionAction = null; + thisAsIGraphicsView.EndInteractionActionWithArgs = null; + thisAsIGraphicsView.CancelInteractionAction = null; + thisAsIGraphicsView.CancelInteractionActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/ImageButton.cs b/src/MauiReactor/ImageButton.cs index e046a54e..234f9bd0 100644 --- a/src/MauiReactor/ImageButton.cs +++ b/src/MauiReactor/ImageButton.cs @@ -86,6 +86,12 @@ internal override void Reset() thisAsIImageButton.Aspect = null; thisAsIImageButton.IsOpaque = null; thisAsIImageButton.Padding = null; + thisAsIImageButton.ClickedAction = null; + thisAsIImageButton.ClickedActionWithArgs = null; + thisAsIImageButton.PressedAction = null; + thisAsIImageButton.PressedActionWithArgs = null; + thisAsIImageButton.ReleasedAction = null; + thisAsIImageButton.ReleasedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/ImageButton.partial.cs b/src/MauiReactor/ImageButton.partial.cs index 56bc9fb9..74e622d5 100644 --- a/src/MauiReactor/ImageButton.partial.cs +++ b/src/MauiReactor/ImageButton.partial.cs @@ -2,10 +2,22 @@ namespace MauiReactor; +public partial class ImageButton +{ + partial void OnReset() + { + var thisAsIImageButton = (IImageButton)this; + System.Diagnostics.Debug.Assert(thisAsIImageButton.ClickedAction == null); + System.Diagnostics.Debug.Assert(thisAsIImageButton.ClickedActionWithArgs == null); + } +} + public partial class ImageButton { public ImageButton(string imageSource) => this.Source(imageSource); public ImageButton(Uri imageSource) => this.Source(imageSource); + + } public partial class Component diff --git a/src/MauiReactor/InlineComponent.cs b/src/MauiReactor/InlineComponent.cs index 3793b2e4..d193808e 100644 --- a/src/MauiReactor/InlineComponent.cs +++ b/src/MauiReactor/InlineComponent.cs @@ -2,18 +2,20 @@ namespace MauiReactor { - public class InlineComponent : Component + public class InlineComponent : Component { - private readonly Func _renderFunc; + private readonly Func, VisualNode> _renderFunc; + private readonly S? _defaultValue; - public InlineComponent(Func renderFunc) + public InlineComponent(Func, VisualNode> renderFunc, S? defaultValue) { _renderFunc = renderFunc; + _defaultValue = defaultValue; } public override VisualNode Render() { - return _renderFunc(new ComponentContext(this)); + return _renderFunc(new ComponentContextState(this, _defaultValue)); } internal void SetStateCore(object? newStateValue, bool invalidateComponent = true) @@ -30,10 +32,10 @@ internal void SetStateCore(object? newStateValue, TimeSpan delay, bool invalidat public class ComponentContextState { - private readonly InlineComponent _component; + private readonly InlineComponent _component; private readonly S? _initialState; - internal ComponentContextState(InlineComponent component, S? initialState = default) + internal ComponentContextState(InlineComponent component, S? initialState = default) { _component = component; _initialState = initialState; @@ -60,23 +62,23 @@ public void Set(Func setStateFunction, int delayMilliseconds, bool inval } } - public class ComponentContext - { - private readonly InlineComponent _component; + //public class ComponentContext + //{ + // private readonly InlineComponent _component; - internal ComponentContext(InlineComponent component) - { - _component = component; - } + // internal ComponentContext(InlineComponent component) + // { + // _component = component; + // } - public ComponentContextState UseState() - => new(_component); - public ComponentContextState UseState(S defaultValue) - => new(_component, defaultValue); + // public ComponentContextState UseState() + // => new(_component); + // public ComponentContextState UseState(S defaultValue) + // => new(_component, defaultValue); - public IServiceProvider Services - => ServiceCollectionProvider.ServiceProvider; - } + // public IServiceProvider Services + // => ServiceCollectionProvider.ServiceProvider; + //} public class InlineComponentState { diff --git a/src/MauiReactor/InputView.cs b/src/MauiReactor/InputView.cs index d87b5c5a..be73e88c 100644 --- a/src/MauiReactor/InputView.cs +++ b/src/MauiReactor/InputView.cs @@ -120,6 +120,8 @@ internal override void Reset() thisAsIInputView.FontSize = null; thisAsIInputView.FontAttributes = null; thisAsIInputView.FontAutoScalingEnabled = null; + thisAsIInputView.TextChangedAction = null; + thisAsIInputView.TextChangedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/ItemsView.cs b/src/MauiReactor/ItemsView.cs index 93048d2b..ae8b0863 100644 --- a/src/MauiReactor/ItemsView.cs +++ b/src/MauiReactor/ItemsView.cs @@ -71,6 +71,12 @@ internal override void Reset() thisAsIItemsView.VerticalScrollBarVisibility = null; thisAsIItemsView.RemainingItemsThreshold = null; thisAsIItemsView.ItemsUpdatingScrollMode = null; + thisAsIItemsView.ScrollToRequestedAction = null; + thisAsIItemsView.ScrollToRequestedActionWithArgs = null; + thisAsIItemsView.ScrolledAction = null; + thisAsIItemsView.ScrolledActionWithArgs = null; + thisAsIItemsView.RemainingItemsThresholdReachedAction = null; + thisAsIItemsView.RemainingItemsThresholdReachedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/ListView.cs b/src/MauiReactor/ListView.cs index 067c0a1b..5b8858f2 100644 --- a/src/MauiReactor/ListView.cs +++ b/src/MauiReactor/ListView.cs @@ -135,6 +135,18 @@ internal override void Reset() thisAsIListView.RefreshControlColor = null; thisAsIListView.HorizontalScrollBarVisibility = null; thisAsIListView.VerticalScrollBarVisibility = null; + thisAsIListView.ItemAppearingAction = null; + thisAsIListView.ItemAppearingActionWithArgs = null; + thisAsIListView.ItemDisappearingAction = null; + thisAsIListView.ItemDisappearingActionWithArgs = null; + thisAsIListView.ItemSelectedAction = null; + thisAsIListView.ItemSelectedActionWithArgs = null; + thisAsIListView.ItemTappedAction = null; + thisAsIListView.ItemTappedActionWithArgs = null; + thisAsIListView.ScrolledAction = null; + thisAsIListView.ScrolledActionWithArgs = null; + thisAsIListView.RefreshingAction = null; + thisAsIListView.RefreshingActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/MenuItem.cs b/src/MauiReactor/MenuItem.cs index fd1617c9..c65993bf 100644 --- a/src/MauiReactor/MenuItem.cs +++ b/src/MauiReactor/MenuItem.cs @@ -50,6 +50,8 @@ internal override void Reset() thisAsIMenuItem.IsDestructive = null; thisAsIMenuItem.IconImageSource = null; thisAsIMenuItem.Text = null; + thisAsIMenuItem.ClickedAction = null; + thisAsIMenuItem.ClickedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/MultiPage`1.cs b/src/MauiReactor/MultiPage`1.cs index b5e68328..eb149b16 100644 --- a/src/MauiReactor/MultiPage`1.cs +++ b/src/MauiReactor/MultiPage`1.cs @@ -49,6 +49,10 @@ internal override void Reset() base.Reset(); var thisAsIGenericMultiPage = (IGenericMultiPage)this; thisAsIGenericMultiPage.SelectedItem = null; + thisAsIGenericMultiPage.CurrentPageChangedAction = null; + thisAsIGenericMultiPage.CurrentPageChangedActionWithArgs = null; + thisAsIGenericMultiPage.PagesChangedAction = null; + thisAsIGenericMultiPage.PagesChangedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/NavigationPage.cs b/src/MauiReactor/NavigationPage.cs index 33d12de3..796ba468 100644 --- a/src/MauiReactor/NavigationPage.cs +++ b/src/MauiReactor/NavigationPage.cs @@ -66,6 +66,12 @@ internal override void Reset() thisAsINavigationPage.BarBackgroundColor = null; thisAsINavigationPage.BarBackground = null; thisAsINavigationPage.BarTextColor = null; + thisAsINavigationPage.PoppedAction = null; + thisAsINavigationPage.PoppedActionWithArgs = null; + thisAsINavigationPage.PoppedToRootAction = null; + thisAsINavigationPage.PoppedToRootActionWithArgs = null; + thisAsINavigationPage.PushedAction = null; + thisAsINavigationPage.PushedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/Page.cs b/src/MauiReactor/Page.cs index 2b34ae8b..925803c0 100644 --- a/src/MauiReactor/Page.cs +++ b/src/MauiReactor/Page.cs @@ -100,6 +100,18 @@ internal override void Reset() thisAsIPage.Padding = null; thisAsIPage.Title = null; thisAsIPage.IconImageSource = null; + thisAsIPage.LayoutChangedAction = null; + thisAsIPage.LayoutChangedActionWithArgs = null; + thisAsIPage.AppearingAction = null; + thisAsIPage.AppearingActionWithArgs = null; + thisAsIPage.DisappearingAction = null; + thisAsIPage.DisappearingActionWithArgs = null; + thisAsIPage.NavigatedToAction = null; + thisAsIPage.NavigatedToActionWithArgs = null; + thisAsIPage.NavigatingFromAction = null; + thisAsIPage.NavigatingFromActionWithArgs = null; + thisAsIPage.NavigatedFromAction = null; + thisAsIPage.NavigatedFromActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/PanGestureRecognizer.cs b/src/MauiReactor/PanGestureRecognizer.cs index 4d4319c5..dcf89733 100644 --- a/src/MauiReactor/PanGestureRecognizer.cs +++ b/src/MauiReactor/PanGestureRecognizer.cs @@ -40,6 +40,8 @@ internal override void Reset() base.Reset(); var thisAsIPanGestureRecognizer = (IPanGestureRecognizer)this; thisAsIPanGestureRecognizer.TouchPoints = null; + thisAsIPanGestureRecognizer.PanUpdatedAction = null; + thisAsIPanGestureRecognizer.PanUpdatedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/Picker.cs b/src/MauiReactor/Picker.cs index 7ff81b62..12968a0f 100644 --- a/src/MauiReactor/Picker.cs +++ b/src/MauiReactor/Picker.cs @@ -90,6 +90,8 @@ internal override void Reset() thisAsIPicker.FontAutoScalingEnabled = null; thisAsIPicker.HorizontalTextAlignment = null; thisAsIPicker.VerticalTextAlignment = null; + thisAsIPicker.SelectedIndexChangedAction = null; + thisAsIPicker.SelectedIndexChangedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/PinchGestureRecognizer.cs b/src/MauiReactor/PinchGestureRecognizer.cs index 712bff56..7ce98b66 100644 --- a/src/MauiReactor/PinchGestureRecognizer.cs +++ b/src/MauiReactor/PinchGestureRecognizer.cs @@ -34,6 +34,9 @@ public PinchGestureRecognizer(Action? GestureRecognizers { get; set; } - - List? Behaviors { get; set; } } public abstract partial class View { List? IView.GestureRecognizers { get; set; } - List? IView.Behaviors { get; set; } partial void OnReset() { var thisAsIView = (IView)this; thisAsIView.GestureRecognizers = null; - thisAsIView.Behaviors = null; } protected override void OnChildAdd(VisualNode node) @@ -30,14 +26,6 @@ protected override void OnChildAdd(VisualNode node) thisAsIView.GestureRecognizers.Add(gestureRecognizer); return; } - else if (node is IBehavior behavior) - { - var thisAsIView = (IView)this; - thisAsIView.Behaviors ??= new List(); - thisAsIView.Behaviors.Add(behavior); - return; - } - base.OnChildAdd(node); } @@ -50,11 +38,6 @@ protected override IEnumerable RenderChildren() if (thisAsIView.GestureRecognizers != null) { children = children.Concat(thisAsIView.GestureRecognizers.Cast()); - } - - if (thisAsIView.Behaviors != null) - { - children = children.Concat(thisAsIView.Behaviors.Cast()); } return children; @@ -71,10 +54,6 @@ protected override void OnAddChild(VisualNode widget, BindableObject childContro else if (childControl is Microsoft.Maui.Controls.MenuFlyout menuFlyout) { NativeControl.SetPropertyValue(FlyoutBase.ContextFlyoutProperty, menuFlyout); - } - else if (childControl is Microsoft.Maui.Controls.Behavior behavior) - { - NativeControl.Behaviors.Add(behavior); } base.OnAddChild(widget, childControl); @@ -92,10 +71,6 @@ protected override void OnRemoveChild(VisualNode widget, BindableObject childCon { NativeControl.SetPropertyValue(FlyoutBase.ContextFlyoutProperty, null); } - else if (childControl is Microsoft.Maui.Controls.Behavior behavior) - { - NativeControl.Behaviors.Remove(behavior); - } base.OnRemoveChild(widget, childControl); diff --git a/src/MauiReactor/VisualElement.cs b/src/MauiReactor/VisualElement.cs index 537d939e..711abb9a 100644 --- a/src/MauiReactor/VisualElement.cs +++ b/src/MauiReactor/VisualElement.cs @@ -208,6 +208,20 @@ internal override void Reset() thisAsIVisualElement.MaximumHeightRequest = null; thisAsIVisualElement.FlowDirection = null; thisAsIVisualElement.ZIndex = null; + thisAsIVisualElement.ChildrenReorderedAction = null; + thisAsIVisualElement.ChildrenReorderedActionWithArgs = null; + thisAsIVisualElement.FocusedAction = null; + thisAsIVisualElement.FocusedActionWithArgs = null; + thisAsIVisualElement.MeasureInvalidatedAction = null; + thisAsIVisualElement.MeasureInvalidatedActionWithArgs = null; + thisAsIVisualElement.SizeChangedAction = null; + thisAsIVisualElement.SizeChangedActionWithArgs = null; + thisAsIVisualElement.UnfocusedAction = null; + thisAsIVisualElement.UnfocusedActionWithArgs = null; + thisAsIVisualElement.LoadedAction = null; + thisAsIVisualElement.LoadedActionWithArgs = null; + thisAsIVisualElement.UnloadedAction = null; + thisAsIVisualElement.UnloadedActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/VisualElement.partial.cs b/src/MauiReactor/VisualElement.partial.cs index 490a92c0..f6c0ebc5 100644 --- a/src/MauiReactor/VisualElement.partial.cs +++ b/src/MauiReactor/VisualElement.partial.cs @@ -9,6 +9,7 @@ public partial interface IVisualElement Shapes.IGeometry? Clip { get; set; } IShadow? Shadow { get; set; } VisualStateGroupList? VisualStateGroups { get; set; } + List? Behaviors { get; set; } } public abstract partial class VisualElement @@ -19,12 +20,28 @@ public abstract partial class VisualElement VisualStateGroupList? IVisualElement.VisualStateGroups { get; set; } + List? IVisualElement.Behaviors { get; set; } + partial void OnReset() { var thisAsIVisualElement = (IVisualElement)this; thisAsIVisualElement.Clip = null; thisAsIVisualElement.Shadow = null; - thisAsIVisualElement.VisualStateGroups = null; + thisAsIVisualElement.VisualStateGroups = null; + thisAsIVisualElement.Behaviors = null; + } + + protected override void OnChildAdd(VisualNode node) + { + if (node is IBehavior behavior) + { + var thisAsIVisualElement = (IVisualElement)this; + thisAsIVisualElement.Behaviors ??= []; + thisAsIVisualElement.Behaviors.Add(behavior); + return; + } + + base.OnChildAdd(node); } protected override void OnMount() @@ -55,6 +72,11 @@ protected override IEnumerable RenderChildren() if (thisAsIVisualElement.Shadow != null) { children = children.Concat(new[] { (VisualNode)thisAsIVisualElement.Shadow }); + } + + if (thisAsIVisualElement.Behaviors != null) + { + children = children.Concat(thisAsIVisualElement.Behaviors.Cast()); } return children; @@ -75,6 +97,10 @@ protected override void OnAddChild(VisualNode widget, BindableObject childNative childNativeControl is Microsoft.Maui.Controls.Shadow shadow) { NativeControl.Shadow = shadow; + } + else if (childNativeControl is Microsoft.Maui.Controls.Behavior behavior) + { + NativeControl.Behaviors.Add(behavior); } base.OnAddChild(widget, childNativeControl); @@ -95,6 +121,10 @@ protected override void OnRemoveChild(VisualNode widget, BindableObject childNat childNativeControl is Microsoft.Maui.Controls.Shadow) { NativeControl.Shadow = null!; + } + else if (childNativeControl is Microsoft.Maui.Controls.Behavior behavior) + { + NativeControl.Behaviors.Remove(behavior); } base.OnRemoveChild(widget, childNativeControl); diff --git a/src/MauiReactor/WebView.cs b/src/MauiReactor/WebView.cs index 5119b0b9..5343e38a 100644 --- a/src/MauiReactor/WebView.cs +++ b/src/MauiReactor/WebView.cs @@ -58,6 +58,10 @@ internal override void Reset() thisAsIWebView.Source = null; thisAsIWebView.UserAgent = null; thisAsIWebView.Cookies = null; + thisAsIWebView.NavigatedAction = null; + thisAsIWebView.NavigatedActionWithArgs = null; + thisAsIWebView.NavigatingAction = null; + thisAsIWebView.NavigatingActionWithArgs = null; OnReset(); } diff --git a/src/MauiReactor/Window.cs b/src/MauiReactor/Window.cs index f110420c..3341aabe 100644 --- a/src/MauiReactor/Window.cs +++ b/src/MauiReactor/Window.cs @@ -189,6 +189,34 @@ internal override void Reset() thisAsIWindow.MaximumHeight = null; thisAsIWindow.MinimumWidth = null; thisAsIWindow.MinimumHeight = null; + thisAsIWindow.SizeChangedAction = null; + thisAsIWindow.SizeChangedActionWithArgs = null; + thisAsIWindow.ModalPoppedAction = null; + thisAsIWindow.ModalPoppedActionWithArgs = null; + thisAsIWindow.ModalPoppingAction = null; + thisAsIWindow.ModalPoppingActionWithArgs = null; + thisAsIWindow.ModalPushedAction = null; + thisAsIWindow.ModalPushedActionWithArgs = null; + thisAsIWindow.ModalPushingAction = null; + thisAsIWindow.ModalPushingActionWithArgs = null; + thisAsIWindow.PopCanceledAction = null; + thisAsIWindow.PopCanceledActionWithArgs = null; + thisAsIWindow.CreatedAction = null; + thisAsIWindow.CreatedActionWithArgs = null; + thisAsIWindow.ResumedAction = null; + thisAsIWindow.ResumedActionWithArgs = null; + thisAsIWindow.ActivatedAction = null; + thisAsIWindow.ActivatedActionWithArgs = null; + thisAsIWindow.DeactivatedAction = null; + thisAsIWindow.DeactivatedActionWithArgs = null; + thisAsIWindow.StoppedAction = null; + thisAsIWindow.StoppedActionWithArgs = null; + thisAsIWindow.DestroyingAction = null; + thisAsIWindow.DestroyingActionWithArgs = null; + thisAsIWindow.BackgroundingAction = null; + thisAsIWindow.BackgroundingActionWithArgs = null; + thisAsIWindow.DisplayDensityChangedAction = null; + thisAsIWindow.DisplayDensityChangedActionWithArgs = null; OnReset(); }