Skip to content

Commit 665dc01

Browse files
committed
Initiate TextField migration in DateTimePicker
1 parent 832cc3a commit 665dc01

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

demo/src/screens/componentScreens/DateTimePickerScreen.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {Component} from 'react';
22
import {ScrollView} from 'react-native';
3-
import {DateTimePicker, DateTimePickerProps, View, Text, TouchableOpacity} from 'react-native-ui-lib'; // eslint-disable-line
3+
import {DateTimePicker, DateTimePickerProps, View, Text} from 'react-native-ui-lib'; // eslint-disable-line
44

55
export default class DateTimePickerScreen extends Component {
66
getCustomInputValue = (value?: string) => {
@@ -27,16 +27,17 @@ export default class DateTimePickerScreen extends Component {
2727
<View padding-page>
2828
<Text text40>Date Time Picker</Text>
2929
<DateTimePicker
30-
// @ts-expect-error
30+
migrateTextField
3131
containerStyle={{marginVertical: 20}}
32-
title={'Date'}
32+
label={'Date'}
3333
placeholder={'Select a date'}
3434
// dateFormat={'MMM D, YYYY'}
3535
// value={new Date('October 13, 2014')}
3636
/>
3737
<DateTimePicker
38+
migrateTextField
3839
mode={'time'}
39-
title={'Time'}
40+
label={'Time'}
4041
placeholder={'Select time'}
4142
// timeFormat={'h:mm A'}
4243
// value={new Date('2015-03-25T12:00:00-06:30')}
@@ -46,24 +47,27 @@ export default class DateTimePickerScreen extends Component {
4647
Disabled
4748
</Text>
4849
<DateTimePicker
50+
migrateTextField
4951
containerStyle={{marginBottom: 20}}
5052
editable={false}
51-
title={'Date'}
53+
label={'Date'}
5254
placeholder={'Select a date'}
5355
/>
5456
<DateTimePicker
57+
migrateTextField
5558
editable={false}
5659
mode={'time'}
57-
title={'Time'}
60+
label={'Time'}
5861
placeholder={'Select time'}
5962
value={new Date('2015-03-25T12:00:00-06:30')}
6063
/>
6164
<Text text60R marginT-40>
6265
Custom Input
6366
</Text>
6467
<DateTimePicker
68+
migrateTextField
6569
containerStyle={{marginVertical: 20}}
66-
title={'Date'}
70+
label={'Date'}
6771
placeholder={'Select a date'}
6872
renderInput={this.renderCustomInput}
6973
dateFormat={'MMM D, YYYY'}

src/components/dateTimePicker/index.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,19 @@ import {useDidUpdate} from 'hooks';
66
import {Colors} from '../../style';
77
import Assets from '../../assets';
88
import {Constants, asBaseComponent, BaseComponentInjectedProps} from '../../commons/new';
9-
import TextField from '../textField';
9+
import TextField from '../textField/TextFieldMigrator';
1010
import {DialogProps} from '../dialog';
1111
import View from '../view';
1212
import Button from '../button';
1313
import ExpandableOverlay, {ExpandableOverlayMethods, RenderCustomOverlayProps} from '../../incubator/expandableOverlay';
14+
import type {TextFieldProps} from '../../incubator/TextField';
1415

1516
const MODES = {
1617
DATE: 'date',
1718
TIME: 'time'
1819
};
1920

20-
/*eslint-disable*/
21-
/**
22-
* @description: Date and Time Picker Component that wraps RNDateTimePicker for date and time modes.
23-
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/DateTimePickerScreen.tsx
24-
* @important: DateTimePicker uses a native library. You MUST add and link the native library to both iOS and Android projects.
25-
* @extends: TextField, react-native-community/datetimepicker
26-
* @extendsLink: https://github.com/react-native-community/react-native-datetimepicker#react-native-datetimepicker
27-
* @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/DateTimePicker/DateTimePicker_iOS.gif?raw=true, https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/DateTimePicker/DateTimePicker_Android.gif?raw=true
28-
*/
29-
/*eslint-enable*/
30-
31-
export interface DateTimePickerProps {
32-
// TODO: extend TextField props
33-
// ...TextField.propTypes,
21+
export type DateTimePickerProps = Omit<TextFieldProps, 'value' | 'onChange'> & {
3422
/**
3523
* The type of picker to display ('date' or 'time')
3624
*/
@@ -107,10 +95,25 @@ export interface DateTimePickerProps {
10795
* The component testID
10896
*/
10997
testID?: string;
98+
/**
99+
* Should migrate to the new TextField implementation
100+
*/
101+
migrateTextField?: boolean;
110102
}
111103

112104
type DateTimePickerPropsInternal = DateTimePickerProps & BaseComponentInjectedProps;
113105

106+
107+
/*eslint-disable*/
108+
/**
109+
* @description: Date and Time Picker Component that wraps RNDateTimePicker for date and time modes.
110+
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/DateTimePickerScreen.tsx
111+
* @important: DateTimePicker uses a native library. You MUST add and link the native library to both iOS and Android projects.
112+
* @extends: TextField, react-native-community/datetimepicker
113+
* @extendsLink: https://github.com/react-native-community/react-native-datetimepicker#react-native-datetimepicker
114+
* @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/DateTimePicker/DateTimePicker_iOS.gif?raw=true, https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/DateTimePicker/DateTimePicker_Android.gif?raw=true
115+
*/
116+
/*eslint-enable*/
114117
function DateTimePicker(props: DateTimePickerPropsInternal) {
115118
const {
116119
value: propsValue,
@@ -134,6 +137,7 @@ function DateTimePicker(props: DateTimePickerPropsInternal) {
134137
// @ts-expect-error
135138
useCustomTheme,
136139
testID,
140+
migrateTextField,
137141
...others
138142
} = props;
139143

@@ -295,9 +299,9 @@ function DateTimePicker(props: DateTimePickerPropsInternal) {
295299
{renderInput ? (
296300
renderInput({...props, value: getStringValue()})
297301
) : (
298-
/* @ts-expect-error */
299302
<TextField
300303
{...others}
304+
migrate={migrateTextField}
301305
testID={testID}
302306
editable={editable}
303307
// @ts-expect-error should be remove after completing TextField migration

0 commit comments

Comments
 (0)