Пуши
This commit is contained in:
@@ -51,12 +51,27 @@ sealed class Screen(val route: String) {
|
||||
|
||||
@Composable
|
||||
fun AppNavigation(
|
||||
navController: NavHostController = rememberNavController()
|
||||
navController: NavHostController = rememberNavController(),
|
||||
navigationManager: core.utils.NavigationManager? = null
|
||||
) {
|
||||
val authViewModel: AuthViewModel = hiltViewModel()
|
||||
val authState by authViewModel.state.collectAsState()
|
||||
val startDestination = if (authState.isAuthenticated) Screen.ChatList.route else Screen.Login.route
|
||||
|
||||
androidx.compose.runtime.LaunchedEffect(navigationManager) {
|
||||
navigationManager?.events?.collect { event ->
|
||||
when (event) {
|
||||
is core.utils.NavEvent.OpenChat -> {
|
||||
if (authState.isAuthenticated) {
|
||||
navController.navigate(Screen.ChatDetail.createRoute(event.chatId, "Chat")) {
|
||||
launchSingleTop = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||
val currentRoute = navBackStackEntry?.destination?.route
|
||||
|
||||
|
||||
Reference in New Issue
Block a user