Rework slider UI
Fixes #1474 (cherry picked from commit e8c9cb2c2e4c24443368f0d653c5283f9671ffec) # Conflicts: # presentation-core/src/main/java/tachiyomi/presentation/core/components/SettingsItems.kt
This commit is contained in:
@@ -52,8 +52,9 @@ sealed class Preference {
|
||||
*/
|
||||
data class SliderPreference(
|
||||
val value: Int,
|
||||
val min: Int = 0,
|
||||
val max: Int,
|
||||
val min: Int = 0,
|
||||
val steps: Int = 0,
|
||||
override val title: String = "",
|
||||
override val subtitle: String? = null,
|
||||
override val icon: ImageVector? = null,
|
||||
|
||||
@@ -5,6 +5,7 @@ import androidx.compose.animation.expandVertically
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.shrinkVertically
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.collectAsState
|
||||
@@ -76,11 +77,11 @@ internal fun PreferenceItem(
|
||||
)
|
||||
}
|
||||
is Preference.PreferenceItem.SliderPreference -> {
|
||||
// TODO: use different composable?
|
||||
SliderItem(
|
||||
label = item.title,
|
||||
min = item.min,
|
||||
max = item.max,
|
||||
steps = item.steps,
|
||||
value = item.value,
|
||||
valueText = item.subtitle.takeUnless { it.isNullOrEmpty() } ?: item.value.toString(),
|
||||
onChange = {
|
||||
@@ -88,6 +89,7 @@ internal fun PreferenceItem(
|
||||
item.onValueChanged(it)
|
||||
}
|
||||
},
|
||||
labelStyle = MaterialTheme.typography.titleLarge,
|
||||
)
|
||||
}
|
||||
is Preference.PreferenceItem.ListPreference<*> -> {
|
||||
|
||||
@@ -177,6 +177,7 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
value = flashMillis / ReaderPreferences.MILLI_CONVERSION,
|
||||
min = 1,
|
||||
max = 15,
|
||||
steps = 13,
|
||||
title = stringResource(MR.strings.pref_flash_duration),
|
||||
subtitle = stringResource(MR.strings.pref_flash_duration_summary, flashMillis),
|
||||
onValueChanged = {
|
||||
@@ -189,6 +190,7 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
value = flashInterval,
|
||||
min = 1,
|
||||
max = 10,
|
||||
steps = 8,
|
||||
title = stringResource(MR.strings.pref_flash_page_interval),
|
||||
subtitle = pluralStringResource(MR.plurals.pref_pages, flashInterval, flashInterval),
|
||||
onValueChanged = {
|
||||
|
||||
Reference in New Issue
Block a user