Skip to content
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

[TM] Add Spec for DatePickerAndroid #24916

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

'use strict';

const DatePickerModule = require('../../BatchedBridge/NativeModules')
.DatePickerAndroid;
import type {Options, DatePickerOpenAction} from './DatePickerAndroidTypes';
import NativeDatePickerAndroid from './NativeDatePickerAndroid';

/**
* Convert a Date to a timestamp.
Expand Down Expand Up @@ -74,7 +73,7 @@ class DatePickerAndroid {
_toMillis(optionsMs, 'minDate');
_toMillis(optionsMs, 'maxDate');
}
return DatePickerModule.open(options);
return NativeDatePickerAndroid.open(options);
}

/**
Expand Down
21 changes: 21 additions & 0 deletions Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
*
* @flow strict-local
* @format
*/

'use strict';

import type {TurboModule} from 'RCTExport';
import * as TurboModuleRegistry from 'TurboModuleRegistry';
import type {Options, DatePickerOpenAction} from './DatePickerAndroidTypes';
import Platform from 'Platform';
pedpess marked this conversation as resolved.
Show resolved Hide resolved

export interface Spec extends TurboModule {
+open: (options: ?Options) => Promise<DatePickerOpenAction>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately some of the types in DatePickerAndroidTypes like Date isn't compatible yet with our codegen system, so for now let's modify these types to use Object (I'll modify it after I import to FB)

}

export default (Platform.OS === 'android'
? TurboModuleRegistry.getEnforcing<Spec>('DatePickerAndroid')
: TurboModuleRegistry.getEnforcing<Spec>('DatePickerIOS'));