Refactor node count display in MainAppBar (#2210)

This commit is contained in:
James Rich 2025-06-22 04:31:07 +00:00 committed by GitHub
parent 3efd463a5b
commit 65ab9eb40d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 5 deletions

View file

@ -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) {
{

View file

@ -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>