-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathutils.ts
More file actions
131 lines (116 loc) · 2.39 KB
/
Copy pathutils.ts
File metadata and controls
131 lines (116 loc) · 2.39 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import type { ColorValue } from 'react-native';
import { tokens } from '../../theme/tokens';
import type { InternalTheme } from '../../types';
const { stateOpacity } = tokens.md.ref;
const getAndroidCheckedColor = ({
theme,
customColor,
}: {
theme: InternalTheme;
customColor?: ColorValue;
}) => {
if (customColor) {
return customColor;
}
return theme.colors.primary;
};
const getAndroidUncheckedColor = ({
theme,
customUncheckedColor,
}: {
theme: InternalTheme;
customUncheckedColor?: ColorValue;
}) => {
if (customUncheckedColor) {
return customUncheckedColor;
}
return theme.colors.onSurfaceVariant;
};
const getAndroidControlColor = ({
theme,
checked,
disabled,
checkedColor,
uncheckedColor,
}: {
theme: InternalTheme;
checked: boolean;
checkedColor: ColorValue;
uncheckedColor: ColorValue;
disabled?: boolean;
}) => {
if (disabled) {
return theme.colors.onSurface;
}
if (checked) {
return checkedColor;
}
return uncheckedColor;
};
export const getAndroidSelectionControlColor = ({
theme,
disabled,
checked,
customColor,
customUncheckedColor,
}: {
theme: InternalTheme;
checked: boolean;
disabled?: boolean;
customColor?: ColorValue;
customUncheckedColor?: ColorValue;
}) => {
const checkedColor = getAndroidCheckedColor({ theme, customColor });
const uncheckedColor = getAndroidUncheckedColor({
theme,
customUncheckedColor,
});
const selectionControlOpacity = disabled
? stateOpacity.disabled
: stateOpacity.enabled;
return {
selectionControlColor: getAndroidControlColor({
theme,
disabled,
checked,
checkedColor,
uncheckedColor,
}),
selectionControlOpacity,
};
};
const getIOSCheckedColor = ({
theme,
disabled,
customColor,
}: {
theme: InternalTheme;
customColor?: ColorValue;
disabled?: boolean;
}) => {
if (disabled) {
return theme.colors.primary;
}
if (customColor) {
return customColor;
}
return theme.colors.primary;
};
export const getSelectionControlIOSColor = ({
theme,
disabled,
customColor,
}: {
theme: InternalTheme;
disabled?: boolean;
customColor?: ColorValue;
}) => {
const checkedColor = getIOSCheckedColor({ theme, disabled, customColor });
const checkedColorOpacity = disabled
? stateOpacity.disabled
: stateOpacity.enabled;
return {
checkedColor,
checkedColorOpacity,
};
};