mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: Allow unlocking excluded modules (#2180)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
8639228721
commit
bcc3a0f107
4 changed files with 100 additions and 15 deletions
|
|
@ -90,6 +90,7 @@ import com.geeksville.mesh.ui.common.components.MultipleChoiceAlertDialog
|
|||
import com.geeksville.mesh.ui.common.components.ScannedQrCodeDialog
|
||||
import com.geeksville.mesh.ui.common.components.SimpleAlertDialog
|
||||
import com.geeksville.mesh.ui.debug.DebugMenuActions
|
||||
import com.geeksville.mesh.ui.radioconfig.RadioConfigMenuActions
|
||||
|
||||
enum class TopLevelDestination(@StringRes val label: Int, val icon: ImageVector, val route: Route) {
|
||||
Contacts(R.string.contacts, Icons.AutoMirrored.TwoTone.Chat, ContactsRoutes.Contacts),
|
||||
|
|
@ -126,8 +127,6 @@ fun MainScreen(
|
|||
|
||||
VersionChecks(viewModel)
|
||||
|
||||
val title by viewModel.title.collectAsStateWithLifecycle()
|
||||
|
||||
val alertDialogState by viewModel.currentAlert.collectAsStateWithLifecycle()
|
||||
alertDialogState?.let { state ->
|
||||
if (state.choices.isNotEmpty()) {
|
||||
|
|
@ -245,7 +244,7 @@ fun MainScreen(
|
|||
.fillMaxSize()
|
||||
) {
|
||||
MainAppBar(
|
||||
title = title,
|
||||
viewModel = viewModel,
|
||||
isManaged = localConfig.security.isManaged,
|
||||
navController = navController,
|
||||
onAction = { action ->
|
||||
|
|
@ -336,7 +335,7 @@ enum class MainMenuAction(@StringRes val stringRes: Int) {
|
|||
@Suppress("LongMethod")
|
||||
@Composable
|
||||
private fun MainAppBar(
|
||||
title: String,
|
||||
viewModel: UIViewModel = hiltViewModel(),
|
||||
isManaged: Boolean,
|
||||
navController: NavHostController,
|
||||
modifier: Modifier = Modifier,
|
||||
|
|
@ -350,6 +349,7 @@ private fun MainAppBar(
|
|||
if (currentDestination?.hasRoute<ContactsRoutes.Messages>() == true) {
|
||||
return
|
||||
}
|
||||
val title by viewModel.title.collectAsStateWithLifecycle("")
|
||||
TopAppBar(
|
||||
title = {
|
||||
when {
|
||||
|
|
@ -405,19 +405,39 @@ private fun MainAppBar(
|
|||
}
|
||||
},
|
||||
actions = {
|
||||
when {
|
||||
currentDestination == null || isTopLevelRoute ->
|
||||
MainMenuActions(isManaged, onAction)
|
||||
|
||||
currentDestination.hasRoute<Route.DebugPanel>() ->
|
||||
DebugMenuActions()
|
||||
|
||||
else -> {}
|
||||
}
|
||||
TopBarActions(
|
||||
viewModel = viewModel,
|
||||
currentDestination = currentDestination,
|
||||
isManaged = isManaged,
|
||||
isTopLevelRoute = isTopLevelRoute,
|
||||
onAction = onAction
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TopBarActions(
|
||||
viewModel: UIViewModel = hiltViewModel(),
|
||||
currentDestination: NavDestination?,
|
||||
isManaged: Boolean,
|
||||
isTopLevelRoute: Boolean,
|
||||
onAction: (MainMenuAction) -> Unit
|
||||
) {
|
||||
when {
|
||||
currentDestination == null || isTopLevelRoute ->
|
||||
MainMenuActions(isManaged, onAction)
|
||||
|
||||
currentDestination.hasRoute<Route.DebugPanel>() ->
|
||||
DebugMenuActions()
|
||||
|
||||
currentDestination.hasRoute<RadioConfigRoutes.RadioConfig>() ->
|
||||
RadioConfigMenuActions(viewModel = viewModel)
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun MainMenuActions(
|
||||
isManaged: Boolean,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue