-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
app/src/main/java/me/ash/reader/ui/page/home/feeds/RememberWindowInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |