Skip to content

DateTimePicker confirm/cancel button props #3161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/components/dateTimePicker/dateTimePicker.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,17 @@
"name": "display",
"type": "string",
"description": "Defines the visual display of the picker. The default value is 'spinner' on iOS and 'default' on Android. The list of all possible values are default, spinner, calendar or clock on Android and default, spinner, compact or inline for iOS. Full list can be found here: https://github.com/react-native-datetimepicker/datetimepicker#display-optional"
},
{
"name": "confirmButtonProps",
"type": "ButtonProps",
"description": "Confirm button props"
},
{
"name": "cancelButtonProps",
"type": "ButtonProps",
"description": "Cancel button props"
}
],
"snippet": ["<DateTimePicker title={'Select time'$1} placeholder={'Placeholder'$2} mode={'time'$3}/>"]
}
}
23 changes: 20 additions & 3 deletions src/components/dateTimePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import TextField, {TextFieldProps, TextFieldMethods} from '../textField';
import type {DialogMigrationProps} from '../../incubator/Dialog';
import {DialogProps} from '../dialog';
import View from '../view';
import Button from '../button';
import Button, {ButtonProps} from '../button';
import ExpandableOverlay, {ExpandableOverlayMethods, RenderCustomOverlayProps} from '../../incubator/expandableOverlay';
import useOldApi, {OldApiProps} from './useOldApi';

Expand Down Expand Up @@ -93,6 +93,14 @@ export type DateTimePickerProps = OldApiProps &
* Allows changing the visual display of the picker
*/
display?: string;
/**
* Confirm button props
*/
confirmButtonProps?: ButtonProps;
/**
* Cancel button props
*/
cancelButtonProps?: ButtonProps;
};

type DateTimePickerPropsInternal = DateTimePickerProps & BaseComponentInjectedProps;
Expand Down Expand Up @@ -131,6 +139,8 @@ const DateTimePicker = forwardRef((props: DateTimePickerPropsInternal, ref: Forw
headerStyle,
testID,
display = Constants.isIOS ? 'spinner' : undefined,
confirmButtonProps,
cancelButtonProps,
...others
} = props;

Expand Down Expand Up @@ -231,10 +241,17 @@ const DateTimePicker = forwardRef((props: DateTimePickerPropsInternal, ref: Forw
link
iconSource={Assets.icons.x}
iconStyle={{tintColor: Colors.$iconDefault}}
onPress={toggleExpandableOverlay}
testID={`${testID}.cancel`}
{...cancelButtonProps}
onPress={toggleExpandableOverlay}
/>
<Button
link
iconSource={Assets.icons.check}
testID={`${testID}.done`}
{...confirmButtonProps}
onPress={onDonePressed}
/>
<Button link iconSource={Assets.icons.check} onPress={onDonePressed} testID={`${testID}.done`}/>
</View>
);
};
Expand Down