Added customizable highlight color palette in epub (#6)
This introduces a user-configurable palette for text highlighting. The four default highlight colors can now be customized by the user from an expanded set of predefined colors. Changes include: - Added a `PaletteManagerDialog` to allow users to select and save their preferred highlight colors. - Implemented `saveHighlightPalette` and `loadHighlightPalette` to persist the user's choices. - The highlighting UI in both vertical and paginated readers now displays the active custom palette. - Added new `HighlightColor` options. - Updated JavaScript to support the expanded color set and improve highlight interaction logic.
This commit is contained in:
parent
1b048c9073
commit
1f111034f1
5 changed files with 3044 additions and 1753 deletions
|
|
@ -283,6 +283,19 @@ fun EpubReaderHost(
|
|||
}
|
||||
}
|
||||
|
||||
var currentHighlightPalette by remember {
|
||||
mutableStateOf(loadHighlightPalette(context))
|
||||
}
|
||||
|
||||
val onUpdateHighlightPalette: (Int, HighlightColor) -> Unit = { index, newColor ->
|
||||
val newList = currentHighlightPalette.toMutableList()
|
||||
if (index in newList.indices) {
|
||||
newList[index] = newColor
|
||||
currentHighlightPalette = newList
|
||||
saveHighlightPalette(context, newList)
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(userHighlights.size, userHighlights.toList()) {
|
||||
saveHighlightsToPrefs(context, epubBook.title, userHighlights)
|
||||
}
|
||||
|
|
@ -1541,6 +1554,8 @@ fun EpubReaderHost(
|
|||
initialCfi = cfiToLoad,
|
||||
initialFragmentId = fragmentToLoad.also { },
|
||||
userHighlights = userHighlights.filter { it.chapterIndex == targetChapterIndex },
|
||||
activeHighlightPalette = currentHighlightPalette,
|
||||
onUpdatePalette = onUpdateHighlightPalette,
|
||||
onHighlightCreated = { cfi, text, colorId ->
|
||||
Timber.d("Vertical Mode (Source): Creating Highlight. CFI: $cfi")
|
||||
Timber.d("Vertical Mode (Source): Text Snippet: '${text.take(50)}...'")
|
||||
|
|
@ -2090,6 +2105,8 @@ fun EpubReaderHost(
|
|||
lineHeightMultiplier = currentLineHeight,
|
||||
fontFamily = activeFontFamily,
|
||||
textAlign = currentTextAlign,
|
||||
activeHighlightPalette = currentHighlightPalette,
|
||||
onUpdatePalette = onUpdateHighlightPalette,
|
||||
ttsHighlightInfo = TtsHighlightInfo(
|
||||
text = ttsState.currentText ?: "",
|
||||
cfi = ttsState.sourceCfi ?: "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue