Skip to content

Commit bd7c078

Browse files
authored
fix(fabric): fix Fabric component & TM specs for new architecture (#877)
* Rename component codegen spec have required "NativeComponent" suffix * Component codegen should be interface only * Reference renamed codegen spec * Fixup TM JS to not include imported type defs * Use buck compatible Plugins header import
1 parent 15db0f9 commit bd7c078

File tree

5 files changed

+49
-25
lines changed

5 files changed

+49
-25
lines changed

ios/fabric/RNDateTimePickerComponentView.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#import <react/renderer/components/RNDateTimePickerCGen/Props.h>
1111
#import <react/renderer/components/RNDateTimePickerCGen/RCTComponentViewHelpers.h>
1212

13-
#import "RCTFabricComponentsPlugins.h"
13+
#import <React/RCTFabricComponentsPlugins.h>
1414
#import "RNDateTimePicker.h"
1515

1616
using namespace facebook::react;

src/picker.ios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
* @format
88
* @flow strict-local
99
*/
10-
import RNDateTimePicker from './specs/NativeComponentDateTimePicker';
10+
import RNDateTimePicker from './specs/DateTimePickerNativeComponent';
1111

1212
export default RNDateTimePicker;

src/specs/NativeComponentDateTimePicker.js renamed to src/specs/DateTimePickerNativeComponent.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,27 @@ type DateTimePickerEvent = $ReadOnly<{|
1818

1919
type NativeProps = $ReadOnly<{|
2020
...ViewProps,
21-
onChange?: ?BubblingEventHandler<DateTimePickerEvent>,
22-
onPickerDismiss?: ?BubblingEventHandler<null>,
23-
maximumDate?: ?Double,
24-
minimumDate?: ?Double,
21+
accentColor?: ?ColorValue,
2522
date?: ?Double,
23+
displayIOS?: WithDefault<
24+
'default' | 'spinner' | 'compact' | 'inline',
25+
'default',
26+
>,
2627
locale?: ?string,
28+
maximumDate?: ?Double,
29+
minimumDate?: ?Double,
2730
minuteInterval?: ?Int32,
2831
mode?: WithDefault<'date' | 'time' | 'datetime' | 'countdown', 'date'>,
29-
timeZoneOffsetInMinutes?: ?Double,
30-
timeZoneName?: ?string,
32+
onChange?: ?BubblingEventHandler<DateTimePickerEvent>,
33+
onPickerDismiss?: ?BubblingEventHandler<null>,
3134
textColor?: ?ColorValue,
32-
accentColor?: ?ColorValue,
3335
themeVariant?: WithDefault<'dark' | 'light' | 'unspecified', 'unspecified'>,
34-
displayIOS?: WithDefault<
35-
'default' | 'spinner' | 'compact' | 'inline',
36-
'default',
37-
>,
36+
timeZoneName?: ?string,
37+
timeZoneOffsetInMinutes?: ?Double,
3838
enabled?: WithDefault<boolean, true>,
3939
|}>;
4040

4141
export default (codegenNativeComponent<NativeProps>('RNDateTimePicker', {
4242
excludedPlatforms: ['android'],
43+
interfaceOnly: true,
4344
}): HostComponent<NativeProps>);

src/specs/NativeModuleDatePicker.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,27 @@
22

33
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
44
import {TurboModuleRegistry} from 'react-native';
5-
import type {DateTimePickerResult} from '../types';
65

7-
type OpenParams = $ReadOnly<{|
8-
// TODO does codegen handle object type?
9-
|}>;
6+
export type DatePickerOpenParams = $ReadOnly<{
7+
dialogButtons?: $ReadOnly<{string: string}>,
8+
display?: string,
9+
maximumDate?: number,
10+
minimumDate?: number,
11+
testID?: string,
12+
timeZoneName?: number,
13+
timeZoneOffsetInMinutes?: number,
14+
}>;
15+
16+
type DateSetAction = 'dateSetAction' | 'dismissedAction';
17+
type DatePickerResult = $ReadOnly<{
18+
action: DateSetAction,
19+
timestamp: number,
20+
utcOffset: number,
21+
}>;
22+
1023
export interface Spec extends TurboModule {
11-
dismiss(): Promise<boolean>;
12-
open(params: OpenParams): Promise<DateTimePickerResult>;
24+
+dismiss: () => Promise<boolean>;
25+
+open: (params: DatePickerOpenParams) => Promise<DatePickerResult>;
1326
}
1427

1528
export default (TurboModuleRegistry.getEnforcing<Spec>('RNCDatePicker'): ?Spec);

src/specs/NativeModuleTimePicker.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@
22

33
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
44
import {TurboModuleRegistry} from 'react-native';
5-
import type {DateTimePickerResult} from '../types';
65

7-
type OpenParams = $ReadOnly<{|
8-
// TODO does codegen handle object type?
9-
|}>;
6+
export type TimePickerOpenParams = $ReadOnly<{
7+
dialogButtons?: $ReadOnly<{string: string}>,
8+
display?: string,
9+
is24Hour?: boolean,
10+
minuteInterval?: number,
11+
timeZoneOffsetInMinutes?: number,
12+
}>;
13+
14+
type TimeSetAction = 'timeSetAction' | 'dismissedAction';
15+
type TimePickerResult = $ReadOnly<{
16+
action: TimeSetAction,
17+
timestamp: number,
18+
utcOffset: number,
19+
}>;
1020

1121
export interface Spec extends TurboModule {
12-
dismiss(): Promise<boolean>;
13-
open(params: OpenParams): Promise<DateTimePickerResult>;
22+
+dismiss: () => Promise<boolean>;
23+
+open: (params: TimePickerOpenParams) => Promise<TimePickerResult>;
1424
}
1525

1626
export default (TurboModuleRegistry.getEnforcing<Spec>('RNCTimePicker'): ?Spec);

0 commit comments

Comments
 (0)