Skip to content

Commit

Permalink
core: Add WindowAdaptiveInfo.isWindowSmall
Browse files Browse the repository at this point in the history
  • Loading branch information
sirambd committed Sep 25, 2024
1 parent 2a02d7b commit de3b3a1
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,14 @@ import androidx.window.core.layout.WindowWidthSizeClass
fun WindowAdaptiveInfo.isWindowLarge(): Boolean = with(windowSizeClass) {
return windowWidthSizeClass == WindowWidthSizeClass.EXPANDED && windowHeightSizeClass != WindowHeightSizeClass.COMPACT
}

/**
* Determines if the current window is classified as a small window suitable for mobile devices.
*
* A window is considered small if its width size class is not [WindowWidthSizeClass.EXPANDED]
* or its height size class is [WindowHeightSizeClass.COMPACT]. This function can be used
* to adapt the UI layout for smaller screens, ensuring a better user experience on mobile devices.
*
* @return `true` if the window is small (mobile), `false` otherwise.
*/
fun WindowAdaptiveInfo.isWindowSmall(): Boolean = !isWindowLarge()

0 comments on commit de3b3a1

Please sign in to comment.