diff --git a/Libraries/Components/CheckBox/CheckBox.macos.js b/Libraries/Components/CheckBox/CheckBox.macos.js index 071b2a6cec7d3b..d0144dae941c82 100644 --- a/Libraries/Components/CheckBox/CheckBox.macos.js +++ b/Libraries/Components/CheckBox/CheckBox.macos.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017-present, Facebook, Inc. + * 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. diff --git a/Libraries/Components/DatePicker/DatePickerIOS.macos.js b/Libraries/Components/DatePicker/DatePickerIOS.macos.js index f18dc0c217731c..faf95e2d3cab1c 100644 --- a/Libraries/Components/DatePicker/DatePickerIOS.macos.js +++ b/Libraries/Components/DatePicker/DatePickerIOS.macos.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. + * 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. diff --git a/Libraries/Components/DatePickerAndroid/DatePickerAndroid.macos.js b/Libraries/Components/DatePickerAndroid/DatePickerAndroid.macos.js index 3e1e76d22f2adb..a0cb3e5e2f8053 100644 --- a/Libraries/Components/DatePickerAndroid/DatePickerAndroid.macos.js +++ b/Libraries/Components/DatePickerAndroid/DatePickerAndroid.macos.js @@ -1,32 +1,15 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. + * 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 + * @flow strict-local */ // TODO(macOS ISS#2323203) -'use strict'; - -import type {Options, DatePickerOpenAction} from './DatePickerAndroidTypes'; - -class DatePickerAndroid { - static async open(options: ?Options): Promise { - 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'; -} - +/* $FlowFixMe allow macOS to share iOS file */ +const DatePickerAndroid = require('./DatePickerAndroid.ios'); module.exports = DatePickerAndroid; diff --git a/Libraries/Components/Picker/PickerAndroid.macos.js b/Libraries/Components/Picker/PickerAndroid.macos.js index f18dc0c217731c..faf95e2d3cab1c 100644 --- a/Libraries/Components/Picker/PickerAndroid.macos.js +++ b/Libraries/Components/Picker/PickerAndroid.macos.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. + * 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. diff --git a/Libraries/Components/Picker/PickerIOS.macos.js b/Libraries/Components/Picker/PickerIOS.macos.js index 675279b044ef9e..65374b3b3c4c5f 100644 --- a/Libraries/Components/Picker/PickerIOS.macos.js +++ b/Libraries/Components/Picker/PickerIOS.macos.js @@ -8,9 +8,11 @@ * This is a controlled component version of RCTPickerIOS * * @format + * @flow */ // TODO(macOS ISS#2323203) +/* $FlowFixMe allow macOS to share iOS file */ const PickerIOS = require('./PickerIOS.ios'); module.exports = PickerIOS; diff --git a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.macos.js b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.macos.js index f18dc0c217731c..faf95e2d3cab1c 100644 --- a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.macos.js +++ b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.macos.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. + * 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. diff --git a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.macos.js b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.macos.js index ab2b63b7b02ca5..d79e2d87990449 100644 --- a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.macos.js +++ b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.macos.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. + * 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. @@ -10,73 +10,6 @@ // TODO(macOS ISS#2323203) -'use strict'; - -const React = require('react'); -const StyleSheet = require('../../StyleSheet/StyleSheet'); - -import RCTProgressViewNativeComponent from './RCTProgressViewNativeComponent'; -import type {ImageSource} from '../../Image/ImageSource'; -import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; -import type {ViewProps} from '../View/ViewPropTypes'; - -type Props = $ReadOnly<{| - ...ViewProps, - - /** - * The progress bar style. - */ - progressViewStyle?: ?('default' | 'bar'), - - /** - * The progress value (between 0 and 1). - */ - progress?: ?number, - - /** - * The tint color of the progress bar itself. - */ - progressTintColor?: ?ColorValue, - - /** - * The tint color of the progress bar track. - */ - trackTintColor?: ?ColorValue, - - /** - * A stretchable image to display as the progress bar. - */ - progressImage?: ?ImageSource, - - /** - * A stretchable image to display behind the progress bar. - */ - trackImage?: ?ImageSource, -|}>; - -/** - * Use `ProgressViewIOS` to render a UIProgressView on iOS. - */ -const ProgressViewIOS = ( - props: Props, - forwardedRef?: ?React.Ref, -) => ( - -); - -const styles = StyleSheet.create({ - progressView: { - height: 2, - }, -}); - -const ProgressViewIOSWithRef = React.forwardRef(ProgressViewIOS); - -/* $FlowFixMe(>=0.89.0 site=react_native_ios_fb) This comment suppresses an - * error found when Flow v0.89 was deployed. To see the error, delete this - * comment and run Flow. */ -module.exports = (ProgressViewIOSWithRef: typeof RCTProgressViewNativeComponent); +/* $FlowFixMe allow macOS to share iOS file */ +const ProgressViewIOSWithRef = require('./ProgressViewIOS.ios'); +module.exports = ProgressViewIOSWithRef; diff --git a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.macos.js b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.macos.js index 533e322f67e042..686598cba46122 100644 --- a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.macos.js +++ b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.macos.js @@ -10,117 +10,6 @@ // TODO(macOS ISS#2323203) -'use strict'; - -import * as React from 'react'; -import StyleSheet from '../../StyleSheet/StyleSheet'; -import type {OnChangeEvent} from './RCTSegmentedControlNativeComponent'; -import type {ViewProps} from '../View/ViewPropTypes'; -import RCTSegmentedControlNativeComponent from './RCTSegmentedControlNativeComponent'; -import type {SyntheticEvent} from 'react-native/Libraries/Types/CoreEventTypes'; - -type SegmentedControlIOSProps = $ReadOnly<{| - ...ViewProps, - /** - * The labels for the control's segment buttons, in order. - */ - values?: $ReadOnlyArray, - /** - * The index in `props.values` of the segment to be (pre)selected. - */ - selectedIndex?: ?number, - /** - * If false the user won't be able to interact with the control. - * Default value is true. - */ - enabled?: boolean, - /** - * Accent color of the control. - */ - tintColor?: ?string, - /** - * If true, then selecting a segment won't persist visually. - * The `onValueChange` callback will still work as expected. - */ - momentary?: ?boolean, - /** - * Callback that is called when the user taps a segment - */ - onChange?: ?(event: SyntheticEvent) => void, - /** - * Callback that is called when the user taps a segment; - * passes the segment's value as an argument - */ - onValueChange?: ?(value: number) => mixed, -|}>; - -type Props = $ReadOnly<{| - ...SegmentedControlIOSProps, - forwardedRef: ?React.Ref, -|}>; - -/** - * Use `SegmentedControlIOS` to render a UISegmentedControl iOS. - * - * #### Programmatically changing selected index - * - * The selected index can be changed on the fly by assigning the - * selectedIndex prop to a state variable, then changing that variable. - * Note that the state variable would need to be updated as the user - * selects a value and changes the index, as shown in the example below. - * - * ```` - * { - * this.setState({selectedIndex: event.nativeEvent.selectedSegmentIndex}); - * }} - * /> - * ```` - */ - -class SegmentedControlIOS extends React.Component { - static defaultProps = { - values: [], - enabled: true, - }; - - _onChange = (event: SyntheticEvent) => { - this.props.onChange && this.props.onChange(event); - this.props.onValueChange && - this.props.onValueChange(event.nativeEvent.value); - }; - - render() { - const {forwardedRef, onValueChange, style, ...props} = this.props; - return ( - - ); - } -} - -const styles = StyleSheet.create({ - segmentedControl: { - height: 28, - }, -}); - -const SegmentedControlIOSWithRef = React.forwardRef( - ( - props: SegmentedControlIOSProps, - forwardedRef: ?React.Ref, - ) => { - return ; - }, -); - -/* $FlowFixMe(>=0.89.0 site=react_native_ios_fb) This comment suppresses an - * error found when Flow v0.89 was deployed. To see the error, delete this - * comment and run Flow. */ -module.exports = (SegmentedControlIOSWithRef: NativeSegmentedControlIOS); +/* $FlowFixMe allow macOS to share iOS file */ +const SegmentedControlIOSWithRef = require('./SegmentedControlIOS.ios'); +module.exports = SegmentedControlIOSWithRef; diff --git a/Libraries/Components/StatusBar/StatusBarIOS.macos.js b/Libraries/Components/StatusBar/StatusBarIOS.macos.js index efdc0808449854..46dc814f92a246 100644 --- a/Libraries/Components/StatusBar/StatusBarIOS.macos.js +++ b/Libraries/Components/StatusBar/StatusBarIOS.macos.js @@ -10,14 +10,6 @@ // TODO(macOS ISS#2323203) -'use strict'; - -const NativeEventEmitter = require('../../EventEmitter/NativeEventEmitter'); -const {StatusBarManager} = require('../../BatchedBridge/NativeModules'); - -/** - * Use `StatusBar` for mutating the status bar. - */ -class StatusBarIOS extends NativeEventEmitter {} - -module.exports = new StatusBarIOS(StatusBarManager); +/* $FlowFixMe allow macOS to share iOS file */ +const StatusBarIOS = require('./StatusBarIOS.ios'); +module.exports = StatusBarIOS; diff --git a/Libraries/Components/TimePickerAndroid/TimePickerAndroid.macos.js b/Libraries/Components/TimePickerAndroid/TimePickerAndroid.macos.js deleted file mode 100644 index c6eb27cb52100e..00000000000000 --- a/Libraries/Components/TimePickerAndroid/TimePickerAndroid.macos.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * 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 - */ - -// TODO(macOS ISS#2323203) - -'use strict'; - -import NativeTimePickerAndroid, { - type TimePickerOptions, - type TimePickerResult, -} from './NativeTimePickerAndroid'; - -const TimePickerAndroid = { - async open(options: TimePickerOptions): Promise { - return Promise.reject({ - message: 'TimePickerAndroid is not supported on this platform.', - }); - }, -}; - -module.exports = TimePickerAndroid; diff --git a/Libraries/Components/ToastAndroid/ToastAndroid.macos.js b/Libraries/Components/ToastAndroid/ToastAndroid.macos.js index 0428d3485c05ec..b1015020e11ee9 100644 --- a/Libraries/Components/ToastAndroid/ToastAndroid.macos.js +++ b/Libraries/Components/ToastAndroid/ToastAndroid.macos.js @@ -10,14 +10,5 @@ // TODO(macOS ISS#2323203) -'use strict'; - -const warning = require('fbjs/lib/warning'); - -const ToastAndroid = { - show: function(message: string, duration: number): void { - warning(false, 'ToastAndroid is not supported on this platform.'); - }, -}; - +const ToastAndroid = require('./ToastAndroid.ios'); module.exports = ToastAndroid; diff --git a/Libraries/Components/Touchable/TouchableNativeFeedback.js b/Libraries/Components/Touchable/TouchableNativeFeedback.ios.js similarity index 85% rename from Libraries/Components/Touchable/TouchableNativeFeedback.js rename to Libraries/Components/Touchable/TouchableNativeFeedback.ios.js index 56cb16c559e153..8efacfa3658346 100644 --- a/Libraries/Components/Touchable/TouchableNativeFeedback.js +++ b/Libraries/Components/Touchable/TouchableNativeFeedback.ios.js @@ -7,8 +7,6 @@ * @format */ -// TODO(macOS ISS#2323203) TODO(windows ISS): this file is TouchableNativeFeedback.ios.js in facebook's repo. Renamed to TouchableNativeFeedback.js since it is shared here between ios, macos, and windows. - 'use strict'; const React = require('react'); diff --git a/Libraries/Components/Touchable/TouchableNativeFeedback.macos.js b/Libraries/Components/Touchable/TouchableNativeFeedback.macos.js new file mode 100644 index 00000000000000..f8fd9462d5fc51 --- /dev/null +++ b/Libraries/Components/Touchable/TouchableNativeFeedback.macos.js @@ -0,0 +1,11 @@ +/** + * 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 + */ + +const DummyTouchableNativeFeedback = require('./TouchableNativeFeedback.ios'); +module.exports = DummyTouchableNativeFeedback; diff --git a/Libraries/Components/View/PlatformViewPropTypes.macos.js b/Libraries/Components/View/PlatformViewPropTypes.macos.js index cf5d82afb5bd3b..5044de931bac12 100644 --- a/Libraries/Components/View/PlatformViewPropTypes.macos.js +++ b/Libraries/Components/View/PlatformViewPropTypes.macos.js @@ -1,9 +1,11 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. + * 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. * + * @providesModule PlatformViewPropTypes + * @format * @flow */ diff --git a/Libraries/Image/Image.js b/Libraries/Image/Image.ios.js similarity index 97% rename from Libraries/Image/Image.js rename to Libraries/Image/Image.ios.js index ac1d2893cf4989..e92ef67b336299 100644 --- a/Libraries/Image/Image.js +++ b/Libraries/Image/Image.ios.js @@ -7,9 +7,6 @@ * @flow * @format */ - -// TODO(macOS ISS#2323203) TODO(windows ISS): this file is Image.ios.js in facebook's repo. Renamed to Image.js since it is shared here between ios, macos, and windows. - 'use strict'; const DeprecatedImagePropType = require('../DeprecatedPropTypes/DeprecatedImagePropType'); diff --git a/Libraries/Components/ToolbarAndroid/ToolbarAndroid.macos.js b/Libraries/Image/Image.macos.js similarity index 66% rename from Libraries/Components/ToolbarAndroid/ToolbarAndroid.macos.js rename to Libraries/Image/Image.macos.js index faf95e2d3cab1c..b4a65b7a676c99 100644 --- a/Libraries/Components/ToolbarAndroid/ToolbarAndroid.macos.js +++ b/Libraries/Image/Image.macos.js @@ -4,11 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * + * @flow * @format */ // TODO(macOS ISS#2323203) -'use strict'; - -module.exports = require('../UnimplementedViews/UnimplementedView'); +/* $FlowFixMe allow macOS to share iOS file */ +const Image = require('./Image.ios'); +module.exports = Image; diff --git a/Libraries/Network/RCTNetworking.js b/Libraries/Network/RCTNetworking.ios.js similarity index 88% rename from Libraries/Network/RCTNetworking.js rename to Libraries/Network/RCTNetworking.ios.js index 7bf9af76709132..73a33ab1d9fbe5 100644 --- a/Libraries/Network/RCTNetworking.js +++ b/Libraries/Network/RCTNetworking.ios.js @@ -8,8 +8,6 @@ * @flow */ -// TODO(macOS ISS#2323203) TODO(windows ISS): this file is RCTNetworking.ios.js in facebook's repo. Renamed to RCTNetworking.js since it is shared here between ios, macos, and windows. - 'use strict'; const NativeEventEmitter = require('../EventEmitter/NativeEventEmitter'); diff --git a/Libraries/Components/ViewPager/ViewPagerAndroid.macos.js b/Libraries/Network/RCTNetworking.macos.js similarity index 62% rename from Libraries/Components/ViewPager/ViewPagerAndroid.macos.js rename to Libraries/Network/RCTNetworking.macos.js index faf95e2d3cab1c..9abb37c80f3b67 100644 --- a/Libraries/Components/ViewPager/ViewPagerAndroid.macos.js +++ b/Libraries/Network/RCTNetworking.macos.js @@ -5,10 +5,11 @@ * LICENSE file in the root directory of this source tree. * * @format + * @flow */ // TODO(macOS ISS#2323203) -'use strict'; - -module.exports = require('../UnimplementedViews/UnimplementedView'); +/* $FlowFixMe allow macOS to share iOS file */ +const RCTNetworking = require('./RCTNetworking.ios'); +module.exports = RCTNetworking; diff --git a/Libraries/Settings/Settings.macos.js b/Libraries/Settings/Settings.macos.js index 2c430ba85f489d..c12e783f5634e3 100644 --- a/Libraries/Settings/Settings.macos.js +++ b/Libraries/Settings/Settings.macos.js @@ -1,85 +1,15 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. + * 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. * - * @providesModule Settings + * @format * @flow */ -// TODO(macOS ISS#2323203) Copied from Settings.ios.js - -'use strict'; - -var RCTDeviceEventEmitter = require('../EventEmitter/RCTDeviceEventEmitter'); -var RCTSettingsManager = require('../BatchedBridge/NativeModules').SettingsManager; - -var invariant = require('fbjs/lib/invariant'); - -var subscriptions: Array<{keys: Array, callback: ?Function}> = []; - -var Settings = { - _settings: RCTSettingsManager && RCTSettingsManager.settings, - - get(key: string): mixed { - return this._settings[key]; - }, - - set(settings: Object) { - this._settings = Object.assign(this._settings, settings); - RCTSettingsManager.setValues(settings); - }, - - watchKeys(keys: string | Array, callback: Function): number { - if (typeof keys === 'string') { - keys = [keys]; - } - - invariant( - Array.isArray(keys), - 'keys should be a string or array of strings' - ); - - //start monitoring for changes to NSUserDefaults - RCTSettingsManager.setIsMonitoringEnabled(true); - - var sid = subscriptions.length; - subscriptions.push({keys: keys, callback: callback}); - return sid; - }, - - clearWatch(watchId: number) { - if (watchId < subscriptions.length) { - subscriptions[watchId] = {keys: [], callback: null}; - - if (!subscriptions.some(subscription => subscription.callback != null)) { - // no subscribers present, stop listening for changes. - RCTSettingsManager.setIsMonitoringEnabled(false); - } - } - }, - - _sendObservations(body: Object) { - Object.keys(body).forEach((key) => { - var newValue = body[key]; - var didChange = this._settings[key] !== newValue; - this._settings[key] = newValue; - - if (didChange) { - subscriptions.forEach((sub) => { - if (sub.keys.indexOf(key) !== -1 && sub.callback) { - sub.callback(); - } - }); - } - }); - }, -}; - -RCTDeviceEventEmitter.addListener( - 'settingsUpdated', - Settings._sendObservations.bind(Settings) -); +// TODO(macOS ISS#2323203) +/* $FlowFixMe allow macOS to share iOS file */ +const Settings = require('./Settings.ios'); module.exports = Settings; diff --git a/Libraries/Utilities/BackHandler.macos.js b/Libraries/Utilities/BackHandler.macos.js index fe30a14e7a9774..0e5ea64949f02e 100644 --- a/Libraries/Utilities/BackHandler.macos.js +++ b/Libraries/Utilities/BackHandler.macos.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. + * 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. @@ -7,57 +7,12 @@ * On Apple TV, this implements back navigation using the TV remote's menu button. * On iOS, this just implements a stub. * - * @providesModule BackHandler + * @flow + * @format */ -// TODO(macOS ISS#2323203) Copied from BackHandler.ios.js - -'use strict'; - -function emptyFunction() {} - -/** - * Detect hardware button presses for back navigation. - * - * Android: Detect hardware back button presses, and programmatically invoke the default back button - * functionality to exit the app if there are no listeners or if none of the listeners return true. - * - * tvOS: Detect presses of the menu button on the TV remote. (Still to be implemented: - * programmatically disable menu button handling - * functionality to exit the app if there are no listeners or if none of the listeners return true.) - * - * iOS: Not applicable. - * - * macOS: Not applicable. - * - * The event subscriptions are called in reverse order (i.e. last registered subscription first), - * and if one subscription returns true then subscriptions registered earlier will not be called. - * - * Example: - * - * ```javascript - * BackHandler.addEventListener('hardwareBackPress', function() { - * // this.onMainScreen and this.goBack are just examples, you need to use your own implementation here - * // Typically you would use the navigator here to go to the last state. - * - * if (!this.onMainScreen()) { - * this.goBack(); - * return true; - * } - * return false; - * }); - * ``` - */ -let BackHandler; - -BackHandler = { - exitApp: emptyFunction, - addEventListener() { - return { - remove: emptyFunction, - }; - }, - removeEventListener: emptyFunction, -}; +// TODO(macOS ISS#2323203) +/* $FlowFixMe allow macOS to share iOS file */ +const BackHandler = require('./BackHandler.ios'); module.exports = BackHandler; diff --git a/Libraries/Utilities/LoadingView.macos.js b/Libraries/Utilities/LoadingView.macos.js index 782bedfbbb69c0..24d6ea9a4c762d 100644 --- a/Libraries/Utilities/LoadingView.macos.js +++ b/Libraries/Utilities/LoadingView.macos.js @@ -8,25 +8,8 @@ * @flow strict-local */ -'use strict'; +// TODO(macOS ISS#2323203) -import processColor from '../StyleSheet/processColor'; -import NativeDevLoadingView from './NativeDevLoadingView'; - -module.exports = { - showMessage(message: string, type: 'load' | 'refresh') { - if (NativeDevLoadingView) { - NativeDevLoadingView.showMessage( - message, - // Use same colors as iOS "Personal Hotspot" bar. - processColor('#ffffff'), - type && type === 'load' - ? processColor('#275714') - : processColor('#2584e8'), - ); - } - }, - hide() { - NativeDevLoadingView && NativeDevLoadingView.hide(); - }, -}; +/* $FlowFixMe allow macOS to share iOS file */ +const LoadingView = require('./LoadingView.ios'); +module.exports = LoadingView;