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
|
||||
}
|
||||
|
|
|
|||
25
app/src/main/res/drawable/ic_twotone_contactless_24.xml
Normal file
25
app/src/main/res/drawable/ic_twotone_contactless_24.xml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,4c-4.42,0 -8,3.58 -8,8s3.58,8 8,8s8,-3.58 8,-8S16.42,4 12,4zM8.46,14.45L7.1,13.83c0.28,-0.61 0.41,-1.24 0.4,-1.86c-0.01,-0.63 -0.14,-1.24 -0.4,-1.8l1.36,-0.63c0.35,0.75 0.53,1.56 0.54,2.4C9.01,12.8 8.83,13.64 8.46,14.45zM11.53,16.01l-1.3,-0.74c0.52,-0.92 0.78,-1.98 0.78,-3.15c0,-1.19 -0.27,-2.33 -0.8,-3.4l1.34,-0.67c0.64,1.28 0.96,2.65 0.96,4.07C12.51,13.55 12.18,14.86 11.53,16.01zM14.67,17.33l-1.35,-0.66c0.78,-1.6 1.18,-3.18 1.18,-4.69c0,-1.51 -0.4,-3.07 -1.18,-4.64l1.34,-0.67C15.56,8.45 16,10.23 16,11.98C16,13.72 15.56,15.52 14.67,17.33z"
|
||||
android:strokeAlpha="0.3"
|
||||
android:fillAlpha="0.3"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,2C6.48,2 2,6.48 2,12c0,5.52 4.48,10 10,10s10,-4.48 10,-10C22,6.48 17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8s8,3.58 8,8S16.42,20 12,20z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M7.1,10.18c0.26,0.56 0.39,1.16 0.4,1.8c0.01,0.63 -0.13,1.25 -0.4,1.86l1.37,0.62c0.37,-0.81 0.55,-1.65 0.54,-2.5c-0.01,-0.84 -0.19,-1.65 -0.54,-2.4L7.1,10.18z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M13.33,7.33c0.78,1.57 1.18,3.14 1.18,4.64c0,1.51 -0.4,3.09 -1.18,4.69l1.35,0.66c0.88,-1.81 1.33,-3.61 1.33,-5.35c0,-1.74 -0.45,-3.53 -1.33,-5.31L13.33,7.33z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M10.2,8.72c0.53,1.07 0.8,2.21 0.8,3.4c0,1.17 -0.26,2.23 -0.78,3.15l1.3,0.74c0.65,-1.15 0.98,-2.45 0.98,-3.89c0,-1.42 -0.32,-2.79 -0.96,-4.07L10.2,8.72z"/>
|
||||
</vector>
|
||||
|
||||
14
app/src/main/res/drawable/ic_twotone_message_24.xml
Normal file
14
app/src/main/res/drawable/ic_twotone_message_24.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M20,4L4,4v13.17L5.17,16L20,16L20,4zM18,14L6,14v-2h12v2zM18,11L6,11L6,9h12v2zM18,8L6,8L6,6h12v2z"
|
||||
android:fillAlpha=".3"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M20,18c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14zM4,17.17L4,4h16v12L5.17,16L4,17.17zM6,12h12v2L6,14zM6,9h12v2L6,11zM6,6h12v2L6,8z"/>
|
||||
</vector>
|
||||
18
app/src/main/res/drawable/ic_twotone_people_24.xml
Normal file
18
app/src/main/res/drawable/ic_twotone_people_24.xml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M9,8.5m-1.5,0a1.5,1.5 0,1 1,3 0a1.5,1.5 0,1 1,-3 0"
|
||||
android:fillAlpha=".3"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M4.34,17h9.32c-0.84,-0.58 -2.87,-1.25 -4.66,-1.25s-3.82,0.67 -4.66,1.25z"
|
||||
android:fillAlpha=".3"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M9,12c1.93,0 3.5,-1.57 3.5,-3.5S10.93,5 9,5 5.5,6.57 5.5,8.5 7.07,12 9,12zM9,7c0.83,0 1.5,0.67 1.5,1.5S9.83,10 9,10s-1.5,-0.67 -1.5,-1.5S8.17,7 9,7zM9,13.75c-2.34,0 -7,1.17 -7,3.5L2,19h14v-1.75c0,-2.33 -4.66,-3.5 -7,-3.5zM4.34,17c0.84,-0.58 2.87,-1.25 4.66,-1.25s3.82,0.67 4.66,1.25L4.34,17zM16.04,13.81c1.16,0.84 1.96,1.96 1.96,3.44L18,19h4v-1.75c0,-2.02 -3.5,-3.17 -5.96,-3.44zM15,12c1.93,0 3.5,-1.57 3.5,-3.5S16.93,5 15,5c-0.54,0 -1.04,0.13 -1.5,0.35 0.63,0.89 1,1.98 1,3.15s-0.37,2.26 -1,3.15c0.46,0.22 0.96,0.35 1.5,0.35z"/>
|
||||
</vector>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M5,19h14L19,5L5,5v14zM7.5,12c0,-0.2 0.02,-0.39 0.04,-0.58l-1.27,-0.99c-0.11,-0.09 -0.15,-0.26 -0.07,-0.39l1.2,-2.07c0.08,-0.13 0.23,-0.18 0.37,-0.13l1.49,0.6c0.31,-0.25 0.66,-0.44 1.02,-0.6l0.22,-1.59c0.03,-0.14 0.15,-0.25 0.3,-0.25h2.4c0.15,0 0.27,0.11 0.3,0.25l0.22,1.59c0.37,0.15 0.7,0.35 1.01,0.59l1.49,-0.6c0.14,-0.05 0.29,0 0.37,0.13l1.2,2.07c0.08,0.13 0.04,0.29 -0.07,0.39l-1.27,0.99c0.03,0.2 0.04,0.39 0.04,0.59 0,0.2 -0.02,0.39 -0.04,0.58l1.27,0.99c0.11,0.09 0.15,0.26 0.07,0.39l-1.2,2.07c-0.08,0.13 -0.23,0.18 -0.37,0.13l-1.49,-0.6c-0.31,0.24 -0.65,0.44 -1.01,0.59l-0.22,1.59c-0.03,0.15 -0.15,0.26 -0.3,0.26h-2.4c-0.15,0 -0.27,-0.11 -0.3,-0.25l-0.22,-1.59c-0.37,-0.15 -0.7,-0.35 -1.01,-0.59l-1.49,0.6c-0.14,0.05 -0.29,0 -0.37,-0.13l-1.2,-2.07c-0.08,-0.13 -0.04,-0.29 0.07,-0.39l1.27,-0.99c-0.03,-0.2 -0.05,-0.39 -0.05,-0.59z"
|
||||
android:fillAlpha=".3"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M6.21,13.97l1.2,2.07c0.08,0.13 0.23,0.18 0.37,0.13l1.49,-0.6c0.31,0.24 0.64,0.44 1.01,0.59l0.22,1.59c0.03,0.14 0.15,0.25 0.3,0.25h2.4c0.15,0 0.27,-0.11 0.3,-0.26l0.22,-1.59c0.36,-0.15 0.7,-0.35 1.01,-0.59l1.49,0.6c0.14,0.05 0.29,0 0.37,-0.13l1.2,-2.07c0.08,-0.13 0.04,-0.29 -0.07,-0.39l-1.27,-0.99c0.03,-0.19 0.04,-0.39 0.04,-0.58 0,-0.2 -0.02,-0.39 -0.04,-0.59l1.27,-0.99c0.11,-0.09 0.15,-0.26 0.07,-0.39l-1.2,-2.07c-0.08,-0.13 -0.23,-0.18 -0.37,-0.13l-1.49,0.6c-0.31,-0.24 -0.64,-0.44 -1.01,-0.59l-0.22,-1.59c-0.03,-0.14 -0.15,-0.25 -0.3,-0.25h-2.4c-0.15,0 -0.27,0.11 -0.3,0.26l-0.22,1.59c-0.36,0.15 -0.71,0.34 -1.01,0.58l-1.49,-0.6c-0.14,-0.05 -0.29,0 -0.37,0.13l-1.2,2.07c-0.08,0.13 -0.04,0.29 0.07,0.39l1.27,0.99c-0.03,0.2 -0.05,0.39 -0.05,0.59 0,0.2 0.02,0.39 0.04,0.59l-1.27,0.99c-0.11,0.1 -0.14,0.26 -0.06,0.39zM12,10.29c0.94,0 1.71,0.77 1.71,1.71s-0.77,1.71 -1.71,1.71 -1.71,-0.77 -1.71,-1.71 0.77,-1.71 1.71,-1.71zM19,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.11,0 2,-0.9 2,-2L21,5c0,-1.1 -0.89,-2 -2,-2zM19,19L5,19L5,5h14v14z"/>
|
||||
</vector>
|
||||
Loading…
Add table
Add a link
Reference in a new issue