refactor: consolidate metric formatting through MetricFormatter (#5169)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: jamesarich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-04-17 12:13:01 -05:00 committed by GitHub
parent 1cd05d5d78
commit 9c8085b0e3
5 changed files with 56 additions and 13 deletions

View file

@ -39,7 +39,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import org.meshtastic.core.common.util.formatString
import org.meshtastic.core.common.util.MetricFormatter
import org.meshtastic.feature.settings.radio.ResponseState
private const val LOADING_OVERLAY_ALPHA = 0.8f
@ -73,7 +73,7 @@ fun LoadingOverlay(state: ResponseState<*>, modifier: Modifier = Modifier) {
trackColor = MaterialTheme.colorScheme.surfaceVariant,
)
Text(
text = formatString("%.0f%%", progress * PERCENTAGE_FACTOR),
text = MetricFormatter.percent(progress * PERCENTAGE_FACTOR, decimalPlaces = 0),
style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.Bold,
)

View file

@ -35,7 +35,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.delay
import org.jetbrains.compose.resources.stringResource
import org.meshtastic.core.common.util.formatString
import org.meshtastic.core.common.util.MetricFormatter
import org.meshtastic.core.resources.Res
import org.meshtastic.core.resources.cancel
import org.meshtastic.core.resources.close
@ -111,7 +111,7 @@ private fun LoadingContent(state: ResponseState.Loading, onComplete: () -> Unit)
val progress by animateFloatAsState(targetValue = clampedProgress, label = "progress")
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Text(
text = formatString("%.0f%%", progress * 100f),
text = MetricFormatter.percent(progress * 100f, decimalPlaces = 0),
style = MaterialTheme.typography.displaySmall,
color = MaterialTheme.colorScheme.secondary,
)