feat(components): let the onboarding actions scroll with the content
A step whose content is taller than the screen loses room to a pinned bar, and the bar hides that there is more below it. scrollingActions moves the call-to-action stack to the end of the scrolling column instead.
This commit is contained in:
1 parent
a366ca9188
commit
98dcaf09ad
1 file changed
+27
-9
@@ -61,6 +61,11 @@ object OnboardingSpace {
|
||||
* [topSpacing] gives a step whose hero is a large picture rather than a mark
|
||||
* room to breathe. [contentPadding] is the scrolling column's own horizontal
|
||||
* inset — a step built from grouped rows passes 0, since those carry their own.
|
||||
*
|
||||
* [scrollingActions] moves the actions off the bottom bar and onto the end of
|
||||
* the scrolling content, for a step whose content is taller than the screen: a
|
||||
* pinned bar there eats the room the content needs and hides the fact that
|
||||
* there is more of it below.
|
||||
*/
|
||||
@Composable
|
||||
fun OnboardingScaffold(
|
||||
@@ -71,6 +76,7 @@ fun OnboardingScaffold(
|
||||
navigationIcon: (@Composable () -> Unit)? = null,
|
||||
topSpacing: Dp = OnboardingSpace.xl,
|
||||
contentPadding: Dp = OnboardingSpace.md,
|
||||
scrollingActions: Boolean = false,
|
||||
body: @Composable ColumnScope.() -> Unit,
|
||||
) {
|
||||
Scaffold(
|
||||
@@ -92,15 +98,9 @@ fun OnboardingScaffold(
|
||||
}
|
||||
},
|
||||
bottomBar = {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.navigationBarsPadding()
|
||||
.padding(horizontal = OnboardingSpace.md, vertical = OnboardingSpace.sm),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
content = actions,
|
||||
)
|
||||
// Pinned actions carry the navigation-bar inset themselves; scrolling
|
||||
// ones get it from the scaffold's own content padding.
|
||||
if (!scrollingActions) ActionsColumn(insetBottom = true, content = actions)
|
||||
},
|
||||
) { innerPadding ->
|
||||
Column(
|
||||
@@ -115,11 +115,29 @@ fun OnboardingScaffold(
|
||||
hero()
|
||||
Spacer(Modifier.height(OnboardingSpace.lg))
|
||||
body()
|
||||
if (scrollingActions) ActionsColumn(insetBottom = false, content = actions)
|
||||
Spacer(Modifier.height(OnboardingSpace.md))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The call-to-action stack, wherever the shell has put it. */
|
||||
@Composable
|
||||
private fun ActionsColumn(
|
||||
insetBottom: Boolean,
|
||||
content: @Composable ColumnScope.() -> Unit,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.then(if (insetBottom) Modifier.navigationBarsPadding() else Modifier)
|
||||
.padding(horizontal = OnboardingSpace.md, vertical = OnboardingSpace.sm),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
content = content,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Where a multi-step onboarding flow has got to: one capsule per step, filled up
|
||||
* to and including [step] (1-based), with [label] — the caller's own localised
|
||||
|
||||
Reference in new issue
Block a user