mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
define our four screens
This commit is contained in:
parent
227450528d
commit
4300447163
7 changed files with 109 additions and 26 deletions
|
|
@ -42,23 +42,23 @@ title.
|
|||
|
||||
Fragments:
|
||||
|
||||
SettingsFragment shows
|
||||
SettingsFragment shows "Settings"
|
||||
username
|
||||
shortname
|
||||
bluetooth pairing list
|
||||
(eventually misc device settings that are not channel related)
|
||||
|
||||
Channel fragment
|
||||
Channel fragment "Channel"
|
||||
qr code, copy link button
|
||||
ch number
|
||||
misc other settings
|
||||
(eventually a way of choosing between past channels)
|
||||
|
||||
ChatFragment
|
||||
ChatFragment "Messages"
|
||||
a text box to enter new texts
|
||||
a scrolling list of rows. each row is a text and a sender info layout
|
||||
|
||||
NodeListFragment
|
||||
NodeListFragment "Users"
|
||||
a node info row for every node
|
||||
|
||||
ViewModels:
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ fun MeshApp() {
|
|||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
// @Preview
|
||||
@Composable
|
||||
fun previewView() {
|
||||
// It seems modaldrawerlayout not yet supported in preview
|
||||
|
|
@ -161,6 +161,15 @@ fun previewView() {
|
|||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun previewDrawer() {
|
||||
AppDrawer(
|
||||
currentScreen = AppStatus.currentScreen,
|
||||
closeDrawer = { }
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AppContent(openDrawer: () -> Unit) {
|
||||
Crossfade(AppStatus.currentScreen) { screen ->
|
||||
|
|
@ -178,11 +187,9 @@ private fun AppContent(openDrawer: () -> Unit) {
|
|||
|
||||
VerticalScroller(modifier = LayoutFlexible(1f)) {
|
||||
when (screen) {
|
||||
is Screen.Home -> HomeContent()
|
||||
is Screen.SelectRadio -> BTScanScreen()
|
||||
// Question: how to get hooks invoked when this screen gets shown/removed?
|
||||
// i.e. I need to start/stop a bluetooth scan operation. depending on the
|
||||
// appearance/disappearance of this screen.
|
||||
Screen.messages -> HomeContent()
|
||||
Screen.settings -> BTScanScreen()
|
||||
else -> TODO()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -192,7 +199,7 @@ private fun AppContent(openDrawer: () -> Unit) {
|
|||
|
||||
@Composable
|
||||
private fun AppDrawer(
|
||||
currentScreen: Screen,
|
||||
currentScreen: ScreenInfo,
|
||||
closeDrawer: () -> Unit
|
||||
) {
|
||||
Column(modifier = LayoutSize.Fill) {
|
||||
|
|
@ -203,15 +210,15 @@ private fun AppDrawer(
|
|||
tint = (MaterialTheme.colors()).primary
|
||||
)
|
||||
Spacer(LayoutWidth(8.dp))
|
||||
VectorImage(id = R.drawable.ic_launcher_new_foreground)
|
||||
// VectorImage(id = R.drawable.ic_launcher_new_foreground)
|
||||
}
|
||||
Divider(color = Color(0x14333333))
|
||||
|
||||
@Composable
|
||||
fun ScreenButton(icon: Int, label: String, screen: Screen) {
|
||||
fun ScreenButton(screen: ScreenInfo) {
|
||||
DrawerButton(
|
||||
icon = icon,
|
||||
label = label,
|
||||
icon = screen.icon,
|
||||
label = screen.label,
|
||||
isSelected = currentScreen == screen
|
||||
) {
|
||||
navigateTo(screen)
|
||||
|
|
@ -219,8 +226,10 @@ private fun AppDrawer(
|
|||
}
|
||||
}
|
||||
|
||||
ScreenButton(R.drawable.ic_launcher_new_foreground, "Home", Screen.Home)
|
||||
ScreenButton(R.drawable.ic_launcher_new_foreground, "Setup", Screen.SelectRadio)
|
||||
ScreenButton(Screen.messages)
|
||||
ScreenButton(Screen.users)
|
||||
ScreenButton(Screen.channel)
|
||||
ScreenButton(Screen.settings)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,22 +3,25 @@ package com.geeksville.mesh.ui
|
|||
import android.util.Base64
|
||||
import androidx.compose.Model
|
||||
import androidx.compose.mutableStateOf
|
||||
import com.geeksville.mesh.MeshProtos
|
||||
import com.geeksville.mesh.MeshUser
|
||||
import com.geeksville.mesh.NodeInfo
|
||||
import com.geeksville.mesh.Position
|
||||
import com.geeksville.mesh.*
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInClient
|
||||
import java.util.*
|
||||
|
||||
|
||||
data class ScreenInfo(val icon: Int, val label: String)
|
||||
|
||||
// defines the screens we have in the app
|
||||
sealed class Screen {
|
||||
object Home : Screen()
|
||||
object SelectRadio : Screen()
|
||||
object Screen {
|
||||
val settings = ScreenInfo(R.drawable.ic_twotone_settings_applications_24, "Settings")
|
||||
val channel = ScreenInfo(R.drawable.ic_twotone_contactless_24, "Channel")
|
||||
val users = ScreenInfo(R.drawable.ic_twotone_people_24, "Users")
|
||||
val messages = ScreenInfo(R.drawable.ic_twotone_message_24, "Messages")
|
||||
}
|
||||
|
||||
|
||||
@Model
|
||||
object AppStatus {
|
||||
var currentScreen: Screen = Screen.Home
|
||||
var currentScreen: ScreenInfo = Screen.messages
|
||||
}
|
||||
|
||||
data class TextMessage(val date: Date, val from: String, val text: String)
|
||||
|
|
@ -96,6 +99,6 @@ object UIState {
|
|||
/**
|
||||
* Temporary solution pending navigation support.
|
||||
*/
|
||||
fun navigateTo(destination: Screen) {
|
||||
fun navigateTo(destination: ScreenInfo) {
|
||||
AppStatus.currentScreen = destination
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue