start cleaning up models

This commit is contained in:
geeksville 2020-02-17 13:34:52 -08:00
parent 52deba7d4b
commit f18ac28dc0
9 changed files with 307 additions and 268 deletions

View file

@ -1,9 +1,7 @@
package com.geeksville.mesh.ui
import android.util.Base64
import androidx.compose.Model
import androidx.compose.mutableStateOf
import com.geeksville.mesh.*
import com.geeksville.mesh.R
data class ScreenInfo(val icon: Int, val label: String)
@ -22,72 +20,6 @@ object AppStatus {
var currentScreen: ScreenInfo = Screen.messages
}
object NodeDB {
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 testNodeNoPosition = NodeInfo(
8,
MeshUser(
"+6508765308".format(8),
"Kevin MesterNoLoc",
"KLO"
),
null,
12345
)
val testNodes = testPositions.mapIndexed { index, it ->
NodeInfo(
9 + index,
MeshUser(
"+65087653%02d".format(9 + index),
"Kevin Mester$index",
"KM$index"
),
it,
12345
)
}
/// A map from nodeid to to nodeinfo
val nodes = mutableStateOf(testNodes.map { it.user!!.id to it }.toMap())
}
/// FIXME - figure out how to merge this staate with the AppStatus Model
object UIState {
/// Kinda ugly - created in the activity but used from Compose - figure out if there is a cleaner way GIXME
// lateinit var googleSignInClient: GoogleSignInClient
/// Are we connected to our radio device
val isConnected = mutableStateOf(false)
/// various radio settings (including the channel)
val radioConfig = mutableStateOf(MeshProtos.RadioConfig.getDefaultInstance())
/// our name in hte radio
/// Note, we generate owner initials automatically for now
val ownerName = mutableStateOf("fixme readfromprefs")
/// Return an URL that represents the current channel values
val channelUrl
get(): String {
val channelBytes = radioConfig.value.channelSettings.toByteArray()
val enc = Base64.encodeToString(channelBytes, Base64.URL_SAFE + Base64.NO_WRAP)
return "https://www.meshtastic.org/c/$enc"
}
}
/**
* Temporary solution pending navigation support.