Ensure a Callback and only one is provided in the Plugin. Also reduce boilerplate code in Nodes.
This commit is contained in:
parent
596b7f00fc
commit
5197154f54
76 changed files with 374 additions and 741 deletions
|
|
@ -12,12 +12,12 @@ import androidx.compose.ui.Modifier
|
|||
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 dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.Assisted
|
||||
import dev.zacsweers.metro.AssistedInject
|
||||
import io.element.android.annotations.ContributesNode
|
||||
import io.element.android.features.licenses.impl.model.DependencyLicenseItem
|
||||
import io.element.android.libraries.architecture.callback
|
||||
|
||||
@ContributesNode(AppScope::class)
|
||||
@AssistedInject
|
||||
|
|
@ -33,10 +33,7 @@ class DependencyLicensesListNode(
|
|||
fun navigateToLicense(license: DependencyLicenseItem)
|
||||
}
|
||||
|
||||
private fun onOpenLicense(license: DependencyLicenseItem) {
|
||||
plugins<Callback>()
|
||||
.forEach { it.navigateToLicense(license) }
|
||||
}
|
||||
private val callback: Callback = callback()
|
||||
|
||||
@Composable
|
||||
override fun View(modifier: Modifier) {
|
||||
|
|
@ -44,7 +41,7 @@ class DependencyLicensesListNode(
|
|||
DependencyLicensesListView(
|
||||
state = state,
|
||||
onBackClick = ::navigateUp,
|
||||
onOpenLicense = ::onOpenLicense,
|
||||
onOpenLicense = callback::navigateToLicense,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue