Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ComponentGenerator - support custom collection types #123

Merged
merged 1 commit into from
May 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
// <auto-generated>
// 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.
// </auto-generated>

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.Collections;
using System.Threading.Tasks;

#pragma warning disable CA2252

namespace BlazorBindings.Maui.Elements.Material.Components
{
public partial class MDComboBox : SKTouchCanvasView
{
static MDComboBox()
{
RegisterAdditionalHandlers();
}

[Parameter] public Color ActiveIndicatorColor { get; set; }
[Parameter] public int? ActiveIndicatorHeight { get; set; }
[Parameter] public float? ActiveIndicatorOpacity { 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? IsOutline { get; set; }
[Parameter] public IList ItemsSource { get; set; }
[Parameter] public string LabelText { get; set; }
[Parameter] public Color LabelTextColor { get; set; }
[Parameter] public float? LabelTextOpacity { get; set; }
[Parameter] public Color OutlineColor { get; set; }
[Parameter] public int? OutlineWidth { get; set; }
[Parameter] public int? SelectedIndex { get; set; }
[Parameter] public MCM.Tokens.Shape? Shape { get; set; }
[Parameter] public Color StateLayerColor { get; set; }
[Parameter] public string Text { get; set; }
[Parameter] public RenderFragment ChildContent { get; set; }
[Parameter] public EventCallback<int> SelectedIndexChanged { get; set; }

public new MCM.ComboBox NativeControl => (MCM.ComboBox)((BindableObject)this).NativeControl;

protected override MCM.ComboBox 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(ActiveIndicatorHeight):
if (!Equals(ActiveIndicatorHeight, value))
{
ActiveIndicatorHeight = (int?)value;
NativeControl.ActiveIndicatorHeight = ActiveIndicatorHeight ?? (int)MCM.ComboBox.ActiveIndicatorHeightProperty.DefaultValue;
}
break;
case nameof(ActiveIndicatorOpacity):
if (!Equals(ActiveIndicatorOpacity, value))
{
ActiveIndicatorOpacity = (float?)value;
NativeControl.ActiveIndicatorOpacity = ActiveIndicatorOpacity ?? (float)MCM.ComboBox.ActiveIndicatorOpacityProperty.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.ComboBox.FontItalicProperty.DefaultValue;
}
break;
case nameof(FontSize):
if (!Equals(FontSize, value))
{
FontSize = (float?)value;
NativeControl.FontSize = FontSize ?? (float)MCM.ComboBox.FontSizeProperty.DefaultValue;
}
break;
case nameof(FontWeight):
if (!Equals(FontWeight, value))
{
FontWeight = (int?)value;
NativeControl.FontWeight = FontWeight ?? (int)MCM.ComboBox.FontWeightProperty.DefaultValue;
}
break;
case nameof(ForegroundColor):
if (!Equals(ForegroundColor, value))
{
ForegroundColor = (Color)value;
NativeControl.ForegroundColor = ForegroundColor;
}
break;
case nameof(IsOutline):
if (!Equals(IsOutline, value))
{
IsOutline = (bool?)value;
NativeControl.IsOutline = IsOutline ?? (bool)MCM.ComboBox.IsOutlineProperty.DefaultValue;
}
break;
case nameof(ItemsSource):
if (!Equals(ItemsSource, value))
{
ItemsSource = (IList)value;
NativeControl.ItemsSource = ItemsSource;
}
break;
case nameof(LabelText):
if (!Equals(LabelText, value))
{
LabelText = (string)value;
NativeControl.LabelText = LabelText;
}
break;
case nameof(LabelTextColor):
if (!Equals(LabelTextColor, value))
{
LabelTextColor = (Color)value;
NativeControl.LabelTextColor = LabelTextColor;
}
break;
case nameof(LabelTextOpacity):
if (!Equals(LabelTextOpacity, value))
{
LabelTextOpacity = (float?)value;
NativeControl.LabelTextOpacity = LabelTextOpacity ?? (float)MCM.ComboBox.LabelTextOpacityProperty.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.ComboBox.OutlineWidthProperty.DefaultValue;
}
break;
case nameof(SelectedIndex):
if (!Equals(SelectedIndex, value))
{
SelectedIndex = (int?)value;
NativeControl.SelectedIndex = SelectedIndex ?? (int)MCM.ComboBox.SelectedIndexProperty.DefaultValue;
}
break;
case nameof(Shape):
if (!Equals(Shape, value))
{
Shape = (MCM.Tokens.Shape?)value;
NativeControl.Shape = Shape ?? (MCM.Tokens.Shape)MCM.ComboBox.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(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<int>)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<MCM.ComboBox, MCM.ComboBoxItem>(builder, sequence++, ChildContent, x => x.Items);
}

static partial void RegisterAdditionalHandlers();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// <auto-generated>
// 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.
// </auto-generated>

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 partial class MDComboBoxItem : MDMenuItem
{
static MDComboBoxItem()
{
RegisterAdditionalHandlers();
}

public new MCM.ComboBoxItem NativeControl => (MCM.ComboBoxItem)((BindableObject)this).NativeControl;

protected override MCM.ComboBoxItem CreateNativeElement() => new();


static partial void RegisterAdditionalHandlers();
}
}
Loading