fix: 页眉字体

This commit is contained in:
HapeLee
2026-06-11 13:34:21 +08:00
parent 55b15c2de3
commit 08f197598f
4 changed files with 46 additions and 3 deletions
@@ -772,6 +772,9 @@ sealed interface ConfigUpdate {
data class TipFooterRight(val value: Int) : ConfigUpdate {
override val actions = setOf(ConfigUpdateAction.UpdateStyle, ConfigUpdateAction.UpdateContent)
}
data class HeaderFont(val path: String) : ConfigUpdate {
override val actions = setOf(ConfigUpdateAction.UpdateStyle)
}
data class HeaderFontSize(val value: Int) : ConfigUpdate {
override val actions = setOf(ConfigUpdateAction.UpdateStyle)
}
@@ -1063,4 +1066,9 @@ sealed interface ConfigUpdate {
data class AutoReadSpeed(val value: Int) : ConfigUpdate {
override val actions = emptySet<ConfigUpdateAction>()
}
// --- Chinese converter ---
data class ChineseConverterType(val value: Int) : ConfigUpdate {
override val actions = setOf(ConfigUpdateAction.ReloadContent)
}
}
@@ -2349,6 +2349,7 @@ class ReadBookViewModel(
is ConfigUpdate.TipFooterLeft -> ReadBookConfig.tipFooterLeft = update.value
is ConfigUpdate.TipFooterMiddle -> ReadBookConfig.tipFooterMiddle = update.value
is ConfigUpdate.TipFooterRight -> ReadBookConfig.tipFooterRight = update.value
is ConfigUpdate.HeaderFont -> ReadBookConfig.headerFont = update.path
is ConfigUpdate.HeaderFontSize -> ReadBookConfig.headerFontSize = update.value
is ConfigUpdate.TipHeaderColor -> ReadBookConfig.tipHeaderColor = update.color
is ConfigUpdate.TipFooterColor -> ReadBookConfig.tipFooterColor = update.color
@@ -2722,27 +2723,32 @@ class ReadBookViewModel(
// --- Display toggles ---
is ConfigUpdate.PaddingDisplayCutouts -> {
ReadConfig.paddingDisplayCutouts = update.value
viewModelScope.launch {
readSettingsRepository.setPaddingDisplayCutouts(update.value)
}
}
is ConfigUpdate.TitleBarMode -> {
ReadConfig.titleBarMode = update.value
viewModelScope.launch {
readSettingsRepository.setTitleBarMode(update.value)
}
postEvent(EventBus.UPDATE_READ_ACTION_BAR, true)
}
is ConfigUpdate.TextFullJustify -> {
ReadBookConfig.textFullJustify = update.value
viewModelScope.launch {
readSettingsRepository.setTextFullJustify(update.value)
}
}
is ConfigUpdate.TextBottomJustify -> {
ReadBookConfig.textBottomJustify = update.value
viewModelScope.launch {
readSettingsRepository.setTextBottomJustify(update.value)
}
}
is ConfigUpdate.AdaptSpecialStyle -> {
ReadConfig.adaptSpecialStyle = update.value
viewModelScope.launch {
readSettingsRepository.setAdaptSpecialStyle(update.value)
}
@@ -2760,6 +2766,7 @@ class ReadBookViewModel(
postEvent(PreferKey.showBrightnessView, "")
}
is ConfigUpdate.UseUnderlineGlobal -> {
ReadConfig.useUnderline = update.value
viewModelScope.launch {
readSettingsRepository.setUseUnderline(update.value)
}
@@ -2782,12 +2789,14 @@ class ReadBookViewModel(
ReadBook.loadContent(false)
}
is ConfigUpdate.ProgressBarBehavior -> {
ReadConfig.progressBarBehavior = update.value
viewModelScope.launch {
readSettingsRepository.setProgressBarBehavior(update.value)
}
_uiState.update { it.copy(styleConfig = buildStyleConfig()) }
}
is ConfigUpdate.NoAnimScrollPage -> {
ReadConfig.noAnimScrollPage = update.value
viewModelScope.launch {
readSettingsRepository.setNoAnimScrollPage(update.value)
}
@@ -2807,6 +2816,14 @@ class ReadBookViewModel(
readSettingsRepository.setAutoReadSpeed(update.value)
}
}
// --- Chinese converter ---
is ConfigUpdate.ChineseConverterType -> {
ReadConfig.chineseConverterType = update.value
viewModelScope.launch {
readSettingsRepository.setChineseConverterType(update.value)
}
}
}
// Notify rendering layer
@@ -49,7 +49,6 @@ private const val COLOR_DIVIDER = 9
@Composable
internal fun HeaderFooterPage(
onOpenFontSelect: () -> Unit,
modifier: Modifier = Modifier,
onIntent: (ReadBookIntent) -> Unit,
) {
@@ -86,6 +85,7 @@ internal fun HeaderFooterPage(
var showColorPicker by remember { mutableStateOf(false) }
var colorPickerId by remember { mutableIntStateOf(0) }
var colorPickerInitial by remember { mutableIntStateOf(0) }
var showFontSelect by remember { mutableStateOf(false) }
val tipNames = remember { ReadBookConfig.tipNames }
val tipValues = remember { ReadBookConfig.tipValues }
@@ -348,7 +348,7 @@ internal fun HeaderFooterPage(
title = stringResource(R.string.header_font),
description = stringResource(R.string.select_font),
imageVector = Icons.Default.TextFields,
onClick = onOpenFontSelect,
onClick = { showFontSelect = true },
)
TinySliderSettingItem(
title = stringResource(R.string.header_font_size),
@@ -390,6 +390,25 @@ internal fun HeaderFooterPage(
},
)
}
// Font selector for header/footer
if (showFontSelect) {
FontSelectSheet(
show = true,
onDismissRequest = { showFontSelect = false },
onSelectFont = {
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.HeaderFont(it)))
onIntent(ReadBookIntent.SaveReadStyleConfig)
showFontSelect = false
},
onSelectSystemTypeface = {
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.HeaderFont("")))
onIntent(ReadBookIntent.SaveReadStyleConfig)
showFontSelect = false
},
onOpenFolderPicker = { /* handled by FontSelectSheet internally */ },
)
}
}
@Composable
@@ -136,7 +136,6 @@ fun ReadStyleContent(
onIntent = onIntent,
)
2 -> HeaderFooterPage(
onOpenFontSelect = onOpenFontSelect,
onIntent = onIntent,
)
}