mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Decouple MainAppBar from UiViewModel (#3216)
This commit is contained in:
parent
6d5e56b34f
commit
a8b0327c41
3 changed files with 9 additions and 43 deletions
|
|
@ -120,7 +120,6 @@ import org.meshtastic.core.ui.icon.Nodes
|
|||
import org.meshtastic.core.ui.icon.Settings
|
||||
import org.meshtastic.core.ui.theme.StatusColors.StatusBlue
|
||||
import org.meshtastic.core.ui.theme.StatusColors.StatusGreen
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
enum class TopLevelDestination(@StringRes val label: Int, val icon: ImageVector, val route: Route) {
|
||||
Conversations(R.string.conversations, MeshtasticIcons.Conversations, ContactsRoutes.ContactsGraph),
|
||||
|
|
@ -131,13 +130,6 @@ enum class TopLevelDestination(@StringRes val label: Int, val icon: ImageVector,
|
|||
;
|
||||
|
||||
companion object {
|
||||
fun NavDestination.isTopLevel(): Boolean = listOf<KClass<out Route>>(
|
||||
ContactsRoutes.Contacts::class,
|
||||
MapRoutes.Map::class,
|
||||
ConnectionsRoutes.Connections::class,
|
||||
)
|
||||
.any { this.hasRoute(it) }
|
||||
|
||||
fun fromNavDestination(destination: NavDestination?): TopLevelDestination? =
|
||||
entries.find { dest -> destination?.hierarchy?.any { it.hasRoute(dest.route::class) } == true }
|
||||
}
|
||||
|
|
@ -382,10 +374,12 @@ fun MainScreen(uIViewModel: UIViewModel = hiltViewModel(), scanModel: BTScanMode
|
|||
)
|
||||
.none { this.hasRoute(it) }
|
||||
|
||||
val ourNodeInfo by uIViewModel.ourNodeInfo.collectAsStateWithLifecycle()
|
||||
AnimatedVisibility(visible = currentDestination?.hasGlobalAppBar() ?: false) {
|
||||
MainAppBar(
|
||||
viewModel = uIViewModel,
|
||||
navController = navController,
|
||||
ourNode = ourNodeInfo,
|
||||
isConnected = connectionState.isConnected(),
|
||||
onAction = { action ->
|
||||
when (action) {
|
||||
is NodeMenuAction.MoreDetails -> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue