mirror of
https://github.com/smyalygames/vegan-e-numbers.git
synced 2025-05-18 12:54:14 +02:00
feat(settings): add option for different themes
This commit is contained in:
parent
64159b798b
commit
1a77654d29
@ -4,8 +4,10 @@ import App
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import data.SettingsVar
|
||||
import io.anthonyberg.veganenumbers.ui.theme.AppTheme
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
@ -13,7 +15,13 @@ class MainActivity : ComponentActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContent {
|
||||
AppTheme {
|
||||
AppTheme(
|
||||
darkTheme = when(SettingsVar.theme.value) {
|
||||
1 -> false
|
||||
2 -> true
|
||||
else -> isSystemInDarkTheme()
|
||||
}
|
||||
) {
|
||||
App()
|
||||
}
|
||||
}
|
||||
|
7
composeApp/src/commonMain/kotlin/data/SettingsVar.kt
Normal file
7
composeApp/src/commonMain/kotlin/data/SettingsVar.kt
Normal file
@ -0,0 +1,7 @@
|
||||
package data
|
||||
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
|
||||
object SettingsVar {
|
||||
val theme = mutableIntStateOf(0)
|
||||
}
|
@ -1,16 +1,22 @@
|
||||
package tab.setting
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
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.runtime.getValue
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
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
|
||||
import data.SettingsVar
|
||||
|
||||
object Settings : Screen {
|
||||
|
||||
@ -42,7 +48,33 @@ object Settings : Screen {
|
||||
|
||||
@Composable
|
||||
private fun SettingsContent() {
|
||||
Text("Theme")
|
||||
Theme()
|
||||
Text("List Style")
|
||||
}
|
||||
|
||||
/**
|
||||
* ALl the different themes that can be picked
|
||||
* - 0 - Auto
|
||||
* - 1 - Light
|
||||
* - 2 - Dark
|
||||
*/
|
||||
@Composable
|
||||
private fun Theme() {
|
||||
var mode by rememberSaveable { SettingsVar.theme }
|
||||
val themes = listOf("Auto", "Light", "Dark")
|
||||
|
||||
Text("Theme")
|
||||
|
||||
for ((index, value) in themes.withIndex()) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
RadioButton(
|
||||
selected = mode == index,
|
||||
onClick = { mode = index }
|
||||
)
|
||||
Text(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user