Skip to content

Commit 96b2318

Browse files
authored
feat: add setting to follow the system theme (#690)
1 parent b943f26 commit 96b2318

File tree

19 files changed

+2233
-2104
lines changed

19 files changed

+2233
-2104
lines changed

.github/workflows/build-tauri.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
matrix:
2020
include:
21-
- os: ubuntu-22.04
21+
- os: ubuntu-latest
2222
name: linux
2323
# https://tauri.app/v1/guides/building/linux#cross-compiling-tauri-applications-for-arm-based-devices
2424
# Cross Compiling is also more of a pain it seems for linux atm, explore later
@@ -57,10 +57,10 @@ jobs:
5757
with:
5858
workspaces: "./app/tauri -> target"
5959
- name: install dependencies (ubuntu only)
60-
if: matrix.os == 'ubuntu-22.04'
60+
if: matrix.os == 'ubuntu-latest'
6161
run: |
6262
sudo apt-get update
63-
sudo apt-get install -y libwebkit2gtk-4.1 build-essential curl wget file libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev javascriptcoregtk-4.1
63+
sudo apt-get install -y libwebkit2gtk-4.1 build-essential curl wget file libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev javascriptcoregtk-4.1 libglib2.0-dev
6464
- name: Install NPM Packages
6565
run: |
6666
yarn install --immutable --network-timeout 120000
@@ -87,7 +87,7 @@ jobs:
8787
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
8888
APPLE_PROVIDER_SHORT_NAME: ${{ secrets.APPLE_PROVIDER_SHORT_NAME }}
8989
# Possibly set up some basic unit testing just to make sure parts render and none of the libraries are straight up breaking
90-
- uses: actions/upload-artifact@v3
90+
- uses: actions/upload-artifact@v4
9191
with:
9292
name: tauri-${{ matrix.name }}
9393
path: |
@@ -130,7 +130,7 @@ jobs:
130130
cache: "yarn"
131131
- name: Generate updater file
132132
run: node app/tauri/release-prep/release-prep.js
133-
- uses: actions/upload-artifact@v3
133+
- uses: actions/upload-artifact@v4
134134
with:
135135
name: tauri-release
136136
path: |

.github/workflows/build.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
runs-on: ${{ matrix.os }}
2727
steps:
2828
- name: Checkout
29-
uses: actions/checkout@v3
29+
uses: actions/checkout@v4
3030
- name: Setup node
3131
uses: actions/setup-node@v3
3232
with:
@@ -62,40 +62,40 @@ jobs:
6262
sudo snap install snapcraft --classic
6363
yarn lerna run build:snap --stream
6464
- name: Upload windows all-in-one build
65-
uses: actions/upload-artifact@v3
65+
uses: actions/upload-artifact@v4
6666
with:
6767
name: built-app-all-in-one-${{ matrix.name }}
6868
path: |
6969
app/electron/dist/Pomatez-v+([0-9]).+([0-9]).+([0-9])-win-*.exe
7070
- name: Upload ia32 builds
71-
uses: actions/upload-artifact@v3
71+
uses: actions/upload-artifact@v4
7272
with:
7373
name: built-app-ia32-${{ matrix.name }}
7474
path: |
7575
app/electron/dist/Pomatez*ia32*.*
7676
- name: Upload x64 builds
77-
uses: actions/upload-artifact@v3
77+
uses: actions/upload-artifact@v4
7878
with:
7979
name: built-app-x64-${{ matrix.name }}
8080
path: |
8181
app/electron/dist/Pomatez*x64*.*
8282
app/electron/dist/Pomatez*x86_64*.*
8383
app/electron/dist/Pomatez*amd64*.*
8484
- name: Upload arm64 builds
85-
uses: actions/upload-artifact@v3
85+
uses: actions/upload-artifact@v4
8686
with:
8787
name: built-app-arm64-${{ matrix.name }}
8888
path: |
8989
app/electron/dist/Pomatez*arm64*.*
9090
app/electron/dist/Pomatez*aarch64*.*
9191
- name: Upload armv7l builds
92-
uses: actions/upload-artifact@v3
92+
uses: actions/upload-artifact@v4
9393
with:
9494
name: built-app-armv7l-${{ matrix.name }}
9595
path: |
9696
app/electron/dist/Pomatez*armv7l*.*
9797
- name: Upload autoupdaters
98-
uses: actions/upload-artifact@v3
98+
uses: actions/upload-artifact@v4
9999
with:
100100
name: built-app-AutoUpdater-${{ matrix.name }}
101101
path: |

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ jobs:
3939

4040
steps:
4141
- name: Checkout repository
42-
uses: actions/checkout@v2
42+
uses: actions/checkout@v4
4343

4444
# Initializes the CodeQL tools for scanning.
4545
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@v2
46+
uses: github/codeql-action/init@v3
4747
with:
4848
languages: ${{ matrix.language }}
4949
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -54,7 +54,7 @@ jobs:
5454
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5555
# If this step fails, then you should remove it and run the build manually (see below)
5656
- name: Autobuild
57-
uses: github/codeql-action/autobuild@v2
57+
uses: github/codeql-action/autobuild@v3
5858

5959
# ℹ️ Command-line programs to run using the OS shell.
6060
# 📚 https://git.io/JvXDl
@@ -68,4 +68,4 @@ jobs:
6868
# make release
6969

7070
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v2
71+
uses: github/codeql-action/analyze@v3

.github/workflows/pre-commit-check.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ concurrency:
1111
jobs:
1212
pre-commit-check:
1313
name: Run pre-commit checks
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-latest
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1818
with:
1919
fetch-depth: 0
2020

@@ -28,14 +28,14 @@ jobs:
2828
2929
# run only if changed files were detected
3030
- name: Run against changes
31-
uses: pre-commit/action@v2.0.3
31+
uses: pre-commit/action@v3.0.1
3232
if: steps.filter.outputs.addedOrModified == 'true'
3333
with:
3434
extra_args: --files ${{ steps.filter.outputs.addedOrModified_files }}
3535

3636
# run if no changed files were detected (e.g. workflow_dispatch on master branch)
3737
- name: Run against all files
38-
uses: pre-commit/action@v2.0.3
38+
uses: pre-commit/action@v3.0.1
3939
if: steps.filter.outputs.addedOrModified != 'true'
4040
with:
4141
extra_args: --all-files

.github/workflows/website-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
deploy:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v4
1010
- name: Use Node.js 18.x
1111
uses: actions/setup-node@v2
1212
with:

.yarn/install-state.gz

-72.9 KB
Binary file not shown.

app/renderer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"@types/react-beautiful-dnd": "^13.0.0",
4747
"@types/react-dom": "^16.9.19",
4848
"@types/react-redux": "^7.1.9",
49-
"@types/react-router-dom": "^5.1.5",
49+
"@types/react-router-dom": "^5.3.3",
5050
"@types/styled-components": "^5.1.2",
5151
"autosize": "^4.0.4",
5252
"is-electron": "^2.2.0",

app/renderer/src/components/Toggler.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type TogglerProps = {
99
id: string;
1010
label: string;
1111
checked: boolean;
12+
disabled?: boolean;
1213
onChange?:
1314
| ((event: React.ChangeEvent<HTMLInputElement>) => void)
1415
| undefined;
@@ -19,6 +20,7 @@ const Toggler: React.FC<TogglerProps> = ({
1920
id,
2021
label,
2122
checked,
23+
disabled,
2224
onChange,
2325
style,
2426
}) => {
@@ -28,6 +30,7 @@ const Toggler: React.FC<TogglerProps> = ({
2830
<StyledTogglerSwitch
2931
type="checkbox"
3032
id={id}
33+
disabled={disabled}
3134
checked={checked}
3235
onChange={onChange}
3336
/>

app/renderer/src/contexts/ConnnectorContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ export const ConnectorProvider: React.FC = ({ children }) => {
3636
Connector = TauriConnectorProvider;
3737
}
3838

39-
return <Connector children={children} />;
39+
return <Connector>{children}</Connector>;
4040
};

app/renderer/src/contexts/ThemeContext.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useRef } from "react";
1+
import React, { useEffect, useRef } from "react";
22
import { isPreferredDark } from "utils";
33
import { GlobalStyles } from "styles";
44
import { useAppDispatch, useAppSelector } from "hooks/storeHooks";
@@ -24,6 +24,21 @@ const ThemeProvider: React.FC = ({ children }) => {
2424
dispatch(setEnableDarkTheme(!settings.enableDarkTheme));
2525
};
2626

27+
useEffect(() => {
28+
if (!settings.followSystemTheme) return;
29+
30+
const media = window.matchMedia("(prefers-color-scheme: dark)");
31+
const listener = (e: MediaQueryListEvent) => {
32+
dispatch(setEnableDarkTheme(e.matches));
33+
};
34+
// Ensure theme matches current system theme
35+
dispatch(setEnableDarkTheme(media.matches));
36+
media.addEventListener("change", listener);
37+
return () => {
38+
media.removeEventListener("change", listener);
39+
};
40+
}, [dispatch, settings.followSystemTheme]);
41+
2742
return (
2843
<ThemeContext.Provider
2944
value={{

0 commit comments

Comments
 (0)