فهرست منبع

feat: 阅读设置相关

HapeLee 2 ماه پیش
والد
کامیت
2efe0514aa

+ 9 - 4
app/src/main/java/io/legado/app/ui/book/read/sheet/TypographyTabs.kt

@@ -127,6 +127,8 @@ private fun FontWeightSetting(
         TinyDropdownSettingItem(
         TinyDropdownSettingItem(
             title = stringResource(R.string.font_weight_text),
             title = stringResource(R.string.font_weight_text),
             selectedValue = if (isCustom) "-1" else value.toString(),
             selectedValue = if (isCustom) "-1" else value.toString(),
+            // 自定义时直接显示当前字重数值,而不是笼统的“自定义”
+            selectedDisplay = if (isCustom) sliderValue.toInt().toString() else null,
             displayEntries = arrayOf(
             displayEntries = arrayOf(
                 weightEntries[2],
                 weightEntries[2],
                 weightEntries[0],
                 weightEntries[0],
@@ -212,6 +214,7 @@ private fun PaddingSliders(
     bottom: Float,
     bottom: Float,
     left: Float,
     left: Float,
     right: Float,
     right: Float,
+    maxValue: Float = 200f,
     onTopChange: (Float) -> Unit,
     onTopChange: (Float) -> Unit,
     onBottomChange: (Float) -> Unit,
     onBottomChange: (Float) -> Unit,
     onLeftChange: (Float) -> Unit,
     onLeftChange: (Float) -> Unit,
@@ -220,28 +223,28 @@ private fun PaddingSliders(
     TinySliderSettingItem(
     TinySliderSettingItem(
         title = stringResource(R.string.padding_top),
         title = stringResource(R.string.padding_top),
         value = top,
         value = top,
-        valueRange = 0f..200f,
+        valueRange = 0f..maxValue,
         imageVector = Icons.Default.VerticalAlignTop,
         imageVector = Icons.Default.VerticalAlignTop,
         onValueChange = onTopChange,
         onValueChange = onTopChange,
     )
     )
     TinySliderSettingItem(
     TinySliderSettingItem(
         title = stringResource(R.string.padding_bottom),
         title = stringResource(R.string.padding_bottom),
         value = bottom,
         value = bottom,
-        valueRange = 0f..200f,
+        valueRange = 0f..maxValue,
         imageVector = Icons.Default.VerticalAlignBottom,
         imageVector = Icons.Default.VerticalAlignBottom,
         onValueChange = onBottomChange,
         onValueChange = onBottomChange,
     )
     )
     TinySliderSettingItem(
     TinySliderSettingItem(
         title = stringResource(R.string.padding_left),
         title = stringResource(R.string.padding_left),
         value = left,
         value = left,
-        valueRange = 0f..200f,
+        valueRange = 0f..maxValue,
         imageVector = Icons.Default.AlignHorizontalLeft,
         imageVector = Icons.Default.AlignHorizontalLeft,
         onValueChange = onLeftChange,
         onValueChange = onLeftChange,
     )
     )
     TinySliderSettingItem(
     TinySliderSettingItem(
         title = stringResource(R.string.padding_right),
         title = stringResource(R.string.padding_right),
         value = right,
         value = right,
-        valueRange = 0f..200f,
+        valueRange = 0f..maxValue,
         imageVector = Icons.Default.AlignHorizontalRight,
         imageVector = Icons.Default.AlignHorizontalRight,
         onValueChange = onRightChange,
         onValueChange = onRightChange,
     )
     )
@@ -946,6 +949,7 @@ internal fun TypographyMarginTab(
             1 -> PaddingSliders(
             1 -> PaddingSliders(
                 top = headerPaddingTop, bottom = headerPaddingBottom,
                 top = headerPaddingTop, bottom = headerPaddingBottom,
                 left = headerPaddingLeft, right = headerPaddingRight,
                 left = headerPaddingLeft, right = headerPaddingRight,
+                maxValue = 500f,
                 onTopChange = {
                 onTopChange = {
                     headerPaddingTop = it
                     headerPaddingTop = it
                     onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.HeaderPaddingTop(it.toInt())))
                     onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.HeaderPaddingTop(it.toInt())))
@@ -967,6 +971,7 @@ internal fun TypographyMarginTab(
             else -> PaddingSliders(
             else -> PaddingSliders(
                 top = footerPaddingTop, bottom = footerPaddingBottom,
                 top = footerPaddingTop, bottom = footerPaddingBottom,
                 left = footerPaddingLeft, right = footerPaddingRight,
                 left = footerPaddingLeft, right = footerPaddingRight,
+                maxValue = 500f,
                 onTopChange = {
                 onTopChange = {
                     footerPaddingTop = it
                     footerPaddingTop = it
                     onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.FooterPaddingTop(it.toInt())))
                     onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.FooterPaddingTop(it.toInt())))

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

@@ -218,6 +218,7 @@ fun TinySettingItem(
 fun TinyDropdownSettingItem(
 fun TinyDropdownSettingItem(
     title: String,
     title: String,
     selectedValue: String,
     selectedValue: String,
+    selectedDisplay: String? = null,
     displayEntries: Array<String>,
     displayEntries: Array<String>,
     entryValues: Array<String>,
     entryValues: Array<String>,
     description: String? = null,
     description: String? = null,
@@ -227,7 +228,9 @@ fun TinyDropdownSettingItem(
     onValueChange: (String) -> Unit,
     onValueChange: (String) -> Unit,
 ) {
 ) {
     var showMenu by remember { mutableStateOf(false) }
     var showMenu by remember { mutableStateOf(false) }
-    val currentEntry = displayEntries.getOrNull(entryValues.indexOf(selectedValue)) ?: selectedValue
+    val currentEntry =
+        selectedDisplay ?: displayEntries.getOrNull(entryValues.indexOf(selectedValue))
+        ?: selectedValue
 
 
     Box(modifier = Modifier.fillMaxWidth()) {
     Box(modifier = Modifier.fillMaxWidth()) {
         TinySettingItem(
         TinySettingItem(