commonMain.ru.alexgladkov.odyssey.compose.navigation.RootComposeBuilder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of odyssey-compose Show documentation
Show all versions of odyssey-compose Show documentation
Lightweight multiplatform navigation library (jvm, android, ios)
package ru.alexgladkov.odyssey.compose.navigation
import androidx.compose.ui.graphics.Color
import ru.alexgladkov.odyssey.compose.AllowedDestination
import ru.alexgladkov.odyssey.compose.RootController
import ru.alexgladkov.odyssey.compose.RenderWithParams
import ru.alexgladkov.odyssey.compose.ScreenType
import ru.alexgladkov.odyssey.compose.helpers.FlowBuilderModel
import ru.alexgladkov.odyssey.compose.navigation.bottom_bar_navigation.MultiStackBuilderModel
import ru.alexgladkov.odyssey.compose.navigation.bottom_bar_navigation.TabsNavModel
import ru.alexgladkov.odyssey.core.configuration.RootConfiguration
/**
* Base builder, declarative helper for navigation graph builder
* @see RootController
*/
class RootComposeBuilder(val configuration: RootConfiguration = RootConfiguration()) {
private val _screens: MutableList = mutableListOf()
private val _screenMap: HashMap> = hashMapOf()
fun addScreen(
key: String,
screenMap: Map>,
) {
_screens.add(AllowedDestination(key = key, screenType = ScreenType.Simple))
_screenMap.putAll(screenMap)
}
fun addFlow(
key: String,
flowBuilderModel: FlowBuilderModel
) {
_screens.add(
AllowedDestination(
key = key,
screenType = ScreenType.Flow(flowBuilderModel = flowBuilderModel)
)
)
}
fun addMultiStack(
key: String,
tabsNavModel: TabsNavModel<*>,
multiStackBuilderModel: MultiStackBuilderModel
) {
_screens.add(
AllowedDestination(
key = key,
screenType = ScreenType.MultiStack(multiStackBuilderModel, tabsNavModel)
)
)
}
fun build(): RootController = RootController(configuration = configuration)
.apply {
updateScreenMap(_screenMap)
setNavigationGraph(_screens)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy