This repository has been archived by the owner on May 9, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 148
/
Copy pathcolors.ts
executable file
·91 lines (74 loc) · 1.95 KB
/
colors.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* Style colors
* @file Theme 主题/颜色配置
* @module app/colors
* @author Surmon <https://github.com/surmon-china>
*/
import { observable } from 'mobx'
import { Appearance } from 'react-native-appearance'
export enum Themes {
Default = 'default',
Dark = 'Dark'
}
type ThemeKey =
| 'primary'// 主题色
| 'secondary' // 次要主题色
| 'primary' // 主题色
| 'secondary' // 次要主题色
| 'accent' // 强调色
| 'red' // 红色,错误色
| 'yellow' // 黄色,警告色
| 'grey' // 银灰色
| 'inverse' // 反色
| 'border' // 边框色
| 'background' // 全局背景色
| 'cardBackground' // 模块背景色
| 'textDefault' // 默认文本
| 'textSecondary' // 次要文本
| 'textMuted' // 禁用文本
| 'textTitle' // 标题文本
| 'textLink' // 链接文本
type Theme = Record<ThemeKey, string>
export const Default: Theme = {
primary: '#0d86ff',
secondary: '#262626',
accent: '#4caf50',
red: '#ff5722',
yellow: '#ffeb3b',
grey: '#e3e3e3',
inverse: '#333333',
border: '#BBBBBB',
background: '#EEEEEE',
cardBackground: '#FFFFFF',
textDefault: '#555',
textSecondary: '#bbb',
textMuted: '#eee',
textTitle: '#222',
textLink: '#000'
}
export const Dark: Theme = {
primary: '#0d86ff',
secondary: '#262626',
accent: '#4caf50',
red: '#ff5722',
yellow: '#ffeb3b',
grey: '#3e3e3e',
inverse: '#FFFFFF',
border: '#333333',
background: '#000000',
cardBackground: '#1a1a1a',
textDefault: '#999999',
textSecondary: '#777777',
textMuted: '#333333',
textTitle: '#EEEEEE',
textLink: '#FFFFFF'
}
export const isDarkSystemTheme = Appearance.getColorScheme() === 'dark'
const colors = observable<Theme>(isDarkSystemTheme ? Dark : Default)
export default colors
export const updateTheme = (darkTheme: boolean) => {
Object.keys(Default).forEach(key => {
const themeKty = (key as keyof Theme)
colors[themeKty] = darkTheme ? Dark[themeKty] : Default[themeKty]
})
}