Skip to content
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

Added ability to change button font color #632

Merged
merged 4 commits into from
Mar 10, 2022
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ export default Example;
👉 Please notice that **all the [`@react-native-community/react-native-datetimepicker`](https://github.com/react-native-community/react-native-datetimepicker) props are supported** as well!

| Name | Type | Default | Description |
| ------------------------- | --------- | ------------ | --------------------------------------------------------------------------------------------------- |
|---------------------------|-----------| ------------ |-----------------------------------------------------------------------------------------------------|
| `buttonTextColorIOS` | string | | The color of the confirm button texts (iOS) |
| `backdropStyleIOS` | style | | The style of the picker backdrop view style (iOS) |
| `cancelButtonTestID` | string | | Used to locate cancel button in end-to-end tests |
| `cancelTextIOS` | string | "Cancel" | The label of the cancel button (iOS) |
Expand Down
10 changes: 8 additions & 2 deletions src/DateTimePickerModal.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const HIGHLIGHT_COLOR_LIGHT = "#ebebeb";

export class DateTimePickerModal extends React.PureComponent {
static propTypes = {
buttonTextColorIOS: PropTypes.string,
cancelButtonTestID: PropTypes.string,
confirmButtonTestID: PropTypes.string,
cancelTextIOS: PropTypes.string,
Expand Down Expand Up @@ -122,6 +123,7 @@ export class DateTimePickerModal extends React.PureComponent {
onChange,
onHide,
backdropStyleIOS,
buttonTextColorIOS,
...otherProps
} = this.props;
const isAppearanceModuleAvailable = !!(
Expand Down Expand Up @@ -181,13 +183,15 @@ export class DateTimePickerModal extends React.PureComponent {
isDarkModeEnabled={_isDarkModeEnabled}
onPress={this.handleConfirm}
label={confirmTextIOS}
buttonTextColorIOS={buttonTextColorIOS}
/>
</View>
<CancelButtonComponent
cancelButtonTestID={cancelButtonTestID}
isDarkModeEnabled={_isDarkModeEnabled}
onPress={this.handleCancel}
label={cancelTextIOS}
buttonTextColorIOS={buttonTextColorIOS}
/>
</Modal>
);
Expand Down Expand Up @@ -224,6 +228,7 @@ export const ConfirmButton = ({
confirmButtonTestID,
onPress,
label,
buttonTextColorIOS,
style = confirmButtonStyles,
}) => {
const themedButtonStyle = isDarkModeEnabled
Expand All @@ -243,7 +248,7 @@ export const ConfirmButton = ({
accessibilityRole="button"
accessibilityLabel={label}
>
<Text style={style.text}>{label}</Text>
<Text style={[style.text, buttonTextColorIOS && { color: buttonTextColorIOS }]}>{label}</Text>
</TouchableHighlight>
);
};
Expand Down Expand Up @@ -275,6 +280,7 @@ export const CancelButton = ({
isDarkModeEnabled,
onPress,
label,
buttonTextColorIOS,
style = cancelButtonStyles,
}) => {
const themedButtonStyle = isDarkModeEnabled
Expand All @@ -293,7 +299,7 @@ export const CancelButton = ({
accessibilityRole="button"
accessibilityLabel={label}
>
<Text style={style.text}>{label}</Text>
<Text style={[style.text, buttonTextColorIOS && { color: buttonTextColorIOS }]}>{label}</Text>
</TouchableHighlight>
);
};
Expand Down
7 changes: 7 additions & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ export type HeaderComponent = React.ComponentType<{
export type PickerComponent = React.ComponentType<IOSNativeProps>;

export interface DateTimePickerProps {
/**
* iOS buttons text color
*
* Default is '#007ff9'
*/
buttonTextColorIOS?: string;

/**
* The prop to locate cancel button for e2e testing
*/
Expand Down