mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Refactor: Inject BluetoothViewModel into ConnectionsScreen (#2228)
This commit is contained in:
parent
1d165a5dc3
commit
ca3c787e71
4 changed files with 29 additions and 17 deletions
|
|
@ -24,6 +24,7 @@ import androidx.navigation.NavHostController
|
|||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.navDeepLink
|
||||
import androidx.navigation.navigation
|
||||
import com.geeksville.mesh.model.BluetoothViewModel
|
||||
import com.geeksville.mesh.model.UIViewModel
|
||||
import com.geeksville.mesh.ui.connections.ConnectionsScreen
|
||||
import com.geeksville.mesh.ui.radioconfig.components.LoRaConfigScreen
|
||||
|
|
@ -41,7 +42,11 @@ sealed class ConnectionsRoutes {
|
|||
/**
|
||||
* Navigation graph for for the top level ConnectionsScreen - [ConnectionsRoutes.Connections].
|
||||
*/
|
||||
fun NavGraphBuilder.connectionsGraph(navController: NavHostController, uiViewModel: UIViewModel) {
|
||||
fun NavGraphBuilder.connectionsGraph(
|
||||
navController: NavHostController,
|
||||
uiViewModel: UIViewModel,
|
||||
bluetoothViewModel: BluetoothViewModel
|
||||
) {
|
||||
navigation<ConnectionsRoutes.ConnectionsGraph>(
|
||||
startDestination = ConnectionsRoutes.Connections,
|
||||
) {
|
||||
|
|
@ -57,7 +62,8 @@ fun NavGraphBuilder.connectionsGraph(navController: NavHostController, uiViewMod
|
|||
navController.getBackStackEntry<ConnectionsRoutes.ConnectionsGraph>()
|
||||
}
|
||||
ConnectionsScreen(
|
||||
uiViewModel,
|
||||
uiViewModel = uiViewModel,
|
||||
bluetoothViewModel = bluetoothViewModel,
|
||||
radioConfigViewModel = hiltViewModel(parentEntry),
|
||||
onNavigateToRadioConfig = { navController.navigate(RadioConfigRoutes.RadioConfig()) },
|
||||
onNavigateToNodeDetails = { navController.navigate(NodesRoutes.NodeDetail(it)) },
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import androidx.navigation.compose.NavHost
|
|||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import com.geeksville.mesh.R
|
||||
import com.geeksville.mesh.model.BluetoothViewModel
|
||||
import com.geeksville.mesh.model.UIViewModel
|
||||
import com.geeksville.mesh.ui.TopLevelDestination.Companion.isTopLevel
|
||||
import com.geeksville.mesh.ui.debug.DebugScreen
|
||||
|
|
@ -74,6 +75,7 @@ fun NavDestination.showLongNameTitle(): Boolean {
|
|||
fun NavGraph(
|
||||
modifier: Modifier = Modifier,
|
||||
uIViewModel: UIViewModel = hiltViewModel(),
|
||||
bluetoothViewModel: BluetoothViewModel = hiltViewModel(),
|
||||
navController: NavHostController = rememberNavController(),
|
||||
) {
|
||||
NavHost(
|
||||
|
|
@ -89,7 +91,7 @@ fun NavGraph(
|
|||
nodesGraph(navController, uIViewModel,)
|
||||
mapGraph(navController, uIViewModel)
|
||||
channelsGraph(navController, uIViewModel)
|
||||
connectionsGraph(navController, uIViewModel)
|
||||
connectionsGraph(navController, uIViewModel, bluetoothViewModel)
|
||||
composable<Route.DebugPanel> { DebugScreen() }
|
||||
radioConfigGraph(navController, uIViewModel)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue