Use the dual pane netplay screen layout only if the width is sufficient

To avoid using dual pane layout on very small devices, ensure that the current width available for display is at least medium (600dp).

It also has to be landscape, the dual pane mode looks weird on a tablet in portrait mode since there's not that much content.
This commit is contained in:
Tom Pratt
2026-05-18 21:35:13 +02:00
committed by Tom Pratt
parent 4d1e749977
commit 8d565e0331
3 changed files with 11 additions and 1 deletions
+1
View File
@@ -166,6 +166,7 @@ dependencies {
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.compose.material.icons)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.material3.adaptive)
implementation(libs.androidx.compose.runtime.livedata)
implementation(libs.androidx.compose.ui)
debugImplementation(libs.androidx.compose.ui.tooling)
@@ -61,6 +61,7 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.SheetValue
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
@@ -87,6 +88,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.window.core.layout.WindowSizeClass
import coil.compose.AsyncImage
import coil.request.ImageRequest
import kotlinx.coroutines.flow.Flow
@@ -171,7 +173,13 @@ fun NetplayScreen(
mutableStateOf(joinAddresses.keys.firstOrNull() ?: JoinInfoType.EXTERNAL)
}
if (LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE) {
val isLandscape =
LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE
val isWidthAtLeastMedium = currentWindowAdaptiveInfo().windowSizeClass
.isWidthAtLeastBreakpoint(WindowSizeClass.WIDTH_DP_MEDIUM_LOWER_BOUND)
val useWideLayout = isLandscape && isWidthAtLeastMedium
if (useWideLayout) {
LandscapeContent(
isHosting = isHosting,
messages = messages,
+1
View File
@@ -35,6 +35,7 @@ androidx-cardview = { group = "androidx.cardview", name = "cardview", version.re
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
androidx-compose-material-icons = { group = "androidx.compose.material", name = "material-icons-extended" }
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
androidx-compose-material3-adaptive = { group = "androidx.compose.material3.adaptive", name = "adaptive" }
androidx-compose-runtime-livedata = { group = "androidx.compose.runtime", name = "runtime-livedata" }
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }