Skip to content

Commit 77ff6c5

Browse files
committed
Change last onboarding step
1 parent 225c623 commit 77ff6c5

File tree

9 files changed

+83
-105
lines changed

9 files changed

+83
-105
lines changed

app/src/main/java/com/twofasapp/ui/main/MainNavHost.kt

+6-10
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import com.twofasapp.feature.home.ui.services.focus.FocusServiceModal
5252
import com.twofasapp.feature.home.ui.services.focus.FocusServiceModalNavArg
5353
import com.twofasapp.feature.security.navigation.securityNavigation
5454
import com.twofasapp.feature.security.ui.lock.LockActivity
55-
import com.twofasapp.feature.startup.navigation.StartupBackupRoute
5655
import com.twofasapp.feature.startup.navigation.StartupRoute
5756
import com.twofasapp.feature.trash.navigation.DisposeRoute
5857
import com.twofasapp.feature.trash.navigation.TrashRoute
@@ -104,16 +103,13 @@ internal fun MainNavHost(
104103

105104
composable(Screen.Startup.route) {
106105
StartupRoute(
107-
openStartupBackup = {
106+
openHome = {
108107
navController.navigate(Screen.Services.route) { popUpTo(0) }
109-
navController.navigate(Screen.StartupBackup.route) { popUpTo(Screen.Services.route) }
110-
})
111-
}
112-
113-
composable(Screen.StartupBackup.route) {
114-
StartupBackupRoute(
115-
openHome = { navController.popBackStack()},
116-
openBackup = { navController.navigate(Screen.Backup.routeWithArgs(NavArg.TurnOnBackup to true)) { popUpTo(Screen.Services.route) } },
108+
},
109+
openBackup = {
110+
navController.navigate(Screen.Services.route) { popUpTo(0) }
111+
navController.navigate(Screen.Backup.routeWithArgs(NavArg.TurnOnBackup to true)) { popUpTo(Screen.Services.route) }
112+
},
117113
)
118114
}
119115

buildlogic/src/main/java/com/twofasapp/buildlogic/extension/KotlinAndroid.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ internal fun Project.applyKotlinAndroid(
5454
)
5555
}
5656

57-
packagingOptions {
57+
packaging {
5858
resources.excludes.add("META-INF/DEPENDENCIES")
5959
resources.excludes.add("META-INF/LICENSE")
6060
resources.excludes.add("META-INF/LICENSE.txt")

core/android/src/main/java/com/twofasapp/android/navigation/Screen.kt

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ sealed class Screen(val route: String) {
99
}
1010

1111
data object Startup : Screen("startup")
12-
data object StartupBackup : Screen("startup/backup")
1312
data object Services : Screen("services")
1413
data object Settings : Screen("settings")
1514
data object EditService : Screen("services/{${NavArg.ServiceId.name}}")

core/locale/src/main/java/com/twofasapp/locale/Strings.kt

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class Strings(c: Context) {
4747
val startupStepThreeBody = c.getString(R.string.introduction__page_3_content)
4848
val startupStepFourHeader = c.getString(R.string.introduction__page_4_title)
4949
val startupStepFourBody = c.getString(R.string.introduction__page_4_content_android)
50-
val startupStartCta = c.getString(R.string.introduction__title)
5150
val startupBackupBody = c.getString(R.string.introduction__backup_description)
5251
val startupBackupSuccessMsg = c.getString(R.string.introduction__backup_success)
5352
val startupBackupCloseCta = c.getString(R.string.introduction__backup_take_risk_cta)

feature/startup/src/main/java/com/twofasapp/feature/startup/navigation/StartupNavigation.kt

+3-11
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,13 @@ package com.twofasapp.feature.startup.navigation
22

33
import androidx.compose.runtime.Composable
44
import com.twofasapp.feature.startup.ui.startup.StartupScreen
5-
import com.twofasapp.feature.startup.ui.startupbackup.StartupBackupScreen
65

76
@Composable
87
fun StartupRoute(
9-
openStartupBackup: () -> Unit
8+
openHome: () -> Unit = {},
9+
openBackup: () -> Unit = {},
1010
) {
11-
StartupScreen(openStartupBackup = openStartupBackup)
12-
}
13-
14-
@Composable
15-
fun StartupBackupRoute(
16-
openHome: () -> Unit,
17-
openBackup: () -> Unit,
18-
) {
19-
StartupBackupScreen(
11+
StartupScreen(
2012
openHome = openHome,
2113
openBackup = openBackup,
2214
)

feature/startup/src/main/java/com/twofasapp/feature/startup/ui/startup/StartupScreen.kt

+61-21
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import androidx.compose.ui.unit.dp
3232
import com.google.accompanist.pager.HorizontalPagerIndicator
3333
import com.twofasapp.designsystem.TwTheme
3434
import com.twofasapp.designsystem.common.TwButton
35+
import com.twofasapp.designsystem.common.TwTextButton
3536
import com.twofasapp.designsystem.ktx.openSafely
3637
import com.twofasapp.feature.startup.R
3738
import com.twofasapp.locale.TwLocale
@@ -40,24 +41,36 @@ import org.koin.androidx.compose.koinViewModel
4041

4142
@Composable
4243
internal fun StartupScreen(
44+
openHome: () -> Unit = {},
45+
openBackup: () -> Unit = {},
4346
viewModel: StartupViewModel = koinViewModel(),
44-
openStartupBackup: () -> Unit
4547
) {
48+
val scope = rememberCoroutineScope()
49+
4650
ScreenContent(
47-
onStartUsingClick = {
48-
viewModel.onStartUsingClicked()
49-
openStartupBackup()
51+
openHome = {
52+
scope.launch {
53+
viewModel.finishOnboarding()
54+
openHome()
55+
}
5056
},
57+
openBackup = {
58+
scope.launch {
59+
viewModel.finishOnboarding()
60+
openBackup()
61+
}
62+
}
5163
)
5264
}
5365

5466
@OptIn(ExperimentalFoundationApi::class)
5567
@Composable
5668
internal fun ScreenContent(
57-
onStartUsingClick: () -> Unit,
69+
openHome: () -> Unit = {},
70+
openBackup: () -> Unit = {},
5871
) {
5972
val scope = rememberCoroutineScope()
60-
val pagerState = rememberPagerState(pageCount = { 4 })
73+
val pagerState = rememberPagerState(pageCount = { 5 })
6174
val uriHandler = LocalUriHandler.current
6275
val context = LocalContext.current
6376

@@ -83,24 +96,36 @@ internal fun ScreenContent(
8396
headerText = TwLocale.strings.startupStepOneHeader,
8497
bodyText = TwLocale.strings.startupStepOneBody,
8598
imageSize = 60.dp,
99+
openHome = openHome,
86100
)
87101

88102
1 -> Step(
89103
image = painterResource(id = R.drawable.onboarding_step_two),
90104
headerText = TwLocale.strings.startupStepTwoHeader,
91105
bodyText = TwLocale.strings.startupStepTwoBody,
106+
openHome = openHome,
92107
)
93108

94109
2 -> Step(
95110
image = painterResource(id = R.drawable.onboarding_step_three),
96111
headerText = TwLocale.strings.startupStepThreeHeader,
97112
bodyText = TwLocale.strings.startupStepThreeBody,
113+
openHome = openHome,
98114
)
99115

100116
3 -> Step(
101117
image = painterResource(id = R.drawable.onboarding_step_four),
102118
headerText = TwLocale.strings.startupStepFourHeader,
103119
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,
104129
)
105130
}
106131
}
@@ -125,37 +150,41 @@ internal fun ScreenContent(
125150
)
126151
}
127152

128-
Spacer(modifier = Modifier.height(12.dp))
153+
Spacer(modifier = Modifier.height(36.dp))
129154

130155
TwButton(
131156
text = when (pagerState.currentPage) {
132157
1 -> TwLocale.strings.commonNext
133158
2 -> TwLocale.strings.commonNext
134-
3 -> TwLocale.strings.startupStartCta
159+
3 -> TwLocale.strings.commonNext
160+
4 -> TwLocale.strings.commonContinue
135161
else -> TwLocale.strings.commonContinue
136162
},
137-
modifier = Modifier.padding(vertical = 24.dp),
138163
onClick = {
139164
if (pagerState.canScrollForward.not()) {
140-
onStartUsingClick()
165+
openBackup()
141166
}
142167

143168
scope.launch {
144169
pagerState.animateScrollToPage(page = pagerState.currentPage + 1)
145170
}
146171
}
147172
)
173+
174+
Spacer(modifier = Modifier.height(16.dp))
148175
}
149176
}
150177
}
151178

152179
@Composable
153180
private fun Step(
154181
image: Painter,
155-
headerText: String,
182+
headerText: String?,
156183
bodyText: String,
157184
modifier: Modifier = Modifier,
158-
imageSize: Dp = 220.dp,
185+
imageSize: Dp = 180.dp,
186+
showBackupSkip: Boolean = false,
187+
openHome: () -> Unit = {},
159188
) {
160189
Column(
161190
modifier = modifier,
@@ -178,26 +207,37 @@ private fun Step(
178207
Spacer(modifier = Modifier.height(24.dp))
179208

180209
// 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+
}
189220

190221
Spacer(modifier = Modifier.height(16.dp))
191222

192223
// Body
193224
Text(
194225
text = bodyText,
195-
style = MaterialTheme.typography.bodyMedium,
226+
style = MaterialTheme.typography.bodyLarge,
196227
modifier = Modifier
197228
.fillMaxWidth()
198229
.padding(horizontal = 24.dp),
199230
textAlign = TextAlign.Center
200231
)
232+
233+
if (showBackupSkip) {
234+
Spacer(modifier = Modifier.height(16.dp))
235+
236+
TwTextButton(
237+
text = TwLocale.strings.startupBackupCloseCta,
238+
onClick = openHome,
239+
)
240+
}
201241
}
202242
}
203243
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
package com.twofasapp.feature.startup.ui.startup
22

33
import androidx.lifecycle.ViewModel
4-
import com.twofasapp.common.ktx.launchScoped
54
import com.twofasapp.data.session.SessionRepository
65

76
class StartupViewModel(
87
private val sessionRepository: SessionRepository
98
) : ViewModel() {
109

11-
fun onStartUsingClicked() {
12-
launchScoped {
13-
sessionRepository.setOnboardingDisplayed(true)
14-
}
10+
suspend fun finishOnboarding() {
11+
sessionRepository.setOnboardingDisplayed(true)
1512
}
1613
}

feature/startup/src/main/java/com/twofasapp/feature/startup/ui/startupbackup/StartupBackupScreen.kt

-44
This file was deleted.

gradle/libs.versions.toml

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
[versions]
22
accompanist = "0.32.0"
3-
agp = "8.2.0-beta05"
4-
appcompat = "1.6.1"
5-
cameraX = "1.2.3"
3+
agp = "8.2.0-beta06"
4+
cameraX = "1.3.0"
65
coil = "2.4.0"
76
commonmark = "0.21.0"
8-
compose = "1.5.1"
9-
composeActivity = "1.7.2"
7+
compose = "1.5.3"
8+
composeActivity = "1.8.0"
109
composeCompiler = "1.5.3"
1110
core = "1.12.0"
1211
firebase = "32.3.1"
1312
glance = "1.0.0"
1413
junit = "4.13.2"
15-
koin = "3.4.3"
16-
koinAndroid = "3.4.6"
14+
koin = "3.5.0"
15+
koinAndroid = "3.5.0"
1716
kotlin = "1.9.10"
1817
kotlinCoroutines = "1.7.3"
1918
kotlinKsp = "1.9.10-1.0.13"
2019
ktor = "2.3.4"
2120
lifecycle = "2.7.0-alpha02"
22-
material3 = "1.2.0-alpha08"
21+
material3 = "1.2.0-alpha09"
2322
room = "2.5.2"
2423

2524
[libraries]
@@ -29,7 +28,7 @@ accompanistPermissions = { module = "com.google.accompanist:accompanist-permissi
2928
accompanistSystemUi = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" }
3029
activityX = { module = "androidx.activity:activity-ktx", version.ref = "composeActivity" }
3130
apacheCommonsCodec = "commons-codec:commons-codec:1.15"
32-
appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
31+
appcompat = "androidx.appcompat:appcompat:1.6.1"
3332
barcodeScanning = "com.google.mlkit:barcode-scanning:17.2.0"
3433
biometric = "androidx.biometric:biometric:1.1.0"
3534
camera2 = { module = "androidx.camera:camera-camera2", version.ref = "cameraX" }
@@ -45,7 +44,7 @@ composeActivity = { module = "androidx.activity:activity-compose", version.ref =
4544
composeAnimation = { module = "androidx.compose.animation:animation", version.ref = "compose" }
4645
composeCompiler = { module = "androidx.compose.compiler:compiler", version.ref = "composeCompiler" }
4746
composeMaterial2 = { module = "androidx.compose.material:material", version.ref = "compose" }
48-
composeNavigation = "androidx.navigation:navigation-compose:2.7.3"
47+
composeNavigation = "androidx.navigation:navigation-compose:2.7.4"
4948
composeUi = { module = "androidx.compose.ui:ui", version.ref = "compose" }
5049
composeUiTooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
5150
composeUiUtil = { module = "androidx.compose.ui:ui-util", version.ref = "compose" }
@@ -82,7 +81,7 @@ lifecycleLifecycle = { module = "androidx.lifecycle:lifecycle-runtime-ktx", vers
8281
lifecycleProcess = { module = "androidx.lifecycle:lifecycle-process", version.ref = "lifecycle" }
8382
lifecycleSavedstate = { module = "androidx.lifecycle:lifecycle-viewmodel-savedstate", version.ref = "lifecycle" }
8483
lottie = "com.airbnb.android:lottie-compose:5.0.3"
85-
material2 = { module = "com.google.android.material:material", version.ref = "appcompat" }
84+
material2 = "com.google.android.material:material:1.10.0"
8685
material3 = { module = "androidx.compose.material3:material3", version.ref = "material3" }
8786
material3Window = { module = "androidx.compose.material3:material3-window-size-class", version.ref = "material3" }
8887
playReview = "com.google.android.play:review:2.0.1"

0 commit comments

Comments
 (0)