Преглед изворни кода

修复列表模式时封面阴影不生效的问题
修复布局设置文字重叠的问题
增加列表模式背景颜色设置

HapeLee пре 6 месеци
родитељ
комит
c0700231b7

+ 1 - 0
app/src/main/java/io/legado/app/constant/PreferKey.kt

@@ -268,6 +268,7 @@ object PreferKey {
     const val bookshelfTitleMaxLines = "bookshelfTitleMaxLines"
     const val bookshelfTitleMaxLines = "bookshelfTitleMaxLines"
     const val bookshelfCoverShadow = "bookshelfCoverShadow"
     const val bookshelfCoverShadow = "bookshelfCoverShadow"
     const val bookshelfSearchActionDirectToSearch = "bookshelfSearchActionDirectToSearch"
     const val bookshelfSearchActionDirectToSearch = "bookshelfSearchActionDirectToSearch"
+    const val bookshelfCardColor = "bookshelfCardColor"
 
 
     const val exploreLayoutGridLandscape = "exploreLayoutGridLandscape"
     const val exploreLayoutGridLandscape = "exploreLayoutGridLandscape"
 
 

+ 7 - 0
app/src/main/java/io/legado/app/ui/config/bookshelfConfig/BookshelfConfig.kt

@@ -148,6 +148,13 @@ object BookshelfConfig {
      */
      */
     var bookshelfCoverShadow by prefDelegate(PreferKey.bookshelfCoverShadow, false)
     var bookshelfCoverShadow by prefDelegate(PreferKey.bookshelfCoverShadow, false)
 
 
+    /**
+     * 书架卡片背景颜色
+     */
+    var bookshelfCardColor by prefDelegate(PreferKey.bookshelfCardColor, 0) {
+        postEvent(EventBus.NOTIFY_MAIN, false)
+    }
+
     /**
     /**
      * 书架搜索按钮是否直接跳转搜索页
      * 书架搜索按钮是否直接跳转搜索页
      */
      */

+ 29 - 12
app/src/main/java/io/legado/app/ui/main/bookshelf/BookItem.kt

@@ -88,7 +88,9 @@ fun BookshelfItem(
     onClick: () -> Unit,
     onClick: () -> Unit,
     onLongClick: (() -> Unit)?
     onLongClick: (() -> Unit)?
 ) {
 ) {
-    val containerColor = if (ThemeConfig.enableDeepPersonalization && ThemeConfig.secondaryThemeColor != 0) {
+    val containerColor = if (!isGrid && BookshelfConfig.bookshelfCardColor != 0) {
+        Color(BookshelfConfig.bookshelfCardColor)
+    } else if (ThemeConfig.enableDeepPersonalization && ThemeConfig.secondaryThemeColor != 0) {
         Color(ThemeConfig.secondaryThemeColor)
         Color(ThemeConfig.secondaryThemeColor)
     } else {
     } else {
         LegadoTheme.colorScheme.cardContainer
         LegadoTheme.colorScheme.cardContainer
@@ -136,21 +138,21 @@ fun BookshelfItem(
                     onClick = onClick,
                     onClick = onClick,
                     onLongClick = onLongClick
                     onLongClick = onLongClick
                 )
                 )
-                .padding(4.dp)
         ) {
         ) {
             Column(horizontalAlignment = Alignment.CenterHorizontally) {
             Column(horizontalAlignment = Alignment.CenterHorizontally) {
 
 
                 Box(
                 Box(
                     modifier = Modifier
                     modifier = Modifier
+                        .padding(4.dp)
                         .fillMaxWidth()
                         .fillMaxWidth()
                         .aspectRatio(5f / 7f)
                         .aspectRatio(5f / 7f)
                         .then(
                         .then(
                             if (coverShadow) Modifier.shadow(
                             if (coverShadow) Modifier.shadow(
                                 4.dp,
                                 4.dp,
-                                MaterialTheme.shapes.extraSmall
+                                RoundedCornerShape(4.dp)
                             ) else Modifier
                             ) else Modifier
                         )
                         )
-                        .clip(MaterialTheme.shapes.extraSmall)
+                        .clip(RoundedCornerShape(4.dp))
                 ) {
                 ) {
                     cover(Modifier.fillMaxSize())
                     cover(Modifier.fillMaxSize())
                     if (gridStyle == 1) {
                     if (gridStyle == 1) {
@@ -191,7 +193,7 @@ fun BookshelfItem(
                         textAlign = if (titleCenter) TextAlign.Center else TextAlign.Start,
                         textAlign = if (titleCenter) TextAlign.Center else TextAlign.Start,
                         modifier = Modifier
                         modifier = Modifier
                             .fillMaxWidth()
                             .fillMaxWidth()
-                            .padding(top = 4.dp)
+                            .padding(top = 4.dp, start = 4.dp, end = 4.dp, bottom = 8.dp)
                     )
                     )
                 }
                 }
             }
             }
@@ -214,17 +216,32 @@ fun BookshelfItem(
             ) {
             ) {
                 Row(
                 Row(
                     modifier = Modifier
                     modifier = Modifier
-                        .fillMaxWidth()
-                        .padding(all = 4.dp),
+                        .fillMaxWidth(),
                     verticalAlignment = Alignment.CenterVertically
                     verticalAlignment = Alignment.CenterVertically
                 ) {
                 ) {
-                    cover(
-                        Modifier
+                    Box(
+                        modifier = Modifier
                             .width(if (!isCompact) 80.dp else 56.dp)
                             .width(if (!isCompact) 80.dp else 56.dp)
-                            .padding(end = 12.dp)
-                    )
+                            .padding(end = 8.dp)
+                    ) {
+                        Box(
+                            modifier = Modifier
+                                .padding(4.dp)
+                                .fillMaxWidth()
+                                .aspectRatio(5f / 7f)
+                                .then(
+                                    if (coverShadow) Modifier.shadow(
+                                        4.dp,
+                                        RoundedCornerShape(4.dp)
+                                    ) else Modifier
+                                )
+                                .clip(RoundedCornerShape(4.dp))
+                        ) {
+                            cover(Modifier.fillMaxSize())
+                        }
+                    }
                     Column(
                     Column(
-                        modifier = Modifier.weight(1f),
+                        modifier = Modifier.weight(1f).padding(top = 4.dp, bottom = 4.dp, end = 8.dp),
                         verticalArrangement = Arrangement.Center
                         verticalArrangement = Arrangement.Center
                     ) {
                     ) {
                     Row(
                     Row(

+ 66 - 46
app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfConfigSheet.kt

@@ -17,6 +17,7 @@ import androidx.compose.runtime.mutableStateOf
 import androidx.compose.runtime.remember
 import androidx.compose.runtime.remember
 import androidx.compose.runtime.setValue
 import androidx.compose.runtime.setValue
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.toArgb
 import androidx.compose.ui.platform.LocalConfiguration
 import androidx.compose.ui.platform.LocalConfiguration
 import androidx.compose.ui.res.stringArrayResource
 import androidx.compose.ui.res.stringArrayResource
 import androidx.compose.ui.res.stringResource
 import androidx.compose.ui.res.stringResource
@@ -25,7 +26,9 @@ import io.legado.app.R
 import io.legado.app.ui.config.bookshelfConfig.BookshelfConfig
 import io.legado.app.ui.config.bookshelfConfig.BookshelfConfig
 import io.legado.app.ui.config.themeConfig.LabelColorManageSheet
 import io.legado.app.ui.config.themeConfig.LabelColorManageSheet
 import io.legado.app.ui.config.themeConfig.ThemeConfig
 import io.legado.app.ui.config.themeConfig.ThemeConfig
+import io.legado.app.ui.theme.LegadoTheme
 import io.legado.app.ui.widget.components.card.GlassCard
 import io.legado.app.ui.widget.components.card.GlassCard
+import io.legado.app.ui.widget.components.dialog.ColorPickerSheet
 import io.legado.app.ui.widget.components.modalBottomSheet.AppModalBottomSheet
 import io.legado.app.ui.widget.components.modalBottomSheet.AppModalBottomSheet
 import io.legado.app.ui.widget.components.settingItem.CompactClickableSettingItem
 import io.legado.app.ui.widget.components.settingItem.CompactClickableSettingItem
 import io.legado.app.ui.widget.components.settingItem.CompactDropdownSettingItem
 import io.legado.app.ui.widget.components.settingItem.CompactDropdownSettingItem
@@ -41,6 +44,7 @@ fun BookshelfConfigSheet(
     val configuration = LocalConfiguration.current
     val configuration = LocalConfiguration.current
     val isLandscape = configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
     val isLandscape = configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
     var showLabelColorManage by remember { mutableStateOf(false) }
     var showLabelColorManage by remember { mutableStateOf(false) }
+    var showColorPicker by remember { mutableStateOf(false) }
 
 
     AppModalBottomSheet(
     AppModalBottomSheet(
         title = stringResource(R.string.bookshelf_layout),
         title = stringResource(R.string.bookshelf_layout),
@@ -135,14 +139,14 @@ fun BookshelfConfigSheet(
                     CompactSwitchSettingItem(
                     CompactSwitchSettingItem(
                         title = stringResource(R.string.compact_title_font),
                         title = stringResource(R.string.compact_title_font),
                         checked = BookshelfConfig.bookshelfTitleSmallFont,
                         checked = BookshelfConfig.bookshelfTitleSmallFont,
-                        color = MaterialTheme.colorScheme.surface,
+                        color = LegadoTheme.colorScheme.surface,
                         onCheckedChange = { BookshelfConfig.bookshelfTitleSmallFont = it }
                         onCheckedChange = { BookshelfConfig.bookshelfTitleSmallFont = it }
                     )
                     )
 
 
                     CompactSwitchSettingItem(
                     CompactSwitchSettingItem(
                         title = stringResource(R.string.center_aligned_title),
                         title = stringResource(R.string.center_aligned_title),
                         checked = BookshelfConfig.bookshelfTitleCenter,
                         checked = BookshelfConfig.bookshelfTitleCenter,
-                        color = MaterialTheme.colorScheme.surface,
+                        color = LegadoTheme.colorScheme.surface,
                         onCheckedChange = { BookshelfConfig.bookshelfTitleCenter = it }
                         onCheckedChange = { BookshelfConfig.bookshelfTitleCenter = it }
                     )
                     )
                 }
                 }
@@ -157,14 +161,14 @@ fun BookshelfConfigSheet(
                     CompactSwitchSettingItem(
                     CompactSwitchSettingItem(
                         title = stringResource(R.string.compact_mode),
                         title = stringResource(R.string.compact_mode),
                         checked = BookshelfConfig.bookshelfLayoutCompact,
                         checked = BookshelfConfig.bookshelfLayoutCompact,
-                        color = MaterialTheme.colorScheme.surface,
+                        color = LegadoTheme.colorScheme.surface,
                         onCheckedChange = { BookshelfConfig.bookshelfLayoutCompact = it }
                         onCheckedChange = { BookshelfConfig.bookshelfLayoutCompact = it }
                     )
                     )
 
 
                     CompactSwitchSettingItem(
                     CompactSwitchSettingItem(
                         title = stringResource(R.string.show_divider_line),
                         title = stringResource(R.string.show_divider_line),
                         checked = BookshelfConfig.bookshelfShowDivider,
                         checked = BookshelfConfig.bookshelfShowDivider,
-                        color = MaterialTheme.colorScheme.surface,
+                        color = LegadoTheme.colorScheme.surface,
                         onCheckedChange = { BookshelfConfig.bookshelfShowDivider = it }
                         onCheckedChange = { BookshelfConfig.bookshelfShowDivider = it }
                     )
                     )
 
 
@@ -181,6 +185,47 @@ fun BookshelfConfigSheet(
                             else BookshelfConfig.bookshelfLayoutListPortrait = it.toInt()
                             else BookshelfConfig.bookshelfLayoutListPortrait = it.toInt()
                         }
                         }
                     )
                     )
+
+                    CompactClickableSettingItem(
+                        title = "卡片背景颜色",
+                        color = LegadoTheme.colorScheme.surface,
+                        onClick = { showColorPicker = true }
+                    )
+
+                    CompactSwitchSettingItem(
+                        title = "显示更多信息",
+                        checked = BookshelfConfig.showBookIntro,
+                        color = LegadoTheme.colorScheme.surface,
+                        onCheckedChange = { BookshelfConfig.showBookIntro = it }
+                    )
+
+                    AnimatedVisibility(visible = BookshelfConfig.showBookIntro) {
+                        Column(
+                            verticalArrangement = Arrangement.spacedBy(8.dp)
+                        ) {
+                            CompactSliderSettingItem(
+                                title = "简介行数",
+                                description = if (BookshelfConfig.bookshelfIntroMaxLines == 0) "显示全部简介" else "显示 ${BookshelfConfig.bookshelfIntroMaxLines} 行简介",
+                                value = BookshelfConfig.bookshelfIntroMaxLines.toFloat(),
+                                valueRange = 0f..10f,
+                                steps = 10,
+                                onValueChange = { BookshelfConfig.bookshelfIntroMaxLines = it.toInt() }
+                            )
+                            CompactSwitchSettingItem(
+                                title = "自定义标签颜色",
+                                checked = ThemeConfig.enableCustomTagColors,
+                                color = LegadoTheme.colorScheme.surface,
+                                onCheckedChange = { ThemeConfig.enableCustomTagColors = it }
+                            )
+                            AnimatedVisibility(visible = ThemeConfig.enableCustomTagColors) {
+                                CompactClickableSettingItem(
+                                    title = "管理标签颜色",
+                                    color = LegadoTheme.colorScheme.surface,
+                                    onClick = { showLabelColorManage = true }
+                                )
+                            }
+                        }
+                    }
                 }
                 }
             }
             }
 
 
@@ -195,14 +240,14 @@ fun BookshelfConfigSheet(
             CompactSwitchSettingItem(
             CompactSwitchSettingItem(
                 title = stringResource(R.string.cover_shadow),
                 title = stringResource(R.string.cover_shadow),
                 checked = BookshelfConfig.bookshelfCoverShadow,
                 checked = BookshelfConfig.bookshelfCoverShadow,
-                color = MaterialTheme.colorScheme.surface,
+                color = LegadoTheme.colorScheme.surface,
                 onCheckedChange = { BookshelfConfig.bookshelfCoverShadow = it }
                 onCheckedChange = { BookshelfConfig.bookshelfCoverShadow = it }
             )
             )
 
 
             CompactSwitchSettingItem(
             CompactSwitchSettingItem(
                 title = "搜索按钮优先打开筛选栏",
                 title = "搜索按钮优先打开筛选栏",
                 checked = BookshelfConfig.bookshelfSearchActionDirectToSearch,
                 checked = BookshelfConfig.bookshelfSearchActionDirectToSearch,
-                color = MaterialTheme.colorScheme.surface,
+                color = LegadoTheme.colorScheme.surface,
                 onCheckedChange = { BookshelfConfig.bookshelfSearchActionDirectToSearch = it }
                 onCheckedChange = { BookshelfConfig.bookshelfSearchActionDirectToSearch = it }
             )
             )
 
 
@@ -210,88 +255,56 @@ fun BookshelfConfigSheet(
             CompactSwitchSettingItem(
             CompactSwitchSettingItem(
                 title = stringResource(R.string.show_unread),
                 title = stringResource(R.string.show_unread),
                 checked = BookshelfConfig.showUnread,
                 checked = BookshelfConfig.showUnread,
-                color = MaterialTheme.colorScheme.surface,
+                color = LegadoTheme.colorScheme.surface,
                 onCheckedChange = { BookshelfConfig.showUnread = it }
                 onCheckedChange = { BookshelfConfig.showUnread = it }
             )
             )
 
 
             CompactSwitchSettingItem(
             CompactSwitchSettingItem(
                 title = stringResource(R.string.show_unread_new),
                 title = stringResource(R.string.show_unread_new),
                 checked = BookshelfConfig.showUnreadNew,
                 checked = BookshelfConfig.showUnreadNew,
-                color = MaterialTheme.colorScheme.surface,
+                color = LegadoTheme.colorScheme.surface,
                 onCheckedChange = { BookshelfConfig.showUnreadNew = it }
                 onCheckedChange = { BookshelfConfig.showUnreadNew = it }
             )
             )
 
 
             CompactSwitchSettingItem(
             CompactSwitchSettingItem(
                 title = stringResource(R.string.show_tip),
                 title = stringResource(R.string.show_tip),
                 checked = BookshelfConfig.showTip,
                 checked = BookshelfConfig.showTip,
-                color = MaterialTheme.colorScheme.surface,
+                color = LegadoTheme.colorScheme.surface,
                 onCheckedChange = { BookshelfConfig.showTip = it }
                 onCheckedChange = { BookshelfConfig.showTip = it }
             )
             )
 
 
             CompactSwitchSettingItem(
             CompactSwitchSettingItem(
                 title = stringResource(R.string.show_book_count),
                 title = stringResource(R.string.show_book_count),
                 checked = BookshelfConfig.showBookCount,
                 checked = BookshelfConfig.showBookCount,
-                color = MaterialTheme.colorScheme.surface,
+                color = LegadoTheme.colorScheme.surface,
                 onCheckedChange = { BookshelfConfig.showBookCount = it }
                 onCheckedChange = { BookshelfConfig.showBookCount = it }
             )
             )
 
 
             CompactSwitchSettingItem(
             CompactSwitchSettingItem(
                 title = stringResource(R.string.show_last_update_time),
                 title = stringResource(R.string.show_last_update_time),
                 checked = BookshelfConfig.showLastUpdateTime,
                 checked = BookshelfConfig.showLastUpdateTime,
-                color = MaterialTheme.colorScheme.surface,
+                color = LegadoTheme.colorScheme.surface,
                 onCheckedChange = { BookshelfConfig.showLastUpdateTime = it }
                 onCheckedChange = { BookshelfConfig.showLastUpdateTime = it }
             )
             )
 
 
-            CompactSwitchSettingItem(
-                title = "列表模式显示更多",
-                checked = BookshelfConfig.showBookIntro,
-                color = MaterialTheme.colorScheme.surface,
-                onCheckedChange = { BookshelfConfig.showBookIntro = it }
-            )
-
-            AnimatedVisibility(visible = BookshelfConfig.showBookIntro) {
-                CompactSliderSettingItem(
-                    title = "简介行数",
-                    description = if (BookshelfConfig.bookshelfIntroMaxLines == 0) "显示全部简介" else "显示 ${BookshelfConfig.bookshelfIntroMaxLines} 行简介",
-                    value = BookshelfConfig.bookshelfIntroMaxLines.toFloat(),
-                    valueRange = 0f..10f,
-                    steps = 10,
-                    onValueChange = { BookshelfConfig.bookshelfIntroMaxLines = it.toInt() }
-                )
-                CompactSwitchSettingItem(
-                    title = "自定义标签颜色",
-                    checked = ThemeConfig.enableCustomTagColors,
-                    color = MaterialTheme.colorScheme.surface,
-                    onCheckedChange = { ThemeConfig.enableCustomTagColors = it }
-                )
-
-                AnimatedVisibility(visible = ThemeConfig.enableCustomTagColors) {
-                    CompactClickableSettingItem(
-                        title = "管理标签颜色",
-                        color = MaterialTheme.colorScheme.surface,
-                        onClick = { showLabelColorManage = true }
-                    )
-                }
-            }
-
             CompactSwitchSettingItem(
             CompactSwitchSettingItem(
                 title = stringResource(R.string.show_wait_up_count),
                 title = stringResource(R.string.show_wait_up_count),
                 checked = BookshelfConfig.showWaitUpCount,
                 checked = BookshelfConfig.showWaitUpCount,
-                color = MaterialTheme.colorScheme.surface,
+                color = LegadoTheme.colorScheme.surface,
                 onCheckedChange = { BookshelfConfig.showWaitUpCount = it }
                 onCheckedChange = { BookshelfConfig.showWaitUpCount = it }
             )
             )
 
 
             CompactSwitchSettingItem(
             CompactSwitchSettingItem(
                 title = stringResource(R.string.show_bookshelf_fast_scroller),
                 title = stringResource(R.string.show_bookshelf_fast_scroller),
                 checked = BookshelfConfig.showBookshelfFastScroller,
                 checked = BookshelfConfig.showBookshelfFastScroller,
-                color = MaterialTheme.colorScheme.surface,
+                color = LegadoTheme.colorScheme.surface,
                 onCheckedChange = { BookshelfConfig.showBookshelfFastScroller = it }
                 onCheckedChange = { BookshelfConfig.showBookshelfFastScroller = it }
             )
             )
 
 
             CompactSwitchSettingItem(
             CompactSwitchSettingItem(
                 title = stringResource(R.string.show_bookshelf_tab_menu),
                 title = stringResource(R.string.show_bookshelf_tab_menu),
                 checked = BookshelfConfig.shouldShowExpandButton,
                 checked = BookshelfConfig.shouldShowExpandButton,
-                color = MaterialTheme.colorScheme.surface,
+                color = LegadoTheme.colorScheme.surface,
                 onCheckedChange = { BookshelfConfig.shouldShowExpandButton = it }
                 onCheckedChange = { BookshelfConfig.shouldShowExpandButton = it }
             )
             )
 
 
@@ -310,5 +323,12 @@ fun BookshelfConfigSheet(
             show = showLabelColorManage,
             show = showLabelColorManage,
             onDismissRequest = { showLabelColorManage = false }
             onDismissRequest = { showLabelColorManage = false }
         )
         )
+
+        ColorPickerSheet(
+            show = showColorPicker,
+            initialColor = if (BookshelfConfig.bookshelfCardColor != 0) BookshelfConfig.bookshelfCardColor else LegadoTheme.colorScheme.surfaceVariant.toArgb(),
+            onDismissRequest = { showColorPicker = false },
+            onColorSelected = { BookshelfConfig.bookshelfCardColor = it }
+        )
     }
     }
 }
 }

+ 1 - 0
app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfScreen.kt

@@ -703,6 +703,7 @@ fun BookshelfScreen(
                                     titleSmallFont = BookshelfConfig.bookshelfTitleSmallFont,
                                     titleSmallFont = BookshelfConfig.bookshelfTitleSmallFont,
                                     titleCenter = BookshelfConfig.bookshelfTitleCenter,
                                     titleCenter = BookshelfConfig.bookshelfTitleCenter,
                                     titleMaxLines = BookshelfConfig.bookshelfTitleMaxLines,
                                     titleMaxLines = BookshelfConfig.bookshelfTitleMaxLines,
+                                    coverShadow = BookshelfConfig.bookshelfCoverShadow,
                                     onClick = {
                                     onClick = {
                                         scope.launch { pagerState.scrollToPage(index) }
                                         scope.launch { pagerState.scrollToPage(index) }
                                         viewModel.setInFolderRoot(false)
                                         viewModel.setInFolderRoot(false)