Thread
#compose
    a

    Amirul Zin

    3 years ago
    Hi all. I’ve been Googling around but can’t seem to find an answer for this. Does JetPack compose support (or planning to support) resource qualifiers? Something that is currently easy to do in Android is supporting multiple configurations e.g. density based, RTL layouts, localizations etc. Powered by DataBinding null-aware inflation, this made supporting all this configurations quite trivial to implement. If it wasn’t supported, maybe something of the below (haven’t look thru the Compose code yet) would work?:
    @Qualifiers("sw600dp")
    @Composable
    fun someView(){
       ...
    }
    Or maybe just pass in the current qualifiers to the composable function? If I got off the wrong starting point, please enlighten me. Thanks!
    jim

    jim

    3 years ago
    We're still identifying which patterns make the most sense with regards to supporting multiple configurations, so details are still TBD. Whereas XML layouts were relatively static (requiring coarse-grained configuration selection), Compose apps/widgets can be much more responsive (eg. see the
    WithConstraints
    widget), which gives you more flexibility to naturally scale the app as the window size increases. To get something mimetic of the existing system, it is also possible for us (or you) to implement a widget that takes in a map of configuration qualifiers to composable lambdas, and will compose the appropriate lambda that matches the current configuration. So there are some options here, but wherever we land, it will likely be more code-centric rather than based on file name/path/annotation.
    Adam Powell

    Adam Powell

    3 years ago
    or to put it another way, at a minimum you'll be able to do something like this:
    @Composable
    fun SomeView() = if (currentConfiguration.smallestScreenWidthDp >= 600) {
        BigView()
    } else {
        SmallView()
    }
    and if we end up needing more than you can express in that sort of way, we'll invest further down the road