From a3a3f44056fbcacd3a9b7e68bf7643099d18f0bf Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 16 Jul 2023 09:59:17 -0400 Subject: [PATCH] Constrain reader sheet to max 75% of height --- .../presentation/components/AdaptiveSheet.kt | 3 + .../presentation/components/TabbedDialog.kt | 2 + .../reader/settings/ReaderSettingsDialog.kt | 59 ++++++++++--------- .../core/components/AdaptiveSheet.kt | 5 +- 4 files changed, 41 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/components/AdaptiveSheet.kt b/app/src/main/java/eu/kanade/presentation/components/AdaptiveSheet.kt index cacb0fe207..1a4f2b9ee7 100644 --- a/app/src/main/java/eu/kanade/presentation/components/AdaptiveSheet.kt +++ b/app/src/main/java/eu/kanade/presentation/components/AdaptiveSheet.kt @@ -6,6 +6,7 @@ import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.animation.togetherWith 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.window.Dialog @@ -70,6 +71,7 @@ fun NavigatorAdaptiveSheet( */ @Composable fun AdaptiveSheet( + modifier: Modifier = Modifier, tonalElevation: Dp = 1.dp, enableSwipeDismiss: Boolean = true, onDismissRequest: () -> Unit, @@ -82,6 +84,7 @@ fun AdaptiveSheet( properties = dialogProperties, ) { AdaptiveSheetImpl( + modifier = modifier, isTabletUi = isTabletUi, tonalElevation = tonalElevation, enableSwipeDismiss = enableSwipeDismiss, diff --git a/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt b/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt index 6e494f275c..76b0dc904a 100644 --- a/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt @@ -40,6 +40,7 @@ object TabbedDialogPaddings { @Composable fun TabbedDialog( + modifier: Modifier = Modifier, onDismissRequest: () -> Unit, tabTitles: List, tabOverflowMenuContent: (@Composable ColumnScope.(() -> Unit) -> Unit)? = null, @@ -47,6 +48,7 @@ fun TabbedDialog( content: @Composable (Int) -> Unit, ) { AdaptiveSheet( + modifier = modifier, onDismissRequest = onDismissRequest, ) { val scope = rememberCoroutineScope() diff --git a/app/src/main/java/eu/kanade/presentation/reader/settings/ReaderSettingsDialog.kt b/app/src/main/java/eu/kanade/presentation/reader/settings/ReaderSettingsDialog.kt index cf5b08997c..583708d982 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/settings/ReaderSettingsDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/settings/ReaderSettingsDialog.kt @@ -1,6 +1,8 @@ package eu.kanade.presentation.reader.settings +import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.foundation.rememberScrollState @@ -30,35 +32,38 @@ fun ReaderSettingsDialog( ) val pagerState = rememberPagerState { tabTitles.size } - TabbedDialog( - onDismissRequest = { - onDismissRequest() - onShowMenus() - }, - tabTitles = tabTitles, - pagerState = pagerState, - ) { page -> - val window = (LocalView.current.parent as? DialogWindowProvider)?.window - - LaunchedEffect(pagerState.currentPage) { - if (pagerState.currentPage == 2) { - window?.setDimAmount(0f) - onHideMenus() - } else { - window?.setDimAmount(0.5f) + BoxWithConstraints { + TabbedDialog( + modifier = Modifier.heightIn(max = maxHeight * 0.75f), + onDismissRequest = { + onDismissRequest() onShowMenus() - } - } + }, + tabTitles = tabTitles, + pagerState = pagerState, + ) { page -> + val window = (LocalView.current.parent as? DialogWindowProvider)?.window - Column( - modifier = Modifier - .padding(vertical = TabbedDialogPaddings.Vertical) - .verticalScroll(rememberScrollState()), - ) { - when (page) { - 0 -> ReadingModePage(screenModel) - 1 -> GeneralPage(screenModel) - 2 -> ColorFilterPage(screenModel) + LaunchedEffect(pagerState.currentPage) { + if (pagerState.currentPage == 2) { + window?.setDimAmount(0f) + onHideMenus() + } else { + window?.setDimAmount(0.5f) + onShowMenus() + } + } + + Column( + modifier = Modifier + .padding(vertical = TabbedDialogPaddings.Vertical) + .verticalScroll(rememberScrollState()), + ) { + when (page) { + 0 -> ReadingModePage(screenModel) + 1 -> GeneralPage(screenModel) + 2 -> ColorFilterPage(screenModel) + } } } } diff --git a/presentation-core/src/main/java/tachiyomi/presentation/core/components/AdaptiveSheet.kt b/presentation-core/src/main/java/tachiyomi/presentation/core/components/AdaptiveSheet.kt index aab3efcec5..24ae1b48d8 100644 --- a/presentation-core/src/main/java/tachiyomi/presentation/core/components/AdaptiveSheet.kt +++ b/presentation-core/src/main/java/tachiyomi/presentation/core/components/AdaptiveSheet.kt @@ -56,6 +56,7 @@ private val sheetAnimationSpec = tween(durationMillis = 350) @Composable fun AdaptiveSheet( + modifier: Modifier = Modifier, isTabletUi: Boolean, tonalElevation: Dp, enableSwipeDismiss: Boolean, @@ -97,7 +98,8 @@ fun AdaptiveSheet( onClick = {}, ) .systemBarsPadding() - .padding(vertical = 16.dp), + .padding(vertical = 16.dp) + .then(modifier), shape = MaterialTheme.shapes.extraLarge, tonalElevation = tonalElevation, content = { @@ -160,6 +162,7 @@ fun AdaptiveSheet( Modifier }, ) + .then(modifier) .offset { IntOffset( 0,