-
Notifications
You must be signed in to change notification settings - Fork 63
Compose bindings (stable only) #352
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
Conversation
|
@moljac this would be awesome to have, is there anything left to do before merging and publish to nuget? |
yes I know it would be awsome to have, but my timeslots are getting smaller and smaller and these artifacts are darn tough to bind. Soon I hope. Sincerely |
|
bound! How do you plan to use it? Can you provide a sample? |
|
Hi @moljac, |
OK. Thanks. I get it.
It would be nice. I would add it to the samples folder, as a use case and for testing ACWs.
You re welcome. And sorry you had to wait. |
I will create it tomorrow and upload it here.
No problem, take your take. |
|
While I generally don't think we should provide samples due to resource constraints, I think in this case we should have something to ensure this works before we publish it. Once we publish this on NuGet, people are going to expect it to work, and we should at least know if it does or not. There are 2 use cases:
The first case is simple, and these bindings are in fact overkill for it. We do not need managed bindings, just a loose The second case is more interesting. My understanding from @jonathanpeppers is that it requires Java compile time dynamic source generation, which we do not support. So this case may not work for Xamarin. I think we need to determine if this second case works or not. If not, I think we should only provide the |
|
Hi, here is the sample project, that consists in a native jetpack compose library, a native app to try the native jetpack compose library and a Xamarin binding to try the native jetpack compose library. NOTE: In the sample project, currently the jetpack compose library and the native app are working, but the Xamarin binding is not working, because the dependencies the jetpack dependencies are missing in Regarding this PR, the binding list is very solid to start, but I think there are three missing packages that are a must have in jetpack libraries Regarding using jetpack compose to build UI in Xamarin, I think that it will not be possible. |
It might be an interesting research project to see if this could possibly work from C#. I suspect it might involved porting their Kotlin compiler plugin to a C# source generator. It might be hard to maintain this overtime, if they keep changing it for each Jetpack release. |
|
Jetpack Compose it's in the very early days, each release it's coupled with a kotlin specific version, because the Kotlin Compiler Plugin API it's not stable, so I would advice to wait at least until the Kotlin Compiler Plugin API is stable, otherwise it will be a hard journey for Xamarin. |
|
Any news on this? What about merging this as is and them improve? |
I dream of getting some time off and dive into monadic parser combinators like Sprache or Superpower which would include parsing only methods decorated with
And this is another story. |
I have |
|
No MCWs generated (only |
jpobst
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's comment out all of the unused metadata. Running the XPath evaluations to apply metadata is one of the most time consuming parts of the binding process, and we know these are always go to fail, adding both time and warnings to the build.
I wonder if we should modify AndroidXProject.cshtml to look for Compose packages (by groupId and modify the <Summary>/<Description> to specify that these are not managed bindings and are only used for including Java files.
| using Android.Widget; | ||
| using Android.Graphics; | ||
|
|
||
| namespace AndroidX.Compose.UI.Text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment out these Additions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed removed namespaces
config.json
Outdated
| "artifactId": "material-icons-extended", | ||
| "version": "1.0.0", | ||
| "nugetVersion": "1.0.0", | ||
| "nugetId": "Xamarin.AndroidX.Compose.Compose.Material.Material.Icons.Extended", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove all of the duplicate parts from the NuGet IDs, ie: let's make this:
Xamarin.AndroidX.Compose.Material.Icons.Extended
It looks like they consistently use the same word for the end of the groupId and the first part of the artifactId, so always deduplicating the names should not cause issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
"as is" on main/masteer for tons of users means - this must be stable... Get it? it would lead people into trap of thinking they can use it in Xamarin world. |
|
Oh, I see, I thought that even with the binding of the API present, the functions annotated with '@composable' wouldn't be accessible/exposed in c#. |
| <remove-node | ||
| path="/api/package[@name='androidx.compose.foundation']" | ||
| /> | ||
| <remove-node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why switch to this style from the previous?
<remove-node path="path=/api/package" />
This seems like more work, and will require us to manually update this with each new namespace added to future Compose versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember I asked have you ever tried that XPath which caused:
BINDINGSGENERATOR : error BG0000: System.InvalidOperationException: The XPath expression evaluated to unexpected type System.Boolean.
Tried several Xpath patterns:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because they duplicate the path= part, which is so subtle I didn't even notice when I copied the value for that comment. 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know - staring at the code does not help... Need some time off...
fixed.
|
Thanks for your hard work in this PR, this is a great improvement to xamarin 👍 |
|
Bom dia @4brunu and... muito obrigado.
I would say - addition instead of improvement... If you get some time to dive in deeper we might discuss it how to add full support like in Kotlin... I have some ideas, but... |
|
Bom dia @moljac Addition is a better word indeed.
That would be a real challenge and I have no idea where to start or how could I help. By the way, I created a PR with some packages that are important to me and also very commonly used in apps/native libraries that use jetpack compose #419. |
|
Is there any new sample for this? Old one from 2021 is not really working for me. Is it possible to build UI with jetpack compose? On .NET 7 Android |
Compose bindings (stable only)
new bindings for àndroidx.compose` artifacts
androidx.compose.animation:animation - -> 1.0.0
androidx.compose.animation:animation-core - -> 1.0.0
androidx.compose.foundation:foundation - -> 1.0.0
androidx.compose.foundation:foundation-layout - -> 1.0.0
androidx.compose.material:material - -> 1.0.0
androidx.compose.material:material-icons-core - -> 1.0.0
androidx.compose.material:material-icons-extended - -> 1.0.0
androidx.compose.material:material-ripple - -> 1.0.0
androidx.compose.runtime:runtime - -> 1.0.0
androidx.compose.runtime:runtime-livedata - -> 1.0.0
androidx.compose.runtime:runtime-rxjava2 - -> 1.0.0
androidx.compose.runtime:runtime-saveable - -> 1.0.0
androidx.compose.ui:ui - -> 1.0.0
androidx.compose.ui:ui-geometry - -> 1.0.0
androidx.compose.ui:ui-graphics - -> 1.0.0
androidx.compose.ui:ui-text - -> 1.0.0
androidx.compose.ui:ui-unit - -> 1.0.0
androidx.compose.ui:ui-util - -> 1.0.0
androidx.compose.ui:ui-viewbinding - -> 1.0.0
androidx.profileinstaller:profile-installer - -> 1.0.0
Checklist