修复列表模式时封面阴影不生效的问题

修复布局设置文字重叠的问题
增加列表模式背景颜色设置
This commit is contained in:
HapeLee
2026-05-10 22:13:53 +08:00
parent 15a931733a
commit c0700231b7
5 changed files with 104 additions and 58 deletions
@@ -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"
@@ -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)
}
/**
* 书架搜索按钮是否直接跳转搜索页
*/
@@ -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(
@@ -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 }
)
}
}
@@ -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)