Bläddra i källkod

fix: 次行缩放问题

HapeLee 3 månader sedan
förälder
incheckning
df154a2628

+ 6 - 2
app/src/main/java/io/legado/app/ui/book/read/sheet/TextTitleSheet.kt

@@ -67,6 +67,7 @@ import io.legado.app.ui.widget.components.settingItem.TinySliderSettingItem
 import io.legado.app.ui.widget.components.settingItem.TinySwitchSettingItem
 import io.legado.app.ui.widget.components.settingItem.TinySwitchSettingItem
 import io.legado.app.ui.widget.components.tabRow.CardTabRow
 import io.legado.app.ui.widget.components.tabRow.CardTabRow
 import kotlinx.coroutines.launch
 import kotlinx.coroutines.launch
+import kotlin.math.roundToInt
 
 
 // Color picker IDs
 // Color picker IDs
 private const val COLOR_TEXT = 1
 private const val COLOR_TEXT = 1
@@ -545,9 +546,12 @@ internal fun TitleSettingsPage(
         TinySliderSettingItem(
         TinySliderSettingItem(
             title = stringResource(R.string.subtitle_scale),
             title = stringResource(R.string.subtitle_scale),
             value = titleSegScaling,
             value = titleSegScaling,
-            valueRange = -20f..20f,
+            valueRange = -2f..2f,
+            steps = 39,
+            stepSize = 0.1f,
+            valueFormat = { "%.1f".format(it) },
             onValueChange = { value ->
             onValueChange = { value ->
-                titleSegScaling = value
+                titleSegScaling = (value * 10).roundToInt() / 10f
                 onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TitleSegScaling(titleSegScaling)))
                 onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TitleSegScaling(titleSegScaling)))
             },
             },
         )
         )

+ 3 - 2
app/src/main/java/io/legado/app/ui/widget/components/ValueStepper.kt

@@ -21,6 +21,7 @@ fun ValueStepper(
     onValueChange: (Float) -> Unit,
     onValueChange: (Float) -> Unit,
     modifier: Modifier = Modifier,
     modifier: Modifier = Modifier,
     enabled: Boolean = true,
     enabled: Boolean = true,
+    stepSize: Float = 1f,
     showDecimal: Boolean = false,
     showDecimal: Boolean = false,
     valueFormat: ((Float) -> String)? = null,
     valueFormat: ((Float) -> String)? = null,
 ) {
 ) {
@@ -31,7 +32,7 @@ fun ValueStepper(
     ) {
     ) {
         SmallOutlinedButton(
         SmallOutlinedButton(
             onClick = {
             onClick = {
-                val newValue = (value.toInt() - 1).toFloat().coerceIn(valueRange)
+                val newValue = (value - stepSize).coerceIn(valueRange)
                 onValueChange(newValue)
                 onValueChange(newValue)
             },
             },
             enabled = enabled,
             enabled = enabled,
@@ -52,7 +53,7 @@ fun ValueStepper(
         )
         )
         SmallOutlinedButton(
         SmallOutlinedButton(
             onClick = {
             onClick = {
-                val newValue = (value.toInt() + 1).toFloat().coerceIn(valueRange)
+                val newValue = (value + stepSize).coerceIn(valueRange)
                 onValueChange(newValue)
                 onValueChange(newValue)
             },
             },
             enabled = enabled,
             enabled = enabled,

+ 2 - 0
app/src/main/java/io/legado/app/ui/widget/components/settingItem/TinySettingItems.kt

@@ -256,6 +256,7 @@ fun TinySliderSettingItem(
     modifier: Modifier = Modifier,
     modifier: Modifier = Modifier,
     color: Color? = LegadoTheme.colorScheme.surfaceContainerLow,
     color: Color? = LegadoTheme.colorScheme.surfaceContainerLow,
     enabled: Boolean = true,
     enabled: Boolean = true,
+    stepSize: Float = 1f,
     showDecimal: Boolean = false,
     showDecimal: Boolean = false,
     valueFormat: ((Float) -> String)? = null,
     valueFormat: ((Float) -> String)? = null,
     onValueChange: (Float) -> Unit,
     onValueChange: (Float) -> Unit,
@@ -280,6 +281,7 @@ fun TinySliderSettingItem(
                 valueRange = valueRange,
                 valueRange = valueRange,
                 onValueChange = onValueChange,
                 onValueChange = onValueChange,
                 enabled = enabled,
                 enabled = enabled,
+                stepSize = stepSize,
                 showDecimal = showDecimal,
                 showDecimal = showDecimal,
                 valueFormat = valueFormat,
                 valueFormat = valueFormat,
             )
             )