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

Add HybridWebView #169

Merged
merged 1 commit into from
Nov 13, 2024
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
72 changes: 72 additions & 0 deletions src/BlazorBindings.Maui/Elements/HybridWebView.generated.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// <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 MC = Microsoft.Maui.Controls;
using Microsoft.AspNetCore.Components;
using System.Threading.Tasks;

#pragma warning disable MBB001

namespace BlazorBindings.Maui.Elements
{
/// <summary>
/// A <see cref="T:Microsoft.Maui.Controls.View" /> that presents local HTML content in a web view and allows JavaScript and C# code to communicate by using messages and by invoking methods.
/// </summary>
public partial class HybridWebView : View
{
static HybridWebView()
{
RegisterAdditionalHandlers();
}

[Parameter] public string DefaultFile { get; set; }
[Parameter] public string HybridRoot { get; set; }
[Parameter] public EventCallback<MC.HybridWebViewRawMessageReceivedEventArgs> OnRawMessageReceived { get; set; }

public new MC.HybridWebView NativeControl => (MC.HybridWebView)((BindableObject)this).NativeControl;

protected override MC.HybridWebView CreateNativeElement() => new();

protected override void HandleParameter(string name, object value)
{
switch (name)
{
case nameof(DefaultFile):
if (!Equals(DefaultFile, value))
{
DefaultFile = (string)value;
NativeControl.DefaultFile = DefaultFile;
}
break;
case nameof(HybridRoot):
if (!Equals(HybridRoot, value))
{
HybridRoot = (string)value;
NativeControl.HybridRoot = HybridRoot;
}
break;
case nameof(OnRawMessageReceived):
if (!Equals(OnRawMessageReceived, value))
{
void NativeControlRawMessageReceived(object sender, MC.HybridWebViewRawMessageReceivedEventArgs e) => InvokeEventCallback(OnRawMessageReceived, e);

OnRawMessageReceived = (EventCallback<MC.HybridWebViewRawMessageReceivedEventArgs>)value;
NativeControl.RawMessageReceived -= NativeControlRawMessageReceived;
NativeControl.RawMessageReceived += NativeControlRawMessageReceived;
}
break;

default:
base.HandleParameter(name, value);
break;
}
}

static partial void RegisterAdditionalHandlers();
}
}
5 changes: 1 addition & 4 deletions src/BlazorBindings.Maui/Elements/StackLayout.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ static StackLayout()
}

/// <summary>
/// Gets or sets the value which indicates the direction which child elements are positioned.
/// Gets or sets the value which indicates the direction which child elements are positioned. Default value is <see cref="F:Microsoft.Maui.Controls.StackOrientation.Vertical" />.
/// </summary>
/// <value>
/// A <see cref="T:Microsoft.Maui.Controls.StackOrientation" /> which indicates the direction children layouts flow. The default value is Vertical.
/// </value>
[Parameter] public MC.StackOrientation? Orientation { get; set; }

public new MC.StackLayout NativeControl => (MC.StackLayout)((BindableObject)this).NativeControl;
Expand Down
144 changes: 27 additions & 117 deletions src/BlazorBindings.Maui/Properties/AttributeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,38 @@

[assembly: InternalsVisibleTo("BlazorBindings.UnitTests")]

//[assembly: GenerateComponentsFromAssembly(typeof(Element),
// Exclude = [
// typeof(Application),
// typeof(AbsoluteLayout),
// typeof(ContentPresenter),
// typeof(Microsoft.Maui.Controls.Compatibility.RelativeLayout),
// typeof(ImageSource),
// typeof(FileImageSource),
// typeof(UriImageSource),
// typeof(StreamImageSource),
// typeof(FontImageSource),
// typeof(Path),
// typeof(FormattedString),
// typeof(NavigationPage)
// ])]
[assembly: GenerateComponentsFromAssembly(typeof(Element),
Exclude = [
typeof(Application),
typeof(AbsoluteLayout),
typeof(ContentPresenter),
typeof(Microsoft.Maui.Controls.Compatibility.RelativeLayout),
typeof(ImageSource),
typeof(FileImageSource),
typeof(UriImageSource),
typeof(StreamImageSource),
typeof(FontImageSource),
typeof(Path),
typeof(FormattedString),
typeof(NavigationPage),
typeof(AppLinkEntry)
])]

[assembly: GenerateComponent(typeof(ActivityIndicator))]
[assembly: GenerateComponent(typeof(BaseMenuItem))]
[assembly: GenerateComponent(typeof(BaseShellItem))]
[assembly: GenerateComponent(typeof(Behavior))]
[assembly: GenerateComponent(typeof(Border))]
[assembly: GenerateComponent(typeof(BoxView))]
[assembly: GenerateComponent(typeof(Brush))]
[assembly: GenerateComponent(typeof(Button))]
[assembly: GenerateComponent(typeof(CarouselView),
GenericProperties = [nameof(CarouselView.CurrentItem)])]
[assembly: GenerateComponent(typeof(CheckBox))]
[assembly: GenerateComponent(typeof(CollectionView))]
[assembly: GenerateComponent(typeof(ContentPage))]
[assembly: GenerateComponent(typeof(ContentView))]
[assembly: GenerateComponent(typeof(CarouselView), GenericProperties = [nameof(CarouselView.CurrentItem)])]
[assembly: GenerateComponent(typeof(DatePicker),
Exclude = [nameof(DatePicker.Date), nameof(DatePicker.DateSelected), nameof(DatePicker.MaximumDate), nameof(DatePicker.MinimumDate)])]
[assembly: GenerateComponent(typeof(Editor))]
[assembly: GenerateComponent(typeof(Element),
Exclude = [ nameof(Element.ChildAdded), nameof(Element.ChildRemoved),
nameof(Element.DescendantAdded), nameof(Element.DescendantRemoved),
nameof(Element.Parent), nameof(Element.ParentChanging), nameof(Element.ParentChanged),
nameof(Element.Handler), nameof(Element.HandlerChanged), nameof(Element.HandlerChanging) ])]
[assembly: GenerateComponent(typeof(Entry), IsGeneric = true)]
[assembly: GenerateComponent(typeof(FlexLayout))]
[assembly: GenerateComponent(typeof(FlyoutItem))]
[assembly: GenerateComponent(typeof(FlyoutPage), Exclude = [nameof(FlyoutPage.Detail)])]
[assembly: GenerateComponent(typeof(Frame))]

Check warning on line 39 in src/BlazorBindings.Maui/Properties/AttributeInfo.cs

View workflow job for this annotation

GitHub Actions / build

'Frame' is obsolete: 'Frame is obsolete as of .NET 9. Please use Border instead.'
[assembly: GenerateComponent(typeof(GestureElement))]
[assembly: GenerateComponent(typeof(GradientBrush))]
[assembly: GenerateComponent(typeof(GradientStop))]
[assembly: GenerateComponent(typeof(GraphicsView))]
[assembly: GenerateComponent(typeof(Grid),
Exclude = [nameof(Grid.ColumnDefinitions), nameof(Grid.RowDefinitions)])]
[assembly: GenerateComponent(typeof(Grid), Exclude = [nameof(Grid.ColumnDefinitions), nameof(Grid.RowDefinitions)])]
[assembly: GenerateComponent(typeof(GroupableItemsView),
Exclude = [nameof(GroupableItemsView.GroupFooterTemplate), nameof(GroupableItemsView.GroupHeaderTemplate), nameof(GroupableItemsView.IsGrouped)])]
[assembly: GenerateComponent(typeof(HorizontalStackLayout))]
[assembly: GenerateComponent(typeof(Image))]
[assembly: GenerateComponent(typeof(ImageButton))]
[assembly: GenerateComponent(typeof(IndicatorView),
PropertyChangedEvents = [nameof(IndicatorView.Position)],
Exclude = [nameof(IndicatorView.ItemsSource), nameof(IndicatorView.IndicatorLayout)])]
Expand All @@ -70,9 +48,6 @@
GenericProperties = [nameof(ItemsView.ItemsSource), nameof(ItemsView.ItemTemplate)],
ContentProperties = [nameof(ItemsView.EmptyView)],
Exclude = [nameof(ItemsView.EmptyViewTemplate), nameof(ItemsView.ItemsSource)])]
[assembly: GenerateComponent(typeof(Label))]
[assembly: GenerateComponent(typeof(Layout))]
[assembly: GenerateComponent(typeof(LinearGradientBrush))]
[assembly: GenerateComponent(typeof(ListView),
Exclude = [nameof(ListView.ItemTemplate)],
GenericProperties = [
Expand All @@ -83,28 +58,22 @@
Aliases = [
$"{nameof(ListView.HeaderTemplate)}:Header",
$"{nameof(ListView.FooterTemplate)}:Footer" ])]
[assembly: GenerateComponent(typeof(MenuItem))]
[assembly: GenerateComponent(typeof(NavigableElement))]
[assembly: GenerateComponent(typeof(Page))]
[assembly: GenerateComponent(typeof(Picker),
GenericProperties = [nameof(Picker.ItemsSource), nameof(Picker.SelectedItem), nameof(Picker.ItemDisplayBinding)],
PropertyChangedEvents = [nameof(Picker.SelectedItem)])]
[assembly: GenerateComponent(typeof(ProgressBar))]
[assembly: GenerateComponent(typeof(RadialGradientBrush))]
[assembly: GenerateComponent(typeof(RadioButton))]
[assembly: GenerateComponent(typeof(RefreshView),
Exclude = [nameof(RefreshView.Refreshing)],
PropertyChangedEvents = [nameof(RefreshView.IsRefreshing)])]
[assembly: GenerateComponent(typeof(ReorderableItemsView), Exclude = [nameof(ReorderableItemsView.CanMixGroups)])]
[assembly: GenerateComponent(typeof(ScrollView))]
[assembly: GenerateComponent(typeof(SearchBar))]
[assembly: GenerateComponent(typeof(ReorderableItemsView),
Exclude = [nameof(ReorderableItemsView.CanMixGroups)])]
[assembly: GenerateComponent(typeof(SearchHandler),
GenericProperties = [nameof(SearchHandler.ItemsSource), nameof(SearchHandler.SelectedItem), nameof(SearchHandler.ItemTemplate)],
PropertyChangedEvents = [nameof(SearchHandler.Query), nameof(SearchHandler.SelectedItem)])]
[assembly: GenerateComponent(typeof(SelectableItemsView),
GenericProperties = [nameof(SelectableItemsView.SelectedItem)],
PropertyChangedEvents = [nameof(SelectableItemsView.SelectedItem), nameof(SelectableItemsView.SelectedItems)])]
[assembly: GenerateComponent(typeof(Shadow), Exclude = [nameof(Shadow.Brush)])]
[assembly: GenerateComponent(typeof(Shadow),
Exclude = [nameof(Shadow.Brush)])]
[assembly: GenerateComponent(typeof(Shell),
GenericProperties = [
$"{nameof(Shell.ItemTemplate)}:Microsoft.Maui.Controls.BaseShellItem",
Expand All @@ -116,87 +85,28 @@
$"{nameof(Shell.FlyoutContentTemplate)}:FlyoutContent",
],
Exclude = [nameof(Shell.Items)])]
[assembly: GenerateComponent(typeof(ShellContent),
Exclude = [nameof(ShellContent.ContentTemplate)])]
[assembly: GenerateComponent(typeof(ShellGroupItem))]
[assembly: GenerateComponent(typeof(ShellContent), Exclude = [nameof(ShellContent.ContentTemplate)])]
[assembly: GenerateComponent(typeof(ShellItem), Exclude = [nameof(ShellItem.Items)])]
[assembly: GenerateComponent(typeof(ShellSection), Exclude = [nameof(ShellSection.Items)])]
[assembly: GenerateComponent(typeof(Slider))]
[assembly: GenerateComponent(typeof(SolidColorBrush))]
[assembly: GenerateComponent(typeof(Span))]
[assembly: GenerateComponent(typeof(StackBase))]
[assembly: GenerateComponent(typeof(StackLayout))]
[assembly: GenerateComponent(typeof(StructuredItemsView),
ContentProperties = [nameof(StructuredItemsView.Header), nameof(StructuredItemsView.Footer)],
Exclude = [nameof(StructuredItemsView.HeaderTemplate), nameof(StructuredItemsView.FooterTemplate)])]
[assembly: GenerateComponent(typeof(Stepper))]
[assembly: GenerateComponent(typeof(StyleableElement))]
[assembly: GenerateComponent(typeof(SwipeView),
ContentProperties = [nameof(SwipeView.LeftItems), nameof(SwipeView.RightItems), nameof(SwipeView.TopItems), nameof(SwipeView.BottomItems)])]
[assembly: GenerateComponent(typeof(SwipeItems),
Exclude = [nameof(SwipeItems.CollectionChanged)])]
[assembly: GenerateComponent(typeof(SwipeItem))]
[assembly: GenerateComponent(typeof(SwipeItemView))]
[assembly: GenerateComponent(typeof(Switch))]
[assembly: GenerateComponent(typeof(Tab))]
[assembly: GenerateComponent(typeof(TabBar))]
[assembly: GenerateComponent(typeof(TabbedPage),
Exclude = [nameof(TabbedPage.ItemsSource), nameof(TabbedPage.ItemTemplate)])]
[assembly: GenerateComponent(typeof(TableView),
Exclude = [nameof(TableView.Root)])]
[assembly: GenerateComponent(typeof(SwipeItems), Exclude = [nameof(SwipeItems.CollectionChanged)])]
[assembly: GenerateComponent(typeof(TabbedPage), Exclude = [nameof(TabbedPage.ItemsSource), nameof(TabbedPage.ItemTemplate)])]
[assembly: GenerateComponent(typeof(TableView), Exclude = [nameof(TableView.Root)])]
[assembly: GenerateComponent(typeof(TableRoot))]
[assembly: GenerateComponent(typeof(TableSection))]
[assembly: GenerateComponent(typeof(TableSectionBase))]
[assembly: GenerateComponent(typeof(TemplatedPage), Exclude = [nameof(TemplatedPage.ControlTemplate)])]
[assembly: GenerateComponent(typeof(TemplatedView))]
[assembly: GenerateComponent(typeof(TimePicker), Exclude = [nameof(TimePicker.Time), nameof(TimePicker.TimeSelected)])]
[assembly: GenerateComponent(typeof(TitleBar))]
[assembly: GenerateComponent(typeof(ToolbarItem))]
[assembly: GenerateComponent(typeof(VerticalStackLayout))]
[assembly: GenerateComponent(typeof(View))]
[assembly: GenerateComponent(typeof(VisualElement), Exclude = [nameof(VisualElement.BackgroundColor)])]
[assembly: GenerateComponent(typeof(WebView), NonContentProperties = [nameof(WebView.Source)])]

[assembly: GenerateComponent(typeof(FlyoutBase))]
[assembly: GenerateComponent(typeof(KeyboardAccelerator))]
[assembly: GenerateComponent(typeof(MenuBar))]
[assembly: GenerateComponent(typeof(MenuBarItem))]
[assembly: GenerateComponent(typeof(MenuFlyout))]
[assembly: GenerateComponent(typeof(MenuFlyoutItem))]
[assembly: GenerateComponent(typeof(MenuFlyoutSeparator))]
[assembly: GenerateComponent(typeof(MenuFlyoutSubItem))]

[assembly: GenerateComponent(typeof(Window))]

// Cells
[assembly: GenerateComponent(typeof(TextCell))]
[assembly: GenerateComponent(typeof(ImageCell))]
[assembly: GenerateComponent(typeof(SwitchCell))]
[assembly: GenerateComponent(typeof(EntryCell),
PropertyChangedEvents = [nameof(EntryCell.Text)])]
[assembly: GenerateComponent(typeof(ViewCell))]
[assembly: GenerateComponent(typeof(Cell))]


// GestureRecognizers
[assembly: GenerateComponent(typeof(GestureRecognizer))]
[assembly: GenerateComponent(typeof(PanGestureRecognizer))]
[assembly: GenerateComponent(typeof(PinchGestureRecognizer))]
[assembly: GenerateComponent(typeof(SwipeGestureRecognizer))]
[assembly: GenerateComponent(typeof(TapGestureRecognizer))]
[assembly: GenerateComponent(typeof(PointerGestureRecognizer))]
[assembly: GenerateComponent(typeof(DragGestureRecognizer))]
[assembly: GenerateComponent(typeof(DropGestureRecognizer))]


// Compatibility
[assembly: GenerateComponent(typeof(Microsoft.Maui.Controls.Compatibility.Layout))]

// Shapes
[assembly: GenerateComponent(typeof(Ellipse))]
[assembly: GenerateComponent(typeof(Line))]
[assembly: GenerateComponent(typeof(Polygon))]
[assembly: GenerateComponent(typeof(Polyline))]
[assembly: GenerateComponent(typeof(Rectangle))]
[assembly: GenerateComponent(typeof(Shape))]
[assembly: GenerateComponent(typeof(RoundRectangle))]
[assembly: GenerateComponent(typeof(Microsoft.Maui.Controls.Compatibility.Layout))]

Check warning on line 112 in src/BlazorBindings.Maui/Properties/AttributeInfo.cs

View workflow job for this annotation

GitHub Actions / build

'Layout' is obsolete: 'Use Microsoft.Maui.Controls.Layout instead. For more information, see https://learn.microsoft.com/dotnet/maui/user-interface/layouts/custom'
Loading