Keep home and the reading settings up while a page loads

The skeleton screens carried a top bar with nothing but Back, so going home or
changing the theme meant waiting for a poem you might not have wanted. Neither
action depends on the content: both are now in the loading bar for the poem and
the category alike, from the first frame.

Share and bookmark are not. They need a poem to act on, so they still arrive
with it — the bar fills out as the content lands rather than appearing whole.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
anas 2026-10-07 17:08:19 +02:00
parent b3f4e527f1
commit f21f4fa727
2 changed files with 23 additions and 5 deletions

View File

@ -60,7 +60,7 @@ fun CategoryScreen(
key = fullUrl, key = fullUrl,
block = { Ganjoor.category(fullUrl) }, block = { Ganjoor.category(fullUrl) },
// The bar stays up with Back already working; only the list waits. // The bar stays up with Back already working; only the list waits.
placeholder = { LoadingCategory(onUp) }, placeholder = { LoadingCategory(onUp, onHome) },
) { cat -> ) { cat ->
// First lines are a separate, optional call; the list shows up without waiting for it. // First lines are a separate, optional call; the list shows up without waiting for it.
var excerpts by remember(cat.id) { mutableStateOf(emptyMap<Int, String>()) } var excerpts by remember(cat.id) { mutableStateOf(emptyMap<Int, String>()) }
@ -132,7 +132,7 @@ fun CategoryScreen(
/** The category screen while its list is on the way: the real top bar over a skeleton list. */ /** The category screen while its list is on the way: the real top bar over a skeleton list. */
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
private fun LoadingCategory(onUp: () -> Unit) { private fun LoadingCategory(onUp: () -> Unit, onHome: () -> Unit) {
Scaffold( Scaffold(
topBar = { topBar = {
TopAppBar( TopAppBar(
@ -142,6 +142,12 @@ private fun LoadingCategory(onUp: () -> Unit) {
Icon(Icons.AutoMirrored.Filled.ArrowBack, stringResource(R.string.back)) Icon(Icons.AutoMirrored.Filled.ArrowBack, stringResource(R.string.back))
} }
}, },
// Home and the reading settings belong to the app, not to this page, so they are
// there from the first frame. Downloading needs to know which poet this is.
actions = {
HomeAction(onHome)
ReadingSettingsAction()
},
) )
} }
) { insets -> ) { insets ->

View File

@ -96,8 +96,9 @@ fun PoemScreen(
Load( Load(
key = fullUrl, key = fullUrl,
block = { Ganjoor.poem(fullUrl) }, block = { Ganjoor.poem(fullUrl) },
// The bar stays up with Back already working; only the text waits. // The bar stays up with Back, Home and the reading settings already working; only
placeholder = { LoadingPoem(wide, onUp, navigationToggle) }, // the text waits. Sharing and bookmarking need a poem, so they arrive with it.
placeholder = { LoadingPoem(wide, onUp, onHome, navigationToggle) },
) { poem -> ) { poem ->
val prefs = LocalSettings.current.value val prefs = LocalSettings.current.value
val style = readingStyle(prefs.font, prefs.fontSize, prefs.fontWeight.weight) val style = readingStyle(prefs.font, prefs.fontSize, prefs.fontWeight.weight)
@ -256,7 +257,12 @@ private data class WordTap(val word: String, val passage: Bookmark, val verse: I
/** The poem screen while its poem is on the way: the real top bar, and the text as a skeleton. */ /** The poem screen while its poem is on the way: the real top bar, and the text as a skeleton. */
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
private fun LoadingPoem(wide: Boolean, onUp: () -> Unit, navigationToggle: (@Composable () -> Unit)?) { private fun LoadingPoem(
wide: Boolean,
onUp: () -> Unit,
onHome: () -> Unit,
navigationToggle: (@Composable () -> Unit)?,
) {
Scaffold( Scaffold(
topBar = { topBar = {
TopAppBar( TopAppBar(
@ -269,6 +275,12 @@ private fun LoadingPoem(wide: Boolean, onUp: () -> Unit, navigationToggle: (@Com
} }
} }
}, },
// Going home and changing the reading settings do not depend on this poem, so
// they do not wait for it. Share and bookmark do, and appear when it lands.
actions = {
HomeAction(onHome)
ReadingSettingsAction()
},
) )
} }
) { insets -> ) { insets ->