mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
refactor
This commit is contained in:
@@ -6,7 +6,7 @@ import isEqual from 'lodash/isEqual'
|
|||||||
import { useCreateCacheMap } from '../customHooks'
|
import { useCreateCacheMap } from '../customHooks'
|
||||||
import getShortCacheMap from './getShortCacheMap'
|
import getShortCacheMap from './getShortCacheMap'
|
||||||
import { SnakeWrapper, ScrollNotification } from './style'
|
import { SnakeWrapper, ScrollNotification } from './style'
|
||||||
import { readerColor, rangeColor, createGradient, snakeSettings } from './snakeSettings'
|
import { createGradient, snakeSettings } from './snakeSettings'
|
||||||
|
|
||||||
const TorrentCache = ({ cache, isMini }) => {
|
const TorrentCache = ({ cache, isMini }) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@@ -16,8 +16,17 @@ const TorrentCache = ({ cache, isMini }) => {
|
|||||||
const ctxRef = useRef(null)
|
const ctxRef = useRef(null)
|
||||||
const cacheMap = useCreateCacheMap(cache)
|
const cacheMap = useCreateCacheMap(cache)
|
||||||
const settingsTarget = isMini ? 'mini' : 'default'
|
const settingsTarget = isMini ? 'mini' : 'default'
|
||||||
const { borderWidth, pieceSize, gapBetweenPieces, backgroundColor, borderColor, cacheMaxHeight, completeColor } =
|
const {
|
||||||
snakeSettings[settingsTarget]
|
readerColor,
|
||||||
|
rangeColor,
|
||||||
|
borderWidth,
|
||||||
|
pieceSize,
|
||||||
|
gapBetweenPieces,
|
||||||
|
backgroundColor,
|
||||||
|
borderColor,
|
||||||
|
cacheMaxHeight,
|
||||||
|
completeColor,
|
||||||
|
} = snakeSettings[settingsTarget]
|
||||||
|
|
||||||
const canvasWidth = isMini ? width * 0.93 : width
|
const canvasWidth = isMini ? width * 0.93 : width
|
||||||
|
|
||||||
@@ -91,6 +100,8 @@ const TorrentCache = ({ cache, isMini }) => {
|
|||||||
borderWidth,
|
borderWidth,
|
||||||
settingsTarget,
|
settingsTarget,
|
||||||
completeColor,
|
completeColor,
|
||||||
|
readerColor,
|
||||||
|
rangeColor,
|
||||||
])
|
])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
export const readerColor = '#000'
|
|
||||||
export const rangeColor = '#afa6e3'
|
|
||||||
|
|
||||||
export const snakeSettings = {
|
export const snakeSettings = {
|
||||||
default: {
|
default: {
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
@@ -10,6 +7,8 @@ export const snakeSettings = {
|
|||||||
completeColor: '#00a572',
|
completeColor: '#00a572',
|
||||||
backgroundColor: '#fff',
|
backgroundColor: '#fff',
|
||||||
progressColor: '#b3dfc9',
|
progressColor: '#b3dfc9',
|
||||||
|
readerColor: '#000',
|
||||||
|
rangeColor: '#afa6e3',
|
||||||
},
|
},
|
||||||
mini: {
|
mini: {
|
||||||
cacheMaxHeight: 340,
|
cacheMaxHeight: 340,
|
||||||
@@ -20,11 +19,14 @@ export const snakeSettings = {
|
|||||||
completeColor: '#4db380',
|
completeColor: '#4db380',
|
||||||
backgroundColor: '#dbf2e8',
|
backgroundColor: '#dbf2e8',
|
||||||
progressColor: '#dbf2e8',
|
progressColor: '#dbf2e8',
|
||||||
|
readerColor: '#2d714f',
|
||||||
|
rangeColor: '#afa6e3',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createGradient = (ctx, percentage, snakeType) => {
|
export const createGradient = (ctx, percentage, snakeType) => {
|
||||||
const { pieceSize, completeColor, progressColor } = snakeSettings[snakeType]
|
const { pieceSize, completeColor, progressColor } = snakeSettings[snakeType]
|
||||||
|
|
||||||
const gradient = ctx.createLinearGradient(0, pieceSize, 0, 0)
|
const gradient = ctx.createLinearGradient(0, pieceSize, 0, 0)
|
||||||
gradient.addColorStop(0, completeColor)
|
gradient.addColorStop(0, completeColor)
|
||||||
gradient.addColorStop(percentage / 100, completeColor)
|
gradient.addColorStop(percentage / 100, completeColor)
|
||||||
|
|||||||
Reference in New Issue
Block a user