Meshtastic-Android/app/src/main/java/com/geeksville/mesh/ui/NodeInfoCard.kt

70 lines
1.8 KiB
Kotlin
Raw Normal View History

2020-02-10 10:32:12 -08:00
package com.geeksville.mesh.ui
/*
2020-02-10 10:32:12 -08:00
import androidx.compose.Composable
import androidx.ui.foundation.Text
import androidx.ui.layout.*
2020-02-10 10:32:12 -08:00
import androidx.ui.material.MaterialTheme
import androidx.ui.material.ProvideEmphasis
import androidx.ui.tooling.preview.Preview
import androidx.ui.unit.dp
import com.geeksville.mesh.NodeInfo
2020-02-10 10:32:12 -08:00
import com.geeksville.mesh.R
2020-02-17 13:34:52 -08:00
import com.geeksville.mesh.model.NodeDB
import androidx.ui.core.Modifier as Modifier1
2020-02-10 10:32:12 -08:00
@Composable
fun CompassHeading(modifier: Modifier1 = Modifier1.None, node: NodeInfo) {
Column {
2020-02-10 14:06:50 -08:00
if (node.position != null) {
Container(modifier = modifier + LayoutSize(40.dp, 40.dp)) {
VectorImage(id = R.drawable.navigation)
}
} else Container(modifier = modifier + LayoutSize(40.dp, 40.dp)) {
VectorImage(id = R.drawable.help)
}
Text("2.3 km") // always reserve space for the distance even if we aren't showing it
2020-02-10 10:32:12 -08:00
}
}
@Composable
fun NodeHeading(node: NodeInfo) {
ProvideEmphasis(emphasis = MaterialTheme.emphasisLevels.high) {
2020-02-17 09:06:22 -08:00
Text(
node.user?.longName ?: "unknown",
style = MaterialTheme.typography.subtitle1
2020-02-17 09:06:22 -08:00
//modifier = LayoutWidth.Fill
)
2020-02-10 10:32:12 -08:00
}
}
/**
* An info card for a node:
*
2020-02-17 12:55:48 -08:00
* on left, the icon for the user (or shortname if that is all we have) (this includes user's distance and heading arrow)
2020-02-10 10:32:12 -08:00
*
* Middle is users fullname
*
*/
@Composable
fun NodeInfoCard(node: NodeInfo) {
// Text("Node: ${it.user?.longName}")
Row(modifier = LayoutPadding(16.dp)) {
UILog.debug("showing NodeInfo $node")
2020-02-17 12:55:48 -08:00
UserIcon(
2020-03-04 11:44:17 -08:00
modifier = LayoutPadding(start = 0.dp, top = 0.dp, end = 0.dp, bottom = 0.dp),
2020-02-17 12:55:48 -08:00
user = node
2020-02-10 10:32:12 -08:00
)
NodeHeading(node)
// FIXME - show compass instead
2020-02-17 12:55:48 -08:00
// CompassHeading(node = node)
2020-02-10 10:32:12 -08:00
}
}
*/