mirror of
https://github.com/smyalygames/vegan-e-numbers.git
synced 2025-05-18 17:04:14 +02:00
feat(settings): add options for displaying e number list information
This commit is contained in:
parent
1a77654d29
commit
6c3d2b1258
@ -4,4 +4,12 @@ import androidx.compose.runtime.mutableIntStateOf
|
|||||||
|
|
||||||
object SettingsVar {
|
object SettingsVar {
|
||||||
val theme = mutableIntStateOf(0)
|
val theme = mutableIntStateOf(0)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* - 0 - E Number Main, Full name Secondary
|
||||||
|
* - 1 - Full name Main, E Number Secondary
|
||||||
|
* - 2 - E Number only
|
||||||
|
* - 3 - Full name only
|
||||||
|
*/
|
||||||
|
val eNumberStyle = mutableIntStateOf(0)
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import cafe.adriel.voyager.core.screen.Screen
|
import cafe.adriel.voyager.core.screen.Screen
|
||||||
import data.EGroup
|
import data.EGroup
|
||||||
import data.ENumber
|
import data.ENumber
|
||||||
|
import data.SettingsVar
|
||||||
|
|
||||||
class ENumberList(private val eNumbers: List<EGroup>, private val searchText: MutableState<String>) : Screen {
|
class ENumberList(private val eNumbers: List<EGroup>, private val searchText: MutableState<String>) : Screen {
|
||||||
|
|
||||||
@ -79,11 +80,21 @@ class ENumberList(private val eNumbers: List<EGroup>, private val searchText: Mu
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fun fact, these settings were added whilst on a plane
|
||||||
@Composable
|
@Composable
|
||||||
private fun ItemList(eNumber: ENumber) {
|
private fun ItemList(eNumber: ENumber) {
|
||||||
|
/*
|
||||||
|
Checks if the settings affect the order of what is displayed
|
||||||
|
Even - E Number is headline
|
||||||
|
Odd - Full name is headline
|
||||||
|
*/
|
||||||
|
val headline = if (SettingsVar.eNumberStyle.value % 2 == 0) eNumber.number else eNumber.name
|
||||||
|
val supporting = if (SettingsVar.eNumberStyle.value % 2 == 0) eNumber.name else eNumber.number
|
||||||
|
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = { Text(text = eNumber.name) },
|
headlineContent = { Text(text = headline) },
|
||||||
supportingContent = { Text(text = eNumber.number) },
|
// Checks if the supporting text is wanted in the settings
|
||||||
|
supportingContent = { if (SettingsVar.eNumberStyle.value < 2) Text(text = supporting) },
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
VeganStatusIcon(
|
VeganStatusIcon(
|
||||||
vegan = eNumber.vegan,
|
vegan = eNumber.vegan,
|
||||||
|
@ -49,7 +49,7 @@ object Settings : Screen {
|
|||||||
@Composable
|
@Composable
|
||||||
private fun SettingsContent() {
|
private fun SettingsContent() {
|
||||||
Theme()
|
Theme()
|
||||||
Text("List Style")
|
ENumberStyle()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,4 +77,24 @@ object Settings : Screen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun ENumberStyle() {
|
||||||
|
var mode by rememberSaveable { SettingsVar.eNumberStyle }
|
||||||
|
val modes = listOf("E Number Main", "Full Name Main", "E Number Only", "Full Name Only")
|
||||||
|
|
||||||
|
Text("List Style")
|
||||||
|
|
||||||
|
for ((index, value) in modes.withIndex()) {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
RadioButton(
|
||||||
|
selected = mode == index,
|
||||||
|
onClick = { mode = index }
|
||||||
|
)
|
||||||
|
Text(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user