From c0700231b7e32aee7591ba516df9cf0cb0143594 Mon Sep 17 00:00:00 2001 From: HapeLee <63206378+HapeLee@users.noreply.github.com> Date: Sun, 10 May 2026 22:13:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=97=E8=A1=A8=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E6=97=B6=E5=B0=81=E9=9D=A2=E9=98=B4=E5=BD=B1=E4=B8=8D?= =?UTF-8?q?=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=B8=83=E5=B1=80=E8=AE=BE=E7=BD=AE=E6=96=87=E5=AD=97?= =?UTF-8?q?=E9=87=8D=E5=8F=A0=E7=9A=84=E9=97=AE=E9=A2=98=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=88=97=E8=A1=A8=E6=A8=A1=E5=BC=8F=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/constant/PreferKey.kt | 1 + .../config/bookshelfConfig/BookshelfConfig.kt | 7 ++ .../legado/app/ui/main/bookshelf/BookItem.kt | 41 +++++-- .../ui/main/bookshelf/BookshelfConfigSheet.kt | 112 +++++++++++------- .../app/ui/main/bookshelf/BookshelfScreen.kt | 1 + 5 files changed, 104 insertions(+), 58 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index ddf3fdc4d..883533bb3 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -268,6 +268,7 @@ object PreferKey { const val bookshelfTitleMaxLines = "bookshelfTitleMaxLines" const val bookshelfCoverShadow = "bookshelfCoverShadow" const val bookshelfSearchActionDirectToSearch = "bookshelfSearchActionDirectToSearch" + const val bookshelfCardColor = "bookshelfCardColor" const val exploreLayoutGridLandscape = "exploreLayoutGridLandscape" diff --git a/app/src/main/java/io/legado/app/ui/config/bookshelfConfig/BookshelfConfig.kt b/app/src/main/java/io/legado/app/ui/config/bookshelfConfig/BookshelfConfig.kt index 23e5edaf9..d2178cd03 100644 --- a/app/src/main/java/io/legado/app/ui/config/bookshelfConfig/BookshelfConfig.kt +++ b/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 bookshelfCardColor by prefDelegate(PreferKey.bookshelfCardColor, 0) { + postEvent(EventBus.NOTIFY_MAIN, false) + } + /** * 书架搜索按钮是否直接跳转搜索页 */ diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookItem.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookItem.kt index 2f8ee637b..c4d568441 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookItem.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookItem.kt @@ -88,7 +88,9 @@ fun BookshelfItem( onClick: () -> 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) } else { LegadoTheme.colorScheme.cardContainer @@ -136,21 +138,21 @@ fun BookshelfItem( onClick = onClick, onLongClick = onLongClick ) - .padding(4.dp) ) { Column(horizontalAlignment = Alignment.CenterHorizontally) { Box( modifier = Modifier + .padding(4.dp) .fillMaxWidth() .aspectRatio(5f / 7f) .then( if (coverShadow) Modifier.shadow( 4.dp, - MaterialTheme.shapes.extraSmall + RoundedCornerShape(4.dp) ) else Modifier ) - .clip(MaterialTheme.shapes.extraSmall) + .clip(RoundedCornerShape(4.dp)) ) { cover(Modifier.fillMaxSize()) if (gridStyle == 1) { @@ -191,7 +193,7 @@ fun BookshelfItem( textAlign = if (titleCenter) TextAlign.Center else TextAlign.Start, modifier = Modifier .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( modifier = Modifier - .fillMaxWidth() - .padding(all = 4.dp), + .fillMaxWidth(), verticalAlignment = Alignment.CenterVertically ) { - cover( - Modifier + Box( + modifier = Modifier .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( - modifier = Modifier.weight(1f), + modifier = Modifier.weight(1f).padding(top = 4.dp, bottom = 4.dp, end = 8.dp), verticalArrangement = Arrangement.Center ) { Row( diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfConfigSheet.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfConfigSheet.kt index e412db2f2..773d80f3c 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfConfigSheet.kt +++ b/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.setValue import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.res.stringArrayResource 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.themeConfig.LabelColorManageSheet 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.dialog.ColorPickerSheet 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.CompactDropdownSettingItem @@ -41,6 +44,7 @@ fun BookshelfConfigSheet( val configuration = LocalConfiguration.current val isLandscape = configuration.orientation == Configuration.ORIENTATION_LANDSCAPE var showLabelColorManage by remember { mutableStateOf(false) } + var showColorPicker by remember { mutableStateOf(false) } AppModalBottomSheet( title = stringResource(R.string.bookshelf_layout), @@ -135,14 +139,14 @@ fun BookshelfConfigSheet( CompactSwitchSettingItem( title = stringResource(R.string.compact_title_font), checked = BookshelfConfig.bookshelfTitleSmallFont, - color = MaterialTheme.colorScheme.surface, + color = LegadoTheme.colorScheme.surface, onCheckedChange = { BookshelfConfig.bookshelfTitleSmallFont = it } ) CompactSwitchSettingItem( title = stringResource(R.string.center_aligned_title), checked = BookshelfConfig.bookshelfTitleCenter, - color = MaterialTheme.colorScheme.surface, + color = LegadoTheme.colorScheme.surface, onCheckedChange = { BookshelfConfig.bookshelfTitleCenter = it } ) } @@ -157,14 +161,14 @@ fun BookshelfConfigSheet( CompactSwitchSettingItem( title = stringResource(R.string.compact_mode), checked = BookshelfConfig.bookshelfLayoutCompact, - color = MaterialTheme.colorScheme.surface, + color = LegadoTheme.colorScheme.surface, onCheckedChange = { BookshelfConfig.bookshelfLayoutCompact = it } ) CompactSwitchSettingItem( title = stringResource(R.string.show_divider_line), checked = BookshelfConfig.bookshelfShowDivider, - color = MaterialTheme.colorScheme.surface, + color = LegadoTheme.colorScheme.surface, onCheckedChange = { BookshelfConfig.bookshelfShowDivider = it } ) @@ -181,6 +185,47 @@ fun BookshelfConfigSheet( 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( title = stringResource(R.string.cover_shadow), checked = BookshelfConfig.bookshelfCoverShadow, - color = MaterialTheme.colorScheme.surface, + color = LegadoTheme.colorScheme.surface, onCheckedChange = { BookshelfConfig.bookshelfCoverShadow = it } ) CompactSwitchSettingItem( title = "搜索按钮优先打开筛选栏", checked = BookshelfConfig.bookshelfSearchActionDirectToSearch, - color = MaterialTheme.colorScheme.surface, + color = LegadoTheme.colorScheme.surface, onCheckedChange = { BookshelfConfig.bookshelfSearchActionDirectToSearch = it } ) @@ -210,88 +255,56 @@ fun BookshelfConfigSheet( CompactSwitchSettingItem( title = stringResource(R.string.show_unread), checked = BookshelfConfig.showUnread, - color = MaterialTheme.colorScheme.surface, + color = LegadoTheme.colorScheme.surface, onCheckedChange = { BookshelfConfig.showUnread = it } ) CompactSwitchSettingItem( title = stringResource(R.string.show_unread_new), checked = BookshelfConfig.showUnreadNew, - color = MaterialTheme.colorScheme.surface, + color = LegadoTheme.colorScheme.surface, onCheckedChange = { BookshelfConfig.showUnreadNew = it } ) CompactSwitchSettingItem( title = stringResource(R.string.show_tip), checked = BookshelfConfig.showTip, - color = MaterialTheme.colorScheme.surface, + color = LegadoTheme.colorScheme.surface, onCheckedChange = { BookshelfConfig.showTip = it } ) CompactSwitchSettingItem( title = stringResource(R.string.show_book_count), checked = BookshelfConfig.showBookCount, - color = MaterialTheme.colorScheme.surface, + color = LegadoTheme.colorScheme.surface, onCheckedChange = { BookshelfConfig.showBookCount = it } ) CompactSwitchSettingItem( title = stringResource(R.string.show_last_update_time), checked = BookshelfConfig.showLastUpdateTime, - color = MaterialTheme.colorScheme.surface, + color = LegadoTheme.colorScheme.surface, 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( title = stringResource(R.string.show_wait_up_count), checked = BookshelfConfig.showWaitUpCount, - color = MaterialTheme.colorScheme.surface, + color = LegadoTheme.colorScheme.surface, onCheckedChange = { BookshelfConfig.showWaitUpCount = it } ) CompactSwitchSettingItem( title = stringResource(R.string.show_bookshelf_fast_scroller), checked = BookshelfConfig.showBookshelfFastScroller, - color = MaterialTheme.colorScheme.surface, + color = LegadoTheme.colorScheme.surface, onCheckedChange = { BookshelfConfig.showBookshelfFastScroller = it } ) CompactSwitchSettingItem( title = stringResource(R.string.show_bookshelf_tab_menu), checked = BookshelfConfig.shouldShowExpandButton, - color = MaterialTheme.colorScheme.surface, + color = LegadoTheme.colorScheme.surface, onCheckedChange = { BookshelfConfig.shouldShowExpandButton = it } ) @@ -310,5 +323,12 @@ fun BookshelfConfigSheet( show = showLabelColorManage, 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 } + ) } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfScreen.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfScreen.kt index 8cb9caab1..4eb5f78ca 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfScreen.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfScreen.kt @@ -703,6 +703,7 @@ fun BookshelfScreen( titleSmallFont = BookshelfConfig.bookshelfTitleSmallFont, titleCenter = BookshelfConfig.bookshelfTitleCenter, titleMaxLines = BookshelfConfig.bookshelfTitleMaxLines, + coverShadow = BookshelfConfig.bookshelfCoverShadow, onClick = { scope.launch { pagerState.scrollToPage(index) } viewModel.setInFolderRoot(false)