Fix securityDelay pref summary
This commit is contained in:
1 parent
8152a04155
commit
78ffe38f54
3 files changed
+10
-3
No files matched your search
@@ -90,10 +90,10 @@ fun SwitchPreference(title: String, summary: String? = null, value: KMutableProp
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun IntSliderPreference(maxValue: Int, minValue: Int = 0, step: Int = maxValue - minValue - 1, title: String, value: KMutableProperty0<Int>, enabled: Boolean = true) {
|
||||
fun IntSliderPreference(maxValue: Int, minValue: Int = 0, step: Int = maxValue - minValue - 1, title: String, summary: String? = null, value: KMutableProperty0<Int>, enabled: Boolean = true) {
|
||||
var v by remember { mutableIntStateOf(value.get()) }
|
||||
fun set(float: Float) = value.set(float.roundToInt().also { v = it })
|
||||
SliderPref(title = title, defaultValue = v.toFloat(), onValueChangeFinished = ::set, valueRange = minValue.toFloat()..maxValue.toFloat(), showValue = true, showInteger = true, steps = step, enabled = enabled)
|
||||
SliderPref(title = title, summary = summary, defaultValue = v.toFloat(), onValueChangeFinished = ::set, valueRange = minValue.toFloat()..maxValue.toFloat(), showValue = true, showInteger = true, steps = step, enabled = enabled)
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -18,6 +18,8 @@ import androidx.compose.ui.res.stringResource
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.ui.LocalNavController
|
||||
import com.hippo.ehviewer.ui.compose.observed
|
||||
import com.hippo.ehviewer.ui.compose.rememberedAccessor
|
||||
import com.hippo.ehviewer.ui.isAuthenticationSupported
|
||||
|
||||
@Composable
|
||||
@@ -43,10 +45,13 @@ fun SecurityScreen() {
|
||||
value = Settings::security,
|
||||
enabled = LocalContext.current.isAuthenticationSupported(),
|
||||
)
|
||||
val securityDelay = Settings::securityDelay.observed
|
||||
val summary = if (securityDelay.value == 0) stringResource(id = R.string.settings_privacy_require_unlock_delay_summary_immediately) else stringResource(id = R.string.settings_privacy_require_unlock_delay_summary, securityDelay.value)
|
||||
IntSliderPreference(
|
||||
maxValue = 30,
|
||||
title = stringResource(id = R.string.settings_privacy_require_unlock_delay),
|
||||
value = Settings::securityDelay,
|
||||
summary = summary,
|
||||
value = securityDelay.rememberedAccessor,
|
||||
enabled = LocalContext.current.isAuthenticationSupported(),
|
||||
)
|
||||
SwitchPreference(
|
||||
|
||||
@@ -24,6 +24,7 @@ import kotlin.math.roundToInt
|
||||
fun SliderPref(
|
||||
title: String,
|
||||
modifier: Modifier = Modifier,
|
||||
summary: String? = null,
|
||||
defaultValue: Float = 0f,
|
||||
onValueChangeFinished: ((Float) -> Unit)? = null,
|
||||
valueRange: ClosedFloatingPointRange<Float> = 0f..1f,
|
||||
@@ -41,6 +42,7 @@ fun SliderPref(
|
||||
TextPref(
|
||||
title = title,
|
||||
modifier = modifier,
|
||||
summary = summary,
|
||||
textColor = textColor,
|
||||
minimalHeight = true,
|
||||
leadingIcon = leadingIcon,
|
||||
|
||||
Reference in new issue
Block a user