Compare commits
5 Commits
31fb8521b8
...
55d499e118
Author | SHA1 | Date | |
---|---|---|---|
|
55d499e118 | ||
|
496e577f8f | ||
|
63486d5107 | ||
|
6c38137a8d | ||
|
78c5be1bb1 |
@ -51,11 +51,12 @@
|
|||||||
"icons/icon.icns",
|
"icons/icon.icns",
|
||||||
"icons/icon.ico"
|
"icons/icon.ico"
|
||||||
],
|
],
|
||||||
"identifier": "xyz.archgrid.comic_viewer",
|
"identifier": "xyz.archgrid.comic-viewer",
|
||||||
"targets": "all"
|
"targets": "all"
|
||||||
},
|
},
|
||||||
"security": {
|
"security": {
|
||||||
"csp": "default-src 'self'; img-src 'self' asset: https://asset.localhost"
|
"devCsp": "default-src 'self'; img-src 'self' asset: https://asset.localhost",
|
||||||
|
"csp": null
|
||||||
},
|
},
|
||||||
"updater": {
|
"updater": {
|
||||||
"active": false
|
"active": false
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//@ts-nocheck
|
||||||
import { Stack, useMantineTheme } from '@mantine/core';
|
import { Stack, useMantineTheme } from '@mantine/core';
|
||||||
import { ifElse, path, propEq } from 'ramda';
|
import { ifElse, path, propEq } from 'ramda';
|
||||||
import { FC, useMemo } from 'react';
|
import { FC, useMemo } from 'react';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//@ts-nocheck
|
||||||
import { Box } from '@mantine/core';
|
import { Box } from '@mantine/core';
|
||||||
import { equals } from 'ramda';
|
import { equals } from 'ramda';
|
||||||
import { FC, useLayoutEffect } from 'react';
|
import { FC, useLayoutEffect } from 'react';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//@ts-nocheck
|
||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
||||||
import { indexOf, isEmpty, length, map, mergeLeft, pluck, range } from 'ramda';
|
import { indexOf, isEmpty, length, map, mergeLeft, pluck, range } from 'ramda';
|
||||||
import { FC, useCallback, useContext, useMemo, useRef } from 'react';
|
import { FC, useCallback, useContext, useMemo, useRef } from 'react';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//@ts-nocheck
|
||||||
import { Box, Center, Text } from '@mantine/core';
|
import { Box, Center, Text } from '@mantine/core';
|
||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
||||||
import { includes, isEmpty, map, not, pipe, sort } from 'ramda';
|
import { includes, isEmpty, map, not, pipe, sort } from 'ramda';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//@ts-nocheck
|
||||||
import { Button, Group, Tooltip } from '@mantine/core';
|
import { Button, Group, Tooltip } from '@mantine/core';
|
||||||
import { notifications } from '@mantine/notifications';
|
import { notifications } from '@mantine/notifications';
|
||||||
import { IconFolder } from '@tabler/icons-react';
|
import { IconFolder } from '@tabler/icons-react';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//@ts-nocheck
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
Group,
|
Group,
|
||||||
|
@ -1,5 +1,70 @@
|
|||||||
import { FC } from 'react';
|
//@ts-nocheck
|
||||||
|
import EventEmitter from 'events';
|
||||||
|
import { find, gt, head, indexOf, isNil, lt, max, pluck, propEq } from 'ramda';
|
||||||
|
import { BaseSyntheticEvent, FC, useCallback, useContext, useMemo } from 'react';
|
||||||
|
import { useLifecycles, useMeasure } from 'react-use';
|
||||||
|
import { EventBusContext } from '../EventBus';
|
||||||
|
import { useFileListStore } from '../states/files';
|
||||||
|
import { useZoomState } from '../states/zoom';
|
||||||
|
|
||||||
export const SingleView: FC = () => {
|
export const SingleView: FC = () => {
|
||||||
return <div></div>;
|
const files = useFileListStore.use.files();
|
||||||
|
const actives = useFileListStore.use.actives();
|
||||||
|
const zoom = useZoomState.use.currentZoom();
|
||||||
|
const viewHeight = useZoomState.use.viewHeight();
|
||||||
|
const updateActives = useFileListStore.use.updateActiveFiles();
|
||||||
|
const ebus = useContext<EventEmitter>(EventBusContext);
|
||||||
|
const [pageConRef, { width: pageConWidth }] = useMeasure();
|
||||||
|
const activeFile = useMemo(() => {
|
||||||
|
let firstFile = head(actives);
|
||||||
|
return find(propEq('filename', firstFile), files);
|
||||||
|
}, [files, actives]);
|
||||||
|
const largerThanView = useMemo(() => {
|
||||||
|
if (isNil(activeFile)) return false;
|
||||||
|
let imageHeightAfterZoom = activeFile?.height * (zoom / 100);
|
||||||
|
return gt(imageHeightAfterZoom, viewHeight);
|
||||||
|
}, [activeFile, viewHeight, zoom]);
|
||||||
|
const handlePaginationAction = useCallback(
|
||||||
|
(event: BaseSyntheticEvent) => {
|
||||||
|
let middle = pageConWidth / 2;
|
||||||
|
let pagingDirection = lt(event.nativeEvent.offsetX, middle) ? -1 : 1;
|
||||||
|
let targetIndex = indexOf(activeFile?.filename, pluck('filename', files)) + pagingDirection;
|
||||||
|
updateActives([files[max(0, targetIndex)].filename]);
|
||||||
|
},
|
||||||
|
[files, activeFile, pageConWidth]
|
||||||
|
);
|
||||||
|
|
||||||
|
useLifecycles(
|
||||||
|
() => {
|
||||||
|
ebus?.addListener('navigate_offset', ({ filename }) => {
|
||||||
|
updateActives([filename]);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
ebus?.removeAllListeners('navigate_offset');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{ position: 'relative', overflow: 'auto', contain: 'strict', height: '100%' }}
|
||||||
|
onClick={handlePaginationAction}
|
||||||
|
ref={pageConRef}
|
||||||
|
>
|
||||||
|
{!isNil(activeFile) && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
justifyContent: largerThanView ? 'flex-start' : 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
width: '100%',
|
||||||
|
height: largerThanView ? '100%' : viewHeight
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img src={activeFile.path} style={{ width: `${zoom}%` }} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//@ts-nocheck
|
||||||
import { ColorScheme, ColorSchemeProvider, MantineProvider } from '@mantine/core';
|
import { ColorScheme, ColorSchemeProvider, MantineProvider } from '@mantine/core';
|
||||||
import { useColorScheme } from '@mantine/hooks';
|
import { useColorScheme } from '@mantine/hooks';
|
||||||
import { Notifications } from '@mantine/notifications';
|
import { Notifications } from '@mantine/notifications';
|
||||||
|
39
src/theme.ts
39
src/theme.ts
@ -1,17 +1,20 @@
|
|||||||
|
//@ts-nocheck
|
||||||
import { MantineTheme } from '@mantine/core';
|
import { MantineTheme } from '@mantine/core';
|
||||||
import { useColorScheme } from '@mantine/hooks';
|
import { useColorScheme } from '@mantine/hooks';
|
||||||
import { ifElse, path, propEq } from 'ramda';
|
import { ifElse, path, propEq } from 'ramda';
|
||||||
|
|
||||||
const bgColorSelectFn = ifElse(
|
const bgColorSelectFn = (lightIndex: number, darkIndex: number) =>
|
||||||
propEq('colorScheme', 'light'),
|
ifElse(
|
||||||
path(['colors', 'cbg', 8]),
|
propEq('colorScheme', 'light'),
|
||||||
path(['colors', 'cbg', 0])
|
path(['colors', 'cbg', lightIndex]),
|
||||||
);
|
path(['colors', 'cbg', darkIndex])
|
||||||
const fgColorSelectFn = ifElse(
|
);
|
||||||
propEq('colorScheme', 'light'),
|
const fgColorSelectFn = (lightIndex: number, darkIndex: number) =>
|
||||||
path(['colors', 'cfg', 0]),
|
ifElse(
|
||||||
path(['colors', 'cfg', 8])
|
propEq('colorScheme', 'light'),
|
||||||
);
|
path(['colors', 'cfg', lightIndex]),
|
||||||
|
path(['colors', 'cfg', darkIndex])
|
||||||
|
);
|
||||||
|
|
||||||
export function useAppTheme(): Partial<MantineTheme> {
|
export function useAppTheme(): Partial<MantineTheme> {
|
||||||
const colorScheme = useColorScheme();
|
const colorScheme = useColorScheme();
|
||||||
@ -50,11 +53,23 @@ export function useAppTheme(): Partial<MantineTheme> {
|
|||||||
globalStyles: theme => ({
|
globalStyles: theme => ({
|
||||||
'html, body': {
|
'html, body': {
|
||||||
height: '100vh',
|
height: '100vh',
|
||||||
color: fgColorSelectFn(theme),
|
color: fgColorSelectFn(0, 8)(theme),
|
||||||
backgroundColor: bgColorSelectFn(theme)
|
backgroundColor: bgColorSelectFn(8, 0)(theme)
|
||||||
},
|
},
|
||||||
'#root': {
|
'#root': {
|
||||||
height: '100%'
|
height: '100%'
|
||||||
|
},
|
||||||
|
'::-webkit-scrollbar': {
|
||||||
|
width: 4,
|
||||||
|
backgroundColor: bgColorSelectFn(6, 2)(theme)
|
||||||
|
},
|
||||||
|
'::-webkit-scrollbar-track': {
|
||||||
|
borderRadius: 2,
|
||||||
|
backgroundColor: 'transparent'
|
||||||
|
},
|
||||||
|
'::-webkit-scrollbar-thumb': {
|
||||||
|
borderRadius: 2,
|
||||||
|
backgroundColor: bgColorSelectFn(4, 4)(theme)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user