Redirect to confirmation screen from the confirmation email
This commit is contained in:
parent
f107994f0b
commit
83d477f6bb
3 changed files with 29 additions and 15 deletions
|
@ -15,6 +15,7 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.compose.LocalLifecycleOwner
|
import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.lifecycle.repeatOnLifecycle
|
import androidx.lifecycle.repeatOnLifecycle
|
||||||
import androidx.navigation.compose.NavHost
|
import androidx.navigation.compose.NavHost
|
||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
|
@ -31,6 +32,7 @@ import ing.bikeshedengineer.debtpirate.navigation.Navigator
|
||||||
import ing.bikeshedengineer.debtpirate.theme.DebtPirateTheme
|
import ing.bikeshedengineer.debtpirate.theme.DebtPirateTheme
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -86,13 +88,11 @@ class MainActivity : ComponentActivity() {
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
navigation<Destination.AuthGraph>(
|
navigation<Destination.AuthGraph>(
|
||||||
startDestination = Destination.RegistrationConfirmationCheckEmailScreen(
|
startDestination = Destination.LoginScreen
|
||||||
emailAddress = "zachary@dziura.email"
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
composable<Destination.LoginScreen>() { LoginScreen() }
|
composable<Destination.LoginScreen> { LoginScreen() }
|
||||||
composable<Destination.RegistrationScreen>() { RegistrationScreen() }
|
composable<Destination.RegistrationScreen> { RegistrationScreen() }
|
||||||
composable<Destination.RegistrationConfirmationCheckEmailScreen>() {
|
composable<Destination.RegistrationConfirmationCheckEmailScreen> {
|
||||||
val (emailAddress, _) = it.toRoute<Destination.RegistrationConfirmationCheckEmailScreen>()
|
val (emailAddress, _) = it.toRoute<Destination.RegistrationConfirmationCheckEmailScreen>()
|
||||||
ConfirmationScreen(
|
ConfirmationScreen(
|
||||||
emailAddress
|
emailAddress
|
||||||
|
@ -129,6 +129,10 @@ class MainActivity : ComponentActivity() {
|
||||||
|
|
||||||
private fun handleNewUserVerificationIntent(userId: Int, sessionToken: String) {
|
private fun handleNewUserVerificationIntent(userId: Int, sessionToken: String) {
|
||||||
Log.d("DebtPirate::MainActivity", "User ID: $userId, Session Token: $sessionToken")
|
Log.d("DebtPirate::MainActivity", "User ID: $userId, Session Token: $sessionToken")
|
||||||
|
|
||||||
|
lifecycleScope.launch {
|
||||||
|
navigator.navigate(Destination.RegistrationConfirmationCheckEmailScreen(comingFromEmail = true))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ing.bikeshedengineer.debtpirate.app.screen.auth.presentation.register
|
package ing.bikeshedengineer.debtpirate.app.screen.auth.presentation.register
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.util.Log
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
@ -70,17 +71,15 @@ fun RegistrationScreen(
|
||||||
val (emailAddress, password) = credentials
|
val (emailAddress, password) = credentials
|
||||||
val result = accountManager.storeCredentials(emailAddress, password)
|
val result = accountManager.storeCredentials(emailAddress, password)
|
||||||
|
|
||||||
when (result) {
|
if (result !is AccountManagerResult.Success) {
|
||||||
is AccountManagerResult.Failure -> {
|
Log.i(
|
||||||
Toast.makeText(context, "Unable to store credentials", Toast.LENGTH_SHORT).show()
|
"DebtPirate::RegistrationScreen",
|
||||||
}
|
"Not able to store credentials in CredentialManager"
|
||||||
else -> {
|
)
|
||||||
Toast.makeText(context, "Registration successful", Toast.LENGTH_SHORT).show()
|
|
||||||
viewModel.onAction(RegistrationScreenAction.ResetFields)
|
|
||||||
viewModel.navigateUp()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewModel.onAction(RegistrationScreenAction.ResetFields)
|
||||||
|
viewModel.navigateToConfirmationScreen(emailAddress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import ing.bikeshedengineer.debtpirate.app.screen.auth.usecase.NewAccountRegistrationValidationResult
|
import ing.bikeshedengineer.debtpirate.app.screen.auth.usecase.NewAccountRegistrationValidationResult
|
||||||
import ing.bikeshedengineer.debtpirate.app.screen.auth.usecase.SubmitAccountRegistrationRequestUseCase
|
import ing.bikeshedengineer.debtpirate.app.screen.auth.usecase.SubmitAccountRegistrationRequestUseCase
|
||||||
import ing.bikeshedengineer.debtpirate.app.screen.auth.usecase.ValidateNewAccountRegistrationUseCase
|
import ing.bikeshedengineer.debtpirate.app.screen.auth.usecase.ValidateNewAccountRegistrationUseCase
|
||||||
|
import ing.bikeshedengineer.debtpirate.navigation.Destination
|
||||||
import ing.bikeshedengineer.debtpirate.navigation.Navigator
|
import ing.bikeshedengineer.debtpirate.navigation.Navigator
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
@ -27,6 +28,16 @@ class RegistrationScreenViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun navigateToConfirmationScreen(emailAddress: String) {
|
||||||
|
viewModelScope.launch {
|
||||||
|
navigator.navigate(Destination.RegistrationConfirmationCheckEmailScreen(emailAddress)) {
|
||||||
|
popUpTo(Destination.LoginScreen) {
|
||||||
|
inclusive = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val _emailAddress = MutableStateFlow("")
|
private val _emailAddress = MutableStateFlow("")
|
||||||
val emailAddress = _emailAddress.asStateFlow()
|
val emailAddress = _emailAddress.asStateFlow()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue