Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GOVUKAPP-1009 Onboarding screens missed when using swipe to navigate #152

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package uk.govuk.app.onboarding.ui

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
Expand Down Expand Up @@ -84,7 +83,6 @@ internal fun OnboardingRoute(
)
}

@OptIn(ExperimentalFoundationApi::class)
@Composable
private fun OnboardingScreen(
pages: List<OnboardingPage>,
Expand All @@ -111,7 +109,10 @@ private fun OnboardingScreen(
.weight(1f),
verticalAlignment = Alignment.Top
) { pageIndex ->
Page(pages[pageIndex])
Page(
page = pages[pageIndex],
isCurrentPage = pagerState.currentPage == pageIndex
)
}

ListDivider()
Expand Down Expand Up @@ -150,6 +151,7 @@ private fun OnboardingScreen(
@Composable
private fun Page(
page: OnboardingPage,
isCurrentPage: Boolean,
modifier: Modifier = Modifier
) {
val focusRequester = remember { FocusRequester() }
Expand Down Expand Up @@ -189,8 +191,10 @@ private fun Page(
.padding(horizontal = GovUkTheme.spacing.extraLarge),
textAlign = TextAlign.Center
)
}

LaunchedEffect(page.title) {
LaunchedEffect(page.title) {
if (isCurrentPage) {
delay(200)
focusRequester.requestFocus()
}
Expand Down
Loading