From bba59493111a4e179745ae387aa3f6f70f5bc8d4 Mon Sep 17 00:00:00 2001 From: Oleksandr Liakhevych Date: Mon, 14 Aug 2023 00:55:33 +0300 Subject: [PATCH] ComponentGenerator: generate all elements from assembly (#136) --- .../MDBaseLazyView.generated.cs | 32 +++ .../MDCheckBox.generated.cs | 141 +++++++++++ .../Material.Components/MDChip.generated.cs | 225 ++++++++++++++++++ .../MDContextMenu.generated.cs | 80 +++++++ .../Material.Components/MDFAB.generated.cs | 206 ++++++++++++++++ .../MDIconButton.generated.cs | 133 +++++++++++ .../MDNavigationBarItem.generated.cs | 216 +++++++++++++++++ .../MDNavigationDrawer.generated.cs | 125 ++++++++++ .../MDNavigationDrawerItem.generated.cs | 182 ++++++++++++++ .../MDRadioButton.generated.cs | 79 ++++++ .../MDRadioButtonItem.generated.cs | 141 +++++++++++ .../MDSKTouchCanvasView.generated.cs | 132 ++++++++++ .../MDSplitView.generated.cs | 76 ++++++ .../Material.Components/MDSwitch.generated.cs | 173 ++++++++++++++ .../MDTabItem.generated.cs | 200 ++++++++++++++++ .../Material.Components/MDTabs.generated.cs | 96 ++++++++ .../Properties/Elements.cs | 18 +- .../ThirdPartyControlsSample.csproj | 1 + .../Extensions/SymbolExtensions.cs | 15 ++ .../GenerateComponentData.cs | 13 +- .../GeneratedPropertyInfo.cs | 2 +- .../GeneratedTypeInfo.cs | 15 +- .../Program.cs | 32 ++- ...GenerateComponentsFromAssemblyAttribute.cs | 9 + 24 files changed, 2312 insertions(+), 30 deletions(-) create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDBaseLazyView.generated.cs create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDCheckBox.generated.cs create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDChip.generated.cs create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDContextMenu.generated.cs create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDFAB.generated.cs create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDIconButton.generated.cs create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDNavigationBarItem.generated.cs create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDNavigationDrawer.generated.cs create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDNavigationDrawerItem.generated.cs create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDRadioButton.generated.cs create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDRadioButtonItem.generated.cs create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDSKTouchCanvasView.generated.cs create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDSplitView.generated.cs create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDSwitch.generated.cs create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDTabItem.generated.cs create mode 100644 samples/ThirdPartyControlsSample/Elements/Material.Components/MDTabs.generated.cs create mode 100644 src/BlazorBindings.Maui/ComponentGenerator/GenerateComponentsFromAssemblyAttribute.cs diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDBaseLazyView.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDBaseLazyView.generated.cs new file mode 100644 index 00000000..bffe5860 --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDBaseLazyView.generated.cs @@ -0,0 +1,32 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public abstract partial class MDBaseLazyView : BlazorBindings.Maui.Elements.ContentView + { + static MDBaseLazyView() + { + RegisterAdditionalHandlers(); + } + + public new MCM.BaseLazyView NativeControl => (MCM.BaseLazyView)((BindableObject)this).NativeControl; + + + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDCheckBox.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDCheckBox.generated.cs new file mode 100644 index 00000000..3d6dbf97 --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDCheckBox.generated.cs @@ -0,0 +1,141 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using Microsoft.Maui.Graphics; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public partial class MDCheckBox : SKTouchCanvasView + { + static MDCheckBox() + { + RegisterAdditionalHandlers(); + } + + [Parameter] public Color ForegroundColor { get; set; } + [Parameter] public bool? IsChecked { get; set; } + [Parameter] public Color MarkColor { get; set; } + [Parameter] public float? MarkOpacity { get; set; } + [Parameter] public Color OnColor { get; set; } + [Parameter] public float? OnOpacity { get; set; } + [Parameter] public Color OutlineColor { get; set; } + [Parameter] public int? OutlineWidth { get; set; } + [Parameter] public Color RippleColor { get; set; } + [Parameter] public Color StateLayerColor { get; set; } + [Parameter] public EventCallback IsCheckedChanged { get; set; } + + public new MCM.CheckBox NativeControl => (MCM.CheckBox)((BindableObject)this).NativeControl; + + protected override MCM.CheckBox CreateNativeElement() => new(); + + protected override void HandleParameter(string name, object value) + { + switch (name) + { + case nameof(ForegroundColor): + if (!Equals(ForegroundColor, value)) + { + ForegroundColor = (Color)value; + NativeControl.ForegroundColor = ForegroundColor; + } + break; + case nameof(IsChecked): + if (!Equals(IsChecked, value)) + { + IsChecked = (bool?)value; + NativeControl.IsChecked = IsChecked ?? (bool)MCM.CheckBox.IsCheckedProperty.DefaultValue; + } + break; + case nameof(MarkColor): + if (!Equals(MarkColor, value)) + { + MarkColor = (Color)value; + NativeControl.MarkColor = MarkColor; + } + break; + case nameof(MarkOpacity): + if (!Equals(MarkOpacity, value)) + { + MarkOpacity = (float?)value; + NativeControl.MarkOpacity = MarkOpacity ?? (float)MCM.CheckBox.MarkOpacityProperty.DefaultValue; + } + break; + case nameof(OnColor): + if (!Equals(OnColor, value)) + { + OnColor = (Color)value; + NativeControl.OnColor = OnColor; + } + break; + case nameof(OnOpacity): + if (!Equals(OnOpacity, value)) + { + OnOpacity = (float?)value; + NativeControl.OnOpacity = OnOpacity ?? (float)MCM.CheckBox.OnOpacityProperty.DefaultValue; + } + break; + case nameof(OutlineColor): + if (!Equals(OutlineColor, value)) + { + OutlineColor = (Color)value; + NativeControl.OutlineColor = OutlineColor; + } + break; + case nameof(OutlineWidth): + if (!Equals(OutlineWidth, value)) + { + OutlineWidth = (int?)value; + NativeControl.OutlineWidth = OutlineWidth ?? (int)MCM.CheckBox.OutlineWidthProperty.DefaultValue; + } + break; + case nameof(RippleColor): + if (!Equals(RippleColor, value)) + { + RippleColor = (Color)value; + NativeControl.RippleColor = RippleColor; + } + break; + case nameof(StateLayerColor): + if (!Equals(StateLayerColor, value)) + { + StateLayerColor = (Color)value; + NativeControl.StateLayerColor = StateLayerColor; + } + break; + case nameof(IsCheckedChanged): + if (!Equals(IsCheckedChanged, value)) + { + void NativeControlCheckedChanged(object sender, MC.CheckedChangedEventArgs e) + { + var value = NativeControl.IsChecked; + IsChecked = value; + InvokeEventCallback(IsCheckedChanged, value); + } + + IsCheckedChanged = (EventCallback)value; + NativeControl.CheckedChanged -= NativeControlCheckedChanged; + NativeControl.CheckedChanged += NativeControlCheckedChanged; + } + break; + + default: + base.HandleParameter(name, value); + break; + } + } + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDChip.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDChip.generated.cs new file mode 100644 index 00000000..d52891db --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDChip.generated.cs @@ -0,0 +1,225 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using Microsoft.Maui.Graphics; +using System; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public partial class MDChip : SKTouchCanvasView + { + static MDChip() + { + RegisterAdditionalHandlers(); + } + + [Parameter] public Color BackgroundColour { get; set; } + [Parameter] public MCM.Tokens.Elevation? Elevation { get; set; } + [Parameter] public string FontFamily { get; set; } + [Parameter] public bool? FontItalic { get; set; } + [Parameter] public float? FontSize { get; set; } + [Parameter] public int? FontWeight { get; set; } + [Parameter] public Color ForegroundColor { get; set; } + [Parameter] public bool? HasCloseIcon { get; set; } + [Parameter] public Color IconColor { get; set; } + [Parameter] public string IconData { get; set; } + [Parameter] public global::IconPacks.Material.IconKind? IconKind { get; set; } + [Parameter] public global::SkiaSharp.SKPicture IconSource { get; set; } + [Parameter] public bool? IsChecked { get; set; } + [Parameter] public Color OutlineColor { get; set; } + [Parameter] public int? OutlineWidth { get; set; } + [Parameter] public Color RippleColor { get; set; } + [Parameter] public MCM.Tokens.Shape? Shape { get; set; } + [Parameter] public Color StateLayerColor { get; set; } + [Parameter] public string Text { get; set; } + [Parameter] public EventCallback IsCheckedChanged { get; set; } + [Parameter] public EventCallback OnClosed { get; set; } + + public new MCM.Chip NativeControl => (MCM.Chip)((BindableObject)this).NativeControl; + + protected override MCM.Chip CreateNativeElement() => new(); + + protected override void HandleParameter(string name, object value) + { + switch (name) + { + case nameof(BackgroundColour): + if (!Equals(BackgroundColour, value)) + { + BackgroundColour = (Color)value; + NativeControl.BackgroundColour = BackgroundColour; + } + break; + case nameof(Elevation): + if (!Equals(Elevation, value)) + { + Elevation = (MCM.Tokens.Elevation?)value; + NativeControl.Elevation = Elevation ?? (MCM.Tokens.Elevation)MCM.Chip.ElevationProperty.DefaultValue; + } + break; + case nameof(FontFamily): + if (!Equals(FontFamily, value)) + { + FontFamily = (string)value; + NativeControl.FontFamily = FontFamily; + } + break; + case nameof(FontItalic): + if (!Equals(FontItalic, value)) + { + FontItalic = (bool?)value; + NativeControl.FontItalic = FontItalic ?? (bool)MCM.Chip.FontItalicProperty.DefaultValue; + } + break; + case nameof(FontSize): + if (!Equals(FontSize, value)) + { + FontSize = (float?)value; + NativeControl.FontSize = FontSize ?? (float)MCM.Chip.FontSizeProperty.DefaultValue; + } + break; + case nameof(FontWeight): + if (!Equals(FontWeight, value)) + { + FontWeight = (int?)value; + NativeControl.FontWeight = FontWeight ?? (int)MCM.Chip.FontWeightProperty.DefaultValue; + } + break; + case nameof(ForegroundColor): + if (!Equals(ForegroundColor, value)) + { + ForegroundColor = (Color)value; + NativeControl.ForegroundColor = ForegroundColor; + } + break; + case nameof(HasCloseIcon): + if (!Equals(HasCloseIcon, value)) + { + HasCloseIcon = (bool?)value; + NativeControl.HasCloseIcon = HasCloseIcon ?? (bool)MCM.Chip.HasCloseIconProperty.DefaultValue; + } + break; + case nameof(IconColor): + if (!Equals(IconColor, value)) + { + IconColor = (Color)value; + NativeControl.IconColor = IconColor; + } + break; + case nameof(IconData): + if (!Equals(IconData, value)) + { + IconData = (string)value; + NativeControl.IconData = IconData; + } + break; + case nameof(IconKind): + if (!Equals(IconKind, value)) + { + IconKind = (global::IconPacks.Material.IconKind?)value; + NativeControl.IconKind = IconKind ?? (global::IconPacks.Material.IconKind)MCM.Chip.IconKindProperty.DefaultValue; + } + break; + case nameof(IconSource): + if (!Equals(IconSource, value)) + { + IconSource = (global::SkiaSharp.SKPicture)value; + NativeControl.IconSource = IconSource; + } + break; + case nameof(IsChecked): + if (!Equals(IsChecked, value)) + { + IsChecked = (bool?)value; + NativeControl.IsChecked = IsChecked ?? (bool)MCM.Chip.IsCheckedProperty.DefaultValue; + } + break; + case nameof(OutlineColor): + if (!Equals(OutlineColor, value)) + { + OutlineColor = (Color)value; + NativeControl.OutlineColor = OutlineColor; + } + break; + case nameof(OutlineWidth): + if (!Equals(OutlineWidth, value)) + { + OutlineWidth = (int?)value; + NativeControl.OutlineWidth = OutlineWidth ?? (int)MCM.Chip.OutlineWidthProperty.DefaultValue; + } + break; + case nameof(RippleColor): + if (!Equals(RippleColor, value)) + { + RippleColor = (Color)value; + NativeControl.RippleColor = RippleColor; + } + break; + case nameof(Shape): + if (!Equals(Shape, value)) + { + Shape = (MCM.Tokens.Shape?)value; + NativeControl.Shape = Shape ?? (MCM.Tokens.Shape)MCM.Chip.ShapeProperty.DefaultValue; + } + break; + case nameof(StateLayerColor): + if (!Equals(StateLayerColor, value)) + { + StateLayerColor = (Color)value; + NativeControl.StateLayerColor = StateLayerColor; + } + break; + case nameof(Text): + if (!Equals(Text, value)) + { + Text = (string)value; + NativeControl.Text = Text; + } + break; + case nameof(IsCheckedChanged): + if (!Equals(IsCheckedChanged, value)) + { + void NativeControlCheckedChanged(object sender, MC.CheckedChangedEventArgs e) + { + var value = NativeControl.IsChecked; + IsChecked = value; + InvokeEventCallback(IsCheckedChanged, value); + } + + IsCheckedChanged = (EventCallback)value; + NativeControl.CheckedChanged -= NativeControlCheckedChanged; + NativeControl.CheckedChanged += NativeControlCheckedChanged; + } + break; + case nameof(OnClosed): + if (!Equals(OnClosed, value)) + { + void NativeControlClosed(object sender, EventArgs e) => InvokeEventCallback(OnClosed); + + OnClosed = (EventCallback)value; + NativeControl.Closed -= NativeControlClosed; + NativeControl.Closed += NativeControlClosed; + } + break; + + default: + base.HandleParameter(name, value); + break; + } + } + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDContextMenu.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDContextMenu.generated.cs new file mode 100644 index 00000000..0b2fc422 --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDContextMenu.generated.cs @@ -0,0 +1,80 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Rendering; +using Microsoft.Maui.Graphics; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public partial class MDContextMenu : BlazorBindings.Maui.Elements.ContentView + { + static MDContextMenu() + { + RegisterAdditionalHandlers(); + } + + [Parameter] public Color BackgroundColour { get; set; } + [Parameter] public Color RippleColor { get; set; } + [Parameter] public int? VisibleItemCount { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } + + public new MCM.ContextMenu NativeControl => (MCM.ContextMenu)((BindableObject)this).NativeControl; + + protected override MCM.ContextMenu CreateNativeElement() => new(); + + protected override void HandleParameter(string name, object value) + { + switch (name) + { + case nameof(BackgroundColour): + if (!Equals(BackgroundColour, value)) + { + BackgroundColour = (Color)value; + NativeControl.BackgroundColour = BackgroundColour; + } + break; + case nameof(RippleColor): + if (!Equals(RippleColor, value)) + { + RippleColor = (Color)value; + NativeControl.RippleColor = RippleColor; + } + break; + case nameof(VisibleItemCount): + if (!Equals(VisibleItemCount, value)) + { + VisibleItemCount = (int?)value; + NativeControl.VisibleItemCount = VisibleItemCount ?? (int)MCM.ContextMenu.VisibleItemCountProperty.DefaultValue; + } + break; + case nameof(ChildContent): + ChildContent = (RenderFragment)value; + break; + + default: + base.HandleParameter(name, value); + break; + } + } + + protected override void RenderAdditionalElementContent(RenderTreeBuilder builder, ref int sequence) + { + base.RenderAdditionalElementContent(builder, ref sequence); + RenderTreeBuilderHelper.AddListContentProperty(builder, sequence++, ChildContent, x => x.Items); + } + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDFAB.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDFAB.generated.cs new file mode 100644 index 00000000..a7c9dde5 --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDFAB.generated.cs @@ -0,0 +1,206 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using Microsoft.Maui.Graphics; +using System; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public partial class MDFAB : SKTouchCanvasView + { + static MDFAB() + { + RegisterAdditionalHandlers(); + } + + [Parameter] public Color BackgroundColour { get; set; } + [Parameter] public MCM.Tokens.Elevation? Elevation { get; set; } + [Parameter] public MCM.FABType? FABType { get; set; } + [Parameter] public string FontFamily { get; set; } + [Parameter] public bool? FontItalic { get; set; } + [Parameter] public float? FontSize { get; set; } + [Parameter] public int? FontWeight { get; set; } + [Parameter] public Color ForegroundColor { get; set; } + [Parameter] public string IconData { get; set; } + [Parameter] public global::IconPacks.Material.IconKind? IconKind { get; set; } + [Parameter] public global::SkiaSharp.SKPicture IconSource { get; set; } + [Parameter] public bool? IsExtended { get; set; } + [Parameter] public Color OutlineColor { get; set; } + [Parameter] public int? OutlineWidth { get; set; } + [Parameter] public Color RippleColor { get; set; } + [Parameter] public MCM.Tokens.Shape? Shape { get; set; } + [Parameter] public Color StateLayerColor { get; set; } + [Parameter] public string Text { get; set; } + [Parameter] public EventCallback IsExtendedChanged { get; set; } + + public new MCM.FAB NativeControl => (MCM.FAB)((BindableObject)this).NativeControl; + + protected override MCM.FAB CreateNativeElement() => new(); + + protected override void HandleParameter(string name, object value) + { + switch (name) + { + case nameof(BackgroundColour): + if (!Equals(BackgroundColour, value)) + { + BackgroundColour = (Color)value; + NativeControl.BackgroundColour = BackgroundColour; + } + break; + case nameof(Elevation): + if (!Equals(Elevation, value)) + { + Elevation = (MCM.Tokens.Elevation?)value; + NativeControl.Elevation = Elevation ?? (MCM.Tokens.Elevation)MCM.FAB.ElevationProperty.DefaultValue; + } + break; + case nameof(FABType): + if (!Equals(FABType, value)) + { + FABType = (MCM.FABType?)value; + NativeControl.FABType = FABType ?? (MCM.FABType)MCM.FAB.FABTypeProperty.DefaultValue; + } + break; + case nameof(FontFamily): + if (!Equals(FontFamily, value)) + { + FontFamily = (string)value; + NativeControl.FontFamily = FontFamily; + } + break; + case nameof(FontItalic): + if (!Equals(FontItalic, value)) + { + FontItalic = (bool?)value; + NativeControl.FontItalic = FontItalic ?? (bool)MCM.FAB.FontItalicProperty.DefaultValue; + } + break; + case nameof(FontSize): + if (!Equals(FontSize, value)) + { + FontSize = (float?)value; + NativeControl.FontSize = FontSize ?? (float)MCM.FAB.FontSizeProperty.DefaultValue; + } + break; + case nameof(FontWeight): + if (!Equals(FontWeight, value)) + { + FontWeight = (int?)value; + NativeControl.FontWeight = FontWeight ?? (int)MCM.FAB.FontWeightProperty.DefaultValue; + } + break; + case nameof(ForegroundColor): + if (!Equals(ForegroundColor, value)) + { + ForegroundColor = (Color)value; + NativeControl.ForegroundColor = ForegroundColor; + } + break; + case nameof(IconData): + if (!Equals(IconData, value)) + { + IconData = (string)value; + NativeControl.IconData = IconData; + } + break; + case nameof(IconKind): + if (!Equals(IconKind, value)) + { + IconKind = (global::IconPacks.Material.IconKind?)value; + NativeControl.IconKind = IconKind ?? (global::IconPacks.Material.IconKind)MCM.FAB.IconKindProperty.DefaultValue; + } + break; + case nameof(IconSource): + if (!Equals(IconSource, value)) + { + IconSource = (global::SkiaSharp.SKPicture)value; + NativeControl.IconSource = IconSource; + } + break; + case nameof(IsExtended): + if (!Equals(IsExtended, value)) + { + IsExtended = (bool?)value; + NativeControl.IsExtended = IsExtended ?? (bool)MCM.FAB.IsExtendedProperty.DefaultValue; + } + break; + case nameof(OutlineColor): + if (!Equals(OutlineColor, value)) + { + OutlineColor = (Color)value; + NativeControl.OutlineColor = OutlineColor; + } + break; + case nameof(OutlineWidth): + if (!Equals(OutlineWidth, value)) + { + OutlineWidth = (int?)value; + NativeControl.OutlineWidth = OutlineWidth ?? (int)MCM.FAB.OutlineWidthProperty.DefaultValue; + } + break; + case nameof(RippleColor): + if (!Equals(RippleColor, value)) + { + RippleColor = (Color)value; + NativeControl.RippleColor = RippleColor; + } + break; + case nameof(Shape): + if (!Equals(Shape, value)) + { + Shape = (MCM.Tokens.Shape?)value; + NativeControl.Shape = Shape ?? (MCM.Tokens.Shape)MCM.FAB.ShapeProperty.DefaultValue; + } + break; + case nameof(StateLayerColor): + if (!Equals(StateLayerColor, value)) + { + StateLayerColor = (Color)value; + NativeControl.StateLayerColor = StateLayerColor; + } + break; + case nameof(Text): + if (!Equals(Text, value)) + { + Text = (string)value; + NativeControl.Text = Text; + } + break; + case nameof(IsExtendedChanged): + if (!Equals(IsExtendedChanged, value)) + { + void NativeControlExtendedChanged(object sender, EventArgs e) + { + var value = NativeControl.IsExtended; + IsExtended = value; + InvokeEventCallback(IsExtendedChanged, value); + } + + IsExtendedChanged = (EventCallback)value; + NativeControl.ExtendedChanged -= NativeControlExtendedChanged; + NativeControl.ExtendedChanged += NativeControlExtendedChanged; + } + break; + + default: + base.HandleParameter(name, value); + break; + } + } + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDIconButton.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDIconButton.generated.cs new file mode 100644 index 00000000..799df5f7 --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDIconButton.generated.cs @@ -0,0 +1,133 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using Microsoft.Maui.Graphics; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public partial class MDIconButton : SKTouchCanvasView + { + static MDIconButton() + { + RegisterAdditionalHandlers(); + } + + [Parameter] public Color BackgroundColour { get; set; } + [Parameter] public MCM.Tokens.Elevation? Elevation { get; set; } + [Parameter] public Color ForegroundColor { get; set; } + [Parameter] public string IconData { get; set; } + [Parameter] public global::IconPacks.Material.IconKind? IconKind { get; set; } + [Parameter] public global::SkiaSharp.SKPicture IconSource { get; set; } + [Parameter] public Color OutlineColor { get; set; } + [Parameter] public int? OutlineWidth { get; set; } + [Parameter] public Color RippleColor { get; set; } + [Parameter] public MCM.Tokens.Shape? Shape { get; set; } + [Parameter] public Color StateLayerColor { get; set; } + + public new MCM.IconButton NativeControl => (MCM.IconButton)((BindableObject)this).NativeControl; + + protected override MCM.IconButton CreateNativeElement() => new(); + + protected override void HandleParameter(string name, object value) + { + switch (name) + { + case nameof(BackgroundColour): + if (!Equals(BackgroundColour, value)) + { + BackgroundColour = (Color)value; + NativeControl.BackgroundColour = BackgroundColour; + } + break; + case nameof(Elevation): + if (!Equals(Elevation, value)) + { + Elevation = (MCM.Tokens.Elevation?)value; + NativeControl.Elevation = Elevation ?? (MCM.Tokens.Elevation)MCM.IconButton.ElevationProperty.DefaultValue; + } + break; + case nameof(ForegroundColor): + if (!Equals(ForegroundColor, value)) + { + ForegroundColor = (Color)value; + NativeControl.ForegroundColor = ForegroundColor; + } + break; + case nameof(IconData): + if (!Equals(IconData, value)) + { + IconData = (string)value; + NativeControl.IconData = IconData; + } + break; + case nameof(IconKind): + if (!Equals(IconKind, value)) + { + IconKind = (global::IconPacks.Material.IconKind?)value; + NativeControl.IconKind = IconKind ?? (global::IconPacks.Material.IconKind)MCM.IconButton.IconKindProperty.DefaultValue; + } + break; + case nameof(IconSource): + if (!Equals(IconSource, value)) + { + IconSource = (global::SkiaSharp.SKPicture)value; + NativeControl.IconSource = IconSource; + } + break; + case nameof(OutlineColor): + if (!Equals(OutlineColor, value)) + { + OutlineColor = (Color)value; + NativeControl.OutlineColor = OutlineColor; + } + break; + case nameof(OutlineWidth): + if (!Equals(OutlineWidth, value)) + { + OutlineWidth = (int?)value; + NativeControl.OutlineWidth = OutlineWidth ?? (int)MCM.IconButton.OutlineWidthProperty.DefaultValue; + } + break; + case nameof(RippleColor): + if (!Equals(RippleColor, value)) + { + RippleColor = (Color)value; + NativeControl.RippleColor = RippleColor; + } + break; + case nameof(Shape): + if (!Equals(Shape, value)) + { + Shape = (MCM.Tokens.Shape?)value; + NativeControl.Shape = Shape ?? (MCM.Tokens.Shape)MCM.IconButton.ShapeProperty.DefaultValue; + } + break; + case nameof(StateLayerColor): + if (!Equals(StateLayerColor, value)) + { + StateLayerColor = (Color)value; + NativeControl.StateLayerColor = StateLayerColor; + } + break; + + default: + base.HandleParameter(name, value); + break; + } + } + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDNavigationBarItem.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDNavigationBarItem.generated.cs new file mode 100644 index 00000000..0e0d6b63 --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDNavigationBarItem.generated.cs @@ -0,0 +1,216 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Rendering; +using Microsoft.Maui.Graphics; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public partial class MDNavigationBarItem : SKTouchCanvasView + { + static MDNavigationBarItem() + { + RegisterAdditionalHandlers(); + } + + [Parameter] public string ActivedIconData { get; set; } + [Parameter] public global::IconPacks.Material.IconKind? ActivedIconKind { get; set; } + [Parameter] public global::SkiaSharp.SKPicture ActivedIconSource { get; set; } + [Parameter] public Color ActiveIndicatorColor { get; set; } + [Parameter] public Color BackgroundColour { get; set; } + [Parameter] public string FontFamily { get; set; } + [Parameter] public bool? FontItalic { get; set; } + [Parameter] public float? FontSize { get; set; } + [Parameter] public int? FontWeight { get; set; } + [Parameter] public Color ForegroundColor { get; set; } + [Parameter] public bool? HasLabel { get; set; } + [Parameter] public string IconData { get; set; } + [Parameter] public global::IconPacks.Material.IconKind? IconKind { get; set; } + [Parameter] public global::SkiaSharp.SKPicture IconSource { get; set; } + [Parameter] public bool? IsActived { get; set; } + [Parameter] public Color RippleColor { get; set; } + [Parameter] public Color StateLayerColor { get; set; } + [Parameter] public string Text { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public EventCallback IsActivedChanged { get; set; } + + public new MCM.NavigationBarItem NativeControl => (MCM.NavigationBarItem)((BindableObject)this).NativeControl; + + protected override MCM.NavigationBarItem CreateNativeElement() => new(); + + protected override void HandleParameter(string name, object value) + { + switch (name) + { + case nameof(ActivedIconData): + if (!Equals(ActivedIconData, value)) + { + ActivedIconData = (string)value; + NativeControl.ActivedIconData = ActivedIconData; + } + break; + case nameof(ActivedIconKind): + if (!Equals(ActivedIconKind, value)) + { + ActivedIconKind = (global::IconPacks.Material.IconKind?)value; + NativeControl.ActivedIconKind = ActivedIconKind ?? (global::IconPacks.Material.IconKind)MCM.NavigationBarItem.ActivedIconKindProperty.DefaultValue; + } + break; + case nameof(ActivedIconSource): + if (!Equals(ActivedIconSource, value)) + { + ActivedIconSource = (global::SkiaSharp.SKPicture)value; + NativeControl.ActivedIconSource = ActivedIconSource; + } + break; + case nameof(ActiveIndicatorColor): + if (!Equals(ActiveIndicatorColor, value)) + { + ActiveIndicatorColor = (Color)value; + NativeControl.ActiveIndicatorColor = ActiveIndicatorColor; + } + break; + case nameof(BackgroundColour): + if (!Equals(BackgroundColour, value)) + { + BackgroundColour = (Color)value; + NativeControl.BackgroundColour = BackgroundColour; + } + break; + case nameof(FontFamily): + if (!Equals(FontFamily, value)) + { + FontFamily = (string)value; + NativeControl.FontFamily = FontFamily; + } + break; + case nameof(FontItalic): + if (!Equals(FontItalic, value)) + { + FontItalic = (bool?)value; + NativeControl.FontItalic = FontItalic ?? (bool)MCM.NavigationBarItem.FontItalicProperty.DefaultValue; + } + break; + case nameof(FontSize): + if (!Equals(FontSize, value)) + { + FontSize = (float?)value; + NativeControl.FontSize = FontSize ?? (float)MCM.NavigationBarItem.FontSizeProperty.DefaultValue; + } + break; + case nameof(FontWeight): + if (!Equals(FontWeight, value)) + { + FontWeight = (int?)value; + NativeControl.FontWeight = FontWeight ?? (int)MCM.NavigationBarItem.FontWeightProperty.DefaultValue; + } + break; + case nameof(ForegroundColor): + if (!Equals(ForegroundColor, value)) + { + ForegroundColor = (Color)value; + NativeControl.ForegroundColor = ForegroundColor; + } + break; + case nameof(HasLabel): + if (!Equals(HasLabel, value)) + { + HasLabel = (bool?)value; + NativeControl.HasLabel = HasLabel ?? (bool)MCM.NavigationBarItem.HasLabelProperty.DefaultValue; + } + break; + case nameof(IconData): + if (!Equals(IconData, value)) + { + IconData = (string)value; + NativeControl.IconData = IconData; + } + break; + case nameof(IconKind): + if (!Equals(IconKind, value)) + { + IconKind = (global::IconPacks.Material.IconKind?)value; + NativeControl.IconKind = IconKind ?? (global::IconPacks.Material.IconKind)MCM.NavigationBarItem.IconKindProperty.DefaultValue; + } + break; + case nameof(IconSource): + if (!Equals(IconSource, value)) + { + IconSource = (global::SkiaSharp.SKPicture)value; + NativeControl.IconSource = IconSource; + } + break; + case nameof(IsActived): + if (!Equals(IsActived, value)) + { + IsActived = (bool?)value; + NativeControl.IsActived = IsActived ?? (bool)MCM.NavigationBarItem.IsActivedProperty.DefaultValue; + } + break; + case nameof(RippleColor): + if (!Equals(RippleColor, value)) + { + RippleColor = (Color)value; + NativeControl.RippleColor = RippleColor; + } + break; + case nameof(StateLayerColor): + if (!Equals(StateLayerColor, value)) + { + StateLayerColor = (Color)value; + NativeControl.StateLayerColor = StateLayerColor; + } + break; + case nameof(Text): + if (!Equals(Text, value)) + { + Text = (string)value; + NativeControl.Text = Text; + } + break; + case nameof(ChildContent): + ChildContent = (RenderFragment)value; + break; + case nameof(IsActivedChanged): + if (!Equals(IsActivedChanged, value)) + { + void NativeControlIsActivedChanged(object sender, MCM.Core.ValueChangedEventArgs e) + { + var value = NativeControl.IsActived; + IsActived = value; + InvokeEventCallback(IsActivedChanged, value); + } + + IsActivedChanged = (EventCallback)value; + NativeControl.IsActivedChanged -= NativeControlIsActivedChanged; + NativeControl.IsActivedChanged += NativeControlIsActivedChanged; + } + break; + + default: + base.HandleParameter(name, value); + break; + } + } + + protected override void RenderAdditionalElementContent(RenderTreeBuilder builder, ref int sequence) + { + base.RenderAdditionalElementContent(builder, ref sequence); + RenderTreeBuilderHelper.AddContentProperty(builder, sequence++, ChildContent, (x, value) => x.Content = (MC.View)value); + } + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDNavigationDrawer.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDNavigationDrawer.generated.cs new file mode 100644 index 00000000..f3930ee5 --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDNavigationDrawer.generated.cs @@ -0,0 +1,125 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Rendering; +using Microsoft.Maui.Graphics; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public partial class MDNavigationDrawer : BlazorBindings.Maui.Elements.TemplatedView + { + static MDNavigationDrawer() + { + RegisterAdditionalHandlers(); + } + + [Parameter] public MCM.DrawerDisplayMode? DisplayMode { get; set; } + [Parameter] public bool? HasToolBar { get; set; } + [Parameter] public bool? IsPaneOpen { get; set; } + [Parameter] public Color PaneBackGroundColour { get; set; } + [Parameter] public double? PaneWidth { get; set; } + [Parameter] public global::IconPacks.Material.IconKind? SwitchIcon { get; set; } + [Parameter] public string Title { get; set; } + [Parameter] public Color ToolBarBackGroundColour { get; set; } + [Parameter] public RenderFragment FooterItems { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } + + public new MCM.NavigationDrawer NativeControl => (MCM.NavigationDrawer)((BindableObject)this).NativeControl; + + protected override MCM.NavigationDrawer CreateNativeElement() => new(); + + protected override void HandleParameter(string name, object value) + { + switch (name) + { + case nameof(DisplayMode): + if (!Equals(DisplayMode, value)) + { + DisplayMode = (MCM.DrawerDisplayMode?)value; + NativeControl.DisplayMode = DisplayMode ?? (MCM.DrawerDisplayMode)MCM.NavigationDrawer.DisplayModeProperty.DefaultValue; + } + break; + case nameof(HasToolBar): + if (!Equals(HasToolBar, value)) + { + HasToolBar = (bool?)value; + NativeControl.HasToolBar = HasToolBar ?? (bool)MCM.NavigationDrawer.HasToolBarProperty.DefaultValue; + } + break; + case nameof(IsPaneOpen): + if (!Equals(IsPaneOpen, value)) + { + IsPaneOpen = (bool?)value; + NativeControl.IsPaneOpen = IsPaneOpen ?? (bool)MCM.NavigationDrawer.IsPaneOpenProperty.DefaultValue; + } + break; + case nameof(PaneBackGroundColour): + if (!Equals(PaneBackGroundColour, value)) + { + PaneBackGroundColour = (Color)value; + NativeControl.PaneBackGroundColour = PaneBackGroundColour; + } + break; + case nameof(PaneWidth): + if (!Equals(PaneWidth, value)) + { + PaneWidth = (double?)value; + NativeControl.PaneWidth = PaneWidth ?? (double)MCM.NavigationDrawer.PaneWidthProperty.DefaultValue; + } + break; + case nameof(SwitchIcon): + if (!Equals(SwitchIcon, value)) + { + SwitchIcon = (global::IconPacks.Material.IconKind?)value; + NativeControl.SwitchIcon = SwitchIcon ?? (global::IconPacks.Material.IconKind)MCM.NavigationDrawer.SwitchIconProperty.DefaultValue; + } + break; + case nameof(Title): + if (!Equals(Title, value)) + { + Title = (string)value; + NativeControl.Title = Title; + } + break; + case nameof(ToolBarBackGroundColour): + if (!Equals(ToolBarBackGroundColour, value)) + { + ToolBarBackGroundColour = (Color)value; + NativeControl.ToolBarBackGroundColour = ToolBarBackGroundColour; + } + break; + case nameof(FooterItems): + FooterItems = (RenderFragment)value; + break; + case nameof(ChildContent): + ChildContent = (RenderFragment)value; + break; + + default: + base.HandleParameter(name, value); + break; + } + } + + protected override void RenderAdditionalElementContent(RenderTreeBuilder builder, ref int sequence) + { + base.RenderAdditionalElementContent(builder, ref sequence); + RenderTreeBuilderHelper.AddListContentProperty(builder, sequence++, FooterItems, x => x.FooterItems); + RenderTreeBuilderHelper.AddListContentProperty(builder, sequence++, ChildContent, x => x.Items); + } + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDNavigationDrawerItem.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDNavigationDrawerItem.generated.cs new file mode 100644 index 00000000..f734d67e --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDNavigationDrawerItem.generated.cs @@ -0,0 +1,182 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using Microsoft.Maui.Graphics; +using System; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public partial class MDNavigationDrawerItem : SKTouchCanvasView + { + static MDNavigationDrawerItem() + { + RegisterAdditionalHandlers(); + } + + [Parameter] public Color ActiveIndicatorColor { get; set; } + [Parameter] public Color BackgroundColour { get; set; } + [Parameter] public Type ContentType { get; set; } + [Parameter] public string FontFamily { get; set; } + [Parameter] public bool? FontItalic { get; set; } + [Parameter] public float? FontSize { get; set; } + [Parameter] public int? FontWeight { get; set; } + [Parameter] public Color ForegroundColor { get; set; } + [Parameter] public string IconData { get; set; } + [Parameter] public global::IconPacks.Material.IconKind? IconKind { get; set; } + [Parameter] public global::SkiaSharp.SKPicture IconSource { get; set; } + [Parameter] public bool? IsActived { get; set; } + [Parameter] public bool? IsExtended { get; set; } + [Parameter] public Color RippleColor { get; set; } + [Parameter] public Color StateLayerColor { get; set; } + [Parameter] public string Text { get; set; } + [Parameter] public string Title { get; set; } + + public new MCM.NavigationDrawerItem NativeControl => (MCM.NavigationDrawerItem)((BindableObject)this).NativeControl; + + protected override MCM.NavigationDrawerItem CreateNativeElement() => new(); + + protected override void HandleParameter(string name, object value) + { + switch (name) + { + case nameof(ActiveIndicatorColor): + if (!Equals(ActiveIndicatorColor, value)) + { + ActiveIndicatorColor = (Color)value; + NativeControl.ActiveIndicatorColor = ActiveIndicatorColor; + } + break; + case nameof(BackgroundColour): + if (!Equals(BackgroundColour, value)) + { + BackgroundColour = (Color)value; + NativeControl.BackgroundColour = BackgroundColour; + } + break; + case nameof(ContentType): + if (!Equals(ContentType, value)) + { + ContentType = (Type)value; + NativeControl.ContentType = ContentType; + } + break; + case nameof(FontFamily): + if (!Equals(FontFamily, value)) + { + FontFamily = (string)value; + NativeControl.FontFamily = FontFamily; + } + break; + case nameof(FontItalic): + if (!Equals(FontItalic, value)) + { + FontItalic = (bool?)value; + NativeControl.FontItalic = FontItalic ?? (bool)MCM.NavigationDrawerItem.FontItalicProperty.DefaultValue; + } + break; + case nameof(FontSize): + if (!Equals(FontSize, value)) + { + FontSize = (float?)value; + NativeControl.FontSize = FontSize ?? (float)MCM.NavigationDrawerItem.FontSizeProperty.DefaultValue; + } + break; + case nameof(FontWeight): + if (!Equals(FontWeight, value)) + { + FontWeight = (int?)value; + NativeControl.FontWeight = FontWeight ?? (int)MCM.NavigationDrawerItem.FontWeightProperty.DefaultValue; + } + break; + case nameof(ForegroundColor): + if (!Equals(ForegroundColor, value)) + { + ForegroundColor = (Color)value; + NativeControl.ForegroundColor = ForegroundColor; + } + break; + case nameof(IconData): + if (!Equals(IconData, value)) + { + IconData = (string)value; + NativeControl.IconData = IconData; + } + break; + case nameof(IconKind): + if (!Equals(IconKind, value)) + { + IconKind = (global::IconPacks.Material.IconKind?)value; + NativeControl.IconKind = IconKind ?? (global::IconPacks.Material.IconKind)MCM.NavigationDrawerItem.IconKindProperty.DefaultValue; + } + break; + case nameof(IconSource): + if (!Equals(IconSource, value)) + { + IconSource = (global::SkiaSharp.SKPicture)value; + NativeControl.IconSource = IconSource; + } + break; + case nameof(IsActived): + if (!Equals(IsActived, value)) + { + IsActived = (bool?)value; + NativeControl.IsActived = IsActived ?? (bool)MCM.NavigationDrawerItem.IsActivedProperty.DefaultValue; + } + break; + case nameof(IsExtended): + if (!Equals(IsExtended, value)) + { + IsExtended = (bool?)value; + NativeControl.IsExtended = IsExtended ?? (bool)MCM.NavigationDrawerItem.IsExtendedProperty.DefaultValue; + } + break; + case nameof(RippleColor): + if (!Equals(RippleColor, value)) + { + RippleColor = (Color)value; + NativeControl.RippleColor = RippleColor; + } + break; + case nameof(StateLayerColor): + if (!Equals(StateLayerColor, value)) + { + StateLayerColor = (Color)value; + NativeControl.StateLayerColor = StateLayerColor; + } + break; + case nameof(Text): + if (!Equals(Text, value)) + { + Text = (string)value; + NativeControl.Text = Text; + } + break; + case nameof(Title): + if (!Equals(Title, value)) + { + Title = (string)value; + NativeControl.Title = Title; + } + break; + + default: + base.HandleParameter(name, value); + break; + } + } + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDRadioButton.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDRadioButton.generated.cs new file mode 100644 index 00000000..7d5e3855 --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDRadioButton.generated.cs @@ -0,0 +1,79 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Rendering; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public partial class MDRadioButton : MDWrapLayout + { + static MDRadioButton() + { + RegisterAdditionalHandlers(); + } + + [Parameter] public int? SelectedIndex { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public EventCallback SelectedIndexChanged { get; set; } + + public new MCM.RadioButton NativeControl => (MCM.RadioButton)((BindableObject)this).NativeControl; + + protected override MCM.RadioButton CreateNativeElement() => new(); + + protected override void HandleParameter(string name, object value) + { + switch (name) + { + case nameof(SelectedIndex): + if (!Equals(SelectedIndex, value)) + { + SelectedIndex = (int?)value; + NativeControl.SelectedIndex = SelectedIndex ?? (int)MCM.RadioButton.SelectedIndexProperty.DefaultValue; + } + break; + case nameof(ChildContent): + ChildContent = (RenderFragment)value; + break; + case nameof(SelectedIndexChanged): + if (!Equals(SelectedIndexChanged, value)) + { + void NativeControlSelectedIndexChanged(object sender, MCM.Core.SelectedIndexChangedEventArgs e) + { + var value = NativeControl.SelectedIndex; + SelectedIndex = value; + InvokeEventCallback(SelectedIndexChanged, value); + } + + SelectedIndexChanged = (EventCallback)value; + NativeControl.SelectedIndexChanged -= NativeControlSelectedIndexChanged; + NativeControl.SelectedIndexChanged += NativeControlSelectedIndexChanged; + } + break; + + default: + base.HandleParameter(name, value); + break; + } + } + + protected override void RenderAdditionalElementContent(RenderTreeBuilder builder, ref int sequence) + { + base.RenderAdditionalElementContent(builder, ref sequence); + RenderTreeBuilderHelper.AddListContentProperty(builder, sequence++, ChildContent, x => x.Items); + } + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDRadioButtonItem.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDRadioButtonItem.generated.cs new file mode 100644 index 00000000..a12c33a6 --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDRadioButtonItem.generated.cs @@ -0,0 +1,141 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using Microsoft.Maui.Graphics; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public partial class MDRadioButtonItem : SKTouchCanvasView + { + static MDRadioButtonItem() + { + RegisterAdditionalHandlers(); + } + + [Parameter] public string FontFamily { get; set; } + [Parameter] public bool? FontItalic { get; set; } + [Parameter] public float? FontSize { get; set; } + [Parameter] public int? FontWeight { get; set; } + [Parameter] public Color ForegroundColor { get; set; } + [Parameter] public bool? IsSelected { get; set; } + [Parameter] public Color OnColor { get; set; } + [Parameter] public Color RippleColor { get; set; } + [Parameter] public Color StateLayerColor { get; set; } + [Parameter] public string Text { get; set; } + [Parameter] public EventCallback IsSelectedChanged { get; set; } + + public new MCM.RadioButtonItem NativeControl => (MCM.RadioButtonItem)((BindableObject)this).NativeControl; + + protected override MCM.RadioButtonItem CreateNativeElement() => new(); + + protected override void HandleParameter(string name, object value) + { + switch (name) + { + case nameof(FontFamily): + if (!Equals(FontFamily, value)) + { + FontFamily = (string)value; + NativeControl.FontFamily = FontFamily; + } + break; + case nameof(FontItalic): + if (!Equals(FontItalic, value)) + { + FontItalic = (bool?)value; + NativeControl.FontItalic = FontItalic ?? (bool)MCM.RadioButtonItem.FontItalicProperty.DefaultValue; + } + break; + case nameof(FontSize): + if (!Equals(FontSize, value)) + { + FontSize = (float?)value; + NativeControl.FontSize = FontSize ?? (float)MCM.RadioButtonItem.FontSizeProperty.DefaultValue; + } + break; + case nameof(FontWeight): + if (!Equals(FontWeight, value)) + { + FontWeight = (int?)value; + NativeControl.FontWeight = FontWeight ?? (int)MCM.RadioButtonItem.FontWeightProperty.DefaultValue; + } + break; + case nameof(ForegroundColor): + if (!Equals(ForegroundColor, value)) + { + ForegroundColor = (Color)value; + NativeControl.ForegroundColor = ForegroundColor; + } + break; + case nameof(IsSelected): + if (!Equals(IsSelected, value)) + { + IsSelected = (bool?)value; + NativeControl.IsSelected = IsSelected ?? (bool)MCM.RadioButtonItem.IsSelectedProperty.DefaultValue; + } + break; + case nameof(OnColor): + if (!Equals(OnColor, value)) + { + OnColor = (Color)value; + NativeControl.OnColor = OnColor; + } + break; + case nameof(RippleColor): + if (!Equals(RippleColor, value)) + { + RippleColor = (Color)value; + NativeControl.RippleColor = RippleColor; + } + break; + case nameof(StateLayerColor): + if (!Equals(StateLayerColor, value)) + { + StateLayerColor = (Color)value; + NativeControl.StateLayerColor = StateLayerColor; + } + break; + case nameof(Text): + if (!Equals(Text, value)) + { + Text = (string)value; + NativeControl.Text = Text; + } + break; + case nameof(IsSelectedChanged): + if (!Equals(IsSelectedChanged, value)) + { + void NativeControlSelectedChanged(object sender, MCM.Core.SelectedChangedEventArgs e) + { + var value = NativeControl.IsSelected; + IsSelected = value; + InvokeEventCallback(IsSelectedChanged, value); + } + + IsSelectedChanged = (EventCallback)value; + NativeControl.SelectedChanged -= NativeControlSelectedChanged; + NativeControl.SelectedChanged += NativeControlSelectedChanged; + } + break; + + default: + base.HandleParameter(name, value); + break; + } + } + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDSKTouchCanvasView.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDSKTouchCanvasView.generated.cs new file mode 100644 index 00000000..5e328f9c --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDSKTouchCanvasView.generated.cs @@ -0,0 +1,132 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Rendering; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public partial class MDSKTouchCanvasView : BlazorBindings.Maui.Elements.SkiaSharp.SKCanvasView + { + static MDSKTouchCanvasView() + { + RegisterAdditionalHandlers(); + } + + [Parameter] public RenderFragment ContextMenu { get; set; } + [Parameter] public EventCallback OnPress { get; set; } + [Parameter] public EventCallback OnMoved { get; set; } + [Parameter] public EventCallback OnRelease { get; set; } + [Parameter] public EventCallback OnLongPressed { get; set; } + [Parameter] public EventCallback OnClick { get; set; } + [Parameter] public EventCallback OnEntered { get; set; } + [Parameter] public EventCallback OnExited { get; set; } + + public new MCM.SKTouchCanvasView NativeControl => (MCM.SKTouchCanvasView)((BindableObject)this).NativeControl; + + protected override MCM.SKTouchCanvasView CreateNativeElement() => new(); + + protected override void HandleParameter(string name, object value) + { + switch (name) + { + case nameof(ContextMenu): + ContextMenu = (RenderFragment)value; + break; + case nameof(OnPress): + if (!Equals(OnPress, value)) + { + void NativeControlPressed(object sender, global::SkiaSharp.Views.Maui.SKTouchEventArgs e) => InvokeEventCallback(OnPress, e); + + OnPress = (EventCallback)value; + NativeControl.Pressed -= NativeControlPressed; + NativeControl.Pressed += NativeControlPressed; + } + break; + case nameof(OnMoved): + if (!Equals(OnMoved, value)) + { + void NativeControlMoved(object sender, global::SkiaSharp.Views.Maui.SKTouchEventArgs e) => InvokeEventCallback(OnMoved, e); + + OnMoved = (EventCallback)value; + NativeControl.Moved -= NativeControlMoved; + NativeControl.Moved += NativeControlMoved; + } + break; + case nameof(OnRelease): + if (!Equals(OnRelease, value)) + { + void NativeControlReleased(object sender, global::SkiaSharp.Views.Maui.SKTouchEventArgs e) => InvokeEventCallback(OnRelease, e); + + OnRelease = (EventCallback)value; + NativeControl.Released -= NativeControlReleased; + NativeControl.Released += NativeControlReleased; + } + break; + case nameof(OnLongPressed): + if (!Equals(OnLongPressed, value)) + { + void NativeControlLongPressed(object sender, global::SkiaSharp.Views.Maui.SKTouchEventArgs e) => InvokeEventCallback(OnLongPressed, e); + + OnLongPressed = (EventCallback)value; + NativeControl.LongPressed -= NativeControlLongPressed; + NativeControl.LongPressed += NativeControlLongPressed; + } + break; + case nameof(OnClick): + if (!Equals(OnClick, value)) + { + void NativeControlClicked(object sender, global::SkiaSharp.Views.Maui.SKTouchEventArgs e) => InvokeEventCallback(OnClick, e); + + OnClick = (EventCallback)value; + NativeControl.Clicked -= NativeControlClicked; + NativeControl.Clicked += NativeControlClicked; + } + break; + case nameof(OnEntered): + if (!Equals(OnEntered, value)) + { + void NativeControlEntered(object sender, global::SkiaSharp.Views.Maui.SKTouchEventArgs e) => InvokeEventCallback(OnEntered, e); + + OnEntered = (EventCallback)value; + NativeControl.Entered -= NativeControlEntered; + NativeControl.Entered += NativeControlEntered; + } + break; + case nameof(OnExited): + if (!Equals(OnExited, value)) + { + void NativeControlExited(object sender, global::SkiaSharp.Views.Maui.SKTouchEventArgs e) => InvokeEventCallback(OnExited, e); + + OnExited = (EventCallback)value; + NativeControl.Exited -= NativeControlExited; + NativeControl.Exited += NativeControlExited; + } + break; + + default: + base.HandleParameter(name, value); + break; + } + } + + protected override void RenderAdditionalElementContent(RenderTreeBuilder builder, ref int sequence) + { + base.RenderAdditionalElementContent(builder, ref sequence); + RenderTreeBuilderHelper.AddContentProperty(builder, sequence++, ContextMenu, (x, value) => x.ContextMenu = (MCM.ContextMenu)value); + } + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDSplitView.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDSplitView.generated.cs new file mode 100644 index 00000000..9893e399 --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDSplitView.generated.cs @@ -0,0 +1,76 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Rendering; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public partial class MDSplitView : BlazorBindings.Maui.Elements.View + { + static MDSplitView() + { + RegisterAdditionalHandlers(); + } + + [Parameter] public MCM.DrawerDisplayMode? DisplayMode { get; set; } + [Parameter] public bool? IsPaneOpen { get; set; } + [Parameter] public RenderFragment Content { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } + + public new MCM.SplitView NativeControl => (MCM.SplitView)((BindableObject)this).NativeControl; + + protected override MCM.SplitView CreateNativeElement() => new(); + + protected override void HandleParameter(string name, object value) + { + switch (name) + { + case nameof(DisplayMode): + if (!Equals(DisplayMode, value)) + { + DisplayMode = (MCM.DrawerDisplayMode?)value; + NativeControl.DisplayMode = DisplayMode ?? (MCM.DrawerDisplayMode)MCM.SplitView.DisplayModeProperty.DefaultValue; + } + break; + case nameof(IsPaneOpen): + if (!Equals(IsPaneOpen, value)) + { + IsPaneOpen = (bool?)value; + NativeControl.IsPaneOpen = IsPaneOpen ?? (bool)MCM.SplitView.IsPaneOpenProperty.DefaultValue; + } + break; + case nameof(Content): + Content = (RenderFragment)value; + break; + case nameof(ChildContent): + ChildContent = (RenderFragment)value; + break; + + default: + base.HandleParameter(name, value); + break; + } + } + + protected override void RenderAdditionalElementContent(RenderTreeBuilder builder, ref int sequence) + { + base.RenderAdditionalElementContent(builder, ref sequence); + RenderTreeBuilderHelper.AddContentProperty(builder, sequence++, Content, (x, value) => x.Content = (MC.View)value); + RenderTreeBuilderHelper.AddContentProperty(builder, sequence++, ChildContent, (x, value) => x.Pane = (MC.View)value); + } + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDSwitch.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDSwitch.generated.cs new file mode 100644 index 00000000..3826d656 --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDSwitch.generated.cs @@ -0,0 +1,173 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using Microsoft.Maui.Graphics; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public partial class MDSwitch : SKTouchCanvasView + { + static MDSwitch() + { + RegisterAdditionalHandlers(); + } + + [Parameter] public MCM.ControlState? ControlState { get; set; } + [Parameter] public bool? HasIcon { get; set; } + [Parameter] public Color IconColor { get; set; } + [Parameter] public float? IconOpacity { get; set; } + [Parameter] public bool? IsChecked { get; set; } + [Parameter] public Color OutlineColor { get; set; } + [Parameter] public int? OutlineWidth { get; set; } + [Parameter] public Color RippleColor { get; set; } + [Parameter] public MCM.Tokens.Shape? Shape { get; set; } + [Parameter] public Color StateLayerColor { get; set; } + [Parameter] public Color ThumbColor { get; set; } + [Parameter] public float? ThumbOpacity { get; set; } + [Parameter] public Color TrackColor { get; set; } + [Parameter] public float? TrackOpacity { get; set; } + [Parameter] public EventCallback IsCheckedChanged { get; set; } + + public new MCM.Switch NativeControl => (MCM.Switch)((BindableObject)this).NativeControl; + + protected override MCM.Switch CreateNativeElement() => new(); + + protected override void HandleParameter(string name, object value) + { + switch (name) + { + case nameof(ControlState): + if (!Equals(ControlState, value)) + { + ControlState = (MCM.ControlState?)value; + NativeControl.ControlState = ControlState ?? default; + } + break; + case nameof(HasIcon): + if (!Equals(HasIcon, value)) + { + HasIcon = (bool?)value; + NativeControl.HasIcon = HasIcon ?? (bool)MCM.Switch.HasIconProperty.DefaultValue; + } + break; + case nameof(IconColor): + if (!Equals(IconColor, value)) + { + IconColor = (Color)value; + NativeControl.IconColor = IconColor; + } + break; + case nameof(IconOpacity): + if (!Equals(IconOpacity, value)) + { + IconOpacity = (float?)value; + NativeControl.IconOpacity = IconOpacity ?? (float)MCM.Switch.IconOpacityProperty.DefaultValue; + } + break; + case nameof(IsChecked): + if (!Equals(IsChecked, value)) + { + IsChecked = (bool?)value; + NativeControl.IsChecked = IsChecked ?? (bool)MCM.Switch.IsCheckedProperty.DefaultValue; + } + break; + case nameof(OutlineColor): + if (!Equals(OutlineColor, value)) + { + OutlineColor = (Color)value; + NativeControl.OutlineColor = OutlineColor; + } + break; + case nameof(OutlineWidth): + if (!Equals(OutlineWidth, value)) + { + OutlineWidth = (int?)value; + NativeControl.OutlineWidth = OutlineWidth ?? (int)MCM.Switch.OutlineWidthProperty.DefaultValue; + } + break; + case nameof(RippleColor): + if (!Equals(RippleColor, value)) + { + RippleColor = (Color)value; + NativeControl.RippleColor = RippleColor; + } + break; + case nameof(Shape): + if (!Equals(Shape, value)) + { + Shape = (MCM.Tokens.Shape?)value; + NativeControl.Shape = Shape ?? (MCM.Tokens.Shape)MCM.Switch.ShapeProperty.DefaultValue; + } + break; + case nameof(StateLayerColor): + if (!Equals(StateLayerColor, value)) + { + StateLayerColor = (Color)value; + NativeControl.StateLayerColor = StateLayerColor; + } + break; + case nameof(ThumbColor): + if (!Equals(ThumbColor, value)) + { + ThumbColor = (Color)value; + NativeControl.ThumbColor = ThumbColor; + } + break; + case nameof(ThumbOpacity): + if (!Equals(ThumbOpacity, value)) + { + ThumbOpacity = (float?)value; + NativeControl.ThumbOpacity = ThumbOpacity ?? (float)MCM.Switch.ThumbOpacityProperty.DefaultValue; + } + break; + case nameof(TrackColor): + if (!Equals(TrackColor, value)) + { + TrackColor = (Color)value; + NativeControl.TrackColor = TrackColor; + } + break; + case nameof(TrackOpacity): + if (!Equals(TrackOpacity, value)) + { + TrackOpacity = (float?)value; + NativeControl.TrackOpacity = TrackOpacity ?? (float)MCM.Switch.TrackOpacityProperty.DefaultValue; + } + break; + case nameof(IsCheckedChanged): + if (!Equals(IsCheckedChanged, value)) + { + void NativeControlCheckedChanged(object sender, MC.CheckedChangedEventArgs e) + { + var value = NativeControl.IsChecked; + IsChecked = value; + InvokeEventCallback(IsCheckedChanged, value); + } + + IsCheckedChanged = (EventCallback)value; + NativeControl.CheckedChanged -= NativeControlCheckedChanged; + NativeControl.CheckedChanged += NativeControlCheckedChanged; + } + break; + + default: + base.HandleParameter(name, value); + break; + } + } + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDTabItem.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDTabItem.generated.cs new file mode 100644 index 00000000..d0168fbc --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDTabItem.generated.cs @@ -0,0 +1,200 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Rendering; +using Microsoft.Maui.Graphics; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public partial class MDTabItem : SKTouchCanvasView + { + static MDTabItem() + { + RegisterAdditionalHandlers(); + } + + [Parameter] public Color ActiveIndicatorColor { get; set; } + [Parameter] public float? ActiveIndicatorOpacity { get; set; } + [Parameter] public MCM.Tokens.Shape? ActiveIndicatorShape { get; set; } + [Parameter] public Color BackgroundColour { get; set; } + [Parameter] public string FontFamily { get; set; } + [Parameter] public bool? FontItalic { get; set; } + [Parameter] public float? FontSize { get; set; } + [Parameter] public int? FontWeight { get; set; } + [Parameter] public Color ForegroundColor { get; set; } + [Parameter] public bool? HasIcon { get; set; } + [Parameter] public bool? HasLabel { get; set; } + [Parameter] public string IconData { get; set; } + [Parameter] public global::IconPacks.Material.IconKind? IconKind { get; set; } + [Parameter] public global::SkiaSharp.SKPicture IconSource { get; set; } + [Parameter] public bool? IsActived { get; set; } + [Parameter] public Color RippleColor { get; set; } + [Parameter] public Color StateLayerColor { get; set; } + [Parameter] public string Text { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } + + public new MCM.TabItem NativeControl => (MCM.TabItem)((BindableObject)this).NativeControl; + + protected override MCM.TabItem CreateNativeElement() => new(); + + protected override void HandleParameter(string name, object value) + { + switch (name) + { + case nameof(ActiveIndicatorColor): + if (!Equals(ActiveIndicatorColor, value)) + { + ActiveIndicatorColor = (Color)value; + NativeControl.ActiveIndicatorColor = ActiveIndicatorColor; + } + break; + case nameof(ActiveIndicatorOpacity): + if (!Equals(ActiveIndicatorOpacity, value)) + { + ActiveIndicatorOpacity = (float?)value; + NativeControl.ActiveIndicatorOpacity = ActiveIndicatorOpacity ?? (float)MCM.TabItem.ActiveIndicatorOpacityProperty.DefaultValue; + } + break; + case nameof(ActiveIndicatorShape): + if (!Equals(ActiveIndicatorShape, value)) + { + ActiveIndicatorShape = (MCM.Tokens.Shape?)value; + NativeControl.ActiveIndicatorShape = ActiveIndicatorShape ?? (MCM.Tokens.Shape)MCM.TabItem.ActiveIndicatorShapeProperty.DefaultValue; + } + break; + case nameof(BackgroundColour): + if (!Equals(BackgroundColour, value)) + { + BackgroundColour = (Color)value; + NativeControl.BackgroundColour = BackgroundColour; + } + break; + case nameof(FontFamily): + if (!Equals(FontFamily, value)) + { + FontFamily = (string)value; + NativeControl.FontFamily = FontFamily; + } + break; + case nameof(FontItalic): + if (!Equals(FontItalic, value)) + { + FontItalic = (bool?)value; + NativeControl.FontItalic = FontItalic ?? (bool)MCM.TabItem.FontItalicProperty.DefaultValue; + } + break; + case nameof(FontSize): + if (!Equals(FontSize, value)) + { + FontSize = (float?)value; + NativeControl.FontSize = FontSize ?? (float)MCM.TabItem.FontSizeProperty.DefaultValue; + } + break; + case nameof(FontWeight): + if (!Equals(FontWeight, value)) + { + FontWeight = (int?)value; + NativeControl.FontWeight = FontWeight ?? (int)MCM.TabItem.FontWeightProperty.DefaultValue; + } + break; + case nameof(ForegroundColor): + if (!Equals(ForegroundColor, value)) + { + ForegroundColor = (Color)value; + NativeControl.ForegroundColor = ForegroundColor; + } + break; + case nameof(HasIcon): + if (!Equals(HasIcon, value)) + { + HasIcon = (bool?)value; + NativeControl.HasIcon = HasIcon ?? (bool)MCM.TabItem.HasIconProperty.DefaultValue; + } + break; + case nameof(HasLabel): + if (!Equals(HasLabel, value)) + { + HasLabel = (bool?)value; + NativeControl.HasLabel = HasLabel ?? (bool)MCM.TabItem.HasLabelProperty.DefaultValue; + } + break; + case nameof(IconData): + if (!Equals(IconData, value)) + { + IconData = (string)value; + NativeControl.IconData = IconData; + } + break; + case nameof(IconKind): + if (!Equals(IconKind, value)) + { + IconKind = (global::IconPacks.Material.IconKind?)value; + NativeControl.IconKind = IconKind ?? (global::IconPacks.Material.IconKind)MCM.TabItem.IconKindProperty.DefaultValue; + } + break; + case nameof(IconSource): + if (!Equals(IconSource, value)) + { + IconSource = (global::SkiaSharp.SKPicture)value; + NativeControl.IconSource = IconSource; + } + break; + case nameof(IsActived): + if (!Equals(IsActived, value)) + { + IsActived = (bool?)value; + NativeControl.IsActived = IsActived ?? (bool)MCM.TabItem.IsActivedProperty.DefaultValue; + } + break; + case nameof(RippleColor): + if (!Equals(RippleColor, value)) + { + RippleColor = (Color)value; + NativeControl.RippleColor = RippleColor; + } + break; + case nameof(StateLayerColor): + if (!Equals(StateLayerColor, value)) + { + StateLayerColor = (Color)value; + NativeControl.StateLayerColor = StateLayerColor; + } + break; + case nameof(Text): + if (!Equals(Text, value)) + { + Text = (string)value; + NativeControl.Text = Text; + } + break; + case nameof(ChildContent): + ChildContent = (RenderFragment)value; + break; + + default: + base.HandleParameter(name, value); + break; + } + } + + protected override void RenderAdditionalElementContent(RenderTreeBuilder builder, ref int sequence) + { + base.RenderAdditionalElementContent(builder, ref sequence); + RenderTreeBuilderHelper.AddContentProperty(builder, sequence++, ChildContent, (x, value) => x.Content = (MC.View)value); + } + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Elements/Material.Components/MDTabs.generated.cs b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDTabs.generated.cs new file mode 100644 index 00000000..a108dd16 --- /dev/null +++ b/samples/ThirdPartyControlsSample/Elements/Material.Components/MDTabs.generated.cs @@ -0,0 +1,96 @@ +// +// This code was generated by a BlazorBindings.Maui component generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// + +using BlazorBindings.Core; +using BlazorBindings.Maui.Elements; +using MC = Microsoft.Maui.Controls; +using MCM = Material.Components.Maui; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Rendering; +using Microsoft.Maui.Graphics; +using System.Threading.Tasks; + +#pragma warning disable CA2252 + +namespace BlazorBindings.Maui.Elements.Material.Components +{ + public partial class MDTabs : BlazorBindings.Maui.Elements.TemplatedView + { + static MDTabs() + { + RegisterAdditionalHandlers(); + } + + [Parameter] public Color ActiveIndicatorColor { get; set; } + [Parameter] public MCM.Tokens.Shape? ActiveIndicatorShape { get; set; } + [Parameter] public bool? HasIcon { get; set; } + [Parameter] public bool? HasLabel { get; set; } + [Parameter] public int? SelectedIndex { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } + + public new MCM.Tabs NativeControl => (MCM.Tabs)((BindableObject)this).NativeControl; + + protected override MCM.Tabs CreateNativeElement() => new(); + + protected override void HandleParameter(string name, object value) + { + switch (name) + { + case nameof(ActiveIndicatorColor): + if (!Equals(ActiveIndicatorColor, value)) + { + ActiveIndicatorColor = (Color)value; + NativeControl.ActiveIndicatorColor = ActiveIndicatorColor; + } + break; + case nameof(ActiveIndicatorShape): + if (!Equals(ActiveIndicatorShape, value)) + { + ActiveIndicatorShape = (MCM.Tokens.Shape?)value; + NativeControl.ActiveIndicatorShape = ActiveIndicatorShape ?? (MCM.Tokens.Shape)MCM.Tabs.ActiveIndicatorShapeProperty.DefaultValue; + } + break; + case nameof(HasIcon): + if (!Equals(HasIcon, value)) + { + HasIcon = (bool?)value; + NativeControl.HasIcon = HasIcon ?? (bool)MCM.Tabs.HasIconProperty.DefaultValue; + } + break; + case nameof(HasLabel): + if (!Equals(HasLabel, value)) + { + HasLabel = (bool?)value; + NativeControl.HasLabel = HasLabel ?? (bool)MCM.Tabs.HasLabelProperty.DefaultValue; + } + break; + case nameof(SelectedIndex): + if (!Equals(SelectedIndex, value)) + { + SelectedIndex = (int?)value; + NativeControl.SelectedIndex = SelectedIndex ?? (int)MCM.Tabs.SelectedIndexProperty.DefaultValue; + } + break; + case nameof(ChildContent): + ChildContent = (RenderFragment)value; + break; + + default: + base.HandleParameter(name, value); + break; + } + } + + protected override void RenderAdditionalElementContent(RenderTreeBuilder builder, ref int sequence) + { + base.RenderAdditionalElementContent(builder, ref sequence); + RenderTreeBuilderHelper.AddListContentProperty(builder, sequence++, ChildContent, x => x.Items); + } + + static partial void RegisterAdditionalHandlers(); + } +} diff --git a/samples/ThirdPartyControlsSample/Properties/Elements.cs b/samples/ThirdPartyControlsSample/Properties/Elements.cs index 716d9cc8..4014a7ca 100644 --- a/samples/ThirdPartyControlsSample/Properties/Elements.cs +++ b/samples/ThirdPartyControlsSample/Properties/Elements.cs @@ -1,7 +1,4 @@ -using AlohaKit.Controls; -using BlazorBindings.Maui.ComponentGenerator; -using SkiaSharp.Views.Maui.Controls; -using XCalendar.Maui.Views; +using BlazorBindings.Maui.ComponentGenerator; // AlohaKit.Controls [assembly: GenerateComponent(typeof(Rating))] @@ -35,17 +32,8 @@ })] // Material.Components.Maui -[assembly: GenerateComponent(typeof(Material.Components.Maui.ProgressIndicator), Aliases = new[] { "ProgressIndicator:MDProgressIndicator" })] -[assembly: GenerateComponent(typeof(Material.Components.Maui.Button), Aliases = new[] { "Button:MDButton" })] -[assembly: GenerateComponent(typeof(Material.Components.Maui.NavigationBar), Aliases = new[] { "NavigationBar:MDNavigationBar" })] -[assembly: GenerateComponent(typeof(Material.Components.Maui.ComboBox), Aliases = new[] { "ComboBox:MDComboBox" })] -[assembly: GenerateComponent(typeof(Material.Components.Maui.ComboBoxItem), Aliases = new[] { "ComboBoxItem:MDComboBoxItem" })] -[assembly: GenerateComponent(typeof(Material.Components.Maui.MenuItem), Aliases = new[] { "MenuItem:MDMenuItem" })] -[assembly: GenerateComponent(typeof(Material.Components.Maui.Card), Aliases = new[] { "Card:MDCard" })] -[assembly: GenerateComponent(typeof(Material.Components.Maui.WrapLayout), Aliases = new[] { "WrapLayout:MDWrapLayout" })] -[assembly: GenerateComponent(typeof(Material.Components.Maui.Popup), Aliases = new[] { "Popup:MDPopup" })] -[assembly: GenerateComponent(typeof(Material.Components.Maui.Label), Aliases = new[] { "Label:MDLabel" })] -[assembly: GenerateComponent(typeof(Material.Components.Maui.TextField), Aliases = new[] { "TextField:MDTextField" })] +[assembly: GenerateComponentsFromAssembly(typeof(Material.Components.Maui.Button), + TypeNamePrefix = "MD")] [assembly: GenerateComponent(typeof(Material.Components.Maui.SKTouchCanvasView))] [assembly: GenerateComponent(typeof(SKCanvasView))] diff --git a/samples/ThirdPartyControlsSample/ThirdPartyControlsSample.csproj b/samples/ThirdPartyControlsSample/ThirdPartyControlsSample.csproj index 3edb2850..fa246ae5 100644 --- a/samples/ThirdPartyControlsSample/ThirdPartyControlsSample.csproj +++ b/samples/ThirdPartyControlsSample/ThirdPartyControlsSample.csproj @@ -50,6 +50,7 @@ + diff --git a/src/BlazorBindings.Maui.ComponentGenerator/Extensions/SymbolExtensions.cs b/src/BlazorBindings.Maui.ComponentGenerator/Extensions/SymbolExtensions.cs index 03c02c7a..4a9d76f1 100644 --- a/src/BlazorBindings.Maui.ComponentGenerator/Extensions/SymbolExtensions.cs +++ b/src/BlazorBindings.Maui.ComponentGenerator/Extensions/SymbolExtensions.cs @@ -39,6 +39,21 @@ public static IPropertySymbol GetProperty(this ITypeSymbol typeSymbol, string pr return GetMember(typeSymbol, propName, includeBaseTypes) as IPropertySymbol; } + public static IEnumerable GetAllTypes(this INamespaceSymbol namespaceSymbol) + { + foreach (var nsOrType in namespaceSymbol.GetMembers()) + { + if (nsOrType is INamedTypeSymbol namedType) + yield return namedType; + + if (nsOrType is INamespaceSymbol ns) + { + foreach (var type in GetAllTypes(ns)) + yield return type; + } + } + } + public static string GetFullName(this INamespaceOrTypeSymbol namespaceOrType) { var stack = new Stack(); diff --git a/src/BlazorBindings.Maui.ComponentGenerator/GenerateComponentData.cs b/src/BlazorBindings.Maui.ComponentGenerator/GenerateComponentData.cs index 352bc59a..b5fbf0c6 100644 --- a/src/BlazorBindings.Maui.ComponentGenerator/GenerateComponentData.cs +++ b/src/BlazorBindings.Maui.ComponentGenerator/GenerateComponentData.cs @@ -1,4 +1,5 @@ using Microsoft.CodeAnalysis; +using System; using System.Collections.Generic; using System.Linq; @@ -11,12 +12,12 @@ public class GenerateComponentSettings public string FileHeader { get; set; } public string TypeAlias { get; set; } public INamedTypeSymbol TypeSymbol { get; set; } - public HashSet Exclude { get; set; } - public HashSet Include { get; set; } - public HashSet ContentProperties { get; set; } - public string[] PropertyChangedEvents { get; set; } - public Dictionary GenericProperties { get; set; } - public Dictionary Aliases { get; set; } + public HashSet Exclude { get; set; } = new(); + public HashSet Include { get; set; } = new(); + public HashSet ContentProperties { get; set; } = new(); + public string[] PropertyChangedEvents { get; set; } = Array.Empty(); + public Dictionary GenericProperties { get; set; } = new(); + public Dictionary Aliases { get; set; } = new(); public GenerateComponentSettings BaseTypeInfo { get; set; } public bool IsBaseTypeGeneric => BaseTypeInfo?.IsGeneric ?? false; diff --git a/src/BlazorBindings.Maui.ComponentGenerator/GeneratedPropertyInfo.cs b/src/BlazorBindings.Maui.ComponentGenerator/GeneratedPropertyInfo.cs index aa374b00..b2f1f781 100644 --- a/src/BlazorBindings.Maui.ComponentGenerator/GeneratedPropertyInfo.cs +++ b/src/BlazorBindings.Maui.ComponentGenerator/GeneratedPropertyInfo.cs @@ -84,7 +84,7 @@ string GetComponentPropertyName() public string GetPropertyDeclaration() { - // razor compiler doesn't allow 'new' properties, it condiders them as duplicates. + // razor compiler doesn't allow 'new' properties, it considers them as duplicates. if (_propertyInfo is not null && _propertyInfo.IsHidingMember()) { return ""; diff --git a/src/BlazorBindings.Maui.ComponentGenerator/GeneratedTypeInfo.cs b/src/BlazorBindings.Maui.ComponentGenerator/GeneratedTypeInfo.cs index 7afd4aff..eb4663d3 100644 --- a/src/BlazorBindings.Maui.ComponentGenerator/GeneratedTypeInfo.cs +++ b/src/BlazorBindings.Maui.ComponentGenerator/GeneratedTypeInfo.cs @@ -64,24 +64,27 @@ public string GetTypeNameAndAddNamespace(ITypeSymbol type) return typeName; } + if (type is not INamedTypeSymbol namedType) + return type.Name; + if (type.ContainingType != null) { - return $"{GetTypeNameAndAddNamespace(type.ContainingType)}.{FormatTypeName(type)}"; + return $"{GetTypeNameAndAddNamespace(type.ContainingType)}.{FormatTypeName(namedType)}"; } var nsName = type.ContainingNamespace.GetFullName(); - return GetTypeNameAndAddNamespace(nsName, FormatTypeName(type)); + return GetTypeNameAndAddNamespace(nsName, FormatTypeName(namedType)); } - private string FormatTypeName(ITypeSymbol type) + private string FormatTypeName(INamedTypeSymbol namedType) { - if (type is not INamedTypeSymbol namedType || !namedType.IsGenericType) + if (!namedType.IsGenericType) { - return type.Name; + return namedType.Name; } var typeNameBuilder = new StringBuilder(); - typeNameBuilder.Append(type.Name); + typeNameBuilder.Append(namedType.Name); typeNameBuilder.Append('<'); var genericArgs = namedType.TypeArguments; for (var i = 0; i < genericArgs.Length; i++) diff --git a/src/BlazorBindings.Maui.ComponentGenerator/Program.cs b/src/BlazorBindings.Maui.ComponentGenerator/Program.cs index 0f67774d..d818be3b 100644 --- a/src/BlazorBindings.Maui.ComponentGenerator/Program.cs +++ b/src/BlazorBindings.Maui.ComponentGenerator/Program.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +using BlazorBindings.Maui.ComponentGenerator.Extensions; using CommandLine; using Microsoft.Build.Locator; using Microsoft.CodeAnalysis; @@ -69,6 +70,8 @@ private static GenerateComponentSettings[] GetTypesToGenerate(Compilation compil { Console.WriteLine("Finding types to generate."); + var elementType = compilation.GetTypeByMetadataName("Microsoft.Maui.Controls.Element"); + var attributes = compilation.Assembly.GetAttributes(); var typesToGenerate = attributes .Where(a => a.AttributeClass?.ToDisplayString() == "BlazorBindings.Maui.ComponentGenerator.GenerateComponentAttribute") @@ -99,7 +102,32 @@ private static GenerateComponentSettings[] GetTypesToGenerate(Compilation compil }; }) .Where(type => type.TypeSymbol != null) - .ToArray(); + .ToList(); + + var typesByAssembly = attributes + .Where(a => a.AttributeClass?.ToDisplayString() == "BlazorBindings.Maui.ComponentGenerator.GenerateComponentsFromAssemblyAttribute") + .SelectMany(a => + { + var containingTypeSymbol = a.ConstructorArguments.FirstOrDefault().Value as INamedTypeSymbol; + var typeNamePrefix = a.NamedArguments.FirstOrDefault(a => a.Key == "TypeNamePrefix").Value.Value as string; + + var typesInAssembly = containingTypeSymbol.ContainingAssembly + .GlobalNamespace.GetAllTypes() + .Where(t => t.DeclaredAccessibility == Accessibility.Public) + .Where(t => !(t.IsGenericType && t.IsDefinition)) + .Where(t => compilation.ClassifyCommonConversion(t, elementType) is { IsReference: true, IsImplicit: true }); + + return typesInAssembly + .Where(typeSymbol => typesToGenerate.Any(t => !SymbolEqualityComparer.Default.Equals(t.TypeSymbol, typeSymbol))) + .Select(typeSymbol => new GenerateComponentSettings + { + FileHeader = FileHeader, + TypeSymbol = typeSymbol, + TypeAlias = typeNamePrefix is null ? null : typeNamePrefix + typeSymbol.Name + }); + }); + + typesToGenerate.AddRange(typesByAssembly); foreach (var info in typesToGenerate) { @@ -107,7 +135,7 @@ private static GenerateComponentSettings[] GetTypesToGenerate(Compilation compil info.BaseTypeInfo = baseTypeInfo; } - return typesToGenerate; + return typesToGenerate.ToArray(); } private static string[] GetNamedArgumentValues(AttributeData attribute, string name) diff --git a/src/BlazorBindings.Maui/ComponentGenerator/GenerateComponentsFromAssemblyAttribute.cs b/src/BlazorBindings.Maui/ComponentGenerator/GenerateComponentsFromAssemblyAttribute.cs new file mode 100644 index 00000000..1fcc3b8a --- /dev/null +++ b/src/BlazorBindings.Maui/ComponentGenerator/GenerateComponentsFromAssemblyAttribute.cs @@ -0,0 +1,9 @@ +namespace BlazorBindings.Maui.ComponentGenerator; + +[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] +public class GenerateComponentsFromAssemblyAttribute : Attribute +{ + public GenerateComponentsFromAssemblyAttribute(Type containingType) { } + + public string TypeNamePrefix { get; set; } +} \ No newline at end of file