currentWindowSizeClass
A composable function that calculates and returns the current window size class.
This function dynamically monitors changes in the window's dimensions using onGlobalWindowSize and calculates the appropriate WindowSizeClass based on the updated width and height. The resulting WindowSizeClass can be used to adapt the UI to different screen sizes.
Return
A WindowSizeClass object representing the current size class of the window.
Example usage:
val windowSizeClass = currentWindowSizeClass()
when (windowSizeClass) {
WindowSizeClass.Compact -> println("Compact layout")
WindowSizeClass.Medium -> println("Medium layout")
WindowSizeClass.Expanded -> println("Expanded layout")
}
Content copied to clipboard