Добавлен экран с сенсорами, убраны пустые строки

This commit is contained in:
DarkCat09 2023-06-05 17:13:13 +04:00
parent e1bb9de063
commit ecb76ca594
3 changed files with 51 additions and 54 deletions

View file

@ -85,14 +85,12 @@ fun AppNavHost() {
val navController = rememberNavController() val navController = rememberNavController()
val coScope = rememberCoroutineScope() val coScope = rememberCoroutineScope()
NavHost(navController = navController, startDestination = "sensors") { NavHost(navController = navController, startDestination = "sensors") {
composable("agreement") { composable("agreement") {
} }
composable("sensors") {
composable("sensors") {
SensorsPage(navController) SensorsPage(navController)
} }
@ -104,23 +102,14 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val db = Room.databaseBuilder( val db = Room.databaseBuilder(
applicationContext, applicationContext,
AppDatabase::class.java, "data" AppDatabase::class.java, "data"
).build() ).build()
setContent { setContent {
val coScope = rememberCoroutineScope() val coScope = rememberCoroutineScope()
//var asd = getPreferences() //var asd = getPreferences()
NarodMonTheme { NarodMonTheme {
@ -156,20 +145,13 @@ class MainActivity : ComponentActivity() {
AppNavHost() AppNavHost()
} }
// A surface container using the 'background' color from the theme // A surface container using the 'background' color from the theme
} }
} }
} }
} }
@Composable @Composable
fun Greeting(name: String, modifier: Modifier = Modifier) { fun Greeting(name: String, modifier: Modifier = Modifier) {
Text( Text(
@ -183,8 +165,6 @@ fun NavHolderEl() {
//NavHost(navController = NavHostController(N), graph =) //NavHost(navController = NavHostController(N), graph =)
} }
@Preview(showBackground = true) @Preview(showBackground = true)
@Composable @Composable
fun GreetingPreview() { fun GreetingPreview() {

View file

@ -27,6 +27,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController import androidx.navigation.compose.rememberNavController
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -38,7 +39,7 @@ import kotlinx.coroutines.launch
@Composable @Composable
fun GenericNavScaffold(title: @Composable () -> Unit, content: @Composable (PaddingValues) -> Unit) { fun GenericNavScaffold(title: @Composable () -> Unit, content: @Composable (PaddingValues) -> Unit) {
val expanded = rememberDrawerState(initialValue = DrawerValue.Closed) val expanded = rememberDrawerState(initialValue = DrawerValue.Closed)
val coScope = rememberCoroutineScope(); val coScope = rememberCoroutineScope()
val navController = rememberNavController() // TODO: Используй меня val navController = rememberNavController() // TODO: Используй меня
ModalNavigationDrawer(drawerState = expanded, drawerContent = { ModalNavigationDrawer(drawerState = expanded, drawerContent = {
@ -48,7 +49,7 @@ fun GenericNavScaffold(title: @Composable () -> Unit, content: @Composable (Padd
NavigationDrawerItem( NavigationDrawerItem(
label = { Text(text = "Drawer Item") }, label = { Text(text = "Drawer Item") },
selected = true, selected = true,
onClick = { /*TODO*/ } onClick = { navController.navigate("sensors") }
) )
} }
}) { }) {
@ -74,8 +75,6 @@ fun GenericNavScaffold(title: @Composable () -> Unit, content: @Composable (Padd
}, },
//drawerContent = { Text(text = "Drawer Menu 1") }, //drawerContent = { Text(text = "Drawer Menu 1") },
content = content, content = content,
) )
} }
} }

View file

@ -1,17 +1,14 @@
package ru.nm17.narodmon.ui.pages package ru.nm17.narodmon.ui.pages
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.FilterChip
import androidx.compose.material3.ModalDrawerSheet
import androidx.compose.material3.NavigationDrawerItem
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController import androidx.navigation.NavController
import ru.nm17.narodmon.Greeting import ru.nm17.narodmon.Greeting
import ru.nm17.narodmon.R import ru.nm17.narodmon.R
@ -21,8 +18,29 @@ import ru.nm17.narodmon.ui.elements.GenericNavScaffold
@Composable @Composable
fun SensorsPage(navController: NavController) { fun SensorsPage(navController: NavController) {
GenericNavScaffold( GenericNavScaffold(
title = { Text(text = stringResource(R.string.sensors_page_title))} title = { Text(text = stringResource(R.string.sensors_page_title)) }
) { ) {
Greeting(name = "world", modifier = Modifier.padding(it)) Column {
Greeting("Hello sensors")
Row {
FilterChip(
selected = true,
onClick = { },
label = { Text("Temp") }
)
FilterChip(
selected = false,
onClick = { },
label = { Text("Abc") }
)
FilterChip(
selected = false,
onClick = { },
label = { Text("Def") }
)
}
}
} }
} }