fix: 页眉字体
This commit is contained in:
@@ -772,6 +772,9 @@ sealed interface ConfigUpdate {
|
|||||||
data class TipFooterRight(val value: Int) : ConfigUpdate {
|
data class TipFooterRight(val value: Int) : ConfigUpdate {
|
||||||
override val actions = setOf(ConfigUpdateAction.UpdateStyle, ConfigUpdateAction.UpdateContent)
|
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 {
|
data class HeaderFontSize(val value: Int) : ConfigUpdate {
|
||||||
override val actions = setOf(ConfigUpdateAction.UpdateStyle)
|
override val actions = setOf(ConfigUpdateAction.UpdateStyle)
|
||||||
}
|
}
|
||||||
@@ -1063,4 +1066,9 @@ sealed interface ConfigUpdate {
|
|||||||
data class AutoReadSpeed(val value: Int) : ConfigUpdate {
|
data class AutoReadSpeed(val value: Int) : ConfigUpdate {
|
||||||
override val actions = emptySet<ConfigUpdateAction>()
|
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.TipFooterLeft -> ReadBookConfig.tipFooterLeft = update.value
|
||||||
is ConfigUpdate.TipFooterMiddle -> ReadBookConfig.tipFooterMiddle = update.value
|
is ConfigUpdate.TipFooterMiddle -> ReadBookConfig.tipFooterMiddle = update.value
|
||||||
is ConfigUpdate.TipFooterRight -> ReadBookConfig.tipFooterRight = 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.HeaderFontSize -> ReadBookConfig.headerFontSize = update.value
|
||||||
is ConfigUpdate.TipHeaderColor -> ReadBookConfig.tipHeaderColor = update.color
|
is ConfigUpdate.TipHeaderColor -> ReadBookConfig.tipHeaderColor = update.color
|
||||||
is ConfigUpdate.TipFooterColor -> ReadBookConfig.tipFooterColor = update.color
|
is ConfigUpdate.TipFooterColor -> ReadBookConfig.tipFooterColor = update.color
|
||||||
@@ -2722,27 +2723,32 @@ class ReadBookViewModel(
|
|||||||
|
|
||||||
// --- Display toggles ---
|
// --- Display toggles ---
|
||||||
is ConfigUpdate.PaddingDisplayCutouts -> {
|
is ConfigUpdate.PaddingDisplayCutouts -> {
|
||||||
|
ReadConfig.paddingDisplayCutouts = update.value
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
readSettingsRepository.setPaddingDisplayCutouts(update.value)
|
readSettingsRepository.setPaddingDisplayCutouts(update.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is ConfigUpdate.TitleBarMode -> {
|
is ConfigUpdate.TitleBarMode -> {
|
||||||
|
ReadConfig.titleBarMode = update.value
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
readSettingsRepository.setTitleBarMode(update.value)
|
readSettingsRepository.setTitleBarMode(update.value)
|
||||||
}
|
}
|
||||||
postEvent(EventBus.UPDATE_READ_ACTION_BAR, true)
|
postEvent(EventBus.UPDATE_READ_ACTION_BAR, true)
|
||||||
}
|
}
|
||||||
is ConfigUpdate.TextFullJustify -> {
|
is ConfigUpdate.TextFullJustify -> {
|
||||||
|
ReadBookConfig.textFullJustify = update.value
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
readSettingsRepository.setTextFullJustify(update.value)
|
readSettingsRepository.setTextFullJustify(update.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is ConfigUpdate.TextBottomJustify -> {
|
is ConfigUpdate.TextBottomJustify -> {
|
||||||
|
ReadBookConfig.textBottomJustify = update.value
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
readSettingsRepository.setTextBottomJustify(update.value)
|
readSettingsRepository.setTextBottomJustify(update.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is ConfigUpdate.AdaptSpecialStyle -> {
|
is ConfigUpdate.AdaptSpecialStyle -> {
|
||||||
|
ReadConfig.adaptSpecialStyle = update.value
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
readSettingsRepository.setAdaptSpecialStyle(update.value)
|
readSettingsRepository.setAdaptSpecialStyle(update.value)
|
||||||
}
|
}
|
||||||
@@ -2760,6 +2766,7 @@ class ReadBookViewModel(
|
|||||||
postEvent(PreferKey.showBrightnessView, "")
|
postEvent(PreferKey.showBrightnessView, "")
|
||||||
}
|
}
|
||||||
is ConfigUpdate.UseUnderlineGlobal -> {
|
is ConfigUpdate.UseUnderlineGlobal -> {
|
||||||
|
ReadConfig.useUnderline = update.value
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
readSettingsRepository.setUseUnderline(update.value)
|
readSettingsRepository.setUseUnderline(update.value)
|
||||||
}
|
}
|
||||||
@@ -2782,12 +2789,14 @@ class ReadBookViewModel(
|
|||||||
ReadBook.loadContent(false)
|
ReadBook.loadContent(false)
|
||||||
}
|
}
|
||||||
is ConfigUpdate.ProgressBarBehavior -> {
|
is ConfigUpdate.ProgressBarBehavior -> {
|
||||||
|
ReadConfig.progressBarBehavior = update.value
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
readSettingsRepository.setProgressBarBehavior(update.value)
|
readSettingsRepository.setProgressBarBehavior(update.value)
|
||||||
}
|
}
|
||||||
_uiState.update { it.copy(styleConfig = buildStyleConfig()) }
|
_uiState.update { it.copy(styleConfig = buildStyleConfig()) }
|
||||||
}
|
}
|
||||||
is ConfigUpdate.NoAnimScrollPage -> {
|
is ConfigUpdate.NoAnimScrollPage -> {
|
||||||
|
ReadConfig.noAnimScrollPage = update.value
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
readSettingsRepository.setNoAnimScrollPage(update.value)
|
readSettingsRepository.setNoAnimScrollPage(update.value)
|
||||||
}
|
}
|
||||||
@@ -2807,6 +2816,14 @@ class ReadBookViewModel(
|
|||||||
readSettingsRepository.setAutoReadSpeed(update.value)
|
readSettingsRepository.setAutoReadSpeed(update.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Chinese converter ---
|
||||||
|
is ConfigUpdate.ChineseConverterType -> {
|
||||||
|
ReadConfig.chineseConverterType = update.value
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setChineseConverterType(update.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify rendering layer
|
// Notify rendering layer
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ private const val COLOR_DIVIDER = 9
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun HeaderFooterPage(
|
internal fun HeaderFooterPage(
|
||||||
onOpenFontSelect: () -> Unit,
|
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onIntent: (ReadBookIntent) -> Unit,
|
onIntent: (ReadBookIntent) -> Unit,
|
||||||
) {
|
) {
|
||||||
@@ -86,6 +85,7 @@ internal fun HeaderFooterPage(
|
|||||||
var showColorPicker by remember { mutableStateOf(false) }
|
var showColorPicker by remember { mutableStateOf(false) }
|
||||||
var colorPickerId by remember { mutableIntStateOf(0) }
|
var colorPickerId by remember { mutableIntStateOf(0) }
|
||||||
var colorPickerInitial by remember { mutableIntStateOf(0) }
|
var colorPickerInitial by remember { mutableIntStateOf(0) }
|
||||||
|
var showFontSelect by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
val tipNames = remember { ReadBookConfig.tipNames }
|
val tipNames = remember { ReadBookConfig.tipNames }
|
||||||
val tipValues = remember { ReadBookConfig.tipValues }
|
val tipValues = remember { ReadBookConfig.tipValues }
|
||||||
@@ -348,7 +348,7 @@ internal fun HeaderFooterPage(
|
|||||||
title = stringResource(R.string.header_font),
|
title = stringResource(R.string.header_font),
|
||||||
description = stringResource(R.string.select_font),
|
description = stringResource(R.string.select_font),
|
||||||
imageVector = Icons.Default.TextFields,
|
imageVector = Icons.Default.TextFields,
|
||||||
onClick = onOpenFontSelect,
|
onClick = { showFontSelect = true },
|
||||||
)
|
)
|
||||||
TinySliderSettingItem(
|
TinySliderSettingItem(
|
||||||
title = stringResource(R.string.header_font_size),
|
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
|
@Composable
|
||||||
|
|||||||
@@ -136,7 +136,6 @@ fun ReadStyleContent(
|
|||||||
onIntent = onIntent,
|
onIntent = onIntent,
|
||||||
)
|
)
|
||||||
2 -> HeaderFooterPage(
|
2 -> HeaderFooterPage(
|
||||||
onOpenFontSelect = onOpenFontSelect,
|
|
||||||
onIntent = onIntent,
|
onIntent = onIntent,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user