|
@@ -7,9 +7,7 @@ import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
|
|
import androidx.compose.material.icons.automirrored.filled.Chat
|
|
|
import androidx.compose.material3.*
|
|
|
import androidx.compose.runtime.*
|
|
|
-import androidx.compose.runtime.livedata.observeAsState
|
|
|
import androidx.compose.ui.Modifier
|
|
|
-import androidx.hilt.navigation.compose.hiltViewModel
|
|
|
import androidx.navigation.NavDestination.Companion.hierarchy
|
|
|
import androidx.navigation.NavGraph.Companion.findStartDestination
|
|
|
import androidx.navigation.NavHostController
|
|
@@ -23,12 +21,12 @@ import androidx.navigation.navigation
|
|
|
import io.nexilis.alpha.ui.components.ActionsMenu
|
|
|
import io.nexilis.alpha.ui.components.Title
|
|
|
import io.nexilis.alpha.ui.screen.Screen
|
|
|
-import io.nexilis.alpha.ui.viewmodel.MainViewModel
|
|
|
+import io.nexilis.alpha.ui.screen.barItems
|
|
|
import io.nexilis.service.data.entities.Buddy
|
|
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
|
@Composable
|
|
|
-fun Main(navController: NavHostController, me: Buddy?) {
|
|
|
+fun Main(navController: NavHostController, me: Buddy) {
|
|
|
val navMainController = rememberNavController()
|
|
|
val hostState = remember { SnackbarHostState() }
|
|
|
val navBackStackEntry by navMainController.currentBackStackEntryAsState()
|
|
@@ -40,16 +38,13 @@ fun Main(navController: NavHostController, me: Buddy?) {
|
|
|
it == Screen.Home.route || it == Screen.Chats.route || it == Screen.Profile.route
|
|
|
}
|
|
|
}
|
|
|
- val mainViewModel: MainViewModel = hiltViewModel()
|
|
|
- val title by mainViewModel.title.observeAsState("")
|
|
|
Scaffold(
|
|
|
modifier = Modifier.fillMaxSize(),
|
|
|
topBar = {
|
|
|
TopAppBar(
|
|
|
title = {
|
|
|
- Title(
|
|
|
- navMainController = navMainController,
|
|
|
- title
|
|
|
+ Title( navController = navController,
|
|
|
+ navMainController = navMainController
|
|
|
)
|
|
|
},
|
|
|
navigationIcon = {
|
|
@@ -82,20 +77,19 @@ fun Main(navController: NavHostController, me: Buddy?) {
|
|
|
route = Graph.home
|
|
|
) {
|
|
|
composable(route = Screen.Home.route) {
|
|
|
- Home(mainViewModel = mainViewModel)
|
|
|
+ Home()
|
|
|
}
|
|
|
composable(route = Screen.Chats.route) {
|
|
|
Chats(
|
|
|
- navController = navMainController,
|
|
|
- mainViewModel = mainViewModel
|
|
|
+ navController = navMainController
|
|
|
)
|
|
|
}
|
|
|
composable(route = Screen.Profile.route) {
|
|
|
- Profile(mainViewModel = mainViewModel)
|
|
|
+ Profile(me = me)
|
|
|
}
|
|
|
navigation(route = Graph.child, startDestination = Screen.Contact.route) {
|
|
|
composable(route = Screen.Contact.route) {
|
|
|
- Contact(navController = navMainController, mainViewModel = mainViewModel)
|
|
|
+ Contact(navController = navMainController)
|
|
|
}
|
|
|
composable(
|
|
|
route = Screen.Chat.route + "/{pin}",
|
|
@@ -138,11 +132,6 @@ fun NavigationIcon(navController: NavHostController, isHome: Boolean) {
|
|
|
fun BottomBar(navController: NavHostController, isHome: Boolean) {
|
|
|
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
|
|
val currentDestination = navBackStackEntry?.destination
|
|
|
- val barItems = listOf(
|
|
|
- Screen.Home,
|
|
|
- Screen.Chats,
|
|
|
- Screen.Profile
|
|
|
- )
|
|
|
if (isHome) NavigationBar {
|
|
|
barItems.forEachIndexed { index, screen ->
|
|
|
NavigationBarItem(
|