From 37230d8bc0ef3059554adee003ca86617ed30363 Mon Sep 17 00:00:00 2001 From: geeksville Date: Mon, 10 Feb 2020 07:49:55 -0800 Subject: [PATCH] preview shows up again --- .../java/com/geeksville/mesh/MainActivity.kt | 73 ++++++++++--------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/MainActivity.kt b/app/src/main/java/com/geeksville/mesh/MainActivity.kt index da1873d9..a57fc8f3 100644 --- a/app/src/main/java/com/geeksville/mesh/MainActivity.kt +++ b/app/src/main/java/com/geeksville/mesh/MainActivity.kt @@ -148,11 +148,6 @@ class MainActivity : AppCompatActivity(), Logging { } } - @Preview - @Composable - fun previewView() { - composeView() - } private fun sendTestPackets() { exceptionReporter { @@ -206,6 +201,38 @@ class MainActivity : AppCompatActivity(), Logging { } } + @Composable + fun HomeContent() { + Column { + Text(text = "Meshtastic") + + Text("Radio connected: ${isConnected.value}") + + nodes.value.values.forEach { + composeNodeInfo(it) + } + + messages.value.forEach { + Text("Text: ${it.text}") + } + + Button(text = "Start scan", + onClick = { + if (bluetoothAdapter != null) { + // Note: We don't want this service to die just because our activity goes away (because it is doing a software update) + // So we use the application context instead of the activity + SoftwareUpdateService.enqueueWork( + applicationContext, + SoftwareUpdateService.startUpdateIntent + ) + } + }) + + Button(text = "send packets", + onClick = { sendTestPackets() }) + } + } + @Composable fun HomeScreen(openDrawer: () -> Unit) { Column { @@ -218,34 +245,7 @@ class MainActivity : AppCompatActivity(), Logging { } ) VerticalScroller(modifier = LayoutFlexible(1f)) { - Column { - Text(text = "Meshtastic") - - Text("Radio connected: ${isConnected.value}") - - nodes.value.values.forEach { - composeNodeInfo(it) - } - - messages.value.forEach { - Text("Text: ${it.text}") - } - - Button(text = "Start scan", - onClick = { - if (bluetoothAdapter != null) { - // Note: We don't want this service to die just because our activity goes away (because it is doing a software update) - // So we use the application context instead of the activity - SoftwareUpdateService.enqueueWork( - applicationContext, - SoftwareUpdateService.startUpdateIntent - ) - } - }) - - Button(text = "send packets", - onClick = { sendTestPackets() }) - } + HomeContent() } } } @@ -276,6 +276,13 @@ class MainActivity : AppCompatActivity(), Logging { } } + @Preview + @Composable + fun previewView() { + // It seems modaldrawerlayout not yet supported in preview + HomeContent() + } + @Composable private fun AppContent(openDrawer: () -> Unit) { Crossfade(AppStatus.currentScreen) { screen ->