@@ -50,6 +50,9 @@ import to.bitkit.ui.theme.AppThemeSurface
5050import to.bitkit.ui.theme.Colors
5151import to.bitkit.ui.utils.withAccent
5252
53+ private const val LAST_PAGE_INDEX = 3
54+ private const val PAGE_COUNT = LAST_PAGE_INDEX + 1
55+
5356@Composable
5457fun OnboardingSlidesScreen (
5558 currentTab : Int = 0,
@@ -59,7 +62,7 @@ fun OnboardingSlidesScreen(
5962 onRestoreClick : () -> Unit ,
6063) {
6164 val scope = rememberCoroutineScope()
62- val pagerState = rememberPagerState(initialPage = currentTab, pageCount = { 5 })
65+ val pagerState = rememberPagerState(initialPage = currentTab, pageCount = { PAGE_COUNT })
6366
6467 Box (
6568 modifier = Modifier
@@ -90,31 +93,23 @@ fun OnboardingSlidesScreen(
9093 )
9194
9295 2 -> OnboardingTab (
93- imageResId = R .drawable.spark,
94- title = stringResource(R .string.onboarding__slide2_header),
95- titleAccentColor = Colors .Yellow ,
96- text = stringResource(R .string.onboarding__slide2_text),
97- modifier = Modifier .testTag(" Slide2" )
98- )
99-
100- 3 -> OnboardingTab (
10196 imageResId = R .drawable.shield,
10297 title = stringResource(R .string.onboarding__slide3_header),
10398 titleAccentColor = Colors .Green ,
10499 text = stringResource(R .string.onboarding__slide3_text),
105- modifier = Modifier .testTag(" Slide3 " )
100+ modifier = Modifier .testTag(" Slide2 " )
106101 )
107102
108- 4 -> CreateWalletScreen (
103+ LAST_PAGE_INDEX -> CreateWalletScreen (
109104 onCreateClick = onCreateClick,
110105 onRestoreClick = onRestoreClick,
111- modifier = Modifier .testTag(" Slide4 " )
106+ modifier = Modifier .testTag(" Slide $LAST_PAGE_INDEX " )
112107 )
113108 }
114109 }
115110
116111 // Dots indicator
117- val isIndicatorVisible = pagerState.currentPage != 4
112+ val isIndicatorVisible = pagerState.currentPage != LAST_PAGE_INDEX
118113 val yOffset by animateDpAsState(
119114 targetValue = if (isIndicatorVisible) 0 .dp else 20 .dp,
120115 animationSpec = tween(durationMillis = 300 ),
@@ -135,7 +130,7 @@ fun OnboardingSlidesScreen(
135130 .offset { IntOffset (0 , yOffset.roundToPx()) }
136131 .alpha(alpha)
137132 ) {
138- repeat(5 ) { index ->
133+ repeat(PAGE_COUNT ) { index ->
139134 val size by animateDpAsState(
140135 targetValue = if (index == pagerState.currentPage) 10 .dp else 7 .dp,
141136 animationSpec = tween(durationMillis = 300 ),
@@ -157,7 +152,7 @@ fun OnboardingSlidesScreen(
157152 onBackClick = null ,
158153 titleText = null ,
159154 actions = {
160- if (pagerState.currentPage == 4 ) {
155+ if (pagerState.currentPage == LAST_PAGE_INDEX ) {
161156 TextButton (
162157 onClick = onAdvancedSetupClick,
163158 modifier = Modifier .testTag(" Passphrase" )
@@ -276,7 +271,7 @@ private fun OnboardingViewPreview3() {
276271private fun OnboardingViewPreview4 () {
277272 AppThemeSurface {
278273 OnboardingSlidesScreen (
279- currentTab = 4 ,
274+ currentTab = LAST_PAGE_INDEX ,
280275 onAdvancedSetupClick = {},
281276 onCreateClick = {},
282277 onRestoreClick = {},
0 commit comments