Constrain reader sheet to max 75% of height

This commit is contained in:
arkon 2023-07-16 09:59:17 -04:00
parent 22c6dbda3f
commit a3a3f44056
4 changed files with 41 additions and 28 deletions

View File

@ -6,6 +6,7 @@ import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith import androidx.compose.animation.togetherWith
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.Dialog
@ -70,6 +71,7 @@ fun NavigatorAdaptiveSheet(
*/ */
@Composable @Composable
fun AdaptiveSheet( fun AdaptiveSheet(
modifier: Modifier = Modifier,
tonalElevation: Dp = 1.dp, tonalElevation: Dp = 1.dp,
enableSwipeDismiss: Boolean = true, enableSwipeDismiss: Boolean = true,
onDismissRequest: () -> Unit, onDismissRequest: () -> Unit,
@ -82,6 +84,7 @@ fun AdaptiveSheet(
properties = dialogProperties, properties = dialogProperties,
) { ) {
AdaptiveSheetImpl( AdaptiveSheetImpl(
modifier = modifier,
isTabletUi = isTabletUi, isTabletUi = isTabletUi,
tonalElevation = tonalElevation, tonalElevation = tonalElevation,
enableSwipeDismiss = enableSwipeDismiss, enableSwipeDismiss = enableSwipeDismiss,

View File

@ -40,6 +40,7 @@ object TabbedDialogPaddings {
@Composable @Composable
fun TabbedDialog( fun TabbedDialog(
modifier: Modifier = Modifier,
onDismissRequest: () -> Unit, onDismissRequest: () -> Unit,
tabTitles: List<String>, tabTitles: List<String>,
tabOverflowMenuContent: (@Composable ColumnScope.(() -> Unit) -> Unit)? = null, tabOverflowMenuContent: (@Composable ColumnScope.(() -> Unit) -> Unit)? = null,
@ -47,6 +48,7 @@ fun TabbedDialog(
content: @Composable (Int) -> Unit, content: @Composable (Int) -> Unit,
) { ) {
AdaptiveSheet( AdaptiveSheet(
modifier = modifier,
onDismissRequest = onDismissRequest, onDismissRequest = onDismissRequest,
) { ) {
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()

View File

@ -1,6 +1,8 @@
package eu.kanade.presentation.reader.settings package eu.kanade.presentation.reader.settings
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
@ -30,7 +32,9 @@ fun ReaderSettingsDialog(
) )
val pagerState = rememberPagerState { tabTitles.size } val pagerState = rememberPagerState { tabTitles.size }
BoxWithConstraints {
TabbedDialog( TabbedDialog(
modifier = Modifier.heightIn(max = maxHeight * 0.75f),
onDismissRequest = { onDismissRequest = {
onDismissRequest() onDismissRequest()
onShowMenus() onShowMenus()
@ -62,4 +66,5 @@ fun ReaderSettingsDialog(
} }
} }
} }
}
} }

View File

@ -56,6 +56,7 @@ private val sheetAnimationSpec = tween<Float>(durationMillis = 350)
@Composable @Composable
fun AdaptiveSheet( fun AdaptiveSheet(
modifier: Modifier = Modifier,
isTabletUi: Boolean, isTabletUi: Boolean,
tonalElevation: Dp, tonalElevation: Dp,
enableSwipeDismiss: Boolean, enableSwipeDismiss: Boolean,
@ -97,7 +98,8 @@ fun AdaptiveSheet(
onClick = {}, onClick = {},
) )
.systemBarsPadding() .systemBarsPadding()
.padding(vertical = 16.dp), .padding(vertical = 16.dp)
.then(modifier),
shape = MaterialTheme.shapes.extraLarge, shape = MaterialTheme.shapes.extraLarge,
tonalElevation = tonalElevation, tonalElevation = tonalElevation,
content = { content = {
@ -160,6 +162,7 @@ fun AdaptiveSheet(
Modifier Modifier
}, },
) )
.then(modifier)
.offset { .offset {
IntOffset( IntOffset(
0, 0,