ScaffoldArticleTopBar
Turns the app bar of the scaffold around this screen into an article bar, as news apps draw over a story: at first only the navigation and actions; once compact, the title after an optional brand; and, with progress, a thin line along the bar's bottom edge showing how much has been read. It follows the screen's state, since this is called from the screen, and leaves with it.
val listState = rememberLazyListState()
ScaffoldArticleTopBar(
title = article.title,
compact = { listState.firstVisibleItemIndex > 0 },
progress = listState::readingProgress,
brand = painterResource(R.drawable.publisher_logo),
)A large bar is drawn small while the article is declared, a hidden one stays hidden, and a search field in the bar takes the title's place. Outside a Toolkit scaffold it does nothing.
Parameters
Whether the article's own header has scrolled away. Read while drawing the bar, so pass a lambda over the scroll state rather than a value, and the screen does not recompose as it scrolls.
How much has been read, from 0 to 1; values outside it are clamped. Null draws no line. See readingProgress for scroll states.
Drawn before the title at the title's height, keeping its own colours, so a multicoloured logo or a vector drawable works. Null draws nothing and leaves no gap.
What a screen reader says for brand; null for none.