JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.28k stars 1.11k forks source link

Support material3-window-size-class #2404

Open manosbatsis opened 1 year ago

manosbatsis commented 1 year ago

See https://developer.android.com/reference/kotlin/androidx/compose/material3/windowsizeclass/WindowSizeClass

wakaztahir commented 1 year ago

any updates?

Laxystem commented 1 year ago

Bumping this up! Any info?

pablichjenkov commented 1 year ago

Bumping this up! Any info?

What makes it different than just getting the size of your root composable and using CompositionLocal to pass it down the tree?

Laxystem commented 1 year ago

Bumping this up! Any info?

What makes it different than just getting the size of your root composable and using CompositionLocal to pass it down the tree?

Material3 theme guidelines have exact descriptions of what to use with different size classes, for example, drawer for large, rail for medium, and bar for small.

pablichjenkov commented 1 year ago

Bumping this up! Any info?

What makes it different than just getting the size of your root composable and using CompositionLocal to pass it down the tree?

Material3 theme guidelines have exact descriptions of what to use with different size classes, for example, drawer for large, rail for medium, and bar for small.

I see your point but what I mean is that this is something in the application side rather than in compose itself. It is in the material spec however I don't see a size to describe TV. Also I believe the width/height aspect ratio is important too, not just one dimension size. So that is why I believe JB/Google has not include it in compose but keep it as separate Library. And it is not hard to compute too. I just checked I have something similar in an adaptive component, here: https://github.com/pablichjenkov/templato/blob/master/components/templato-components/src/commonMain/kotlin/com/pablichj/templato/component/core/adaptive/AdaptiveSizeComponent.kt#L113

Laxystem commented 1 year ago

I see your point but what I mean is that this is something in the application side rather than in compose itself. It is in the material spec however I don't see a size to describe TV. Also I believe the width/height aspect ratio is important too, not just one dimension size.

Well, it is not a separate library - for JetBrains Compose it simply does not exist. I do not see why would you not implement features that can be found in Google Compose.

For me, writing the math myself isn't worth it. Sure, it is simple, but I have lots of these small simple stuff to implement. If it was a library, android & iOS support could be a thing - but it is not, and implementing support for them manually, as I said, will take too much time.

This will be a neat thing, but not really major for me. I do not see why would you object to the addition of such an API?

pablichjenkov commented 1 year ago

Well, it is not a separate library - for JetBrains Compose it simply does not exist...

Oh I see, excuse my ignorance. I see it has been released as part of material 3 artifacts recently. Sorry I didn't know that, I thought it was still being released as a separate library. In such a case I believe it is just a matter of time until JB catches up with Google stuff.

chrisbanes commented 1 year ago

FYI: I built https://github.com/chrisbanes/material3-windowsizeclass-multiplatform as a stop-gap until support comes to Compose Multiplatform.

Shabinder commented 10 months ago

With 1.5.0 release.

in desktop, LocalWindow.current is marked internal and hence not accessible, any known alternative to get current windows DpSize ?

egorikftp commented 1 month ago

@igordmn Any updates for this issue?

issamux commented 3 weeks ago

hi,

I wonder why we can’t integrate it into the CompositionLocal (at least in android side)

It was very easy to use this like :

 val LocalDevicePostureFlow = compositionLocalOf<DevicePosture> {
  error("No DevicePostureFlow provided")
  }

val LocalWindowSize = compositionLocalOf<WindowSizeClass> {
error("No WindowSizeClass provided")
 }

and use it in code :

          val windowSize = calculateWindowSizeClass(this)
          val devicePosture = devicePostureFlow.collectAsState()

          CompositionLocalProvider(
                    LocalDevicePostureFlow provides devicePosture.value,
                    LocalWindowSize provides windowSize
                ) {
                    MyAppComposeUi()
                }

Am I missing something about using it in Local composition !!!