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

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

View file

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

View file

@ -1,17 +1,14 @@
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.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalDrawerSheet
import androidx.compose.material3.NavigationDrawerItem
import androidx.compose.material3.FilterChip
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import ru.nm17.narodmon.Greeting
import ru.nm17.narodmon.R
@ -21,8 +18,29 @@ import ru.nm17.narodmon.ui.elements.GenericNavScaffold
@Composable
fun SensorsPage(navController: NavController) {
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") }
)
}
}
}
}