r

    romainguy

    3 years ago
    @rivu.chakraborty You shouldn't rely on the XML syntax so much, it's going away. Use the regular function call syntax instead.
    rivu.chakraborty

    rivu.chakraborty

    3 years ago
    @romainguy I agree and understand, but the issue is I'm getting this compiler error saying "Stateless function shouldn't be invoked" when trying to use the DSL style, I'm stuck with XML syntax until I find a workaround.
    r

    romainguy

    3 years ago
    You're missing the import for composer
    Please do not tell folks to use the XML syntax it's going to create more confusion 😃
    rivu.chakraborty

    rivu.chakraborty

    3 years ago
    I've an import to
    androidx.compose.composer
    , I'll update the post right away, to replace the XML syntax with DSL @romainguy
    themishkun

    themishkun

    3 years ago
    You should set compiler flag
    -P plugin:androidx.compose.plugins.kotlin:syntax=FCS
    to get rid of this warning
    Look at the AndroidXUiPlugin for more details
    r

    romainguy

    3 years ago
    That too, thanks Mikhail
    We need to make it the default
    bloder

    bloder

    3 years ago
    @rivu.chakraborty Good article, I'm just missing the detailed explanation about why we need the usage of the
    CraneWrapper
    , probably we should use when we define a style or something like that but I don't know why (didn't have time to check this part of source code)
    rivu.chakraborty

    rivu.chakraborty

    3 years ago
    Thanks @themishkun that worked like a charm, I'll add this as well in my blog, it'll no doubt help a lot of folks.
    @bloder thanks. For the CraneWrapper, as me and @ragunathjawahar discussed last day, we guess that it happens as when encountering a more complex component than Text,
    compose
    expects a theme. I didn't mention it in the post as I'm not 100% sure about it yet, just wanted to give folks a heads-up that they need CraneWrapper and a theme to use any composable other than text.
    r

    romainguy

    3 years ago
    CraneWrapper
    is a
    View
    that sets up Compose underneath
    It’s how we hook up Jetpack Compose to the View hierarchy
    r

    ragunathjawahar

    3 years ago
    @bloder the
    CraneWrapper
    uses the
    AndroidCraneView
    to host the compose tree. Besides that, it also grants access to the
    Context
    ,
    Density
    ,
    FocusManager
    and
    TextInputService
    implicitly to any of your composables (downstream) via their corresponding ambients.
    r

    romainguy

    3 years ago
    In particular it sets up access to the context, to density, to the focus manager and to text input
    Note that the name
    Crane
    will likely disappear soon
    It was the internal code name of Compose, this is just a leftover
    r

    ragunathjawahar

    3 years ago
    For example, if you want access to the
    Context
    . You could use
    val context = +ambient(ContextAmbient)
    in one of your composables.
    l

    Leland Richardson [G]

    3 years ago
    you can think of CraneWrapper as a composable that converts the hierarchy from views -> compose ui. Composables underneath it should target compose UI, composables outside of it should target views. Right now this isn’t enforced at the compiler level but will be at some point. If you’re just using compose to target views, it’s not needed at all right now. If you’re using compose UI, you should put it at the root of your hierarchy.
    bloder

    bloder

    3 years ago
    Ohh thank you for the explanations, an other question about it, following this concept isn't make sense wrapping our composables automatically in
    setContent
    like a default wrapping of
    CraneWrapper
    ?
    r

    romainguy

    3 years ago
    One of the many, many reasons why Jetpack Compose isn’t ready for production 🙂
    bloder

    bloder

    3 years ago
    Nice, thank you! I'm pretty excited to use it, is Compose open to community contributions? I really would like to help if it's possible.
    r

    romainguy

    3 years ago
    It’s one of the reasons we wanted to Open Source it 🙂
    bloder

    bloder

    3 years ago
    is there a issue / feature list like a youtrack? I could not find 😕
    themishkun

    themishkun

    3 years ago
    @romainguy I’ve submitted a PR regarding that plugin checker defaults https://android-review.googlesource.com/c/platform/frameworks/support/+/960637