Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGladkov committed Jul 25, 2022
2 parents fb7ba9e + f77b837 commit 467ab27
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 20 deletions.
2 changes: 1 addition & 1 deletion buildSrc/buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
object Dependencies {

val odyssey = "1.0.0-beta12"
val odyssey = "1.0.0-beta13"
val odysseyPackage = "io.github.alexgladkov"

object DI {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fun RootComposeBuilder.topNavScreen() {

fun RootComposeBuilder.customNavScreen() {
customNavigation(name = "drawer", tabsNavModel = CustomConfiguration(
content = { DrawerScreen() }
content = { params -> DrawerScreen(params) }
)) {
tab(FeedTab()) {
screen(name = "tab") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -91,7 +90,7 @@ fun ActionsScreen(count: Int?) {
"Show Drawer Navigation",
icon = Icons.Filled.DashboardCustomize
) {
rootController.present("drawer")
rootController.present("drawer", params = "Custom Title from params")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package ru.alexgladkov.common.compose.screens

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
Expand All @@ -20,22 +17,31 @@ import ru.alexgladkov.odyssey.compose.controllers.MultiStackRootController
import ru.alexgladkov.odyssey.compose.local.LocalRootController

@Composable
fun DrawerScreen() {
fun DrawerScreen(params: Any?) {
val rootController = LocalRootController.current as MultiStackRootController
val tabItem = rootController.stackChangeObserver.collectAsState()
val coroutineScope = rememberCoroutineScope()
val scaffoldState = rememberScaffoldState(
drawerState = rememberDrawerState(DrawerValue.Open)
)

Scaffold (
Scaffold(
scaffoldState = scaffoldState,
drawerContent = {
Column(
modifier = Modifier
.fillMaxSize()
.background(color = Color.DarkGray)
) {
params?.toString()?.let { title ->
Text(
modifier = Modifier.height(40.dp).padding(10.dp).fillMaxWidth(),
text = title,
textAlign = TextAlign.Start,
color = Color.White
)
}

rootController.tabItems.forEach { currentItem ->
Text(
modifier = Modifier.height(40.dp).fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ru.alexgladkov.common.compose.tabs

import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import ru.alexgladkov.common.compose.theme.Odyssey
import ru.alexgladkov.odyssey.compose.navigation.RootComposeBuilder
import ru.alexgladkov.odyssey.compose.navigation.bottom_bar_navigation.*
Expand Down Expand Up @@ -31,7 +30,7 @@ class TopConfiguration : TabsNavModel<TopNavConfiguration>() {
}
}

class CustomConfiguration(private val content: @Composable () -> Unit) :
class CustomConfiguration(private val content: @Composable (params: Any?) -> Unit) :
TabsNavModel<CustomNavConfiguration>() {

override val navConfiguration: CustomNavConfiguration
Expand Down
4 changes: 2 additions & 2 deletions documentation/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Add dependencies to gradle
```kotlin
named("commonMain") {
dependencies {
implementation("io.github.alexgladkov:odyssey-core:1.0.0-beta12") // For core classes
implementation("io.github.alexgladkov:odyssey-compose:1.0.0-beta12") // For compose extensions
implementation("io.github.alexgladkov:odyssey-core:1.0.0-beta13") // For core classes
implementation("io.github.alexgladkov:odyssey-compose:1.0.0-beta13") // For compose extensions
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ open class RootController(
tabsNavModel = screenType.tabsNavModel,
launchFlag = launchFlag,
startScreen = startScreen,
startTabPosition = startTabPosition
startTabPosition = startTabPosition,
params = params
)
}
}
Expand Down Expand Up @@ -437,7 +438,8 @@ open class RootController(
tabsNavModel: TabsNavModel<*>,
startScreen: String? = null,
startTabPosition: Int = 0,
launchFlag: LaunchFlag?
launchFlag: LaunchFlag?,
params: Any? = null,
) {
if (rootControllerType == RootControllerType.Flow || rootControllerType == RootControllerType.MultiStack)
throw IllegalStateException("Don't use flow inside flow, call findRootController instead")
Expand Down Expand Up @@ -474,7 +476,8 @@ open class RootController(
animationType = animationType,
params = MultiStackBundle(
rootController = rootController,
startScreen = startScreen
startScreen = startScreen,
params = params
)
)

Expand Down Expand Up @@ -512,7 +515,7 @@ open class RootController(
TabsNavType.Custom -> {
val customNavConfiguration =
bundle.rootController.tabsNavModel.navConfiguration as CustomNavConfiguration
customNavConfiguration.content()
customNavConfiguration.content(bundle.params)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ data class FlowBundle(

data class MultiStackBundle(
val startScreen: String?,
val rootController: MultiStackRootController
val rootController: MultiStackRootController,
val params: Any? = null
)

data class DeepLinkBundle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ data class TopNavConfiguration(
}

data class CustomNavConfiguration(
val content: @Composable () -> Unit
val content: @Composable (params: Any?) -> Unit
) : TabsNavConfiguration {
override val type = TabsNavType.Custom
}
Expand Down

0 comments on commit 467ab27

Please sign in to comment.