-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Migrated to Recoil state management library * Upgraded to Capacitor 4 * Store & retrieve animation settings from preferences * Store & retrieve background settings from preferences * Migrated to @capacitor/preferences (from cordova preferences) * Implemented dark mode setting * Fade when changing app theme
- Loading branch information
1 parent
4d40b83
commit 9385d16
Showing
16 changed files
with
191 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { StatusBar, Style } from '@capacitor/status-bar' | ||
import { Capacitor } from '@capacitor/core' | ||
|
||
export const matchDarkMode = window.matchMedia('(prefers-color-scheme: dark)') | ||
const darkModeListener = () => { | ||
setDarkMode.apply(matchDarkMode.matches) | ||
} | ||
|
||
export const setDarkMode = (darkMode = 'auto') => { | ||
const apply = (isDark: boolean) => { | ||
document.body.classList.toggle('dark', isDark) | ||
} | ||
|
||
if (darkMode === 'auto') { | ||
apply(matchDarkMode.matches) | ||
matchDarkMode.addEventListener('change', darkModeListener) | ||
} else { | ||
apply(darkMode === 'dark') | ||
} | ||
} | ||
|
||
export const statusBarListener = () => { | ||
setStatusBarTheme.apply(matchDarkMode.matches) | ||
} | ||
|
||
export const setStatusBarTheme = (darkMode = 'auto') => { | ||
const apply = (isDark: boolean) => { | ||
StatusBar.setBackgroundColor({ color: isDark ? '#000000' : '#FFFFFF' }) | ||
StatusBar.setStyle({ style: isDark ? Style.Dark : Style.Light }) | ||
} | ||
|
||
if (Capacitor.getPlatform() !== 'web') { | ||
if (darkMode === 'auto') { | ||
apply(matchDarkMode.matches) | ||
matchDarkMode.addEventListener('change', statusBarListener) | ||
} else { | ||
apply(darkMode === 'dark') | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.