Skip to content

Commit

Permalink
style: Clean OnboardingScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarX committed Dec 4, 2024
1 parent 1b16302 commit a7e3410
Showing 1 changed file with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,17 @@ fun OnboardingScreen(goToMainActivity: () -> Unit) {
}

val onboardingPages = buildList {
Page.entries.forEach { page ->
add(page.toOnboardingPage(isHighlighted))
}
Page.entries.forEach { page -> add(page.toOnboardingPage(isHighlighted)) }
}

OnboardingScaffold(
pagerState = pagerState,
onboardingPages = onboardingPages,
bottomContent = {
bottomContent = { paddingValues ->
BottomContent(
modifier = Modifier
.padding(it)
.consumeWindowInsets(it),
.padding(paddingValues)
.consumeWindowInsets(paddingValues),
isLastPage = { isLastPage },
startMainActivity = goToMainActivity,
goToNextPage = { coroutineScope.launch { pagerState.animateScrollToPage(pagerState.currentPage + 1) } },
Expand All @@ -91,7 +89,7 @@ fun OnboardingScreen(goToMainActivity: () -> Unit) {
@Composable
private fun Page.toOnboardingPage(isHighlighted: Map<Page, MutableState<Boolean>>) = OnboardingPage(
background = background.image(),
illustration = { Illustration(illustration) },
illustration = { Image(illustration.image(), contentDescription = null) },
text = {
TitleAndDescription(
page = this,
Expand All @@ -100,11 +98,6 @@ private fun Page.toOnboardingPage(isHighlighted: Map<Page, MutableState<Boolean>
}
)

@Composable
private fun Illustration(illustration: ThemedImage) {
Image(illustration.image(), contentDescription = null)
}

@Composable
private fun TitleAndDescription(page: Page, isHighlighted: () -> Boolean) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Expand Down Expand Up @@ -132,7 +125,7 @@ private fun BottomContent(
modifier: Modifier = Modifier,
isLastPage: () -> Boolean,
startMainActivity: () -> Unit,
goToNextPage: () -> Unit
goToNextPage: () -> Unit,
) {
Box(
contentAlignment = Alignment.Center,
Expand Down

0 comments on commit a7e3410

Please sign in to comment.