Use WindowSizeClass instead of just checking portrait/landscape orientation
This commit is contained in:
parent
15eca13ff8
commit
69fb344517
2 changed files with 22 additions and 9 deletions
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2026 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.designsystem.utils
|
||||
|
||||
import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi
|
||||
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
|
||||
import androidx.compose.material3.windowsizeclass.WindowHeightSizeClass
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@OptIn(ExperimentalMaterial3AdaptiveApi::class)
|
||||
@Composable
|
||||
fun hasCompactHeightWindowSize(): Boolean {
|
||||
return currentWindowAdaptiveInfo().windowSizeClass.heightSizeClass == WindowHeightSizeClass.Compact
|
||||
}
|
||||
|
|
@ -51,7 +51,6 @@ import androidx.compose.ui.layout.ContentScale
|
|||
import androidx.compose.ui.layout.onSizeChanged
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import androidx.compose.ui.platform.LocalWindowInfo
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.heading
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
|
|
@ -78,6 +77,7 @@ import io.element.android.libraries.designsystem.theme.components.IconButton
|
|||
import io.element.android.libraries.designsystem.theme.components.Scaffold
|
||||
import io.element.android.libraries.designsystem.theme.components.Text
|
||||
import io.element.android.libraries.designsystem.theme.components.TopAppBar
|
||||
import io.element.android.libraries.designsystem.utils.hasCompactHeightWindowSize
|
||||
import io.element.android.libraries.designsystem.utils.snackbar.SnackbarHost
|
||||
import io.element.android.libraries.designsystem.utils.snackbar.rememberSnackbarHostState
|
||||
import io.element.android.libraries.matrix.api.media.MediaSource
|
||||
|
|
@ -112,10 +112,7 @@ fun MediaViewerView(
|
|||
var showOverlay by remember { mutableStateOf(true) }
|
||||
|
||||
val currentData = state.listData.getOrNull(state.currentIndex)
|
||||
val isLandscape = with(LocalWindowInfo.current) {
|
||||
containerDpSize.width > containerDpSize.height
|
||||
}
|
||||
val defaultBottomPaddingInPixels = if (LocalInspectionMode.current && !isLandscape) 303 else 0
|
||||
val defaultBottomPaddingInPixels = if (LocalInspectionMode.current && !hasCompactHeightWindowSize()) 303 else 0
|
||||
|
||||
BackHandler { onBackClick() }
|
||||
Scaffold(
|
||||
|
|
@ -552,13 +549,10 @@ private fun MediaViewerBottomBar(
|
|||
}
|
||||
val scrollState = rememberScrollState()
|
||||
val showBottomShadow by remember { derivedStateOf { scrollState.value < scrollState.maxValue } }
|
||||
val isLandscape = with(LocalWindowInfo.current) {
|
||||
containerDpSize.width > containerDpSize.height
|
||||
}
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.heightIn(max = if (isLandscape) maxCaptionHeightLandscape else maxCaptionHeightPortrait),
|
||||
.heightIn(max = if (hasCompactHeightWindowSize()) maxCaptionHeightLandscape else maxCaptionHeightPortrait),
|
||||
) {
|
||||
Text(
|
||||
modifier = Modifier
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue