diff --git a/app/src/main/java/com/ganjoor/android/ui/ColumnBrowser.kt b/app/src/main/java/com/ganjoor/android/ui/ColumnBrowser.kt index cd98363..f9d3c48 100644 --- a/app/src/main/java/com/ganjoor/android/ui/ColumnBrowser.kt +++ b/app/src/main/java/com/ganjoor/android/ui/ColumnBrowser.kt @@ -61,6 +61,7 @@ import androidx.compose.material3.VerticalDivider import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.Stable +import androidx.compose.runtime.compositionLocalOf import androidx.compose.runtime.getValue import androidx.compose.runtime.key import androidx.compose.runtime.mutableIntStateOf @@ -156,6 +157,12 @@ private val CatEntry.url is CatEntry.Poem -> poem.fullUrl } +/** + * True while a side panel (the reading settings) is open beside the page on a large screen. + * The columns step aside for it, so the page keeps its room, and come back when it closes. + */ +val LocalSidePanelOpen = compositionLocalOf { false } + /** * The columns beside [content]. [expanded] (840dp and up) shows up to three list columns; * narrower, only the newest one, with a way back up in its header. @@ -174,7 +181,11 @@ fun ColumnBrowser( content: @Composable (toggle: @Composable () -> Unit) -> Unit, ) { val settings = LocalSettings.current - val hidden = settings.value.columnsHidden + // Hidden by the reader (reader view, remembered) or only while the settings panel is open. + // The second never touches the saved choice, so closing the panel puts back exactly what + // was there: the columns if they were showing, reader view if it was on. + val makingRoom = LocalSidePanelOpen.current + val hidden = settings.value.columnsHidden || makingRoom val columns = remember(url, isPoem) { columnUrls(url, isPoem) } // What is selected in each column: the next step of the path, down to the open poem. val path = if (isPoem) columns + url else columns @@ -219,13 +230,14 @@ fun ColumnBrowser( Box(Modifier.weight(1f).fillMaxHeight()) { content { // Hiding is in the top bar; bringing them back is the floating button below, - // which is there whenever they are hidden. + // which is there whenever the reader has hidden them. if (!hidden) ColumnsToggle { settings.update { it.copy(columnsHidden = true) } } } // Reader view: the page has the whole screen, and one button, at the edge the // columns went to, brings them back as they were. + // Not while the settings panel is open: the columns would stay away for it anyway. ShowColumnsButton( - visible = hidden, + visible = hidden && !makingRoom, onShow = { settings.update { it.copy(columnsHidden = false) } }, modifier = Modifier .align(Alignment.BottomStart) diff --git a/app/src/main/java/com/ganjoor/android/ui/GanjoorApp.kt b/app/src/main/java/com/ganjoor/android/ui/GanjoorApp.kt index 786ded0..b8cf5b6 100644 --- a/app/src/main/java/com/ganjoor/android/ui/GanjoorApp.kt +++ b/app/src/main/java/com/ganjoor/android/ui/GanjoorApp.kt @@ -112,7 +112,10 @@ fun GanjoorApp() { // On a large screen reading settings open in a panel on the left, where the dictionary // opens, so the page stays in view and shows each change as it is made. Row(Modifier.fillMaxSize()) { + // The columns fold away while the settings panel is open, so the page doesn't end up + // squeezed between them and the panel. Box(Modifier.weight(1f)) { + CompositionLocalProvider(LocalSidePanelOpen provides (wide && settingsOpen)) { NavHost( navController = nav, startDestination = PoetsRoute, @@ -237,6 +240,7 @@ fun GanjoorApp() { } } } + } if (wide) { AnimatedVisibility( visible = settingsOpen, diff --git a/design/components/ColumnBrowser/README.md b/design/components/ColumnBrowser/README.md index b249451..5a7c830 100644 --- a/design/components/ColumnBrowser/README.md +++ b/design/components/ColumnBrowser/README.md @@ -51,6 +51,7 @@ On large screens, tapping a word opens **WordPanel** on the left instead of the On large screens the gear opens **ReadingSettingsPanel** on the left, where the dictionary opens, instead of the bottom sheet: - It has the same width and surface as the dictionary panel, with a "Reading settings" header and a ✕ button. The settings and their order are the same as in the sheet. - The page stays in view beside the panel, so a change of theme, font, weight or size shows on the poem as it's made. +- While the panel is open, the poets and list columns fold away so the page keeps its room. When it closes they come back, but only if they were showing before: this never changes the saved reader-view choice, and the floating "show the list" button stays hidden while the panel is open. - ✕ or Back closes it. Phones keep the bottom sheet. ## Loading diff --git a/design/wireframes/8-settings.png b/design/wireframes/8-settings.png index c018dcb..8fd6896 100644 Binary files a/design/wireframes/8-settings.png and b/design/wireframes/8-settings.png differ