we now show real distances in the GUI

This commit is contained in:
geeksville 2020-02-17 15:03:34 -08:00
parent 3b89abe1ef
commit 6f39ba1331
4 changed files with 37 additions and 4 deletions

View file

@ -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])
}
}