-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeme.ts
63 lines (55 loc) · 1.23 KB
/
theme.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
import { UnistylesRegistry, UnistylesRuntime } from 'react-native-unistyles';
const breakpoints = {
xs: 0,
sm: 576,
md: 768,
lg: 992,
xl: 1200,
superLarge: 2000,
tvLike: 4000,
};
const same = {
scale: (value = 10) => {
const threshold = 1 / 360;
return Math.round(value * threshold * UnistylesRuntime.screen.width);
},
width: (percentage = 1) => {
return UnistylesRuntime.screen.width * (percentage / 100);
},
};
export const lightTheme = {
colors: {
typography: '#000000',
background: '#ffffff',
primary: 'blue',
secondary: 'brown',
},
...same,
} as const;
export const darkTheme = {
colors: {
typography: '#ffffff',
background: '#000000',
primary: 'green',
secondary: 'royalblue',
},
...same,
} as const;
// define other themes
type AppBreakpoints = typeof breakpoints;
type AppThemes = {
light: typeof lightTheme;
dark: typeof darkTheme;
};
declare module 'react-native-unistyles' {
export interface UnistylesBreakpoints extends AppBreakpoints {}
export interface UnistylesThemes extends AppThemes {}
}
UnistylesRegistry.addBreakpoints(breakpoints)
.addThemes({
light: lightTheme,
dark: darkTheme,
})
.addConfig({
adaptiveThemes: true,
});