AvaloniaUI / AvaloniaMauiHybrid

Brings templated controls, pixel perfect rendering, animations, styling and composition to Maui
MIT License
175 stars 13 forks source link

Add Windows and update to net7 #8

Closed juwens closed 10 months ago

juwens commented 1 year ago

work in progress

blocked by: https://github.com/AvaloniaUI/Avalonia/issues/12782

major

minor

caveats

juwens commented 1 year ago

@kekekeks i tricked the build (for the while beeing) by renaming all maui xaml files to mxaml, like you ava does with axaml.

To workaround this issue: https://github.com/AvaloniaUI/AvaloniaMauiHybrid/issues/7#issuecomment-1703177240

I also needed to disable FluentTheme, because it could not be resolved.

https://github.com/AvaloniaUI/AvaloniaMauiHybrid/blob/157e066d06d1dd14c63ffc72c63d579c5641c82a/MauiSampleApp/AvaloniaApp.axaml#L6

juwens commented 1 year ago

it starts, no avalonia rendering visible yet (but that is expected, cause there is no code for that yet)

image
maxkatz6 commented 1 year ago

due to an shortcoming of avalonia, which tries to parse every xaml file, and terminates and throws an error if it fails

It parses xaml files only if they were added in csproj with <AvaloniaView Include=".xaml" />. You don't need these.

I also needed to disable FluentTheme, because it could not be resolved.

Add Avalonia.Themes.Fluent package

juwens commented 1 year ago

@maxkatz6

thx for taking a look into it.

It parses xaml files only if they were added in csproj with <AvaloniaView Include=".xaml" />. You don't need these.

I think you missed the point where i already analysed and explained that in the issue.

You can try it yourself with my PR (just reset some commits before i renamed to mxaml). In the csproj no single xaml file was added to AvaloniaView.

You can look at the the binlog analysis, the problem has two main components:

  1. maui implicitly adds all xaml files to ItemGroup AdditionalFiles (this is no problem, and acceptable behavior)
  2. ItemGroup AdditionalFilesare are passed to the csc and the source-generators
  3. AvaloniaNameGenerator sourcegen parses all ".xaml", ".paml", "*.axaml" files in the AdditionalFiles list
  4. it fails critical if the xaml file (from the AdditionalFiles ItemGroup) is a maui file

https://github.com/AvaloniaUI/AvaloniaMauiHybrid/issues/7#issuecomment-1703177240

https://github.com/AvaloniaUI/AvaloniaMauiHybrid/issues/7#issuecomment-1703291594

maxkatz6 commented 1 year ago

@juwens hi! I just updated main branch to Avalonia 11 with .NET 7. Seems to work fine at least on Android.

There were some issues with Kotlin StdLib on android though.

I added workaround for your issue with AdditionalFiles by disabled Name source generator, which is optional for Avalonia (it won't generate c# properties for x:Name xaml elements). I created https://github.com/AvaloniaUI/Avalonia/issues/12855 to track this issue. Either way, it shouldn't block this PR anymore, and mxaml file format is optional now.

juwens commented 1 year ago

@maxkatz6 thanks, i'm very grateful for your help. That'll definitely help.

Cause i try to add maui-windows (WinUI), i discovered an impediment (the lack of a WinUI "AvaloniaView"). Currently i'm digging into the whole platform-abstraction of avalonia and try to implement an AvaloniaView for WinUI https://github.com/AvaloniaUI/Avalonia/issues/12782

cesarchefinho commented 11 months ago

@maxkatz6 thanks, i'm very grateful for your help. That'll definitely help.

Cause i try to add maui-windows (WinUI), i discovered an impediment (the lack of a WinUI "AvaloniaView"). Currently i'm digging into the whole platform-abstraction of avalonia and try to implement an AvaloniaView for WinUI AvaloniaUI/Avalonia#12782

if you can add windows and browser without maui, in the same solution as maui hybrid , then we can implement specific code in windows project or in browser project and dont use maui in these plataforms...

see #12

juwens commented 10 months ago

I close it for now, as there are several outstanding things to be solved before continuing here. But i'll try to do a second attempt when i can.