Skip to content
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

Support material3-window-size-class #2404

Open
manosbatsis opened this issue Oct 14, 2022 · 12 comments
Open

Support material3-window-size-class #2404

manosbatsis opened this issue Oct 14, 2022 · 12 comments
Assignees
Labels

Comments

@manosbatsis
Copy link

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

@wakaztahir
Copy link

any updates?

@igordmn igordmn added the enhancement New feature or request label Feb 13, 2023
@Laxystem
Copy link

Laxystem commented May 16, 2023

Bumping this up! Any info?

@pablichjenkov
Copy link

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
Copy link

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
Copy link

pablichjenkov commented May 18, 2023

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
Copy link

Laxystem commented May 19, 2023

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
Copy link

pablichjenkov commented May 19, 2023

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
Copy link

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

@Shabinder
Copy link

With 1.5.0 release.

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

@igordmn igordmn changed the title Support material3-window-size-class? Support material3-window-size-class Sep 15, 2023
@egorikftp
Copy link

@igordmn
Any updates for this issue?

@issamux
Copy link
Contributor

issamux commented Jun 10, 2024

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 !!!

@okushnikov
Copy link

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests