Skip to content

Commit

Permalink
fix: Add customCancelButton and customConfirmButton types (#656)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This is a breaking change since it might break your typechecking flow.
  • Loading branch information
luizaugustoventura committed Sep 6, 2022
1 parent 064ccdf commit 29ec272
Showing 1 changed file with 84 additions and 13 deletions.
97 changes: 84 additions & 13 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,80 @@ import {
AndroidNativeProps,
} from "@react-native-community/datetimepicker";

export type CancelButtonComponent = React.ComponentType<{
isDarkModeEnabled: boolean;
onPress(): void;
label: string;
}>;

export type ConfirmButtonComponent = React.ComponentType<{
isDisabled: boolean;
onPress(): void;
label: string;
}>;
export type CancelButtonStylePropTypes = {
button: {
borderRadius: number,
height: number | string,
marginBottom: number | string,
justifyContent: string,
},
buttonLight: {
backgroundColor: string,
},
buttonDark: {
backgroundColor: string,
},
text: {
padding: number | string,
textAlign: string,
color: string,
fontSize: number,
fontWeight: string,
backgroundColor: string,
},
};

export type ConfirmButtonStylePropTypes = {
button: {
borderTopWidth: number,
backgroundColor: string,
height: number | string,
justifyContent: string,
},
buttonLight: {
borderColor: string,
},
buttonDark: {
borderColor: string,
},
text: {
textAlign: string,
color: string,
fontSize: number,
fontWeight: string,
backgroundColor: string,
},
};

export type CancelButtonPropTypes = {
isDarkModeEnabled?: boolean,
cancelButtonTestID?: string,
onPress: () => void,
label: string,
buttonTextColorIOS?: string,
style?: CancelButtonStylePropTypes,
};

export type ConfirmButtonPropTypes = {
isDarkModeEnabled?: boolean,
confirmButtonTestID?: string,
onPress: () => void,
label: string,
buttonTextColorIOS?: string,
style?: ConfirmButtonStylePropTypes,
};

export type CustomCancelButtonPropTypes = {
isDarkModeEnabled?: boolean,
onPress: () => void,
label: string,
};

export type CustomConfirmButtonPropTypes = {
isDarkModeEnabled?: boolean,
onPress: () => void,
label: string,
};

export type HeaderComponent = React.ComponentType<{
label: string;
Expand Down Expand Up @@ -65,12 +128,12 @@ export interface DateTimePickerProps {
/**
* A custom component for the cancel button on iOS
*/
customCancelButtonIOS?: CancelButtonComponent;
customCancelButtonIOS?: React.FunctionComponent<CustomCancelButtonPropTypes>;

/**
* A custom component for the confirm button on iOS
*/
customConfirmButtonIOS?: ConfirmButtonComponent;
customConfirmButtonIOS?: React.FunctionComponent<CustomConfirmButtonPropTypes>;

/**
* A custom component for the title container on iOS
Expand Down Expand Up @@ -232,3 +295,11 @@ export default class DateTimePicker extends React.Component<
ReactNativeModalDateTimePickerProps,
any
> {}

export const cancelButtonStyles: CancelButtonStylePropTypes;

export const CancelButton: React.FunctionComponent<CancelButtonPropTypes>;

export const confirmButtonStyles: ConfirmButtonStylePropTypes;

export const ConfirmButton: React.FunctionComponent<ConfirmButtonPropTypes>;

0 comments on commit 29ec272

Please sign in to comment.