mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-24 03:42:15 +00:00
Add: IntPref composable
This commit is contained in:
parent
372fe8bb07
commit
ce374887b3
@ -213,3 +213,38 @@ fun EnumPreference(
|
|||||||
onClick = onClick
|
onClick = onClick
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun IntPreference(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
prefKey: Preferences.Key<Int>,
|
||||||
|
index: Int = 1,
|
||||||
|
groupSize: Int = 1,
|
||||||
|
isEnabled: Boolean = true,
|
||||||
|
onClick: (() -> Unit) = {},
|
||||||
|
) {
|
||||||
|
var prefValue by remember {
|
||||||
|
mutableStateOf(Preferences[prefKey])
|
||||||
|
}
|
||||||
|
SideEffect {
|
||||||
|
CoroutineScope(Dispatchers.Default).launch {
|
||||||
|
Preferences.subject.collect {
|
||||||
|
when (it) {
|
||||||
|
prefKey -> prefValue = Preferences[prefKey]
|
||||||
|
else -> {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BasePreference(
|
||||||
|
modifier = modifier,
|
||||||
|
titleId = NonBooleanPrefsMeta[prefKey] ?: -1,
|
||||||
|
summary = prefValue.toString(),
|
||||||
|
index = index,
|
||||||
|
groupSize = groupSize,
|
||||||
|
isEnabled = isEnabled,
|
||||||
|
onClick = onClick
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user