Skip to content

Commit 29ec272

Browse files
fix: Add customCancelButton and customConfirmButton types (#656)
BREAKING CHANGE: This is a breaking change since it might break your typechecking flow.
1 parent 064ccdf commit 29ec272

File tree

1 file changed

+84
-13
lines changed

1 file changed

+84
-13
lines changed

typings/index.d.ts

Lines changed: 84 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,80 @@ import {
1212
AndroidNativeProps,
1313
} from "@react-native-community/datetimepicker";
1414

15-
export type CancelButtonComponent = React.ComponentType<{
16-
isDarkModeEnabled: boolean;
17-
onPress(): void;
18-
label: string;
19-
}>;
20-
21-
export type ConfirmButtonComponent = React.ComponentType<{
22-
isDisabled: boolean;
23-
onPress(): void;
24-
label: string;
25-
}>;
15+
export type CancelButtonStylePropTypes = {
16+
button: {
17+
borderRadius: number,
18+
height: number | string,
19+
marginBottom: number | string,
20+
justifyContent: string,
21+
},
22+
buttonLight: {
23+
backgroundColor: string,
24+
},
25+
buttonDark: {
26+
backgroundColor: string,
27+
},
28+
text: {
29+
padding: number | string,
30+
textAlign: string,
31+
color: string,
32+
fontSize: number,
33+
fontWeight: string,
34+
backgroundColor: string,
35+
},
36+
};
37+
38+
export type ConfirmButtonStylePropTypes = {
39+
button: {
40+
borderTopWidth: number,
41+
backgroundColor: string,
42+
height: number | string,
43+
justifyContent: string,
44+
},
45+
buttonLight: {
46+
borderColor: string,
47+
},
48+
buttonDark: {
49+
borderColor: string,
50+
},
51+
text: {
52+
textAlign: string,
53+
color: string,
54+
fontSize: number,
55+
fontWeight: string,
56+
backgroundColor: string,
57+
},
58+
};
59+
60+
export type CancelButtonPropTypes = {
61+
isDarkModeEnabled?: boolean,
62+
cancelButtonTestID?: string,
63+
onPress: () => void,
64+
label: string,
65+
buttonTextColorIOS?: string,
66+
style?: CancelButtonStylePropTypes,
67+
};
68+
69+
export type ConfirmButtonPropTypes = {
70+
isDarkModeEnabled?: boolean,
71+
confirmButtonTestID?: string,
72+
onPress: () => void,
73+
label: string,
74+
buttonTextColorIOS?: string,
75+
style?: ConfirmButtonStylePropTypes,
76+
};
77+
78+
export type CustomCancelButtonPropTypes = {
79+
isDarkModeEnabled?: boolean,
80+
onPress: () => void,
81+
label: string,
82+
};
83+
84+
export type CustomConfirmButtonPropTypes = {
85+
isDarkModeEnabled?: boolean,
86+
onPress: () => void,
87+
label: string,
88+
};
2689

2790
export type HeaderComponent = React.ComponentType<{
2891
label: string;
@@ -65,12 +128,12 @@ export interface DateTimePickerProps {
65128
/**
66129
* A custom component for the cancel button on iOS
67130
*/
68-
customCancelButtonIOS?: CancelButtonComponent;
131+
customCancelButtonIOS?: React.FunctionComponent<CustomCancelButtonPropTypes>;
69132

70133
/**
71134
* A custom component for the confirm button on iOS
72135
*/
73-
customConfirmButtonIOS?: ConfirmButtonComponent;
136+
customConfirmButtonIOS?: React.FunctionComponent<CustomConfirmButtonPropTypes>;
74137

75138
/**
76139
* A custom component for the title container on iOS
@@ -232,3 +295,11 @@ export default class DateTimePicker extends React.Component<
232295
ReactNativeModalDateTimePickerProps,
233296
any
234297
> {}
298+
299+
export const cancelButtonStyles: CancelButtonStylePropTypes;
300+
301+
export const CancelButton: React.FunctionComponent<CancelButtonPropTypes>;
302+
303+
export const confirmButtonStyles: ConfirmButtonStylePropTypes;
304+
305+
export const ConfirmButton: React.FunctionComponent<ConfirmButtonPropTypes>;

0 commit comments

Comments
 (0)