Add auto reader background color

This commit is contained in:
schroda
2026-07-15 22:34:51 +02:00
parent 7559676e68
commit 3562f5f647
18 changed files with 440 additions and 45 deletions

View File

@@ -25,6 +25,7 @@ export const READER_DEFAULT_PAGES_STATE: Omit<
| 'setPageUrls'
| 'setPageSpreadStates'
| 'setPageLoadStates'
| 'setPageBackgroundColor'
| 'setPages'
| 'setTransitionPageMode'
| 'setRetryFailedPagesKeyPrefix'
@@ -36,6 +37,7 @@ export const READER_DEFAULT_PAGES_STATE: Omit<
pageUrls: [],
pageSpreadStates: [{ url: '', isSpread: false }],
pageLoadStates: [{ url: '', loaded: false }],
pageBackgroundColors: [{ url: '', color: undefined }],
pages: [
{
name: '1',
@@ -114,6 +116,19 @@ export const createReaderPagesStoreSlice = <T extends ReaderPagesStoreSlice>(
undefined,
createActionName('setPageLoadStates'),
),
setPageBackgroundColor: (dominantColors) =>
set(
(draft) => {
if (typeof dominantColors === 'function') {
draft.pages.pageBackgroundColors = dominantColors(get().pages.pageBackgroundColors);
return;
}
draft.pages.pageBackgroundColors = dominantColors;
},
undefined,
createActionName('setPageBackgroundColors'),
),
setPages: (pages) =>
set(
(draft) => {