-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathutils.ts
More file actions
129 lines (115 loc) · 2.31 KB
/
utils.ts
File metadata and controls
129 lines (115 loc) · 2.31 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
import { tokens } from '../../styles/themes/tokens';
import type { InternalTheme } from '../../types';
const { stateOpacity } = tokens.md.ref;
const getAndroidCheckedColor = ({
theme,
customColor,
}: {
theme: InternalTheme;
customColor?: string;
}) => {
if (customColor) {
return customColor;
}
return theme.colors.primary;
};
const getAndroidUncheckedColor = ({
theme,
customUncheckedColor,
}: {
theme: InternalTheme;
customUncheckedColor?: string;
}) => {
if (customUncheckedColor) {
return customUncheckedColor;
}
return theme.colors.onSurfaceVariant;
};
const getAndroidControlColor = ({
theme,
checked,
disabled,
checkedColor,
uncheckedColor,
}: {
theme: InternalTheme;
checked: boolean;
checkedColor: string;
uncheckedColor: string;
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?: string;
customUncheckedColor?: string;
}) => {
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?: string;
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?: string;
}) => {
const checkedColor = getIOSCheckedColor({ theme, disabled, customColor });
const checkedColorOpacity = disabled
? stateOpacity.disabled
: stateOpacity.enabled;
return {
checkedColor,
checkedColorOpacity,
};
};