Фикс #10 #15
2 changed files with 48 additions and 41 deletions
|
@ -47,50 +47,12 @@ import kotlinx.coroutines.launch
|
|||
import ru.nm17.narodmon.db.AppDatabase
|
||||
import ru.nm17.narodmon.db.entities.KVSetting
|
||||
import ru.nm17.narodmon.ui.dialogs.AgreementDialog
|
||||
import ru.nm17.narodmon.ui.navHost.AppNavHost
|
||||
import ru.nm17.narodmon.ui.navHost.MainScreen
|
||||
import ru.nm17.narodmon.ui.sensorsScreen.SensorsScreen
|
||||
import ru.nm17.narodmon.ui.theme.NarodMonTheme
|
||||
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun AppNavHost() {
|
||||
val navController = rememberNavController()
|
||||
val coScope = rememberCoroutineScope()
|
||||
NavHost(navController = navController, startDestination = "sensors") {
|
||||
composable("agreement") {
|
||||
|
||||
}
|
||||
|
||||
composable("sensors") {
|
||||
Scaffold(bottomBar = {
|
||||
BottomAppBar(actions = {
|
||||
Image(
|
||||
Icons.Rounded.Menu,
|
||||
contentDescription = null
|
||||
)
|
||||
}, floatingActionButton = {
|
||||
FloatingActionButton(onClick = { /*TODO*/ }) {
|
||||
Image(
|
||||
Icons.Rounded.Add,
|
||||
contentDescription = ""
|
||||
)
|
||||
}
|
||||
},
|
||||
contentPadding = PaddingValues(start = 16.dp)
|
||||
)
|
||||
}) {
|
||||
Column(modifier = Modifier.padding(it)) {
|
||||
SensorsScreen(navController)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*...*/
|
||||
|
||||
}
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -153,7 +115,6 @@ class MainActivity : ComponentActivity() {
|
|||
}
|
||||
} else {
|
||||
AppNavHost()
|
||||
|
||||
}
|
||||
|
||||
// A surface container using the 'background' color from the theme
|
||||
|
|
46
app/src/main/java/ru/nm17/narodmon/ui/navHost/AppNavHost.kt
Normal file
46
app/src/main/java/ru/nm17/narodmon/ui/navHost/AppNavHost.kt
Normal file
|
@ -0,0 +1,46 @@
|
|||
package ru.nm17.narodmon.ui.navHost
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.rounded.Add
|
||||
import androidx.compose.material.icons.rounded.Menu
|
||||
import androidx.compose.material3.BottomAppBar
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FloatingActionButton
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import ru.nm17.narodmon.ui.sensorsScreen.SensorsScreen
|
||||
import ru.nm17.narodmon.ui.settings.SettingsScreen
|
||||
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun AppNavHost() {
|
||||
val navController = rememberNavController()
|
||||
NavHost(navController = navController, startDestination = "main") {
|
||||
composable("main") {
|
||||
MainScreen(navController)
|
||||
}
|
||||
composable("settings") {
|
||||
SettingsScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewAppNavHost() {
|
||||
AppNavHost()
|
||||
}
|
Loading…
Reference in a new issue