-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathstyles.ts
128 lines (123 loc) · 4.47 KB
/
styles.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
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
import { StyleSheet } from "react-native";
import type { TextStyle, ViewStyle } from "react-native";
import type { CustomTimerPickerStyles } from "../TimerPicker/styles";
export interface CustomTimerPickerModalStyles extends CustomTimerPickerStyles {
button?: TextStyle;
buttonContainer?: ViewStyle;
cancelButton?: TextStyle;
confirmButton?: TextStyle;
container?: ViewStyle;
contentContainer?: ViewStyle;
modalTitle?: TextStyle;
}
const DARK_MODE_BACKGROUND_COLOR = "#232323";
const DARK_MODE_TEXT_COLOR = "#E9E9E9";
const LIGHT_MODE_BACKGROUND_COLOR = "#F1F1F1";
const LIGHT_MODE_TEXT_COLOR = "#1B1B1B";
export const generateStyles = (
customStyles: CustomTimerPickerModalStyles | undefined,
variables?: {
hasModalTitle: boolean;
}
) => {
const {
button: customButtonStyle,
buttonContainer: customButtonContainerStyle,
cancelButton: customCancelButtonStyle,
confirmButton: customConfirmButtonStyle,
container: customContainerStyle,
contentContainer: customContentContainerStyle,
modalTitle: customModalTitleStyle,
...customTimerPickerStyles
} = customStyles ?? {};
return StyleSheet.create({
container: {
justifyContent: "center",
overflow: "hidden",
...customContainerStyle,
// disable setting alignItems here because it can affect
// the FlatList's ability to calculate its layout, which can
// stop snapToOffsets working properly
alignItems: undefined,
},
contentContainer: {
backgroundColor:
customTimerPickerStyles?.backgroundColor ??
(customTimerPickerStyles?.theme === "dark"
? DARK_MODE_BACKGROUND_COLOR
: LIGHT_MODE_BACKGROUND_COLOR),
justifyContent: "center",
alignItems: "center",
borderRadius: 20,
overflow: "hidden",
...customContentContainerStyle,
// disable setting padding here because it can affect
// the FlatList's ability to calculate its layout, which can
// stop snapToOffsets working properly
paddingHorizontal: 0,
paddingVertical: 0,
},
buttonContainer: {
flexDirection: "row",
marginTop: 25,
marginBottom: 20,
...customButtonContainerStyle,
},
button: {
marginHorizontal: 12,
paddingVertical: 10,
paddingHorizontal: 20,
borderWidth: 1,
borderRadius: 10,
fontSize: 16,
overflow: "hidden",
...customTimerPickerStyles?.text,
...customButtonStyle,
},
cancelButton: {
borderColor: "gray",
color:
customTimerPickerStyles?.theme === "dark"
? DARK_MODE_TEXT_COLOR
: "gray",
backgroundColor:
customTimerPickerStyles?.theme === "dark" ? "gray" : undefined,
...customTimerPickerStyles?.text,
...customCancelButtonStyle,
},
confirmButton: {
borderColor: "green",
color:
customTimerPickerStyles?.theme === "dark"
? DARK_MODE_TEXT_COLOR
: "green",
backgroundColor:
customTimerPickerStyles?.theme === "dark" ? "green" : undefined,
...customTimerPickerStyles?.text,
...customConfirmButtonStyle,
},
modalTitle: {
fontSize: 24,
fontWeight: "600",
marginTop: 20,
marginBottom: 15,
color:
customTimerPickerStyles?.theme === "dark"
? DARK_MODE_TEXT_COLOR
: LIGHT_MODE_TEXT_COLOR,
...customTimerPickerStyles?.text,
...customModalTitleStyle,
},
timerPickerStyles: {
...customTimerPickerStyles,
pickerContainer: {
// set padding here instead of on modal content container because it can affect
// the FlatList's ability to calculate its layout, which can
// stop snapToOffsets working properly
paddingHorizontal: 20,
paddingTop: !variables?.hasModalTitle ? 20 : 0,
...(customTimerPickerStyles?.pickerContainer ?? {}),
},
},
});
};