@@ -19,31 +19,54 @@ const LIGHT_MODE_BACKGROUND_COLOR = "#F1F1F1";
19
19
const LIGHT_MODE_TEXT_COLOR = "#1B1B1B" ;
20
20
21
21
export const generateStyles = (
22
- customStyles : CustomTimerPickerModalStyles | undefined
23
- ) =>
24
- StyleSheet . create ( {
22
+ customStyles : CustomTimerPickerModalStyles | undefined ,
23
+ variables ?: {
24
+ hasModalTitle : boolean ;
25
+ }
26
+ ) => {
27
+ const {
28
+ button : customButtonStyle ,
29
+ buttonContainer : customButtonContainerStyle ,
30
+ cancelButton : customCancelButtonStyle ,
31
+ confirmButton : customConfirmButtonStyle ,
32
+ container : customContainerStyle ,
33
+ contentContainer : customContentContainerStyle ,
34
+ modalTitle : customModalTitleStyle ,
35
+ ...customTimerPickerStyles
36
+ } = customStyles ?? { } ;
37
+
38
+ return StyleSheet . create ( {
25
39
container : {
26
40
justifyContent : "center" ,
27
- alignItems : "center" ,
28
41
overflow : "hidden" ,
29
- ...customStyles ?. container ,
42
+ ...customContainerStyle ,
43
+ // disable setting alignItems here because it can affect
44
+ // the FlatList's ability to calculate its layout, which can
45
+ // stop snapToOffsets working properly
46
+ alignItems : undefined ,
30
47
} ,
31
48
contentContainer : {
32
49
backgroundColor :
33
- customStyles ?. backgroundColor ??
34
- ( customStyles ?. theme === "dark"
50
+ customTimerPickerStyles ?. backgroundColor ??
51
+ ( customTimerPickerStyles ?. theme === "dark"
35
52
? DARK_MODE_BACKGROUND_COLOR
36
53
: LIGHT_MODE_BACKGROUND_COLOR ) ,
37
54
justifyContent : "center" ,
38
55
alignItems : "center" ,
39
56
borderRadius : 20 ,
40
- padding : 20 ,
41
- ...customStyles ?. contentContainer ,
57
+ overflow : "hidden" ,
58
+ ...customContentContainerStyle ,
59
+ // disable setting padding here because it can affect
60
+ // the FlatList's ability to calculate its layout, which can
61
+ // stop snapToOffsets working properly
62
+ paddingHorizontal : 0 ,
63
+ paddingVertical : 0 ,
42
64
} ,
43
65
buttonContainer : {
44
66
flexDirection : "row" ,
45
67
marginTop : 25 ,
46
- ...customStyles ?. buttonContainer ,
68
+ marginBottom : 20 ,
69
+ ...customButtonContainerStyle ,
47
70
} ,
48
71
button : {
49
72
marginHorizontal : 12 ,
@@ -53,36 +76,53 @@ export const generateStyles = (
53
76
borderRadius : 10 ,
54
77
fontSize : 16 ,
55
78
overflow : "hidden" ,
56
- ...customStyles ?. text ,
57
- ...customStyles ?. button ,
79
+ ...customTimerPickerStyles ?. text ,
80
+ ...customButtonStyle ,
58
81
} ,
59
82
cancelButton : {
60
83
borderColor : "gray" ,
61
84
color :
62
- customStyles ?. theme === "dark" ? DARK_MODE_TEXT_COLOR : "gray" ,
85
+ customTimerPickerStyles ?. theme === "dark"
86
+ ? DARK_MODE_TEXT_COLOR
87
+ : "gray" ,
63
88
backgroundColor :
64
- customStyles ?. theme === "dark" ? "gray" : undefined ,
65
- ...customStyles ?. text ,
66
- ...customStyles ?. cancelButton ,
89
+ customTimerPickerStyles ?. theme === "dark" ? "gray" : undefined ,
90
+ ...customTimerPickerStyles ?. text ,
91
+ ...customCancelButtonStyle ,
67
92
} ,
68
93
confirmButton : {
69
94
borderColor : "green" ,
70
95
color :
71
- customStyles ?. theme === "dark" ? DARK_MODE_TEXT_COLOR : "green" ,
96
+ customTimerPickerStyles ?. theme === "dark"
97
+ ? DARK_MODE_TEXT_COLOR
98
+ : "green" ,
72
99
backgroundColor :
73
- customStyles ?. theme === "dark" ? "green" : undefined ,
74
- ...customStyles ?. text ,
75
- ...customStyles ?. confirmButton ,
100
+ customTimerPickerStyles ?. theme === "dark" ? "green" : undefined ,
101
+ ...customTimerPickerStyles ?. text ,
102
+ ...customConfirmButtonStyle ,
76
103
} ,
77
104
modalTitle : {
78
105
fontSize : 24 ,
79
106
fontWeight : "600" ,
107
+ marginTop : 20 ,
80
108
marginBottom : 15 ,
81
109
color :
82
- customStyles ?. theme === "dark"
110
+ customTimerPickerStyles ?. theme === "dark"
83
111
? DARK_MODE_TEXT_COLOR
84
112
: LIGHT_MODE_TEXT_COLOR ,
85
- ...customStyles ?. text ,
86
- ...customStyles ?. modalTitle ,
113
+ ...customTimerPickerStyles ?. text ,
114
+ ...customModalTitleStyle ,
115
+ } ,
116
+ timerPickerStyles : {
117
+ ...customTimerPickerStyles ,
118
+ pickerContainer : {
119
+ // set padding here instead of on modal content container because it can affect
120
+ // the FlatList's ability to calculate its layout, which can
121
+ // stop snapToOffsets working properly
122
+ paddingHorizontal : 20 ,
123
+ paddingTop : ! variables ?. hasModalTitle ? 20 : 0 ,
124
+ ...( customTimerPickerStyles ?. pickerContainer ?? { } ) ,
125
+ } ,
87
126
} ,
88
127
} ) ;
128
+ } ;
0 commit comments