mirror of
https://github.com/smyalygames/vegan-e-numbers.git
synced 2025-05-18 13:34:13 +02:00
feat(app): add settings and about screens
This commit is contained in:
parent
5a028e3b07
commit
64159b798b
@ -9,7 +9,6 @@ import androidx.compose.material.icons.filled.Clear
|
||||
import androidx.compose.material.icons.filled.MoreVert
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.material.icons.outlined.Info
|
||||
import androidx.compose.material.icons.outlined.Place
|
||||
import androidx.compose.material.icons.outlined.Settings
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
@ -22,7 +21,12 @@ import androidx.compose.ui.semantics.traversalIndex
|
||||
import androidx.compose.ui.unit.dp
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
import tab.About
|
||||
import tab.Licenses
|
||||
import tab.setting.Settings
|
||||
import veganenumbers.composeapp.generated.resources.Res
|
||||
import veganenumbers.composeapp.generated.resources.handshake_24px
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
@ -83,13 +87,12 @@ private fun OptionsMenu(expanded: MutableState<Boolean>) {
|
||||
) {
|
||||
DropdownMenuItem(
|
||||
text = { Text("Settings") },
|
||||
onClick = { /* TODO open settings screen */ },
|
||||
onClick = { navigator.push(Settings) },
|
||||
leadingIcon = { Icon(imageVector = Icons.Outlined.Settings, contentDescription = "Open settings") }
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text("About") },
|
||||
onClick = { /* TODO open about screen */ },
|
||||
leadingIcon = { Icon(imageVector = Icons.Outlined.Place, contentDescription = "Information about the application") }
|
||||
onClick = { navigator.push(About) },
|
||||
leadingIcon = { Icon(imageVector = Icons.Outlined.Info, contentDescription = "Information about the application") }
|
||||
)
|
||||
DropdownMenuItem(
|
||||
|
47
composeApp/src/commonMain/kotlin/tab/About.kt
Normal file
47
composeApp/src/commonMain/kotlin/tab/About.kt
Normal file
@ -0,0 +1,47 @@
|
||||
package tab
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import cafe.adriel.voyager.core.screen.Screen
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
|
||||
object About : Screen {
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
override fun Content() {
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
|
||||
Scaffold (
|
||||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text("About") },
|
||||
navigationIcon = {
|
||||
IconButton(onClick = { navigator.pop() }) {
|
||||
Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Go back to main app")
|
||||
}
|
||||
},
|
||||
scrollBehavior = scrollBehavior
|
||||
)
|
||||
},
|
||||
) {
|
||||
Column (modifier = Modifier.padding(it)) {
|
||||
AboutContent()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AboutContent() {
|
||||
Text("This app was created by Anthony Berg")
|
||||
}
|
||||
}
|
48
composeApp/src/commonMain/kotlin/tab/setting/Settings.kt
Normal file
48
composeApp/src/commonMain/kotlin/tab/setting/Settings.kt
Normal file
@ -0,0 +1,48 @@
|
||||
package tab.setting
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import cafe.adriel.voyager.core.screen.Screen
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
|
||||
object Settings : Screen {
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
override fun Content() {
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
|
||||
Scaffold (
|
||||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text("Settings") },
|
||||
navigationIcon = {
|
||||
IconButton(onClick = { navigator.pop() }) {
|
||||
Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Go back to main app")
|
||||
}
|
||||
},
|
||||
scrollBehavior = scrollBehavior
|
||||
)
|
||||
},
|
||||
) {
|
||||
Column (modifier = Modifier.padding(it)) {
|
||||
SettingsContent()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SettingsContent() {
|
||||
Text("Theme")
|
||||
Text("List Style")
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user