mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Refactor node count display in MainAppBar (#2210)
This commit is contained in:
parent
3efd463a5b
commit
65ab9eb40d
2 changed files with 15 additions and 5 deletions
|
|
@ -36,6 +36,7 @@ import androidx.compose.material.icons.twotone.People
|
|||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
|
|
@ -357,7 +358,7 @@ enum class MainMenuAction(@StringRes val stringRes: Int) {
|
|||
ABOUT(R.string.about),
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class)
|
||||
@Suppress("LongMethod")
|
||||
@Composable
|
||||
private fun MainAppBar(
|
||||
|
|
@ -381,10 +382,7 @@ private fun MainAppBar(
|
|||
TopAppBar(
|
||||
title = {
|
||||
val title = when {
|
||||
currentDestination == null -> stringResource(id = R.string.app_name)
|
||||
|
||||
currentDestination.hasRoute<NodesRoutes.Nodes>() -> stringResource(id = R.string.app_name) +
|
||||
" ($onlineNodeCount/$totalNodeCount)"
|
||||
currentDestination == null || isTopLevelRoute -> stringResource(id = R.string.app_name)
|
||||
|
||||
currentDestination.hasRoute<Route.DebugPanel>() -> stringResource(id = R.string.debug_panel)
|
||||
|
||||
|
|
@ -403,6 +401,17 @@ private fun MainAppBar(
|
|||
style = MaterialTheme.typography.titleLarge,
|
||||
)
|
||||
},
|
||||
subtitle = {
|
||||
if (currentDestination?.hasRoute<NodesRoutes.Nodes>() == true) {
|
||||
Text(
|
||||
text = stringResource(
|
||||
R.string.node_count_template,
|
||||
onlineNodeCount,
|
||||
totalNodeCount
|
||||
),
|
||||
)
|
||||
}
|
||||
},
|
||||
modifier = modifier,
|
||||
navigationIcon = if (canNavigateBack && !isTopLevelRoute) {
|
||||
{
|
||||
|
|
|
|||
|
|
@ -694,4 +694,5 @@
|
|||
<string name="export_keys_confirmation">Exports public and private keys to a file. Please store somewhere securely.</string>
|
||||
<string name="modules_unlocked">Modules unlocked</string>
|
||||
<string name="remote">Remote</string>
|
||||
<string name="node_count_template">(%1$d online / %2$d total)</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue