mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
add access. labels to node chips (#2688)
This commit is contained in:
parent
8e9def7566
commit
66ea72e5b3
2 changed files with 29 additions and 29 deletions
|
|
@ -42,6 +42,8 @@ import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
|
import androidx.compose.ui.semantics.semantics
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
|
|
@ -70,7 +72,8 @@ fun ContactItem(
|
||||||
.combinedClickable(onClick = onClick, onLongClick = onLongClick)
|
.combinedClickable(onClick = onClick, onLongClick = onLongClick)
|
||||||
.background(color = if (selected) Color.Gray else MaterialTheme.colorScheme.background)
|
.background(color = if (selected) Color.Gray else MaterialTheme.colorScheme.background)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(horizontal = 8.dp, vertical = 6.dp),
|
.padding(horizontal = 8.dp, vertical = 6.dp)
|
||||||
|
.semantics { contentDescription = shortName },
|
||||||
shape = RoundedCornerShape(12.dp),
|
shape = RoundedCornerShape(12.dp),
|
||||||
) {
|
) {
|
||||||
val colors =
|
val colors =
|
||||||
|
|
@ -86,7 +89,7 @@ fun ContactItem(
|
||||||
Row(modifier = Modifier.fillMaxWidth().padding(8.dp), verticalAlignment = Alignment.CenterVertically) {
|
Row(modifier = Modifier.fillMaxWidth().padding(8.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||||
AssistChip(
|
AssistChip(
|
||||||
onClick = onNodeChipClick,
|
onClick = onNodeChipClick,
|
||||||
modifier = Modifier.padding(end = 8.dp).width(72.dp),
|
modifier = Modifier.padding(end = 8.dp).width(72.dp).semantics { contentDescription = shortName },
|
||||||
label = {
|
label = {
|
||||||
Text(
|
Text(
|
||||||
text = shortName,
|
text = shortName,
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,8 @@ import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
|
import androidx.compose.ui.semantics.semantics
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextDecoration
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
|
@ -58,18 +60,19 @@ fun NodeChip(
|
||||||
val inputChipInteractionSource = remember { MutableInteractionSource() }
|
val inputChipInteractionSource = remember { MutableInteractionSource() }
|
||||||
Box {
|
Box {
|
||||||
ElevatedAssistChip(
|
ElevatedAssistChip(
|
||||||
modifier = modifier
|
modifier =
|
||||||
.width(IntrinsicSize.Min)
|
modifier.width(IntrinsicSize.Min).defaultMinSize(minWidth = 72.dp).semantics {
|
||||||
.defaultMinSize(minWidth = 72.dp),
|
contentDescription = node.user.shortName.ifEmpty { "Node" }
|
||||||
|
},
|
||||||
elevation = AssistChipDefaults.elevatedAssistChipElevation(),
|
elevation = AssistChipDefaults.elevatedAssistChipElevation(),
|
||||||
colors = AssistChipDefaults.elevatedAssistChipColors(
|
colors =
|
||||||
|
AssistChipDefaults.elevatedAssistChipColors(
|
||||||
containerColor = Color(nodeColor),
|
containerColor = Color(nodeColor),
|
||||||
labelColor = Color(textColor),
|
labelColor = Color(textColor),
|
||||||
),
|
),
|
||||||
label = {
|
label = {
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier
|
modifier = Modifier.fillMaxWidth(),
|
||||||
.fillMaxWidth(),
|
|
||||||
text = node.user.shortName.ifEmpty { "???" },
|
text = node.user.shortName.ifEmpty { "???" },
|
||||||
fontSize = MaterialTheme.typography.labelLarge.fontSize,
|
fontSize = MaterialTheme.typography.labelLarge.fontSize,
|
||||||
textDecoration = TextDecoration.LineThrough.takeIf { isIgnored },
|
textDecoration = TextDecoration.LineThrough.takeIf { isIgnored },
|
||||||
|
|
@ -81,14 +84,15 @@ fun NodeChip(
|
||||||
interactionSource = inputChipInteractionSource,
|
interactionSource = inputChipInteractionSource,
|
||||||
)
|
)
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier =
|
||||||
.matchParentSize()
|
Modifier.matchParentSize()
|
||||||
.combinedClickable(
|
.combinedClickable(
|
||||||
onClick = { onAction(NodeMenuAction.MoreDetails(node)) },
|
onClick = { onAction(NodeMenuAction.MoreDetails(node)) },
|
||||||
onLongClick = { menuExpanded = true },
|
onLongClick = { menuExpanded = true },
|
||||||
interactionSource = inputChipInteractionSource,
|
interactionSource = inputChipInteractionSource,
|
||||||
indication = null,
|
indication = null,
|
||||||
)
|
)
|
||||||
|
.semantics { contentDescription = node.user.shortName.ifEmpty { "Node" } },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
NodeMenu(
|
NodeMenu(
|
||||||
|
|
@ -99,7 +103,7 @@ fun NodeChip(
|
||||||
onAction = {
|
onAction = {
|
||||||
menuExpanded = false
|
menuExpanded = false
|
||||||
onAction(it)
|
onAction(it)
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,22 +111,15 @@ fun NodeChip(
|
||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
fun NodeChipPreview() {
|
fun NodeChipPreview() {
|
||||||
val user = MeshProtos.User.newBuilder()
|
val user = MeshProtos.User.newBuilder().setShortName("\uD83E\uDEE0").setLongName("John Doe").build()
|
||||||
.setShortName("\uD83E\uDEE0")
|
val node =
|
||||||
.setLongName("John Doe")
|
Node(
|
||||||
.build()
|
num = 13444,
|
||||||
val node = Node(
|
user = user,
|
||||||
num = 13444,
|
isIgnored = false,
|
||||||
user = user,
|
paxcounter = PaxcountProtos.Paxcount.newBuilder().setBle(10).setWifi(5).build(),
|
||||||
isIgnored = false,
|
environmentMetrics =
|
||||||
paxcounter = PaxcountProtos.Paxcount.newBuilder().setBle(10).setWifi(5).build(),
|
TelemetryProtos.EnvironmentMetrics.newBuilder().setTemperature(25f).setRelativeHumidity(60f).build(),
|
||||||
environmentMetrics = TelemetryProtos.EnvironmentMetrics.newBuilder().setTemperature(25f)
|
)
|
||||||
.setRelativeHumidity(60f).build()
|
NodeChip(node = node, isThisNode = false, isConnected = true, onAction = {})
|
||||||
)
|
|
||||||
NodeChip(
|
|
||||||
node = node,
|
|
||||||
isThisNode = false,
|
|
||||||
isConnected = true,
|
|
||||||
onAction = {}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue