UI: fix the typo `totalGb` in `StorageMetrics`
This commit is contained in:
parent
69f2bd62f9
commit
41615be5ae
|
|
@ -99,7 +99,7 @@ class ModelRepositoryImpl @Inject constructor(
|
||||||
emit(
|
emit(
|
||||||
StorageMetrics(
|
StorageMetrics(
|
||||||
usedGB = modelsSizeBytes / BYTES_IN_GB,
|
usedGB = modelsSizeBytes / BYTES_IN_GB,
|
||||||
totalGB = availableSpaceBytes / BYTES_IN_GB
|
availableGB = availableSpaceBytes / BYTES_IN_GB
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
delay(STORAGE_METRICS_UPDATE_INTERVAL)
|
delay(STORAGE_METRICS_UPDATE_INTERVAL)
|
||||||
|
|
@ -343,5 +343,5 @@ class ModelRepositoryImpl @Inject constructor(
|
||||||
|
|
||||||
data class StorageMetrics(
|
data class StorageMetrics(
|
||||||
val usedGB: Float,
|
val usedGB: Float,
|
||||||
val totalGB: Float
|
val availableGB: Float
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import androidx.compose.material.icons.filled.WarningAmber
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.Label
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
|
|
@ -174,7 +175,9 @@ fun StorageTopBar(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
StorageIndicator(storageMetrics = storageMetrics)
|
storageMetrics?.let {
|
||||||
|
StorageIndicator(storageMetrics = it)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
colors = TopAppBarDefaults.topAppBarColors(
|
colors = TopAppBarDefaults.topAppBarColors(
|
||||||
containerColor = MaterialTheme.colorScheme.surface,
|
containerColor = MaterialTheme.colorScheme.surface,
|
||||||
|
|
@ -238,23 +241,17 @@ fun TemperatureIndicator(temperatureMetrics: TemperatureMetrics, useFahrenheit:
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun StorageIndicator(storageMetrics: StorageMetrics?) {
|
fun StorageIndicator(storageMetrics: StorageMetrics) {
|
||||||
val usedGb = storageMetrics?.usedGB
|
val usedGb = storageMetrics.usedGB
|
||||||
val totalGb = storageMetrics?.totalGB
|
val availableGb = storageMetrics.availableGB
|
||||||
val usedRatio = if (usedGb != null && totalGb != null && totalGb > 0.0f) {
|
|
||||||
usedGb / totalGb
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
Row(modifier = Modifier.padding(end = 8.dp), verticalAlignment = Alignment.CenterVertically) {
|
Row(modifier = Modifier.padding(end = 8.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.SdStorage,
|
imageVector = Icons.Default.SdStorage,
|
||||||
contentDescription = "Storage",
|
contentDescription = "Storage",
|
||||||
tint = when {
|
tint = when {
|
||||||
usedRatio == null -> MaterialTheme.colorScheme.onSurface
|
availableGb < 5.0f -> MaterialTheme.colorScheme.error
|
||||||
usedRatio > 0.9f -> MaterialTheme.colorScheme.error
|
availableGb < 10.0f -> MaterialTheme.colorScheme.tertiary
|
||||||
usedRatio > 0.7f -> MaterialTheme.colorScheme.tertiary
|
|
||||||
else -> MaterialTheme.colorScheme.onSurface
|
else -> MaterialTheme.colorScheme.onSurface
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -262,9 +259,7 @@ fun StorageIndicator(storageMetrics: StorageMetrics?) {
|
||||||
Spacer(modifier = Modifier.width(2.dp))
|
Spacer(modifier = Modifier.width(2.dp))
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = storageMetrics?.let {
|
text = String.format(Locale.getDefault(), "%.1f / %.1f GB", usedGb, availableGb),
|
||||||
String.format(Locale.getDefault(), "%.1f / %.1f GB", it.usedGB, it.totalGB)
|
|
||||||
} ?: String.format(Locale.getDefault(), " - / - GB"),
|
|
||||||
style = MaterialTheme.typography.bodySmall
|
style = MaterialTheme.typography.bodySmall
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue