Skip to content

DateTimePicker - Implement themeVariant prop #1357

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
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
16 changes: 14 additions & 2 deletions src/components/dateTimePicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ const MODES = {
TIME: 'time'
};


const THEME_VARIANTS = {
LIGHT: 'light',
DARK: 'dark'
};


/*eslint-disable*/
/**
* @description: Date and Time Picker Component that wraps RNDateTimePicker for date and time modes.
Expand Down Expand Up @@ -98,7 +105,11 @@ class DateTimePicker extends Component {
/**
* Render custom input
*/
renderInput: PropTypes.elementType
renderInput: PropTypes.elementType,
/**
* Override system theme variant (dark or light mode) used by the date picker.
*/
themeVariant: PropTypes.oneOf(Object.values(THEME_VARIANTS))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a required prop? Can it be an optional one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a required prop? Can it be an optional one?

It is optional. Required would be themeVariant: PropTypes.oneOf(Object.values(THEME_VARIANTS)).isRequired

};

static defaultProps = {
Expand Down Expand Up @@ -236,7 +247,7 @@ class DateTimePicker extends Component {
}

const {value, showExpandableOverlay} = this.state;
const {mode, minimumDate, maximumDate, locale, is24Hour, minuteInterval, timeZoneOffsetInMinutes} = this.props;
const {mode, minimumDate, maximumDate, locale, is24Hour, minuteInterval, timeZoneOffsetInMinutes, themeVariant} = this.props;

if (showExpandableOverlay) {
return (
Expand All @@ -251,6 +262,7 @@ class DateTimePicker extends Component {
minuteInterval={minuteInterval}
timeZoneOffsetInMinutes={timeZoneOffsetInMinutes}
display={Constants.isIOS ? 'spinner' : undefined}
themeVariant={themeVariant}
/>
);
}
Expand Down