Skip to content

Commit c2bc66c

Browse files
authored
Add textColor and backgroundColor props to DateTimePicker component (#3481)
* Add textColor and backgroundColor props to DateTimePicker component * Add cancelButtonProps to DateTimePickerScreen for customizable icon style
1 parent 70c99d7 commit c2bc66c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

demo/src/screens/componentScreens/DateTimePickerScreen.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ export default class DateTimePickerScreen extends Component<{}, State> {
6666
containerStyle={{marginVertical: 20}}
6767
label={'Date'}
6868
placeholder={'Select a date'}
69+
// textColor={Colors.red30}
70+
// backgroundColor={Colors.$backgroundDark}
71+
// cancelButtonProps={{iconStyle: {tintColor: Colors.$iconDefaultLight}}}
6972
// value={new Date('October 13, 2014')}
7073
/>
7174
<DateTimePicker

src/components/dateTimePicker/index.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ export type DateTimePickerProps = OldApiProps &
9494
* Allows changing the visual display of the picker
9595
*/
9696
display?: string;
97+
/**
98+
* Text color of the wheel picker items
99+
*/
100+
textColor?: string;
101+
/**
102+
* Background color of the wheel picker
103+
*/
104+
backgroundColor?: string;
97105
/**
98106
* Confirm button props
99107
*/
@@ -137,6 +145,8 @@ const DateTimePicker = forwardRef((props: DateTimePickerPropsInternal, ref: Forw
137145
onChange,
138146
dialogProps,
139147
migrateDialog,
148+
textColor = Colors.$textDefault,
149+
backgroundColor = Colors.$backgroundDefault,
140150
headerStyle,
141151
testID,
142152
display = Constants.isIOS ? 'spinner' : undefined,
@@ -186,6 +196,10 @@ const DateTimePicker = forwardRef((props: DateTimePickerPropsInternal, ref: Forw
186196
};
187197
}, [dialogProps, testID]);
188198

199+
const dateTimePickerStyle = useMemo(() => {
200+
return {backgroundColor};
201+
}, [backgroundColor]);
202+
189203
const {getStringValue: getStringValueOld} = useOldApi({dateFormat, dateFormatter, timeFormat, timeFormatter});
190204

191205
const getStringValue = () => {
@@ -240,6 +254,7 @@ const DateTimePicker = forwardRef((props: DateTimePickerPropsInternal, ref: Forw
240254
row
241255
spread
242256
bg-$backgroundDefault
257+
backgroundColor={backgroundColor}
243258
paddingH-20
244259
style={[styles.header, headerStyle]}
245260
testID={`${testID}.header`}
@@ -280,6 +295,8 @@ const DateTimePicker = forwardRef((props: DateTimePickerPropsInternal, ref: Forw
280295
minuteInterval={minuteInterval}
281296
timeZoneOffsetInMinutes={timeZoneOffsetInMinutes}
282297
display={display}
298+
textColor={textColor}
299+
style={dateTimePickerStyle}
283300
themeVariant={themeVariant}
284301
testID={`${testID}.picker`}
285302
/>

0 commit comments

Comments
 (0)