This commit is contained in:
Халимов Рустам
2026-04-15 02:40:52 +03:00
parent 9560a9235f
commit 8409c51842
16 changed files with 207 additions and 34 deletions
+16 -1
View File
@@ -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