Skip to content

Commit

Permalink
support large screens
Browse files Browse the repository at this point in the history
  • Loading branch information
mosayeb-a committed Dec 23, 2023
1 parent 4f0758b commit 8d21032
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package me.ash.reader.ui.page.home.feeds

import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp


@Composable
fun rememberWindowInfo(): WindowInfo {
val configuration = LocalConfiguration.current
return WindowInfo(
screenWidthInfo = when {
configuration.screenWidthDp < 600 -> WindowInfo.WindowType.Compat
configuration.screenWidthDp < 840 -> WindowInfo.WindowType.Medium
else -> WindowInfo.WindowType.Expanded
},
screenHeightInfo = when {
configuration.screenWidthDp < 480 -> WindowInfo.WindowType.Compat
configuration.screenWidthDp < 900 -> WindowInfo.WindowType.Medium
else -> WindowInfo.WindowType.Expanded
},
screenWidth = configuration.screenWidthDp.dp,
screenHeight = configuration.screenWidthDp.dp,
)
}

data class WindowInfo(
val screenWidthInfo: WindowType,
val screenHeightInfo: WindowType,
val screenWidth: Dp,
val screenHeight: Dp

) {
sealed class WindowType {
object Compat : WindowType()
object Medium : WindowType()
object Expanded : WindowType()
}
}

0 comments on commit 8d21032

Please sign in to comment.