-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3213 from CruGlobal/accountCreationFeedback
GT-2112 Present auth error messages to the user on login
- Loading branch information
Showing
28 changed files
with
633 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
app/src/main/kotlin/org/cru/godtools/ui/login/LoginLayoutEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
package org.cru.godtools.ui.login | ||
|
||
import org.cru.godtools.account.AccountType | ||
|
||
sealed class LoginLayoutEvent { | ||
class Login(val type: AccountType) : LoginLayoutEvent() | ||
object Close : LoginLayoutEvent() | ||
data object Close : LoginLayoutEvent() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
library/account/src/main/kotlin/org/cru/godtools/account/LoginResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.cru.godtools.account | ||
|
||
sealed interface LoginResponse { | ||
data object Success : LoginResponse | ||
open class Error : LoginResponse { | ||
data object UserNotFound : Error() | ||
data object UserAlreadyExists : Error() | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...y/account/src/main/kotlin/org/cru/godtools/account/compose/LocalGodToolsAccountManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.cru.godtools.account.compose | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.ProvidedValue | ||
import androidx.compose.runtime.compositionLocalOf | ||
import androidx.compose.ui.platform.LocalContext | ||
import dagger.hilt.EntryPoint | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.EntryPointAccessors | ||
import dagger.hilt.components.SingletonComponent | ||
import org.cru.godtools.account.GodToolsAccountManager | ||
|
||
internal object LocalGodToolsAccountManager { | ||
private val LocalComposition = compositionLocalOf<GodToolsAccountManager?> { null } | ||
|
||
/** | ||
* Returns current composition local value for the manager or fallback to resolution using Dagger. | ||
*/ | ||
val current: GodToolsAccountManager | ||
@Composable | ||
get() = LocalComposition.current | ||
?: EntryPointAccessors.fromApplication<AccountEntryPoint>(LocalContext.current).accountManager | ||
|
||
/** | ||
* Associates a [GodToolsAccountManager] key to a value in a call to [CompositionLocalProvider]. | ||
*/ | ||
infix fun provides(accountManager: GodToolsAccountManager): ProvidedValue<GodToolsAccountManager?> { | ||
return LocalComposition.provides(accountManager) | ||
} | ||
} | ||
|
||
@EntryPoint | ||
@InstallIn(SingletonComponent::class) | ||
internal interface AccountEntryPoint { | ||
val accountManager: GodToolsAccountManager | ||
} |
8 changes: 8 additions & 0 deletions
8
library/account/src/main/kotlin/org/cru/godtools/account/compose/LoginLauncher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.cru.godtools.account.compose | ||
|
||
import androidx.compose.runtime.Composable | ||
import org.cru.godtools.account.LoginResponse | ||
|
||
@Composable | ||
fun rememberLoginLauncher(createAccount: Boolean, onResponse: (LoginResponse) -> Unit) = | ||
LocalGodToolsAccountManager.current.rememberLauncherForLogin(createAccount, onResponse) |
Oops, something went wrong.