From f09f98e63724b6d9e08e268fbce0e3fd35ddfec3 Mon Sep 17 00:00:00 2001 From: mezhendosina Date: Wed, 21 Jun 2023 15:29:05 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A3=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D1=81=D0=B2=D0=BE=D1=8F=20=D0=B2=D0=BD?= =?UTF-8?q?=D1=83=D1=82=D1=80=D0=B5=D0=BD=D0=BD=D1=8F=D1=8F=20=D0=BD=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=B3=D0=B0=D1=86=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/nm17/narodmon/ui/navHost/AppNavHost.kt | 4 +- .../ru/nm17/narodmon/ui/settings/Settings.kt | 12 ++++++ .../ui/settings/SettingsNavigation.kt | 39 +++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/ru/nm17/narodmon/ui/settings/Settings.kt create mode 100644 app/src/main/java/ru/nm17/narodmon/ui/settings/SettingsNavigation.kt diff --git a/app/src/main/java/ru/nm17/narodmon/ui/navHost/AppNavHost.kt b/app/src/main/java/ru/nm17/narodmon/ui/navHost/AppNavHost.kt index 8a53f00..9697fa4 100644 --- a/app/src/main/java/ru/nm17/narodmon/ui/navHost/AppNavHost.kt +++ b/app/src/main/java/ru/nm17/narodmon/ui/navHost/AppNavHost.kt @@ -6,7 +6,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController -import ru.nm17.narodmon.ui.settings.SettingsScreen +import ru.nm17.narodmon.ui.settings.SettingsNavigation @OptIn(ExperimentalMaterial3Api::class) @@ -18,7 +18,7 @@ fun AppNavHost() { MainScreen(navController) } composable("settings") { - SettingsScreen() + SettingsNavigation() } } } diff --git a/app/src/main/java/ru/nm17/narodmon/ui/settings/Settings.kt b/app/src/main/java/ru/nm17/narodmon/ui/settings/Settings.kt new file mode 100644 index 0000000..6ff326e --- /dev/null +++ b/app/src/main/java/ru/nm17/narodmon/ui/settings/Settings.kt @@ -0,0 +1,12 @@ +package ru.nm17.narodmon.ui.settings + +import androidx.annotation.StringRes +import ru.nm17.narodmon.R + +sealed class Settings(val route: String, @StringRes val resourceId: Int) { + + object Main : Settings("settings_main", R.string.settings) + object AboutApp : Settings("settings_about_app", R.string.about_app) + + object Debug : Settings("settings_debug_menu", R.string.debug_menu) +} \ No newline at end of file diff --git a/app/src/main/java/ru/nm17/narodmon/ui/settings/SettingsNavigation.kt b/app/src/main/java/ru/nm17/narodmon/ui/settings/SettingsNavigation.kt new file mode 100644 index 0000000..f8cc7a2 --- /dev/null +++ b/app/src/main/java/ru/nm17/narodmon/ui/settings/SettingsNavigation.kt @@ -0,0 +1,39 @@ +package ru.nm17.narodmon.ui.settings + +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.composable +import androidx.navigation.compose.rememberNavController + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun SettingsNavigation() { + val navController = rememberNavController() + Scaffold(topBar = { + TopAppBar(title = { Text(text = navController.currentDestination?.route ?: "") }) + }) { + NavHost( + navController = navController, + startDestination = Settings.Main.route, + modifier = Modifier.padding(it) + ) { + composable(Settings.Main.route) { SettingsScreen(navController) } + composable(Settings.AboutApp.route) { } + composable(Settings.Debug.route) { } + } + + } +} + +@Preview +@Composable +fun PreviewSettingsNavigation() { + SettingsNavigation() +} \ No newline at end of file