mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
we now show real distances in the GUI
This commit is contained in:
parent
3b89abe1ef
commit
6f39ba1331
4 changed files with 37 additions and 4 deletions
|
|
@ -96,7 +96,10 @@ fun addDistance(
|
|||
return doubleArrayOf(lat + dLat, longitude + dLong)
|
||||
}
|
||||
|
||||
fun LatLongToMeter(
|
||||
/**
|
||||
* @return distance in meters along the surface of the earth (ish)
|
||||
*/
|
||||
fun latLongToMeter(
|
||||
lat_a: Double,
|
||||
lng_a: Double,
|
||||
lat_b: Double,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ val TimestampEmphasis = object : Emphasis {
|
|||
@Composable
|
||||
fun MessageCard(msg: TextMessage, modifier: Modifier = Modifier.None) {
|
||||
Row(modifier = modifier) {
|
||||
UserIcon(null)
|
||||
UserIcon(NodeDB.nodes.value[msg.from])
|
||||
|
||||
Column(modifier = LayoutPadding(left = 12.dp)) {
|
||||
Row {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import androidx.ui.material.MaterialTheme
|
|||
import androidx.ui.tooling.preview.Preview
|
||||
import com.geeksville.mesh.NodeInfo
|
||||
import com.geeksville.mesh.R
|
||||
import com.geeksville.mesh.model.NodeDB
|
||||
|
||||
/**
|
||||
* Show the user icon for a particular user with distance from the operator and a small pointer
|
||||
|
|
@ -22,7 +23,10 @@ fun UserIcon(user: NodeInfo? = null, modifier: Modifier = Modifier.None) {
|
|||
tint = palette.onSecondary,
|
||||
modifier = LayoutGravity.Center
|
||||
)
|
||||
Text("1.2 km", modifier = LayoutGravity.Center)
|
||||
val ourNodeInfo = NodeDB.ourNodeInfo
|
||||
val distance = ourNodeInfo.distanceStr(user)
|
||||
if (distance != null)
|
||||
Text(distance, modifier = LayoutGravity.Center)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -31,6 +35,6 @@ fun UserIcon(user: NodeInfo? = null, modifier: Modifier = Modifier.None) {
|
|||
fun previewUserIcon() {
|
||||
// another bug? It seems modaldrawerlayout not yet supported in preview
|
||||
MaterialTheme(colors = palette) {
|
||||
UserIcon()
|
||||
UserIcon(NodeDB.testNodes[1])
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue