@@ -5,6 +5,7 @@ import androidx.compose.runtime.Composable
55import androidx.compose.runtime.CompositionLocalProvider
66import androidx.compose.runtime.remember
77import androidx.compose.runtime.staticCompositionLocalOf
8+ import androidx.compose.ui.platform.LocalContext
89import cafe.adriel.voyager.core.annotation.ExperimentalVoyagerApi
910import cafe.adriel.voyager.core.lifecycle.LifecycleEffectOnce
1011import cafe.adriel.voyager.core.registry.ScreenRegistry
@@ -18,6 +19,9 @@ import com.flipcash.app.contact.verification.email.EmailVerificationScreen
1819import com.flipcash.app.contact.verification.phone.PhoneVerificationScreen
1920import com.flipcash.app.core.NavScreenProvider
2021import com.flipcash.app.core.verification.email.EmailDeeplinkOrigin
22+ import com.flipcash.features.contact.verification.R
23+ import com.getcode.manager.BottomBarAction
24+ import com.getcode.manager.BottomBarManager
2125import com.getcode.navigation.core.LocalCodeNavigator
2226import com.getcode.navigation.modal.ModalScreen
2327import kotlinx.parcelize.IgnoredOnParcel
@@ -29,6 +33,7 @@ class VerificationFlowScreen(
2933 private val target : NavScreenProvider ? = null ,
3034 private val includePhone : Boolean = true ,
3135 private val includeEmail : Boolean = true ,
36+ private val showSuccess : Boolean = target == null && (includePhone xor includeEmail),
3237 private val emailAddress : String? = null ,
3338 private val emailVerificationCode : String? = null ,
3439): ModalScreen, Parcelable {
@@ -39,12 +44,41 @@ class VerificationFlowScreen(
3944 @Composable
4045 override fun ModalContent () {
4146 val codeNavigator = LocalCodeNavigator .current
42-
43- fun goToTargetOrReturn () {
47+ val context = LocalContext .current
48+ fun showSuccess () {
49+ if (includePhone) {
50+ BottomBarManager .showMessage(
51+ title = context.getString(R .string.prompt_title_phoneVerifiedSuccessfully),
52+ subtitle = context.getString(R .string.prompt_description_phoneVerifiedSuccessfully),
53+ actions = listOf (
54+ BottomBarAction (text = context.getString(android.R .string.ok))
55+ ),
56+ type = BottomBarManager .BottomBarMessageType .SUCCESS ,
57+ ) {
58+ codeNavigator.pop()
59+ }
60+ } else {
61+ BottomBarManager .showMessage(
62+ title = context.getString(R .string.prompt_title_emailVerifiedSuccessfully),
63+ subtitle = context.getString(R .string.prompt_description_emailVerifiedSuccessfully),
64+ actions = listOf (
65+ BottomBarAction (text = context.getString(android.R .string.ok))
66+ ),
67+ type = BottomBarManager .BottomBarMessageType .SUCCESS ,
68+ ) {
69+ codeNavigator.pop()
70+ }
71+ }
72+ }
73+ fun goToTargetOrReturn (wasSuccessful : Boolean ) {
4474 if (target != null ) {
4575 codeNavigator.replace(ScreenRegistry .get(target))
4676 } else {
47- codeNavigator.pop()
77+ if (wasSuccessful && showSuccess) {
78+ showSuccess()
79+ } else {
80+ codeNavigator.pop()
81+ }
4882 }
4983 }
5084
@@ -55,7 +89,7 @@ class VerificationFlowScreen(
5589
5690 val screens = buildScreenSet(includePhone, includeEmail, emailAddress, emailVerificationCode)
5791 if (screens.isEmpty()) {
58- goToTargetOrReturn()
92+ goToTargetOrReturn(false )
5993 return
6094 }
6195
@@ -69,11 +103,11 @@ class VerificationFlowScreen(
69103 if (includeEmail) {
70104 navigator.push(EmailVerificationScreen ())
71105 } else {
72- goToTargetOrReturn()
106+ goToTargetOrReturn(wasSuccessful = true )
73107 }
74108 }
75109 VerificationFlowStep .Email -> {
76- goToTargetOrReturn()
110+ goToTargetOrReturn(wasSuccessful = true )
77111 }
78112 }
79113 }
0 commit comments