mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Fix DatePickerAndroid flow errors
Summary: This diff fixes errors in our internal call sites caused by D12919276. Reviewed By: TheSavior Differential Revision: D13489905 fbshipit-source-id: e149fb9b479172529c473108e10a2ff1d3066aa7
This commit is contained in:
committed by
Facebook Github Bot
parent
60f3b53cef
commit
0b1f74712f
@@ -11,27 +11,7 @@
|
||||
'use strict';
|
||||
|
||||
const DatePickerModule = require('NativeModules').DatePickerAndroid;
|
||||
|
||||
type Options = $ReadOnly<{|
|
||||
date?: ?(Date | number),
|
||||
minDate?: ?(Date | number),
|
||||
maxDate?: ?(Date | number),
|
||||
mode?: ?('calender' | 'spinner' | 'default'),
|
||||
|}>;
|
||||
|
||||
type DatePickerOpenAction =
|
||||
| {|
|
||||
action: 'dateSetAction',
|
||||
year: number,
|
||||
month: number,
|
||||
day: number,
|
||||
|}
|
||||
| {|
|
||||
action: 'dismissedAction',
|
||||
year: typeof undefined,
|
||||
month: typeof undefined,
|
||||
day: typeof undefined,
|
||||
|};
|
||||
import type {Options, DatePickerOpenAction} from 'DatePickerAndroidTypes';
|
||||
|
||||
/**
|
||||
* Convert a Date to a timestamp.
|
||||
@@ -86,12 +66,12 @@ class DatePickerAndroid {
|
||||
* Note the native date picker dialog has some UI glitches on Android 4 and lower
|
||||
* when using the `minDate` and `maxDate` options.
|
||||
*/
|
||||
static async open(options: Options): Promise<DatePickerOpenAction> {
|
||||
static async open(options: ?Options): Promise<DatePickerOpenAction> {
|
||||
const optionsMs = options;
|
||||
if (optionsMs) {
|
||||
_toMillis(options, 'date');
|
||||
_toMillis(options, 'minDate');
|
||||
_toMillis(options, 'maxDate');
|
||||
if (optionsMs != null) {
|
||||
_toMillis(optionsMs, 'date');
|
||||
_toMillis(optionsMs, 'minDate');
|
||||
_toMillis(optionsMs, 'maxDate');
|
||||
}
|
||||
return DatePickerModule.open(options);
|
||||
}
|
||||
@@ -99,11 +79,11 @@ class DatePickerAndroid {
|
||||
/**
|
||||
* A date has been selected.
|
||||
*/
|
||||
static dateSetAction = 'dateSetAction';
|
||||
static +dateSetAction: 'dateSetAction' = 'dateSetAction';
|
||||
/**
|
||||
* The dialog has been dismissed.
|
||||
*/
|
||||
static dismissedAction = 'dismissedAction';
|
||||
static +dismissedAction: 'dismissedAction' = 'dismissedAction';
|
||||
}
|
||||
|
||||
module.exports = DatePickerAndroid;
|
||||
|
||||
@@ -10,19 +10,21 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
type Options = $ReadOnly<{|
|
||||
date?: ?(Date | number),
|
||||
minDate?: ?(Date | number),
|
||||
maxDate?: ?(Date | number),
|
||||
mode?: ?('calender' | 'spinner' | 'default'),
|
||||
|}>;
|
||||
import type {Options, DatePickerOpenAction} from 'DatePickerAndroidTypes';
|
||||
|
||||
const DatePickerAndroid = {
|
||||
async open(options: Options): Promise<void> {
|
||||
return Promise.reject({
|
||||
message: 'DatePickerAndroid is not supported on this platform.',
|
||||
});
|
||||
},
|
||||
};
|
||||
class DatePickerAndroid {
|
||||
static async open(options: ?Options): Promise<DatePickerOpenAction> {
|
||||
throw new Error('DatePickerAndroid is not supported on this platform.');
|
||||
}
|
||||
|
||||
/**
|
||||
* A date has been selected.
|
||||
*/
|
||||
static +dateSetAction: 'dateSetAction' = 'dateSetAction';
|
||||
/**
|
||||
* The dialog has been dismissed.
|
||||
*/
|
||||
static +dismissedAction: 'dismissedAction' = 'dismissedAction';
|
||||
}
|
||||
|
||||
module.exports = DatePickerAndroid;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
*/
|
||||
|
||||
export type Options = $ReadOnly<{|
|
||||
date?: ?(Date | number),
|
||||
minDate?: ?(Date | number),
|
||||
maxDate?: ?(Date | number),
|
||||
mode?: ?('calender' | 'spinner' | 'default'),
|
||||
|}>;
|
||||
|
||||
export type DatePickerOpenAction =
|
||||
| {|
|
||||
action: 'dateSetAction',
|
||||
year: number,
|
||||
month: number,
|
||||
day: number,
|
||||
|}
|
||||
| {|
|
||||
action: 'dismissedAction',
|
||||
year: void,
|
||||
month: void,
|
||||
day: void,
|
||||
|};
|
||||
Reference in New Issue
Block a user