Use context parameter for the parentNode
This commit is contained in:
parent
02dc71c4c3
commit
f174084942
138 changed files with 450 additions and 375 deletions
|
|
@ -16,8 +16,8 @@ import io.element.android.libraries.architecture.createNode
|
|||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultPreferencesEntryPoint : PreferencesEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
params: PreferencesEntryPoint.Params,
|
||||
callback: PreferencesEntryPoint.Callback,
|
||||
|
|
|
|||
|
|
@ -216,7 +216,6 @@ class PreferencesFlowNode(
|
|||
}
|
||||
NavTarget.TroubleshootNotifications -> {
|
||||
notificationTroubleShootEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
callback = object : NotificationTroubleShootEntryPoint.Callback {
|
||||
override fun onDone() {
|
||||
|
|
@ -235,9 +234,8 @@ class PreferencesFlowNode(
|
|||
}
|
||||
NavTarget.PushHistory -> {
|
||||
pushHistoryEntryPoint.createNode(
|
||||
this,
|
||||
buildContext,
|
||||
object : PushHistoryEntryPoint.Callback {
|
||||
buildContext = buildContext,
|
||||
callback = object : PushHistoryEntryPoint.Callback {
|
||||
override fun onDone() {
|
||||
if (backstack.canPop()) {
|
||||
backstack.pop()
|
||||
|
|
@ -270,7 +268,6 @@ class PreferencesFlowNode(
|
|||
}
|
||||
NavTarget.LockScreenSettings -> {
|
||||
lockScreenEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
navTarget = LockScreenEntryPoint.Target.Settings,
|
||||
callback = object : LockScreenEntryPoint.Callback {
|
||||
|
|
@ -290,16 +287,15 @@ class PreferencesFlowNode(
|
|||
}
|
||||
}
|
||||
logoutEntryPoint.createNode(
|
||||
parentNode = this,
|
||||
buildContext = buildContext,
|
||||
callback = callBack,
|
||||
)
|
||||
}
|
||||
is NavTarget.OssLicenses -> {
|
||||
openSourceLicensesEntryPoint.createNode(this, buildContext)
|
||||
openSourceLicensesEntryPoint.createNode(buildContext)
|
||||
}
|
||||
NavTarget.AccountDeactivation -> {
|
||||
accountDeactivationEntryPoint.createNode(this, buildContext)
|
||||
accountDeactivationEntryPoint.createNode(buildContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ class DefaultPreferencesEntryPointTest {
|
|||
buildContext = buildContext,
|
||||
plugins = plugins,
|
||||
lockScreenEntryPoint = object : LockScreenEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
navTarget: LockScreenEntryPoint.Target,
|
||||
callback: LockScreenEntryPoint.Callback,
|
||||
|
|
@ -52,31 +52,33 @@ class DefaultPreferencesEntryPointTest {
|
|||
override fun pinUnlockIntent(context: Context) = lambdaError()
|
||||
},
|
||||
notificationTroubleShootEntryPoint = object : NotificationTroubleShootEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
callback: NotificationTroubleShootEntryPoint.Callback,
|
||||
) = lambdaError()
|
||||
},
|
||||
pushHistoryEntryPoint = object : PushHistoryEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
callback: PushHistoryEntryPoint.Callback,
|
||||
) = lambdaError()
|
||||
},
|
||||
logoutEntryPoint = object : LogoutEntryPoint {
|
||||
context(parentNode: Node)
|
||||
override fun createNode(
|
||||
parentNode: Node,
|
||||
buildContext: BuildContext,
|
||||
callback: LogoutEntryPoint.Callback,
|
||||
) = lambdaError()
|
||||
},
|
||||
openSourceLicensesEntryPoint = object : OpenSourceLicensesEntryPoint {
|
||||
override fun createNode(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||
context(parentNode: Node)
|
||||
override fun createNode(buildContext: BuildContext) = lambdaError()
|
||||
},
|
||||
accountDeactivationEntryPoint = object : AccountDeactivationEntryPoint {
|
||||
override fun createNode(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||
context(parentNode: Node)
|
||||
override fun createNode(buildContext: BuildContext) = lambdaError()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
@ -90,12 +92,13 @@ class DefaultPreferencesEntryPointTest {
|
|||
val params = PreferencesEntryPoint.Params(
|
||||
initialElement = PreferencesEntryPoint.InitialTarget.NotificationSettings,
|
||||
)
|
||||
val result = entryPoint.createNode(
|
||||
parentNode = parentNode,
|
||||
buildContext = BuildContext.root(null),
|
||||
params = params,
|
||||
callback = callback,
|
||||
)
|
||||
val result = with(parentNode) {
|
||||
entryPoint.createNode(
|
||||
buildContext = BuildContext.root(null),
|
||||
params = params,
|
||||
callback = callback,
|
||||
)
|
||||
}
|
||||
assertThat(result).isInstanceOf(PreferencesFlowNode::class.java)
|
||||
assertThat(result.plugins).contains(params)
|
||||
assertThat(result.plugins).contains(callback)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue