Files
klatab/common/colors.tsx
2024-09-15 14:36:20 +02:00

71 lines
2.0 KiB
TypeScript

import { useContext } from 'react';
import { useColorScheme } from 'react-native';
import { SettingsContext } from '../SettingsProvider';
import { Appearance } from 'react-native';
export const useColors = () => {
let colorTheme = useColorScheme(); // Device color scheme (light or dark)
const { settings } = useContext(SettingsContext); // Accessing user settings
if (settings && !settings.systemTheme) {
colorTheme = settings.darkTheme ? 'dark' : 'light'; // Use user-defined setting if not following system
}
// Return the appropriate color scheme based on the color theme
return colorTheme === 'dark' ? darkModeColors : lightModeColors;
};
export const useDayColors = () => {
let colorTheme = useColorScheme(); // Device color scheme (light or dark)
const { settings } = useContext(SettingsContext); // Accessing user settings
if (settings && !settings.systemTheme) {
colorTheme = settings.darkTheme ? 'dark' : 'light'; // Use user-defined setting if not following system
}
// Return the appropriate color scheme based on the color theme
return colorTheme === 'dark' ? darkModeDayColors : lightModeDayColors;
};
const lightModeColors = {
theme: 'light',
primary: '#4CAF50',
secondary: '#8AE44E',
accent: '#e600c7',
backPrimary: '#f2f2f2',
backSecondary: '#E3E3E3',
text: '#040404',
textDisabled: '#b7b7b7',
textAccent: '#9a9a9a',
};
const darkModeColors = {
theme: 'dark',
primary: '#4CAF50',
secondary: '#8AE44E',
accent: '#80006f',
backPrimary: '#3D3D3D',
backSecondary: '#2A2A2A',
text: '#F1F1F1',
textDisabled: '#808080',
textAccent: '#9c9c9c',
};
const lightModeDayColors = {
schoolday: lightModeColors.backPrimary,
weekend: '#8bb6f8',
holiday: '#4c6ba8',
bridgeday: '#c5dbff',
vacation: '#c5dbff',
examday: '#FFD700'
};
const darkModeDayColors = {
schoolday: darkModeColors.backPrimary,
weekend: '#1a439c',
holiday: '#4080ff',
bridgeday: '#3f63b2',
vacation: '#3f63b2',
examday: '#808000'
};