-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathutils.ts
More file actions
106 lines (89 loc) · 1.73 KB
/
Copy pathutils.ts
File metadata and controls
106 lines (89 loc) · 1.73 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { Platform } from 'react-native';
import setColor from 'color';
import {
grey400,
grey800,
grey50,
grey700,
white,
black,
} from '../../theme/colors';
import type { InternalTheme } from '../../types';
type BaseProps = {
theme: InternalTheme;
disabled?: boolean;
value?: boolean;
};
const getCheckedColor = ({
theme,
color,
}: {
theme: InternalTheme;
color?: string;
}) => {
if (color) {
return color;
}
return theme.colors.primary;
};
const getThumbTintColor = ({
theme,
disabled,
value,
checkedColor,
}: BaseProps & { checkedColor: string }) => {
const isIOS = Platform.OS === 'ios';
if (isIOS) {
return undefined;
}
if (disabled) {
if (theme.dark) {
return grey800;
}
return grey400;
}
if (value) {
return checkedColor;
}
if (theme.dark) {
return grey400;
}
return grey50;
};
const getOnTintColor = ({
theme,
disabled,
value,
checkedColor,
}: BaseProps & { checkedColor: string }) => {
const isIOS = Platform.OS === 'ios';
if (isIOS) {
return checkedColor;
}
if (disabled) {
if (theme.dark) {
return setColor(white).alpha(0.06).rgb().string();
}
return setColor(black).alpha(0.12).rgb().string();
}
if (value) {
return theme.colors.surfaceContainerHighest;
}
if (theme.dark) {
return grey700;
}
return 'rgb(178, 175, 177)';
};
export const getSwitchColor = ({
theme,
disabled,
value,
color,
}: BaseProps & { color?: string }) => {
const checkedColor = getCheckedColor({ theme, color });
return {
onTintColor: getOnTintColor({ theme, disabled, value, checkedColor }),
thumbTintColor: getThumbTintColor({ theme, disabled, value, checkedColor }),
checkedColor,
};
};