cleanup the new Compose UI a bit

This commit is contained in:
geeksville 2020-02-10 10:32:12 -08:00
parent 6fed223a35
commit 4a99d0d3ec
6 changed files with 384 additions and 291 deletions

View file

@ -0,0 +1,61 @@
package com.geeksville.mesh.ui
import androidx.compose.Model
import androidx.compose.mutableStateOf
import com.geeksville.mesh.MeshUser
import com.geeksville.mesh.NodeInfo
import com.geeksville.mesh.Position
import java.util.*
// defines the screens we have in the app
sealed class Screen {
object Home : Screen()
// object Settings : Screen()
}
@Model
object AppStatus {
var currentScreen: Screen = Screen.Home
}
data class TextMessage(val date: Date, val from: String, val text: String)
/// FIXME - figure out how to merge this staate with the AppStatus Model
object UIState {
private val testPositions = arrayOf(
Position(32.776665, -96.796989, 35), // dallas
Position(32.960758, -96.733521, 35), // richardson
Position(32.912901, -96.781776, 35) // north dallas
)
val testNodes = testPositions.mapIndexed { index, it ->
NodeInfo(
9 + index,
MeshUser("+65087653%02d".format(9 + index), "Kevin Mester$index", "KM$index"),
it,
12345
)
}
val testTexts = listOf(
TextMessage(Date(), "+6508675310", "I found the cache"),
TextMessage(Date(), "+6508675311", "Help! I've fallen and I can't get up.")
)
/// A map from nodeid to to nodeinfo
val nodes = mutableStateOf(testNodes.map { it.user!!.id to it }.toMap())
val messages = mutableStateOf(testTexts)
/// Are we connected to our radio device
var isConnected = mutableStateOf(false)
}
/**
* Temporary solution pending navigation support.
*/
fun navigateTo(destination: Screen) {
AppStatus.currentScreen = destination
}