mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
chore: standardize resources and update documentation for Navigation 3 (#4961)
This commit is contained in:
parent
1faa802fe6
commit
464a12b9f7
42 changed files with 216 additions and 149 deletions
|
|
@ -43,7 +43,6 @@ import androidx.compose.runtime.setValue
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
|
|
@ -54,6 +53,11 @@ import org.meshtastic.core.resources.Res
|
|||
import org.meshtastic.core.resources.air_quality_icon
|
||||
import org.meshtastic.core.resources.close
|
||||
import org.meshtastic.core.resources.indoor_air_quality_iaq
|
||||
import org.meshtastic.core.resources.preview_dot
|
||||
import org.meshtastic.core.resources.preview_gauge
|
||||
import org.meshtastic.core.resources.preview_gradient
|
||||
import org.meshtastic.core.resources.preview_pill
|
||||
import org.meshtastic.core.resources.preview_text
|
||||
import org.meshtastic.core.ui.icon.MeshtasticIcons
|
||||
import org.meshtastic.core.ui.icon.ThumbUp
|
||||
import org.meshtastic.core.ui.icon.Warning
|
||||
|
|
@ -112,8 +116,6 @@ fun IndoorAirQuality(iaq: Int?, displayMode: IaqDisplayMode = IaqDisplayMode.Pil
|
|||
}
|
||||
var isLegendOpen by remember { mutableStateOf(false) }
|
||||
val iaqEnum = getIaq(iaq)
|
||||
val gradient = Brush.linearGradient(colors = Iaq.entries.map { it.color })
|
||||
|
||||
if (iaqEnum != null) {
|
||||
Column {
|
||||
when (displayMode) {
|
||||
|
|
@ -166,7 +168,7 @@ fun IndoorAirQuality(iaq: Int?, displayMode: IaqDisplayMode = IaqDisplayMode.Pil
|
|||
strokeWidth = 8.dp,
|
||||
color = iaqEnum.color,
|
||||
)
|
||||
Text(text = "${iaqEnum.description}")
|
||||
Text(text = iaqEnum.description)
|
||||
}
|
||||
|
||||
IaqDisplayMode.Gradient -> {
|
||||
|
|
@ -230,7 +232,7 @@ private fun IndoorAirQualityPreview() {
|
|||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Text("Pill", style = MaterialTheme.typography.titleLarge)
|
||||
Text(stringResource(Res.string.preview_pill), style = MaterialTheme.typography.titleLarge)
|
||||
Row {
|
||||
IndoorAirQuality(iaq = 6)
|
||||
IndoorAirQuality(iaq = 51)
|
||||
|
|
@ -244,7 +246,7 @@ private fun IndoorAirQualityPreview() {
|
|||
IndoorAirQuality(iaq = 351)
|
||||
}
|
||||
|
||||
Text("Dot", style = MaterialTheme.typography.titleLarge)
|
||||
Text(stringResource(Res.string.preview_dot), style = MaterialTheme.typography.titleLarge)
|
||||
Row {
|
||||
IndoorAirQuality(iaq = 6, displayMode = IaqDisplayMode.Dot)
|
||||
IndoorAirQuality(iaq = 51, displayMode = IaqDisplayMode.Dot)
|
||||
|
|
@ -254,7 +256,7 @@ private fun IndoorAirQualityPreview() {
|
|||
IndoorAirQuality(iaq = 351, displayMode = IaqDisplayMode.Dot)
|
||||
}
|
||||
|
||||
Text("Text", style = MaterialTheme.typography.titleLarge)
|
||||
Text(stringResource(Res.string.preview_text), style = MaterialTheme.typography.titleLarge)
|
||||
Row {
|
||||
IndoorAirQuality(iaq = 6, displayMode = IaqDisplayMode.Text)
|
||||
IndoorAirQuality(iaq = 51, displayMode = IaqDisplayMode.Text)
|
||||
|
|
@ -266,7 +268,7 @@ private fun IndoorAirQualityPreview() {
|
|||
IndoorAirQuality(iaq = 500, displayMode = IaqDisplayMode.Text)
|
||||
}
|
||||
|
||||
Text("Gauge", style = MaterialTheme.typography.titleLarge)
|
||||
Text(stringResource(Res.string.preview_gauge), style = MaterialTheme.typography.titleLarge)
|
||||
Row {
|
||||
IndoorAirQuality(iaq = 6, displayMode = IaqDisplayMode.Gauge)
|
||||
IndoorAirQuality(iaq = 51, displayMode = IaqDisplayMode.Gauge)
|
||||
|
|
@ -284,7 +286,7 @@ private fun IndoorAirQualityPreview() {
|
|||
IndoorAirQuality(iaq = 500, displayMode = IaqDisplayMode.Gauge)
|
||||
}
|
||||
|
||||
Text("Gradient", style = MaterialTheme.typography.titleLarge)
|
||||
Text(stringResource(Res.string.preview_gradient), style = MaterialTheme.typography.titleLarge)
|
||||
IndoorAirQuality(iaq = 6, displayMode = IaqDisplayMode.Gradient)
|
||||
IndoorAirQuality(iaq = 51, displayMode = IaqDisplayMode.Gradient)
|
||||
IndoorAirQuality(iaq = 101, displayMode = IaqDisplayMode.Gradient)
|
||||
|
|
|
|||
|
|
@ -58,6 +58,11 @@ import androidx.compose.ui.zIndex
|
|||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.launch
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import org.meshtastic.core.resources.Res
|
||||
import org.meshtastic.core.resources.preview_footer
|
||||
import org.meshtastic.core.resources.preview_header
|
||||
import org.meshtastic.core.resources.preview_item
|
||||
|
||||
// Derived in part from:
|
||||
// https://github.com/androidx/androidx/blob/c92ad2941368202b2d78b8d14c71bf81e9525944/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/LazyColumnDragAndDropDemo.kt
|
||||
|
|
@ -80,15 +85,15 @@ fun LazyColumnDragAndDropDemo() {
|
|||
contentPadding = PaddingValues(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp),
|
||||
) {
|
||||
item { Text("Header", Modifier.fillMaxWidth().padding(20.dp)) }
|
||||
item { Text(stringResource(Res.string.preview_header), Modifier.fillMaxWidth().padding(20.dp)) }
|
||||
|
||||
itemsIndexed(list, key = { _, item -> item }) { index, item ->
|
||||
DraggableItem(dragDropState, index + 1) { isDragging ->
|
||||
Card { Text("Item $item", Modifier.fillMaxWidth().padding(20.dp)) }
|
||||
DraggableItem(dragDropState, index + 1) {
|
||||
Card { Text(stringResource(Res.string.preview_item, item), Modifier.fillMaxWidth().padding(20.dp)) }
|
||||
}
|
||||
}
|
||||
|
||||
item { Text("Footer", Modifier.fillMaxWidth().padding(20.dp)) }
|
||||
item { Text(stringResource(Res.string.preview_footer), Modifier.fillMaxWidth().padding(20.dp)) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import org.meshtastic.core.ui.viewmodel.UIViewModel
|
|||
* - System-wide alerts and snackbar hosts
|
||||
* - Deep link navigation interception logic
|
||||
*
|
||||
* Platform hosts (Main.kt) should invoke this at the root of their theme before rendering the main NavDisplay.
|
||||
* Platform hosts should invoke this near the root before rendering `MeshtasticNavDisplay`.
|
||||
*/
|
||||
@Composable
|
||||
fun MeshtasticCommonAppSetup(
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ fun RegularPreference(
|
|||
Box {
|
||||
Icon(
|
||||
imageVector = trailingIcon,
|
||||
contentDescription = "trailingIcon",
|
||||
contentDescription = null,
|
||||
modifier = Modifier.padding(start = 8.dp).wrapContentWidth(Alignment.End),
|
||||
tint = color,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import org.jetbrains.compose.resources.stringResource
|
|||
import org.meshtastic.core.resources.Res
|
||||
import org.meshtastic.core.resources.baro_pressure
|
||||
import org.meshtastic.core.resources.env_metrics_log
|
||||
import org.meshtastic.core.resources.hardware_model
|
||||
import org.meshtastic.core.resources.humidity
|
||||
import org.meshtastic.core.resources.iaq
|
||||
import org.meshtastic.core.resources.node_id
|
||||
|
|
@ -225,7 +226,7 @@ fun HardwareInfo(
|
|||
IconInfo(
|
||||
modifier = modifier,
|
||||
icon = MeshtasticIcons.HardwareModel,
|
||||
contentDescription = "Hardware Model",
|
||||
contentDescription = stringResource(Res.string.hardware_model),
|
||||
text = hwModel,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
contentColor = contentColor,
|
||||
|
|
|
|||
|
|
@ -74,7 +74,11 @@ import androidx.compose.ui.unit.dp
|
|||
import androidx.compose.ui.unit.sp
|
||||
import androidx.compose.ui.window.Popup
|
||||
import kotlinx.coroutines.launch
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import org.koin.compose.viewmodel.koinViewModel
|
||||
import org.meshtastic.core.resources.Res
|
||||
import org.meshtastic.core.resources.clear
|
||||
import org.meshtastic.core.resources.search_emoji
|
||||
import org.meshtastic.core.ui.component.BottomSheetDialog
|
||||
|
||||
// ── Constants ──────────────────────────────────────────────────────────────────
|
||||
|
|
@ -207,7 +211,7 @@ private fun SearchBar(query: String, onQueryChange: (String) -> Unit) {
|
|||
modifier = Modifier.fillMaxWidth().height(52.dp),
|
||||
placeholder = {
|
||||
Text(
|
||||
text = "Search emoji\u2026",
|
||||
text = stringResource(Res.string.search_emoji),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
|
|
@ -221,7 +225,7 @@ private fun SearchBar(query: String, onQueryChange: (String) -> Unit) {
|
|||
IconButton(onClick = { onQueryChange("") }) {
|
||||
Icon(
|
||||
imageVector = Icons.Rounded.Close,
|
||||
contentDescription = "Clear",
|
||||
contentDescription = stringResource(Res.string.clear),
|
||||
modifier = Modifier.size(20.dp),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ import androidx.compose.material3.Text
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import org.meshtastic.core.resources.Res
|
||||
import org.meshtastic.core.resources.preview_custom_composable_line_one
|
||||
import org.meshtastic.core.resources.preview_custom_composable_line_two
|
||||
import org.meshtastic.core.ui.component.MeshtasticDialog
|
||||
import org.meshtastic.core.ui.theme.AppTheme
|
||||
|
||||
|
|
@ -120,8 +124,8 @@ fun PreviewComposableAlert() {
|
|||
title = "Custom Content",
|
||||
composableMessage = {
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
Text("This is a custom composable")
|
||||
Text("With multiple lines and styles")
|
||||
Text(stringResource(Res.string.preview_custom_composable_line_one))
|
||||
Text(stringResource(Res.string.preview_custom_composable_line_two))
|
||||
}
|
||||
},
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue