-
Notifications
You must be signed in to change notification settings - Fork 226
Merge on boarding module to login module #4746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -18,15 +18,17 @@ import com.bumble.appyx.core.lifecycle.subscribe | |
import com.bumble.appyx.core.modality.BuildContext | ||
import com.bumble.appyx.core.node.Node | ||
import com.bumble.appyx.core.plugin.Plugin | ||
import com.bumble.appyx.core.plugin.plugins | ||
import com.bumble.appyx.navmodel.backstack.BackStack | ||
import com.bumble.appyx.navmodel.backstack.operation.push | ||
import com.bumble.appyx.navmodel.backstack.operation.singleTop | ||
import dagger.assisted.Assisted | ||
import dagger.assisted.AssistedInject | ||
import io.element.android.anvilannotations.ContributesNode | ||
import io.element.android.compound.theme.ElementTheme | ||
import io.element.android.features.login.api.LoginFlowType | ||
import io.element.android.features.login.api.LoginEntryPoint | ||
import io.element.android.features.login.impl.accountprovider.AccountProviderDataSource | ||
import io.element.android.features.login.impl.onboarding.OnBoardingNode | ||
import io.element.android.features.login.impl.qrcode.QrCodeLoginFlowNode | ||
import io.element.android.features.login.impl.screens.changeaccountprovider.ChangeAccountProviderNode | ||
import io.element.android.features.login.impl.screens.confirmaccountprovider.ConfirmAccountProviderNode | ||
|
@@ -35,9 +37,7 @@ import io.element.android.features.login.impl.screens.loginpassword.LoginPasswor | |
import io.element.android.features.login.impl.screens.searchaccountprovider.SearchAccountProviderNode | ||
import io.element.android.libraries.architecture.BackstackView | ||
import io.element.android.libraries.architecture.BaseFlowNode | ||
import io.element.android.libraries.architecture.NodeInputs | ||
import io.element.android.libraries.architecture.createNode | ||
import io.element.android.libraries.architecture.inputs | ||
import io.element.android.libraries.di.AppScope | ||
import io.element.android.libraries.matrix.api.auth.OidcDetails | ||
import io.element.android.libraries.oidc.api.OidcAction | ||
|
@@ -57,7 +57,7 @@ class LoginFlowNode @AssistedInject constructor( | |
private val oidcEntryPoint: OidcEntryPoint, | ||
) : BaseFlowNode<LoginFlowNode.NavTarget>( | ||
backstack = BackStack( | ||
initialElement = NavTarget.Root, | ||
initialElement = NavTarget.OnBoarding, | ||
savedStateMap = buildContext.savedStateMap, | ||
), | ||
buildContext = buildContext, | ||
|
@@ -66,12 +66,6 @@ class LoginFlowNode @AssistedInject constructor( | |
private var activity: Activity? = null | ||
private var darkTheme: Boolean = false | ||
|
||
data class Inputs( | ||
val flowType: LoginFlowType, | ||
) : NodeInputs | ||
|
||
private val inputs: Inputs = inputs() | ||
|
||
private var customChromeTabStarted = false | ||
|
||
override fun onBuilt() { | ||
|
@@ -96,10 +90,15 @@ class LoginFlowNode @AssistedInject constructor( | |
|
||
sealed interface NavTarget : Parcelable { | ||
@Parcelize | ||
data object Root : NavTarget | ||
data object OnBoarding : NavTarget | ||
|
||
@Parcelize | ||
data object QrCode : NavTarget | ||
|
||
@Parcelize | ||
data object ConfirmAccountProvider : NavTarget | ||
data class ConfirmAccountProvider( | ||
val isAccountCreation: Boolean, | ||
) : NavTarget | ||
|
||
@Parcelize | ||
data object ChangeAccountProvider : NavTarget | ||
|
@@ -119,16 +118,36 @@ class LoginFlowNode @AssistedInject constructor( | |
|
||
override fun resolve(navTarget: NavTarget, buildContext: BuildContext): Node { | ||
return when (navTarget) { | ||
NavTarget.Root -> { | ||
if (inputs.flowType == LoginFlowType.SIGN_IN_QR_CODE) { | ||
createNode<QrCodeLoginFlowNode>(buildContext) | ||
} else { | ||
resolve(NavTarget.ConfirmAccountProvider, buildContext) | ||
NavTarget.OnBoarding -> { | ||
val callback = object : OnBoardingNode.Callback { | ||
override fun onSignUp() { | ||
backstack.push( | ||
NavTarget.ConfirmAccountProvider(isAccountCreation = true) | ||
) | ||
} | ||
|
||
override fun onSignIn() { | ||
backstack.push( | ||
NavTarget.ConfirmAccountProvider(isAccountCreation = false) | ||
) | ||
} | ||
|
||
override fun onSignInWithQrCode() { | ||
backstack.push(NavTarget.QrCode) | ||
} | ||
|
||
override fun onReportProblem() { | ||
plugins<LoginEntryPoint.Callback>().forEach { it.onReportProblem() } | ||
} | ||
} | ||
createNode<OnBoardingNode>(buildContext, listOf(callback)) | ||
} | ||
NavTarget.QrCode -> { | ||
createNode<QrCodeLoginFlowNode>(buildContext) | ||
} | ||
NavTarget.ConfirmAccountProvider -> { | ||
is NavTarget.ConfirmAccountProvider -> { | ||
val inputs = ConfirmAccountProviderNode.Inputs( | ||
isAccountCreation = inputs.flowType == LoginFlowType.SIGN_UP, | ||
isAccountCreation = navTarget.isAccountCreation, | ||
) | ||
val callback = object : ConfirmAccountProviderNode.Callback { | ||
override fun onOidcDetails(oidcDetails: OidcDetails) { | ||
|
@@ -162,7 +181,10 @@ class LoginFlowNode @AssistedInject constructor( | |
val callback = object : ChangeAccountProviderNode.Callback { | ||
override fun onDone() { | ||
// Go back to the Account Provider screen | ||
backstack.singleTop(NavTarget.ConfirmAccountProvider) | ||
val confirmAccountProvider = backstack.elements.value.firstOrNull { | ||
it.key.navTarget is NavTarget.ConfirmAccountProvider | ||
}?.key?.navTarget ?: NavTarget.ConfirmAccountProvider(isAccountCreation = false) | ||
backstack.singleTop(confirmAccountProvider) | ||
} | ||
|
||
override fun onOtherClick() { | ||
|
@@ -176,7 +198,10 @@ class LoginFlowNode @AssistedInject constructor( | |
val callback = object : SearchAccountProviderNode.Callback { | ||
override fun onDone() { | ||
// Go back to the Account Provider screen | ||
backstack.singleTop(NavTarget.ConfirmAccountProvider) | ||
val confirmAccountProvider = backstack.elements.value.firstOrNull { | ||
it.key.navTarget is NavTarget.ConfirmAccountProvider | ||
}?.key?.navTarget ?: NavTarget.ConfirmAccountProvider(isAccountCreation = false) | ||
backstack.singleTop(confirmAccountProvider) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is maybe a better way to do this, but it works... |
||
} | ||
} | ||
|
||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This node could be simplified more, since there is no need for a backstack anymore, but it can stay like this.