diff --git a/.eslintrc.json b/.eslintrc.json index e54edb1..37fb724 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,7 @@ { "env": { "browser": true, - "es2020": true, + "es2021": true, "node": true }, "extends": [ @@ -12,7 +12,7 @@ "ecmaFeatures": { "jsx": true }, - "ecmaVersion": 11, + "ecmaVersion": 12, "sourceType": "module" }, "plugins": [ diff --git a/README.md b/README.md index fdc0ca1..22ea799 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ ![GitHub package.json version](https://img.shields.io/github/package-json/v/CodeDead/DeadHash-js) ![GitHub](https://img.shields.io/github/license/CodeDead/DeadHash-Js) -![GitHub Releases (by Release)](https://img.shields.io/github/downloads/CodeDead/DeadHash-js/2.1.0/total) +![GitHub Releases (by Release)](https://img.shields.io/github/downloads/CodeDead/DeadHash-js/2.1.1/total) -DeadHash is a free and open-source utility to calculate file and text hashes. The following hash calculations are supported: +DeadHash is a free and open-source utility to calculate file and text hashes and checksums. The following calculations are supported: * MD4 * MD5 @@ -16,9 +16,28 @@ DeadHash is a free and open-source utility to calculate file and text hashes. Th * SHA-384 * SHA-512 * RIPEMD-160 +* CRC32 This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app) and built using [Electron](https://electronjs.org/). +## Building + +In order to produce binary distributable files or to start a development build, you must first issue the following command, +in order to ensure that the React build is up-to-date: +``` +yarn react-build +``` + +After running `yarn react-build`, you can issue the following command in order to produce the binary distributable files: +``` +yarn build +``` + +If you want to start the development version, you can issue the following command, after running `yarn react-build`: +``` +yarn start +``` + ## Learn More You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). diff --git a/package.json b/package.json index 80ed71f..b673851 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "deadhash", - "version": "2.1.0", + "version": "2.1.1", "description": "File and text hash calculator", "homepage": "./", "private": true, @@ -37,6 +37,7 @@ "dependencies": { "@material-ui/core": "^4.11.3", "@material-ui/icons": "^4.11.2", + "crc": "^3.8.0", "cross-env": "^7.0.3", "electron-is-dev": "^1.2.0", "react": "^17.0.1", @@ -44,7 +45,7 @@ "react-dom": "^17.0.1", "react-router": "^5.2.0", "react-router-dom": "^5.2.0", - "react-scripts": "^4.0.1" + "react-scripts": "^4.0.2" }, "scripts": { "react-start": "react-scripts start", @@ -70,8 +71,9 @@ }, "devDependencies": { "concurrently": "^5.3.0", - "electron": "^11.2.1", + "electron": "^11.2.2", "electron-builder": "^22.9.1", + "eslint": "^7.19.0", "eslint-config-airbnb": "^18.2.1", "eslint-plugin-import": "^2.22.1", "eslint-plugin-jsx-a11y": "^6.4.1", diff --git a/public/workers/FileWorker/index.html b/public/workers/FileWorker/index.html index 570c2d1..35b2a9f 100644 --- a/public/workers/FileWorker/index.html +++ b/public/workers/FileWorker/index.html @@ -9,8 +9,9 @@ const ipcRenderer = window.require('electron').ipcRenderer; const fs = window.require('fs'); const crypto = window.require('crypto'); + const crc32Calculator = require('crc').crc32; - const fileHash = (filePath, md4, md5, sha1, sha224, sha256, sha384, sha512, ripemd160) => { + const fileHash = (filePath, md4, md5, sha1, sha224, sha256, sha384, sha512, ripemd160, crc32) => { return new Promise((resolve, reject) => { let MD4, MD5, @@ -19,7 +20,8 @@ SHA256, SHA384, SHA512, - RIPEMD160; + RIPEMD160, + crc32Checksum; if (md4) MD4 = crypto.createHash('md4'); if (md5) MD5 = crypto.createHash('md5'); @@ -30,6 +32,7 @@ if (sha512) SHA512 = crypto.createHash('sha512'); if (ripemd160) RIPEMD160 = crypto.createHash('ripemd160'); + try { const s = fs.createReadStream(filePath.toString()); @@ -42,6 +45,7 @@ if (sha384) SHA384.update(data); if (sha512) SHA512.update(data); if (ripemd160) RIPEMD160.update(data); + if (crc32) crc32Checksum = crc32Calculator(data, crc32Checksum); }); s.on('end', () => { @@ -103,6 +107,12 @@ .toString() }); } + if (crc32) { + newHashes.push({ + type: 'CRC32', + hash: crc32Checksum.toString(16), + }); + } if (newHashes.length === 0) newHashes = null; @@ -120,7 +130,7 @@ } ipcRenderer.on("calculate-file-hash", (e, data) => { - fileHash(data.filePath, data.md4, data.md5, data.sha1, data.sha224, data.sha256, data.sha384, data.sha512, data.ripemd160) + fileHash(data.filePath, data.md4, data.md5, data.sha1, data.sha224, data.sha256, data.sha384, data.sha512, data.ripemd160, data.crc32) .then(data => { ipcRenderer.send("file-hash-calculated", data); }) diff --git a/public/workers/TextWorker/index.html b/public/workers/TextWorker/index.html index b03b819..83f411c 100644 --- a/public/workers/TextWorker/index.html +++ b/public/workers/TextWorker/index.html @@ -9,7 +9,7 @@ const ipcRenderer = window.require('electron').ipcRenderer; const crypto = window.require('crypto'); - const textHash = (text, md4, md5, sha1, sha224, sha256, sha384, sha512, ripemd160) => { + const textHash = (text, md4, md5, sha1, sha224, sha256, sha384, sha512, ripemd160, crc32) => { return new Promise((resolve, reject) => { let newHashes = []; try { @@ -85,6 +85,13 @@ .toString() }); } + if (crc32) { + const { crc32 } = require('crc'); + newHashes.push({ + type: 'CRC32', + hash: crc32(text).toString(16), + }); + } if (newHashes.length === 0) newHashes = null; @@ -96,7 +103,7 @@ }; ipcRenderer.on('calculate-text-hash', (e, data) => { - textHash(data.text, data.md4, data.md5, data.sha1, data.sha224, data.sha256, data.sha384, data.sha512, data.ripemd160) + textHash(data.text, data.md4, data.md5, data.sha1, data.sha224, data.sha256, data.sha384, data.sha512, data.ripemd160, data.crc32) .then(data => { ipcRenderer.send('text-hash-calculated', data); }) diff --git a/src/components/App/index.jsx b/src/components/App/index.jsx index 2cd5ec5..e4314ed 100644 --- a/src/components/App/index.jsx +++ b/src/components/App/index.jsx @@ -5,7 +5,7 @@ import { createMuiTheme, ThemeProvider } from '@material-ui/core/styles'; import Home from '../../routes/Home'; import Settings from '../../routes/Settings'; import ThemeSelector from '../../utils/ThemeSelector'; -import Topbar from '../Topbar'; +import TopBar from '../TopBar'; import About from '../../routes/About'; import File from '../../routes/File'; import Text from '../../routes/Text'; @@ -71,7 +71,7 @@ const App = () => { - + diff --git a/src/components/Drawerbar/index.jsx b/src/components/DrawerBar/index.jsx similarity index 98% rename from src/components/Drawerbar/index.jsx rename to src/components/DrawerBar/index.jsx index 99bf3c2..2486a44 100644 --- a/src/components/Drawerbar/index.jsx +++ b/src/components/DrawerBar/index.jsx @@ -37,7 +37,7 @@ const useStyles = makeStyles((theme) => ({ const { ipcRenderer } = window.require('electron'); -const Drawerbar = ({ open, onClose }) => { +const DrawerBar = ({ open, onClose }) => { const [state] = useContext(MainContext); const language = state.languages[state.languageIndex]; const selectedItem = state.selectedListItem; @@ -145,4 +145,4 @@ const Drawerbar = ({ open, onClose }) => { ); }; -export default Drawerbar; +export default DrawerBar; diff --git a/src/components/Topbar/index.jsx b/src/components/TopBar/index.jsx similarity index 89% rename from src/components/Topbar/index.jsx rename to src/components/TopBar/index.jsx index 30bfc56..c5a963d 100644 --- a/src/components/Topbar/index.jsx +++ b/src/components/TopBar/index.jsx @@ -9,11 +9,13 @@ import MenuIcon from '@material-ui/icons/Menu'; import Menu from '@material-ui/core/Menu'; import MenuItem from '@material-ui/core/MenuItem'; import CloseIcon from '@material-ui/icons/Close'; +import Brightness5Icon from '@material-ui/icons/Brightness5'; +import Brightness7Icon from '@material-ui/icons/Brightness7'; import MinimizeIcon from '@material-ui/icons/Minimize'; import FullScreenIcon from '@material-ui/icons/Fullscreen'; import FullscreenExitIcon from '@material-ui/icons/FullscreenExit'; -import Drawerbar from '../Drawerbar'; -import { setLanguageIndex } from '../../reducers/MainReducer/Actions'; +import DrawerBar from '../DrawerBar'; +import { setLanguageIndex, setThemeStyle } from '../../reducers/MainReducer/Actions'; import { MainContext } from '../../contexts/MainContextProvider'; const drawerWidth = 220; @@ -45,11 +47,16 @@ const useStyles = makeStyles((theme) => ({ const { ipcRenderer } = window.require('electron'); -const Topbar = () => { +const TopBar = () => { const [state, d1] = useContext(MainContext); const { - languageIndex, minimizeEnabled, maximizeEnabled, languageEnabled, + languageIndex, + minimizeEnabled, + maximizeEnabled, + languageEnabled, + themeStyle, + themeToggleEnabled, } = state; const language = state.languages[languageIndex]; @@ -124,6 +131,13 @@ const Topbar = () => { ipcRenderer.send('handle-maximize'); }; + /** + * Change the theme style + */ + const changeThemeStyle = () => { + d1(setThemeStyle(themeStyle === 'dark' ? 'light' : 'dark')); + }; + return (
{ {language.appName} + {themeToggleEnabled ? ( + + {themeStyle === 'dark' ? : } + + ) : null} + {languageEnabled ? (
@@ -264,10 +284,10 @@ const Topbar = () => { - setDrawerOpen(false)} /> + setDrawerOpen(false)} />
); }; -export default Topbar; +export default TopBar; diff --git a/src/contexts/CryptoContextReducer/index.jsx b/src/contexts/CryptoContextReducer/index.jsx index 2437bb9..ce354cc 100644 --- a/src/contexts/CryptoContextReducer/index.jsx +++ b/src/contexts/CryptoContextReducer/index.jsx @@ -9,6 +9,7 @@ const sha256 = localStorage.sha256 && localStorage.sha256 === 'true' ? true : !l const sha384 = localStorage.sha384 && localStorage.sha384 === 'true' ? true : !localStorage.sha384; const sha512 = localStorage.sha512 && localStorage.sha512 === 'true' ? true : !localStorage.sha512; const ripemd160 = localStorage.ripemd160 && localStorage.ripemd160 === 'true' ? true : !localStorage.ripemd160; +const crc32 = localStorage.crc32 && localStorage.crc32 === 'true' ? true : !localStorage.crc32; const initState = { md4, @@ -19,6 +20,7 @@ const initState = { sha384, sha512, ripemd160, + crc32, fileHashes: null, textHashes: null, textInput: '', diff --git a/src/contexts/MainContextProvider/index.jsx b/src/contexts/MainContextProvider/index.jsx index f53eed5..0213076 100644 --- a/src/contexts/MainContextProvider/index.jsx +++ b/src/contexts/MainContextProvider/index.jsx @@ -28,6 +28,7 @@ const autoUpdate = localStorage.autoUpdate && localStorage.autoUpdate === 'true' const minimizeEnabled = localStorage.minimizeEnabled && localStorage.minimizeEnabled === 'true' ? true : !localStorage.minimizeEnabled; const maximizeEnabled = localStorage.maximizeEnabled && localStorage.maximizeEnabled === 'true' ? true : !localStorage.maximizeEnabled; const languageEnabled = localStorage.languageEnabled && localStorage.languageEnabled === 'true' ? true : !localStorage.languageEnabled; +const themeToggleEnabled = localStorage.themeToggleEnabled && localStorage.themeToggleEnabled === 'true' ? true : !localStorage.themeToggleEnabled; const canDragDrop = localStorage.canDragDrop && localStorage.canDragDrop === 'true' ? true : !localStorage.canDragDrop; const initState = { @@ -53,6 +54,7 @@ const initState = { minimizeEnabled, maximizeEnabled, languageEnabled, + themeToggleEnabled, canDragDrop, }; diff --git a/src/languages/de_DE/index.js b/src/languages/de_DE/index.js index 87015a3..778f363 100644 --- a/src/languages/de_DE/index.js +++ b/src/languages/de_DE/index.js @@ -40,6 +40,7 @@ const de_DE = () => ({ sha512: 'SHA-512', ripemd160: 'RIPEMD-160', sha224: 'SHA-224', + crc32: 'CRC32', file: 'Datei', fileSubtitle: 'Berechnen Sie Datei-Hashes', text: 'Text', @@ -80,6 +81,7 @@ const de_DE = () => ({ dark: 'Dunkel', orange: 'Orange', orangeThemeDescription: 'Lass uns Niederländisch werden.', + themeToggleEnabled: 'Thema umschalten', }); // eslint-disable-next-line camelcase diff --git a/src/languages/en_US/index.js b/src/languages/en_US/index.js index 5322481..19c90c5 100644 --- a/src/languages/en_US/index.js +++ b/src/languages/en_US/index.js @@ -40,6 +40,7 @@ const en_US = () => ({ sha512: 'SHA-512', ripemd160: 'RIPEMD-160', sha224: 'SHA-224', + crc32: 'CRC32', file: 'File', fileSubtitle: 'Calculate file hashes', text: 'Text', @@ -80,6 +81,7 @@ const en_US = () => ({ dark: 'Dark', orange: 'Orange', orangeThemeDescription: 'Let\'s get Dutch.', + themeToggleEnabled: 'Theme toggle', }); // eslint-disable-next-line camelcase diff --git a/src/languages/es_ES/index.js b/src/languages/es_ES/index.js index 5f39ea5..95ca675 100644 --- a/src/languages/es_ES/index.js +++ b/src/languages/es_ES/index.js @@ -40,6 +40,7 @@ const es_ES = () => ({ sha512: 'SHA-512', ripemd160: 'RIPEMD-160', sha224: 'SHA-224', + crc32: 'CRC32', file: 'Archivo', fileSubtitle: 'Calcular hashes de archivos', text: 'Texto', @@ -80,6 +81,7 @@ const es_ES = () => ({ dark: 'Oscuro', orange: 'Naranja', orangeThemeDescription: 'Vamos a holandeses.', + themeToggleEnabled: 'Alternar tema', }); // eslint-disable-next-line camelcase diff --git a/src/languages/fr_FR/index.js b/src/languages/fr_FR/index.js index c8415ea..2210359 100644 --- a/src/languages/fr_FR/index.js +++ b/src/languages/fr_FR/index.js @@ -40,6 +40,7 @@ const fr_FR = () => ({ sha512: 'SHA-512', ripemd160: 'RIPEMD-160', sha224: 'SHA-224', + crc32: 'CRC32', file: 'File', fileSubtitle: 'Calculer les hachages de fichier', text: 'Texte', @@ -80,6 +81,7 @@ const fr_FR = () => ({ dark: 'Foncé', orange: 'Orange', orangeThemeDescription: 'Il faut que ça Néerlandais.', + themeToggleEnabled: 'Basculer le thème', }); // eslint-disable-next-line camelcase diff --git a/src/languages/it_IT/index.js b/src/languages/it_IT/index.js index 80c3c1a..1e2dc00 100644 --- a/src/languages/it_IT/index.js +++ b/src/languages/it_IT/index.js @@ -40,6 +40,7 @@ const it_IT = () => ({ sha512: 'SHA-512', ripemd160: 'RIPEMD-160', sha224: 'SHA-224', + crc32: 'CRC32', file: 'File', fileSubtitle: 'Calcola gli hash dei file', text: 'Testo', @@ -80,6 +81,7 @@ const it_IT = () => ({ dark: 'Buio', orange: 'Arancia', orangeThemeDescription: 'Prendiamo l\'olandese.', + themeToggleEnabled: 'Commutazione del tema', }); // eslint-disable-next-line camelcase diff --git a/src/languages/jp_JP/index.js b/src/languages/jp_JP/index.js index ace5caf..4e68003 100644 --- a/src/languages/jp_JP/index.js +++ b/src/languages/jp_JP/index.js @@ -40,6 +40,7 @@ const jp_JP = () => ({ sha512: 'SHA-512', ripemd160: 'RIPEMD-160', sha224: 'SHA-224', + crc32: 'CRC32', file: 'ファイル', fileSubtitle: 'ファイルハッシュの計算', text: 'テキスト', @@ -80,6 +81,7 @@ const jp_JP = () => ({ dark: '闇', orange: 'オレンジ', orangeThemeDescription: 'オランダ語を取得しましょう。', + themeToggleEnabled: 'テーマの切り替え', }); // eslint-disable-next-line camelcase diff --git a/src/languages/nl_NL/index.js b/src/languages/nl_NL/index.js index 2ed934a..af14b8f 100644 --- a/src/languages/nl_NL/index.js +++ b/src/languages/nl_NL/index.js @@ -40,6 +40,7 @@ const nl_NL = () => ({ sha512: 'SHA-512', ripemd160: 'RIPEMD-160', sha224: 'SHA-224', + crc32: 'CRC32', file: 'Bestand', fileSubtitle: 'Bereken bestand hashes', text: 'Tekst', @@ -80,6 +81,7 @@ const nl_NL = () => ({ dark: 'Donker', orange: 'Oranje', orangeThemeDescription: 'Op z\'n Nederlands.', + themeToggleEnabled: 'Thema wisselen', }); // eslint-disable-next-line camelcase diff --git a/src/languages/pt_PT/index.js b/src/languages/pt_PT/index.js index 7d49949..9c921cd 100644 --- a/src/languages/pt_PT/index.js +++ b/src/languages/pt_PT/index.js @@ -40,6 +40,7 @@ const pt_PT = () => ({ sha512: 'SHA-512', ripemd160: 'RIPEMD-160', sha224: 'SHA-224', + crc32: 'CRC32', file: 'Arquivo', fileSubtitle: 'Calcular hashes de arquivo', text: 'Texto', @@ -80,6 +81,7 @@ const pt_PT = () => ({ dark: 'Sombrio', orange: 'Laranja', orangeThemeDescription: 'Vamos para o holandês.', + themeToggleEnabled: 'Alternar tema', }); // eslint-disable-next-line camelcase diff --git a/src/languages/ru_RU/index.js b/src/languages/ru_RU/index.js index 9aca48d..269bfbc 100644 --- a/src/languages/ru_RU/index.js +++ b/src/languages/ru_RU/index.js @@ -40,6 +40,7 @@ const ru_RU = () => ({ sha512: 'SHA-512', ripemd160: 'RIPEMD-160', sha224: 'SHA-224', + crc32: 'CRC32', file: 'файл', fileSubtitle: 'Рассчитать хэши файлов', text: 'Текст', @@ -80,6 +81,7 @@ const ru_RU = () => ({ dark: 'Тьма', orange: 'Оранжевый', orangeThemeDescription: 'Давайте перейдем к голландскому.', + themeToggleEnabled: 'Переключение темы', }); // eslint-disable-next-line camelcase diff --git a/src/languages/tr_TR/index.js b/src/languages/tr_TR/index.js index 1808bf8..3ad0b01 100644 --- a/src/languages/tr_TR/index.js +++ b/src/languages/tr_TR/index.js @@ -40,6 +40,7 @@ const tr_TR = () => ({ sha512: 'SHA-512', ripemd160: 'RIPEMD-160', sha224: 'SHA-224', + crc32: 'CRC32', file: 'Dosya', fileSubtitle: 'Dosya karmaları hesapla', text: 'Metin', @@ -80,6 +81,7 @@ const tr_TR = () => ({ dark: 'Karanlık', orange: 'Turuncu', orangeThemeDescription: 'Dutch alalım.', + themeToggleEnabled: 'Tema geçişi', }); // eslint-disable-next-line camelcase diff --git a/src/reducers/CryptoReducer/Actions/actionTypes.js b/src/reducers/CryptoReducer/Actions/actionTypes.js index 98bdb8d..0965fdb 100644 --- a/src/reducers/CryptoReducer/Actions/actionTypes.js +++ b/src/reducers/CryptoReducer/Actions/actionTypes.js @@ -6,6 +6,7 @@ export const SET_SHA384_STATE = 'SET_SHA384_STATE'; export const SET_SHA512_STATE = 'SET_SHA512_STATE'; export const SET_RIPEMD160_STATE = 'SET_RIPEMD160_STATE'; export const SET_SHA224_STATE = 'SET_SHA224_STATE'; +export const SET_CRC32_STATE = 'SET_CRC32_STATE'; export const RESET_CRYPTO_REDUCER = 'RESET_CRYPTO_REDUCER'; export const SET_FILE_HASHES = 'SET_FILE_HASHES'; export const SET_TEXT_HASHES = 'SET_TEXT_HASHES'; diff --git a/src/reducers/CryptoReducer/Actions/index.js b/src/reducers/CryptoReducer/Actions/index.js index 2fcfba1..85fb5df 100644 --- a/src/reducers/CryptoReducer/Actions/index.js +++ b/src/reducers/CryptoReducer/Actions/index.js @@ -1,5 +1,6 @@ import { RESET_CRYPTO_REDUCER, + SET_CRC32_STATE, SET_CURRENT_FILE, SET_FILE_COMPARE_HASH, SET_FILE_COMPARING, @@ -62,6 +63,11 @@ export const setSha224State = (state) => ({ payload: state, }); +export const setCrc32State = (state) => ({ + type: SET_CRC32_STATE, + payload: state, +}); + export const resetCryptoReducer = () => ({ type: RESET_CRYPTO_REDUCER, }); diff --git a/src/reducers/CryptoReducer/index.js b/src/reducers/CryptoReducer/index.js index bc5df3b..0353635 100644 --- a/src/reducers/CryptoReducer/index.js +++ b/src/reducers/CryptoReducer/index.js @@ -1,5 +1,6 @@ import { RESET_CRYPTO_REDUCER, + SET_CRC32_STATE, SET_CURRENT_FILE, SET_FILE_COMPARE_HASH, SET_FILE_COMPARING, @@ -74,6 +75,12 @@ const CryptoReducer = (state, action) => { ...state, sha224: action.payload, }; + case SET_CRC32_STATE: + localStorage.crc32 = action.payload; + return { + ...state, + crc32: action.payload, + }; case RESET_CRYPTO_REDUCER: localStorage.md4 = true; localStorage.md5 = true; @@ -83,6 +90,7 @@ const CryptoReducer = (state, action) => { localStorage.sha512 = true; localStorage.ripemd160 = true; localStorage.sha224 = true; + localStorage.crc32 = true; return { ...state, @@ -94,6 +102,7 @@ const CryptoReducer = (state, action) => { sha384: true, sha512: true, ripemd160: true, + crc32: true, }; case SET_TEXT_HASHES: return { diff --git a/src/reducers/MainReducer/Actions/actionTypes.js b/src/reducers/MainReducer/Actions/actionTypes.js index 53b6668..85f632d 100644 --- a/src/reducers/MainReducer/Actions/actionTypes.js +++ b/src/reducers/MainReducer/Actions/actionTypes.js @@ -8,4 +8,5 @@ export const RESET_MAIN_REDUCER = 'RESET_MAIN_REDUCER'; export const SET_MINIMIZE_STATUS = 'SET_MINIMIZE_STATUS'; export const SET_MAXIMIZE_STATUS = 'SET_MAXIMIZE_STATUS'; export const SET_LANGUAGE_STATUS = 'SET_LANGUAGE_STATUS'; +export const SET_THEME_TOGGLE_STATUS = 'SET_THEME_TOGGLE_STATUS'; export const SET_CAN_DRAG_DROP = 'SET_CAN_DRAG_DROP'; diff --git a/src/reducers/MainReducer/Actions/index.js b/src/reducers/MainReducer/Actions/index.js index 1a889c4..624014b 100644 --- a/src/reducers/MainReducer/Actions/index.js +++ b/src/reducers/MainReducer/Actions/index.js @@ -9,6 +9,7 @@ import { SET_MINIMIZE_STATUS, SET_THEME_INDEX, SET_THEME_STYLE, + SET_THEME_TOGGLE_STATUS, SET_UPDATE_CHECKED, } from './actionTypes'; @@ -61,6 +62,11 @@ export const setLanguageButtonStatus = (status) => ({ payload: status, }); +export const setThemeToggleStatus = (status) => ({ + type: SET_THEME_TOGGLE_STATUS, + payload: status, +}); + export const setCanDragDrop = (status) => ({ type: SET_CAN_DRAG_DROP, payload: status, diff --git a/src/reducers/MainReducer/index.js b/src/reducers/MainReducer/index.js index 6b8f371..a748937 100644 --- a/src/reducers/MainReducer/index.js +++ b/src/reducers/MainReducer/index.js @@ -9,6 +9,7 @@ import { SET_MINIMIZE_STATUS, SET_THEME_INDEX, SET_THEME_STYLE, + SET_THEME_TOGGLE_STATUS, SET_UPDATE_CHECKED, } from './Actions/actionTypes'; @@ -52,22 +53,26 @@ const MainReducer = (state, action) => { }; case RESET_MAIN_REDUCER: localStorage.languageIndex = 1; + localStorage.themeStyle = 'light'; localStorage.themeIndex = 0; localStorage.autoUpdate = true; localStorage.minimizeEnabled = true; localStorage.maximizeEnabled = true; localStorage.languageEnabled = true; localStorage.canDragDrop = true; + localStorage.themeToggleEnabled = true; return { ...state, languageIndex: 1, + themeStyle: 'light', themeIndex: 0, autoUpdate: true, minimizeEnabled: true, maximizeEnabled: true, languageEnabled: true, canDragDrop: true, + themeToggleEnabled: true, }; case SET_MINIMIZE_STATUS: localStorage.minimizeEnabled = action.payload; @@ -87,6 +92,12 @@ const MainReducer = (state, action) => { ...state, languageEnabled: action.payload, }; + case SET_THEME_TOGGLE_STATUS: + localStorage.themeToggleEnabled = action.payload; + return { + ...state, + themeToggleEnabled: action.payload, + }; case SET_CAN_DRAG_DROP: localStorage.canDragDrop = action.payload; return { diff --git a/src/routes/File/index.jsx b/src/routes/File/index.jsx index c9f4f06..01d0c01 100644 --- a/src/routes/File/index.jsx +++ b/src/routes/File/index.jsx @@ -59,7 +59,7 @@ const File = () => { const file = crypto.currentFile; const { - md4, md5, sha1, sha224, sha256, sha384, sha512, ripemd160, + md4, md5, sha1, sha224, sha256, sha384, sha512, ripemd160, crc32, } = crypto; const compare = crypto.fileComparing; @@ -146,6 +146,7 @@ const File = () => { sha384, sha512, ripemd160, + crc32, }); }; diff --git a/src/routes/Settings/index.jsx b/src/routes/Settings/index.jsx index 7928b41..e0f16a0 100644 --- a/src/routes/Settings/index.jsx +++ b/src/routes/Settings/index.jsx @@ -34,14 +34,21 @@ import GridList from '../../components/GridList'; import { resetMainReducer, setActiveListItem, - setAutoUpdate, setCanDragDrop, setLanguageButtonStatus, - setLanguageIndex, setMaximizeStatus, setMinimizeStatus, - setThemeIndex, setThemeStyle, + setAutoUpdate, + setCanDragDrop, + setLanguageButtonStatus, + setLanguageIndex, + setMaximizeStatus, + setMinimizeStatus, + setThemeIndex, + setThemeStyle, + setThemeToggleStatus, } from '../../reducers/MainReducer/Actions'; import { MainContext } from '../../contexts/MainContextProvider'; import { CryptoContext } from '../../contexts/CryptoContextReducer'; import { - resetCryptoReducer, setMd4State, + resetCryptoReducer, + setMd4State, setMd5State, setRipeMd160State, setSha1State, @@ -49,6 +56,7 @@ import { setSha256State, setSha384State, setSha512State, + setCrc32State, } from '../../reducers/CryptoReducer/Actions'; const useStyles = makeStyles((theme) => ({ @@ -82,17 +90,22 @@ const Settings = () => { const [state, d1] = useContext(MainContext); const [crypto, d2] = useContext(CryptoContext); - const { themeIndex, themeStyle } = state; - const { languageIndex } = state; + const { + themeIndex, + themeStyle, + languageIndex, + canDragDrop, + minimizeEnabled, + maximizeEnabled, + languageEnabled, + autoUpdate, + themeToggleEnabled, + } = state; + const language = state.languages[languageIndex]; - const dragDrop = state.canDragDrop; - const { autoUpdate } = state; - const minimize = state.minimizeEnabled; - const maximize = state.maximizeEnabled; - const languageStatus = state.languageEnabled; const { - md4, md5, sha1, sha224, sha256, sha384, sha512, ripemd160, + md4, md5, sha1, sha224, sha256, sha384, sha512, ripemd160, crc32, } = crypto; const [errorMessage, setErrorMessage] = useState(null); @@ -229,9 +242,9 @@ const Settings = () => { d1(setCanDragDrop(e.target.checked))} - value="dragDrop" + value="canDragDrop" color="primary" /> )} @@ -240,9 +253,9 @@ const Settings = () => { d1(setMinimizeStatus(e.target.checked))} - value="minimize" + value="minimizeEnabled" color="primary" /> )} @@ -251,9 +264,9 @@ const Settings = () => { d1(setMaximizeStatus(e.target.checked))} - value="maximize" + value="maximizeEnabled" color="primary" /> )} @@ -262,14 +275,25 @@ const Settings = () => { d1(setLanguageButtonStatus(e.target.checked))} - value="language" + value="languageEnabled" color="primary" /> )} label={language.languageEnabled} /> + d1(setThemeToggleStatus(e.target.checked))} + value="themeToggleEnabled" + color="primary" + /> + )} + label={language.themeToggleEnabled} + /> {language.language}