Procházet zdrojové kódy

fix: 优化页眉页脚间距展开滚动并提取硬编码边距字符串

fansangg před 4 měsíci
rodič
revize
c3ba892fa3

+ 18 - 19
app/src/main/java/io/legado/app/ui/book/read/sheet/HeaderFooterPage.kt

@@ -2,7 +2,6 @@ package io.legado.app.ui.book.read.sheet
 
 import androidx.compose.animation.AnimatedVisibility
 import androidx.compose.animation.core.FastOutSlowInEasing
-import androidx.compose.animation.core.LinearEasing
 import androidx.compose.animation.core.tween
 import androidx.compose.animation.expandVertically
 import androidx.compose.animation.fadeIn
@@ -65,10 +64,8 @@ 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.tabRow.CardTabRow
 import io.legado.app.utils.getCompatColor
-import kotlinx.coroutines.delay
 import kotlinx.coroutines.launch
 import org.koin.compose.koinInject
-import kotlin.time.Duration.Companion.milliseconds
 
 // Color picker IDs
 private const val COLOR_HEADER = 7
@@ -124,25 +121,15 @@ internal fun HeaderFooterPage(
     val headerScrollState = rememberScrollState()
     val footerScrollState = rememberScrollState()
 
-    LaunchedEffect(expandHeaderPadding) {
+    LaunchedEffect(expandHeaderPadding, headerScrollState.maxValue) {
         if (expandHeaderPadding) {
-            //等动画结束后再滚动到底部,否则maxValue值不是最新
-            delay(300.milliseconds)
-            headerScrollState.animateScrollTo(
-                headerScrollState.maxValue,
-                animationSpec = tween(durationMillis = 200, easing = LinearEasing)
-            )
+            headerScrollState.scrollTo(headerScrollState.maxValue)
         }
     }
 
-    LaunchedEffect(expandFooterPadding) {
+    LaunchedEffect(expandFooterPadding, footerScrollState.maxValue) {
         if (expandFooterPadding) {
-            //等动画结束后再滚动到底部,否则maxValue值不是最新
-            delay(300.milliseconds)
-            footerScrollState.animateScrollTo(
-                footerScrollState.maxValue,
-                animationSpec = tween(durationMillis = 200, easing = LinearEasing)
-            )
+            footerScrollState.scrollTo(footerScrollState.maxValue)
         }
     }
 
@@ -313,7 +300,13 @@ internal fun HeaderFooterPage(
                         Spacer(Modifier.height(8.dp))
                         TinyClickableSettingItem(
                             title = stringResource(R.string.padding),
-                            description = "上: ${headerPaddingTop.toInt()}  下: ${headerPaddingBottom.toInt()}  左: ${headerPaddingLeft.toInt()}  右: ${headerPaddingRight.toInt()}",
+                            description = stringResource(
+                                R.string.padding_format,
+                                headerPaddingTop.toInt(),
+                                headerPaddingBottom.toInt(),
+                                headerPaddingLeft.toInt(),
+                                headerPaddingRight.toInt(),
+                            ),
                             trailingContent = {
                                 Icon(
                                     imageVector = if (expandHeaderPadding) Icons.Default.ExpandMore else Icons.Default.ChevronRight,
@@ -437,7 +430,13 @@ internal fun HeaderFooterPage(
                         Spacer(Modifier.height(8.dp))
                         TinyClickableSettingItem(
                             title = stringResource(R.string.padding),
-                            description = "上: ${footerPaddingTop.toInt()}  下: ${footerPaddingBottom.toInt()}  左: ${footerPaddingLeft.toInt()}  右: ${footerPaddingRight.toInt()}",
+                            description = stringResource(
+                                R.string.padding_format,
+                                footerPaddingTop.toInt(),
+                                footerPaddingBottom.toInt(),
+                                footerPaddingLeft.toInt(),
+                                footerPaddingRight.toInt(),
+                            ),
                             trailingContent = {
                                 Icon(
                                     imageVector = if (expandFooterPadding) Icons.Default.ExpandMore else Icons.Default.ChevronRight,

+ 1 - 0
app/src/main/res/values-zh-rCN/strings.xml

@@ -352,6 +352,7 @@
     <string name="padding_bottom">下边距</string>
     <string name="padding_left">左边距</string>
     <string name="padding_right">右边距</string>
+    <string name="padding_format">上: %1$d  下: %2$d  左: %3$d  右: %4$d</string>
     <string name="check_book_source">校验书源</string>
     <string name="check_select_source">校验所选</string>
     <string name="progress_show">%1$s      进度 %2$d/%3$d</string>

+ 1 - 0
app/src/main/res/values-zh-rHK/strings.xml

@@ -299,6 +299,7 @@
     <string name="padding_bottom">下邊距</string>
     <string name="padding_left">左邊距</string>
     <string name="padding_right">右邊距</string>
+    <string name="padding_format">上: %1$d  下: %2$d  左: %3$d  右: %4$d</string>
     <string name="check_book_source">校驗書源</string>
     <string name="check_select_source">校驗所選</string>
     <string name="progress_show">%1$s      進度 %2$d/%3$d</string>

+ 1 - 0
app/src/main/res/values-zh-rTW/strings.xml

@@ -301,6 +301,7 @@
     <string name="padding_bottom">下邊距</string>
     <string name="padding_left">左邊距</string>
     <string name="padding_right">右邊距</string>
+    <string name="padding_format">上: %1$d  下: %2$d  左: %3$d  右: %4$d</string>
     <string name="check_book_source">校驗書源</string>
     <string name="check_select_source">校驗所選</string>
     <string name="progress_show">%1$s      進度 %2$d/%3$d</string>

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -373,6 +373,7 @@
     <string name="padding_bottom">Bottom</string>
     <string name="padding_left">Left</string>
     <string name="padding_right">Right</string>
+    <string name="padding_format">Top: %1$d  Bottom: %2$d  Left: %3$d  Right: %4$d</string>
     <string name="check_book_source">Check book sources</string>
     <string name="check_select_source">Check the selected source</string>
     <string name="progress_show">%1$s      Progress %2$d/%3$d</string>