mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-19 19:31:43 +02:00
Changes the name of the nav to avoid confusing the auto import
This commit is contained in:
@@ -30,7 +30,7 @@ import kotlin.reflect.KClass
|
||||
|
||||
@Stable
|
||||
object EmptyNav : INav {
|
||||
override val scope: CoroutineScope get() = TODO("Not yet implemented")
|
||||
override val navigationScope: CoroutineScope get() = TODO("Not yet implemented")
|
||||
override val drawerState = DrawerState(DrawerValue.Closed)
|
||||
|
||||
override fun closeDrawer() = runBlocking { drawerState.close() }
|
||||
|
@@ -28,7 +28,7 @@ import kotlin.reflect.KClass
|
||||
|
||||
@Stable
|
||||
interface INav {
|
||||
val scope: CoroutineScope
|
||||
val navigationScope: CoroutineScope
|
||||
val drawerState: DrawerState
|
||||
|
||||
fun closeDrawer()
|
||||
|
@@ -34,20 +34,20 @@ import kotlin.reflect.KClass
|
||||
@Stable
|
||||
class Nav(
|
||||
val controller: NavHostController,
|
||||
override val scope: CoroutineScope,
|
||||
override val navigationScope: CoroutineScope,
|
||||
) : INav {
|
||||
override val drawerState = DrawerState(DrawerValue.Closed)
|
||||
|
||||
override fun closeDrawer() {
|
||||
scope.launch { drawerState.close() }
|
||||
navigationScope.launch { drawerState.close() }
|
||||
}
|
||||
|
||||
override fun openDrawer() {
|
||||
scope.launch { drawerState.open() }
|
||||
navigationScope.launch { drawerState.open() }
|
||||
}
|
||||
|
||||
override fun nav(route: Route) {
|
||||
scope.launch {
|
||||
navigationScope.launch {
|
||||
if (getRouteWithArguments(controller) != route) {
|
||||
controller.navigate(route)
|
||||
}
|
||||
@@ -55,7 +55,7 @@ class Nav(
|
||||
}
|
||||
|
||||
override fun nav(computeRoute: suspend () -> Route?) {
|
||||
scope.launch {
|
||||
navigationScope.launch {
|
||||
val route = computeRoute()
|
||||
if (route != null && getRouteWithArguments(controller) != route) {
|
||||
controller.navigate(route)
|
||||
@@ -64,7 +64,7 @@ class Nav(
|
||||
}
|
||||
|
||||
override fun newStack(route: Route) {
|
||||
scope.launch {
|
||||
navigationScope.launch {
|
||||
controller.navigate(route) {
|
||||
popUpTo(route) {
|
||||
inclusive = true
|
||||
@@ -75,7 +75,7 @@ class Nav(
|
||||
}
|
||||
|
||||
override fun popBack() {
|
||||
scope.launch {
|
||||
navigationScope.launch {
|
||||
controller.navigateUp()
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class Nav(
|
||||
route: Route,
|
||||
klass: KClass<T>,
|
||||
) {
|
||||
scope.launch {
|
||||
navigationScope.launch {
|
||||
controller.navigate(route) {
|
||||
popUpTo<T>(klass) { inclusive = true }
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ import kotlin.reflect.KClass
|
||||
|
||||
class ObservableNav(
|
||||
val sourceNav: INav,
|
||||
override val scope: CoroutineScope,
|
||||
override val navigationScope: CoroutineScope,
|
||||
val onBeforeNavigate: () -> Unit,
|
||||
) : INav {
|
||||
override val drawerState: DrawerState = sourceNav.drawerState
|
||||
@@ -42,28 +42,28 @@ class ObservableNav(
|
||||
}
|
||||
|
||||
override fun nav(route: Route) {
|
||||
scope.launch {
|
||||
navigationScope.launch {
|
||||
onBeforeNavigate()
|
||||
}
|
||||
sourceNav.nav(route)
|
||||
}
|
||||
|
||||
override fun nav(computeRoute: suspend () -> Route?) {
|
||||
scope.launch {
|
||||
navigationScope.launch {
|
||||
onBeforeNavigate()
|
||||
}
|
||||
sourceNav.nav(computeRoute)
|
||||
}
|
||||
|
||||
override fun newStack(route: Route) {
|
||||
scope.launch {
|
||||
navigationScope.launch {
|
||||
onBeforeNavigate()
|
||||
}
|
||||
sourceNav.newStack(route)
|
||||
}
|
||||
|
||||
override fun popBack() {
|
||||
scope.launch {
|
||||
navigationScope.launch {
|
||||
onBeforeNavigate()
|
||||
}
|
||||
sourceNav.popBack()
|
||||
@@ -73,7 +73,7 @@ class ObservableNav(
|
||||
route: Route,
|
||||
upToClass: KClass<T>,
|
||||
) {
|
||||
scope.launch {
|
||||
navigationScope.launch {
|
||||
onBeforeNavigate()
|
||||
}
|
||||
sourceNav.popUpTo(route, upToClass)
|
||||
|
@@ -30,7 +30,7 @@ import kotlin.reflect.KClass
|
||||
|
||||
class TwoPaneNav(
|
||||
val nav: INav,
|
||||
override val scope: CoroutineScope,
|
||||
override val navigationScope: CoroutineScope,
|
||||
) : INav {
|
||||
override val drawerState: DrawerState = nav.drawerState
|
||||
|
||||
@@ -45,7 +45,7 @@ class TwoPaneNav(
|
||||
}
|
||||
|
||||
override fun nav(computeRoute: suspend () -> Route?) {
|
||||
scope.launch {
|
||||
navigationScope.launch {
|
||||
val route = computeRoute()
|
||||
if (route != null) {
|
||||
if (route is Route.Room || route is Route.PublicChatChannel) {
|
||||
|
Reference in New Issue
Block a user