Skip to content

Commit

Permalink
Add textColor and backgroundColor props to DateTimePicker component (#…
Browse files Browse the repository at this point in the history
…3481)

* Add textColor and backgroundColor props to DateTimePicker component

* Add cancelButtonProps to DateTimePickerScreen for customizable icon style
  • Loading branch information
ethanshar authored Jan 7, 2025
1 parent 70c99d7 commit c2bc66c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions demo/src/screens/componentScreens/DateTimePickerScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export default class DateTimePickerScreen extends Component<{}, State> {
containerStyle={{marginVertical: 20}}
label={'Date'}
placeholder={'Select a date'}
// textColor={Colors.red30}
// backgroundColor={Colors.$backgroundDark}
// cancelButtonProps={{iconStyle: {tintColor: Colors.$iconDefaultLight}}}
// value={new Date('October 13, 2014')}
/>
<DateTimePicker
Expand Down
17 changes: 17 additions & 0 deletions src/components/dateTimePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ export type DateTimePickerProps = OldApiProps &
* Allows changing the visual display of the picker
*/
display?: string;
/**
* Text color of the wheel picker items
*/
textColor?: string;
/**
* Background color of the wheel picker
*/
backgroundColor?: string;
/**
* Confirm button props
*/
Expand Down Expand Up @@ -137,6 +145,8 @@ const DateTimePicker = forwardRef((props: DateTimePickerPropsInternal, ref: Forw
onChange,
dialogProps,
migrateDialog,
textColor = Colors.$textDefault,
backgroundColor = Colors.$backgroundDefault,
headerStyle,
testID,
display = Constants.isIOS ? 'spinner' : undefined,
Expand Down Expand Up @@ -186,6 +196,10 @@ const DateTimePicker = forwardRef((props: DateTimePickerPropsInternal, ref: Forw
};
}, [dialogProps, testID]);

const dateTimePickerStyle = useMemo(() => {
return {backgroundColor};
}, [backgroundColor]);

const {getStringValue: getStringValueOld} = useOldApi({dateFormat, dateFormatter, timeFormat, timeFormatter});

const getStringValue = () => {
Expand Down Expand Up @@ -240,6 +254,7 @@ const DateTimePicker = forwardRef((props: DateTimePickerPropsInternal, ref: Forw
row
spread
bg-$backgroundDefault
backgroundColor={backgroundColor}
paddingH-20
style={[styles.header, headerStyle]}
testID={`${testID}.header`}
Expand Down Expand Up @@ -280,6 +295,8 @@ const DateTimePicker = forwardRef((props: DateTimePickerPropsInternal, ref: Forw
minuteInterval={minuteInterval}
timeZoneOffsetInMinutes={timeZoneOffsetInMinutes}
display={display}
textColor={textColor}
style={dateTimePickerStyle}
themeVariant={themeVariant}
testID={`${testID}.picker`}
/>
Expand Down

0 comments on commit c2bc66c

Please sign in to comment.