Show toast message when registering
This commit is contained in:
parent
a343f2e2a0
commit
2a69fbcef7
4 changed files with 11 additions and 12 deletions
|
@ -2,6 +2,7 @@ package ing.bikeshedengineer.debtpirate.app.screen.auth.presentation.register
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
|
@ -71,15 +72,16 @@ fun RegistrationScreen(
|
|||
val result = accountManager.storeCredentials(emailAddress, password)
|
||||
|
||||
when (result) {
|
||||
is AccountManagerResult.Unavailable -> {
|
||||
is AccountManagerResult.Failure -> {
|
||||
Toast.makeText(context, "Unable to store credentials", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(context, "Registration successful", Toast.LENGTH_SHORT).show()
|
||||
viewModel.onAction(RegistrationScreenAction.ResetFields)
|
||||
viewModel.navigateUp()
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
Log.d("RegistrationScreen", "$result")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,8 +107,6 @@ class RegistrationScreenViewModel @Inject constructor(
|
|||
submitAccountRegistrationRequest(emailAddress, name, confirmPassword)
|
||||
|
||||
_onRegistrationComplete.emit(Pair(emailAddress, confirmPassword))
|
||||
|
||||
resetFields()
|
||||
} catch (err: Throwable) {
|
||||
// TODO...
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package ing.bikeshedengineer.debtpirate.domain.model
|
||||
|
||||
sealed interface AccountManagerResult {
|
||||
data class Success(val username: String) : AccountManagerResult
|
||||
data object Success : AccountManagerResult
|
||||
data object Unavailable : AccountManagerResult
|
||||
data object Canceled : AccountManagerResult
|
||||
data object Failure : AccountManagerResult
|
||||
|
|
|
@ -24,15 +24,14 @@ class AccountManager(private val context: Activity) {
|
|||
)
|
||||
)
|
||||
|
||||
AccountManagerResult.Success(emailAddress)
|
||||
AccountManagerResult.Success
|
||||
} catch (err: CreateCredentialNoCreateOptionException) {
|
||||
Log.w(
|
||||
"DebtPirate::AccountManager",
|
||||
"Cannot store credentials; a Google account isn't associated with this device"
|
||||
)
|
||||
AccountManagerResult.Unavailable
|
||||
} catch (err: CreateCredentialCancellationException) {
|
||||
err.printStackTrace()
|
||||
} catch (_: CreateCredentialCancellationException) {
|
||||
AccountManagerResult.Canceled
|
||||
} catch (err: CreateCredentialException) {
|
||||
err.printStackTrace()
|
||||
|
|
Loading…
Add table
Reference in a new issue