xamarin / AndroidX

AndroidX bindings for .NET for Android
MIT License
181 stars 45 forks source link

Material3 NavigationBar #984

Closed justin-caldicott closed 2 days ago

justin-caldicott commented 2 days ago

Android application type

Android for .NET (net6.0-android, etc.)

Affected platform version

dotnet 8.0.402, android

Description

I can't work out how to include the material3 NavigationBar included in Jetpack Compose: https://m3.material.io/components/navigation-bar/overview

Are there bindings for this? I've been poking around in various assemblies added from the Xamarin.AndroidX.Compose.Material3 nuget package. The closest I found is NavigationBarDefaults and NavigationBarKt but these appear to be classes, not views, so when I get errors when trying to add them to my Layout.xml.

Steps to Reproduce

  1. Start a new Android app project (not MAUI)
  2. Add the Xamarin.AndroidX.Compose.Material3 NuGet package
  3. Be unsure how to add the newer material 3 NavigationBar (I'm using Rider)

Did you find any workaround?

No response

Relevant log output

No response

jpobst commented 2 days ago

If it part of Jetpack Compose then it will not be usable from .NET for Android.

Compose UIs can only be created in Kotlin, not Java. As .NET for Android bridges via Java, it cannot create them either.

https://stackoverflow.com/questions/66433437/can-i-write-jetpack-compose-components-in-java/66433621#66433621

The Compose packages we provide contain the .jar/.aar so that libraries that depend on them will function, but they do not provide C# bindings as they can't be used to create Compose UIs.

justin-caldicott commented 2 days ago

Thanks for clarifying @jpobst. I'd not come across Jetpack Compose until yesterday (don't often get to work on our Android app). No problem, I've started to use the material-components equivalents.

Longer term I hope native UI's via .NET remains a thing if Google start to release features only via Jetpack Compose. The pattern of sharing as much as possible in view models between our apps and then using fairly thin native UIs has been working well for us. 🤞