Initial commit
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package ru.tanexc.hemoanalysis.navigation
|
||||
|
||||
import com.arkivanov.decompose.ComponentContext
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.IO
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
|
||||
abstract class BaseComponent(
|
||||
val context: ComponentContext,
|
||||
val onNavigate: (Config) -> Unit,
|
||||
val onBack: () -> Unit
|
||||
): ComponentContext by context {
|
||||
val componentScope: CoroutineScope
|
||||
get() = CoroutineScope(SupervisorJob() + Dispatchers.IO).withLifecycle(lifecycle)
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package ru.tanexc.hemoanalysis.navigation
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
sealed class Config(
|
||||
val navLabelResId: String,
|
||||
val navIconResId: String
|
||||
) {
|
||||
|
||||
@Serializable
|
||||
data object Analysis: Config(
|
||||
navLabelResId = "analysis_label",
|
||||
navIconResId = "analysis",
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data object Settings: Config(
|
||||
navLabelResId = "settings_label",
|
||||
navIconResId = "settings",
|
||||
)
|
||||
|
||||
companion object {
|
||||
val navEntries: List<Config> = listOf(Analysis, Settings)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package ru.tanexc.hemoanalysis.navigation
|
||||
|
||||
import com.arkivanov.essenty.lifecycle.Lifecycle
|
||||
import com.arkivanov.essenty.lifecycle.doOnDestroy
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.cancel
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import org.koin.mp.KoinPlatform.getKoin
|
||||
|
||||
fun CoroutineScope.withLifecycle(lifecycle: Lifecycle): CoroutineScope {
|
||||
lifecycle.doOnDestroy(::cancel)
|
||||
return this
|
||||
}
|
||||
|
||||
inline fun <reified T : BaseComponent> getComponent(vararg parameters: Any?) = getKoin().get<T> {
|
||||
parametersOf(*parameters)
|
||||
}
|
||||
Reference in New Issue
Block a user