mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-07-26 22:42:17 +00:00
fix: keep navigation layout stable across rotation
This commit is contained in:
parent
0ac38dce43
commit
7cd424e206
2 changed files with 44 additions and 1 deletions
|
|
@ -68,6 +68,7 @@ import androidx.compose.ui.platform.LocalFocusManager
|
|||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.zIndex
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
|
|
@ -1842,7 +1843,11 @@ private fun MainAppContent(
|
|||
)
|
||||
|
||||
BoxWithConstraints(modifier = Modifier.fillMaxSize()) {
|
||||
val isTabletLayout = useTabletFloatingTabBar || maxWidth >= 768.dp
|
||||
val isTabletLayout = isTabletAppLayout(
|
||||
width = maxWidth,
|
||||
height = maxHeight,
|
||||
forceTabletLayout = useTabletFloatingTabBar,
|
||||
)
|
||||
val useNativeBottomTabs = if (useNativeNavigation) {
|
||||
useNativeTabBar
|
||||
} else {
|
||||
|
|
@ -3574,6 +3579,12 @@ private fun MainAppContent(
|
|||
}
|
||||
}
|
||||
|
||||
internal fun isTabletAppLayout(
|
||||
width: Dp,
|
||||
height: Dp,
|
||||
forceTabletLayout: Boolean = false,
|
||||
): Boolean = forceTabletLayout || minOf(width, height) >= 768.dp
|
||||
|
||||
@Composable
|
||||
private fun rememberGuardedPopBackStack(
|
||||
navController: NuvioNavigator,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
package com.nuvio.app
|
||||
|
||||
import androidx.compose.ui.unit.dp
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class AppLayoutTest {
|
||||
|
||||
@Test
|
||||
fun `phone navigation classification stays stable across rotation`() {
|
||||
assertFalse(isTabletAppLayout(width = 666.dp, height = 1000.dp))
|
||||
assertFalse(isTabletAppLayout(width = 1000.dp, height = 666.dp))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `tablet navigation classification stays stable across rotation`() {
|
||||
assertTrue(isTabletAppLayout(width = 800.dp, height = 1280.dp))
|
||||
assertTrue(isTabletAppLayout(width = 1280.dp, height = 800.dp))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `platform override still forces tablet navigation`() {
|
||||
assertTrue(
|
||||
isTabletAppLayout(
|
||||
width = 390.dp,
|
||||
height = 844.dp,
|
||||
forceTabletLayout = true,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue