@@ -32,6 +32,7 @@ import androidx.compose.ui.unit.dp
32
32
import com.google.accompanist.pager.HorizontalPagerIndicator
33
33
import com.twofasapp.designsystem.TwTheme
34
34
import com.twofasapp.designsystem.common.TwButton
35
+ import com.twofasapp.designsystem.common.TwTextButton
35
36
import com.twofasapp.designsystem.ktx.openSafely
36
37
import com.twofasapp.feature.startup.R
37
38
import com.twofasapp.locale.TwLocale
@@ -40,24 +41,36 @@ import org.koin.androidx.compose.koinViewModel
40
41
41
42
@Composable
42
43
internal fun StartupScreen (
44
+ openHome : () -> Unit = {},
45
+ openBackup : () -> Unit = {},
43
46
viewModel : StartupViewModel = koinViewModel(),
44
- openStartupBackup : () -> Unit
45
47
) {
48
+ val scope = rememberCoroutineScope()
49
+
46
50
ScreenContent (
47
- onStartUsingClick = {
48
- viewModel.onStartUsingClicked()
49
- openStartupBackup()
51
+ openHome = {
52
+ scope.launch {
53
+ viewModel.finishOnboarding()
54
+ openHome()
55
+ }
50
56
},
57
+ openBackup = {
58
+ scope.launch {
59
+ viewModel.finishOnboarding()
60
+ openBackup()
61
+ }
62
+ }
51
63
)
52
64
}
53
65
54
66
@OptIn(ExperimentalFoundationApi ::class )
55
67
@Composable
56
68
internal fun ScreenContent (
57
- onStartUsingClick : () -> Unit ,
69
+ openHome : () -> Unit = {},
70
+ openBackup : () -> Unit = {},
58
71
) {
59
72
val scope = rememberCoroutineScope()
60
- val pagerState = rememberPagerState(pageCount = { 4 })
73
+ val pagerState = rememberPagerState(pageCount = { 5 })
61
74
val uriHandler = LocalUriHandler .current
62
75
val context = LocalContext .current
63
76
@@ -83,24 +96,36 @@ internal fun ScreenContent(
83
96
headerText = TwLocale .strings.startupStepOneHeader,
84
97
bodyText = TwLocale .strings.startupStepOneBody,
85
98
imageSize = 60 .dp,
99
+ openHome = openHome,
86
100
)
87
101
88
102
1 -> Step (
89
103
image = painterResource(id = R .drawable.onboarding_step_two),
90
104
headerText = TwLocale .strings.startupStepTwoHeader,
91
105
bodyText = TwLocale .strings.startupStepTwoBody,
106
+ openHome = openHome,
92
107
)
93
108
94
109
2 -> Step (
95
110
image = painterResource(id = R .drawable.onboarding_step_three),
96
111
headerText = TwLocale .strings.startupStepThreeHeader,
97
112
bodyText = TwLocale .strings.startupStepThreeBody,
113
+ openHome = openHome,
98
114
)
99
115
100
116
3 -> Step (
101
117
image = painterResource(id = R .drawable.onboarding_step_four),
102
118
headerText = TwLocale .strings.startupStepFourHeader,
103
119
bodyText = TwLocale .strings.startupStepFourBody,
120
+ openHome = openHome,
121
+ )
122
+
123
+ 4 -> Step (
124
+ image = painterResource(id = com.twofasapp.designsystem.R .drawable.illustration_2fas_backup),
125
+ headerText = null ,
126
+ bodyText = TwLocale .strings.startupBackupBody,
127
+ showBackupSkip = true ,
128
+ openHome = openHome,
104
129
)
105
130
}
106
131
}
@@ -125,37 +150,41 @@ internal fun ScreenContent(
125
150
)
126
151
}
127
152
128
- Spacer (modifier = Modifier .height(12 .dp))
153
+ Spacer (modifier = Modifier .height(36 .dp))
129
154
130
155
TwButton (
131
156
text = when (pagerState.currentPage) {
132
157
1 -> TwLocale .strings.commonNext
133
158
2 -> TwLocale .strings.commonNext
134
- 3 -> TwLocale .strings.startupStartCta
159
+ 3 -> TwLocale .strings.commonNext
160
+ 4 -> TwLocale .strings.commonContinue
135
161
else -> TwLocale .strings.commonContinue
136
162
},
137
- modifier = Modifier .padding(vertical = 24 .dp),
138
163
onClick = {
139
164
if (pagerState.canScrollForward.not ()) {
140
- onStartUsingClick ()
165
+ openBackup ()
141
166
}
142
167
143
168
scope.launch {
144
169
pagerState.animateScrollToPage(page = pagerState.currentPage + 1 )
145
170
}
146
171
}
147
172
)
173
+
174
+ Spacer (modifier = Modifier .height(16 .dp))
148
175
}
149
176
}
150
177
}
151
178
152
179
@Composable
153
180
private fun Step (
154
181
image : Painter ,
155
- headerText : String ,
182
+ headerText : String? ,
156
183
bodyText : String ,
157
184
modifier : Modifier = Modifier ,
158
- imageSize : Dp = 220.dp,
185
+ imageSize : Dp = 180.dp,
186
+ showBackupSkip : Boolean = false,
187
+ openHome : () -> Unit = {},
159
188
) {
160
189
Column (
161
190
modifier = modifier,
@@ -178,26 +207,37 @@ private fun Step(
178
207
Spacer (modifier = Modifier .height(24 .dp))
179
208
180
209
// Header
181
- Text (
182
- text = headerText,
183
- style = MaterialTheme .typography.headlineSmall,
184
- modifier = Modifier
185
- .fillMaxWidth()
186
- .padding(horizontal = 16 .dp),
187
- textAlign = TextAlign .Center
188
- )
210
+ if (headerText != null ) {
211
+ Text (
212
+ text = headerText,
213
+ style = MaterialTheme .typography.headlineSmall,
214
+ modifier = Modifier
215
+ .fillMaxWidth()
216
+ .padding(horizontal = 16 .dp),
217
+ textAlign = TextAlign .Center
218
+ )
219
+ }
189
220
190
221
Spacer (modifier = Modifier .height(16 .dp))
191
222
192
223
// Body
193
224
Text (
194
225
text = bodyText,
195
- style = MaterialTheme .typography.bodyMedium ,
226
+ style = MaterialTheme .typography.bodyLarge ,
196
227
modifier = Modifier
197
228
.fillMaxWidth()
198
229
.padding(horizontal = 24 .dp),
199
230
textAlign = TextAlign .Center
200
231
)
232
+
233
+ if (showBackupSkip) {
234
+ Spacer (modifier = Modifier .height(16 .dp))
235
+
236
+ TwTextButton (
237
+ text = TwLocale .strings.startupBackupCloseCta,
238
+ onClick = openHome,
239
+ )
240
+ }
201
241
}
202
242
}
203
243
}
0 commit comments