Skip to content

Commit

Permalink
Updated ComposeNavigatorByKey and ComposeNavigatorByContent to extend…
Browse files Browse the repository at this point in the history
… StackNavigator
  • Loading branch information
chRyNaN committed Feb 28, 2022
1 parent 57c2283 commit b27b237
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import com.chrynan.navigation.*
interface ComposeNavigationIntentStackNavigatorByKey<Context, Intent : NavigationIntent> :
ComposeNavigatorByKey<Context, Intent>,
NavigationEventHandler<Intent, ComposeNavigationIntentScope<Context, Intent>>,
NavigationEventNavigator<Intent>,
StackNavigator {
NavigationEventNavigator<Intent> {

val scope: ComposeNavigationIntentScope<Context, Intent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.compose.runtime.Composable
import kotlinx.coroutines.flow.Flow
import com.chrynan.navigation.StackDuplicateContentStrategy
import com.chrynan.navigation.Navigator
import com.chrynan.navigation.StackNavigator

@ExperimentalNavigationApi
interface ComposeNavigator<Key> : Navigator {
Expand Down Expand Up @@ -39,7 +40,8 @@ interface ComposeContextNavigator<Context, Key> : ComposeNavigator<Key> {

@ExperimentalNavigationApi
interface ComposeNavigatorByContent<Context, Key> : ComposeNavigator<Key>,
ComposeContextNavigator<Context, Key> {
ComposeContextNavigator<Context, Key>,
StackNavigator {

@Composable
fun goTo(
Expand All @@ -63,7 +65,8 @@ fun <Context, Key> ComposeNavigatorByContent<Context, Key>.goTo(

@ExperimentalNavigationApi
interface ComposeNavigatorByKey<Context, Key> : ComposeNavigator<Key>,
ComposeContextNavigator<Context, Key> {
ComposeContextNavigator<Context, Key>,
StackNavigator {

fun goTo(
key: Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@ package com.chrynan.navigation.compose
import androidx.compose.runtime.Composable
import com.chrynan.presentation.ViewModel
import com.chrynan.navigation.StackDuplicateContentStrategy
import com.chrynan.navigation.StackNavigator
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.filterNotNull

@ExperimentalNavigationApi
abstract class BaseComposeNavigatorByContentViewModel<Context, Key> : ViewModel(),
ComposeNavigator<Key>,
ComposeNavigatorByContent<Context, Key>,
StackNavigator,
ComposeContextNavigator<Context, Key> {
ComposeNavigatorByContent<Context, Key> {

@Composable
internal abstract fun ComposeNavigationContentScope<Context, Key>.content(key: Key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.chrynan.navigation.compose
import androidx.compose.runtime.Composable
import com.chrynan.presentation.ViewModel
import com.chrynan.navigation.StackDuplicateContentStrategy
import com.chrynan.navigation.StackNavigator
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.filterNotNull
Expand All @@ -14,10 +13,7 @@ abstract class BaseComposeNavigatorByKeyViewModel<Context, Key, NavigationScope
final override val keySaver: Saver<Key, Any>,
private val initialKeys: (Context) -> Key
) : ViewModel(),
ComposeNavigator<Key>,
ComposeNavigatorByKey<Context, Key>,
StackNavigator,
ComposeContextNavigator<Context, Key> {
ComposeNavigatorByKey<Context, Key> {

internal abstract val content: @Composable NavigationScope.(key: Key) -> Unit

Expand Down

0 comments on commit b27b237

Please sign in to comment.