Просмотр исходного кода

fix: 修复护眼设置弹窗布局挤压

5151561 3 месяцев назад
Родитель
Сommit
5bb0dc2bc0

+ 57 - 43
app/src/main/java/io/legado/app/ui/book/read/sheet/EyeProtectionConfigSheet.kt

@@ -1,13 +1,19 @@
 package io.legado.app.ui.book.read.sheet
 
 import androidx.compose.animation.AnimatedVisibility
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
 import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.getValue
 import androidx.compose.runtime.mutableStateOf
 import androidx.compose.runtime.remember
 import androidx.compose.runtime.setValue
+import androidx.compose.ui.Modifier
 import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
 import io.legado.app.R
 import io.legado.app.ui.widget.components.dialog.TimePickerDialog
 import io.legado.app.ui.widget.components.modalBottomSheet.AppModalBottomSheet
@@ -44,50 +50,58 @@ fun EyeProtectionConfigSheet(
         show = show,
         onDismissRequest = onDismissRequest,
         title = stringResource(R.string.eye_protection),
+        animateContentSize = false,
     ) {
-        SwitchSettingItem(
-            title = stringResource(R.string.eye_protection_enabled),
-            description = stringResource(R.string.eye_protection_enabled_summary),
-            checked = enabled,
-            onCheckedChange = onEnabledChange,
-        )
-        SwitchSettingItem(
-            title = stringResource(R.string.eye_protection_auto_night),
-            description = stringResource(R.string.eye_protection_auto_night_summary),
-            checked = autoNight,
-            onCheckedChange = onAutoNightChange,
-        )
-        AnimatedVisibility(visible = configured) {
-            Column {
-                SliderSettingItem(
-                    title = stringResource(R.string.eye_protection_intensity),
-                    description = stringResource(
-                        R.string.eye_protection_intensity_summary,
-                        intensity
-                    ),
-                    value = intensity.toFloat(),
-                    defaultValue = 50f,
-                    valueRange = 0f..100f,
-                    onValueChange = { onIntensityChange(it.toInt()) },
-                )
-                SwitchSettingItem(
-                    title = stringResource(R.string.eye_protection_schedule),
-                    description = stringResource(R.string.eye_protection_schedule_summary),
-                    checked = schedule,
-                    onCheckedChange = onScheduleChange,
-                )
-                AnimatedVisibility(visible = schedule) {
-                    Column {
-                        ClickableSettingItem(
-                            title = stringResource(R.string.eye_protection_start_time),
-                            option = startTime,
-                            onClick = { editingStartTime = true },
-                        )
-                        ClickableSettingItem(
-                            title = stringResource(R.string.eye_protection_end_time),
-                            option = endTime,
-                            onClick = { editingEndTime = true },
-                        )
+        Column(
+            modifier = Modifier
+                .fillMaxWidth()
+                .verticalScroll(rememberScrollState())
+                .padding(bottom = 16.dp),
+        ) {
+            SwitchSettingItem(
+                title = stringResource(R.string.eye_protection_enabled),
+                description = stringResource(R.string.eye_protection_enabled_summary),
+                checked = enabled,
+                onCheckedChange = onEnabledChange,
+            )
+            SwitchSettingItem(
+                title = stringResource(R.string.eye_protection_auto_night),
+                description = stringResource(R.string.eye_protection_auto_night_summary),
+                checked = autoNight,
+                onCheckedChange = onAutoNightChange,
+            )
+            AnimatedVisibility(visible = configured) {
+                Column {
+                    SliderSettingItem(
+                        title = stringResource(R.string.eye_protection_intensity),
+                        description = stringResource(
+                            R.string.eye_protection_intensity_summary,
+                            intensity
+                        ),
+                        value = intensity.toFloat(),
+                        defaultValue = 50f,
+                        valueRange = 0f..100f,
+                        onValueChange = { onIntensityChange(it.toInt()) },
+                    )
+                    SwitchSettingItem(
+                        title = stringResource(R.string.eye_protection_schedule),
+                        description = stringResource(R.string.eye_protection_schedule_summary),
+                        checked = schedule,
+                        onCheckedChange = onScheduleChange,
+                    )
+                    AnimatedVisibility(visible = schedule) {
+                        Column {
+                            ClickableSettingItem(
+                                title = stringResource(R.string.eye_protection_start_time),
+                                option = startTime,
+                                onClick = { editingStartTime = true },
+                            )
+                            ClickableSettingItem(
+                                title = stringResource(R.string.eye_protection_end_time),
+                                option = endTime,
+                                onClick = { editingEndTime = true },
+                            )
+                        }
                     }
                 }
             }