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.annotation.SuppressLint
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
|
@ -71,15 +72,16 @@ fun RegistrationScreen(
|
||||||
val result = accountManager.storeCredentials(emailAddress, password)
|
val result = accountManager.storeCredentials(emailAddress, password)
|
||||||
|
|
||||||
when (result) {
|
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()
|
viewModel.navigateUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Log.d("RegistrationScreen", "$result")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,8 +107,6 @@ class RegistrationScreenViewModel @Inject constructor(
|
||||||
submitAccountRegistrationRequest(emailAddress, name, confirmPassword)
|
submitAccountRegistrationRequest(emailAddress, name, confirmPassword)
|
||||||
|
|
||||||
_onRegistrationComplete.emit(Pair(emailAddress, confirmPassword))
|
_onRegistrationComplete.emit(Pair(emailAddress, confirmPassword))
|
||||||
|
|
||||||
resetFields()
|
|
||||||
} catch (err: Throwable) {
|
} catch (err: Throwable) {
|
||||||
// TODO...
|
// TODO...
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package ing.bikeshedengineer.debtpirate.domain.model
|
package ing.bikeshedengineer.debtpirate.domain.model
|
||||||
|
|
||||||
sealed interface AccountManagerResult {
|
sealed interface AccountManagerResult {
|
||||||
data class Success(val username: String) : AccountManagerResult
|
data object Success : AccountManagerResult
|
||||||
data object Unavailable : AccountManagerResult
|
data object Unavailable : AccountManagerResult
|
||||||
data object Canceled : AccountManagerResult
|
data object Canceled : AccountManagerResult
|
||||||
data object Failure : AccountManagerResult
|
data object Failure : AccountManagerResult
|
||||||
|
|
|
@ -24,15 +24,14 @@ class AccountManager(private val context: Activity) {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
AccountManagerResult.Success(emailAddress)
|
AccountManagerResult.Success
|
||||||
} catch (err: CreateCredentialNoCreateOptionException) {
|
} catch (err: CreateCredentialNoCreateOptionException) {
|
||||||
Log.w(
|
Log.w(
|
||||||
"DebtPirate::AccountManager",
|
"DebtPirate::AccountManager",
|
||||||
"Cannot store credentials; a Google account isn't associated with this device"
|
"Cannot store credentials; a Google account isn't associated with this device"
|
||||||
)
|
)
|
||||||
AccountManagerResult.Unavailable
|
AccountManagerResult.Unavailable
|
||||||
} catch (err: CreateCredentialCancellationException) {
|
} catch (_: CreateCredentialCancellationException) {
|
||||||
err.printStackTrace()
|
|
||||||
AccountManagerResult.Canceled
|
AccountManagerResult.Canceled
|
||||||
} catch (err: CreateCredentialException) {
|
} catch (err: CreateCredentialException) {
|
||||||
err.printStackTrace()
|
err.printStackTrace()
|
||||||
|
|
Loading…
Add table
Reference in a new issue