From 213fc0f19d966b335fb7bf313f5aff1c8da5b93b Mon Sep 17 00:00:00 2001 From: Tom Underhill Date: Sun, 2 Aug 2020 14:55:56 -0700 Subject: [PATCH] `yarn flow-check-macos` is clean. --- Libraries/Alert/RCTAlertManager.macos.js | 7 ++- .../AccessibilityInfo.macos.js | 46 +++++++++++++------ .../__tests__/DrawerAndroid-test.js | 2 +- .../__tests__/ProgressBarAndroid-test.js | 2 +- Libraries/Utilities/Platform.macos.js | 14 ++++-- 5 files changed, 46 insertions(+), 25 deletions(-) diff --git a/Libraries/Alert/RCTAlertManager.macos.js b/Libraries/Alert/RCTAlertManager.macos.js index c59417d2bb..ace01a090c 100644 --- a/Libraries/Alert/RCTAlertManager.macos.js +++ b/Libraries/Alert/RCTAlertManager.macos.js @@ -10,8 +10,7 @@ // TODO(macOS ISS#2323203) -'use strict'; +/* $FlowFixMe allow macOS to share iOS file */ +const alertWithArgs = require('./RCTAlertManager.ios'); -var RCTAlertManager = require('../BatchedBridge/NativeModules').AlertManager; - -module.exports = RCTAlertManager; +module.exports = alertWithArgs; diff --git a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.macos.js b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.macos.js index f80a18669c..095cf67c30 100644 --- a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.macos.js +++ b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.macos.js @@ -17,8 +17,6 @@ const RCTDeviceEventEmitter = require('../../EventEmitter/RCTDeviceEventEmitter' import NativeAccessibilityManager from './NativeAccessibilityManager'; -const warning = require('fbjs/lib/warning'); - const CHANGE_EVENT_NAME = { invertColorsChanged: 'invertColorsChanged', reduceMotionChanged: 'reduceMotionChanged', @@ -35,6 +33,16 @@ type ChangeEventName = $Keys<{ }>; const _subscriptions = new Map(); + +/** + * Sometimes it's useful to know whether or not the device has a screen reader + * that is currently active. The `AccessibilityInfo` API is designed for this + * purpose. You can use it to query the current state of the screen reader as + * well as to register to be notified when the state of the screen reader + * changes. + * + * See http://facebook.github.io/react-native/docs/accessibilityinfo.html + */ const AccessibilityInfo = { /** * iOS only @@ -130,7 +138,10 @@ const AccessibilityInfo = { * * Same as `isScreenReaderEnabled` */ - get fetch() { + get fetch(): $FlowFixMe { + console.warn( + 'AccessibilityInfo.fetch is deprecated, call Accessibility.isScreenReaderEnabled instead', + ); return this.isScreenReaderEnabled; }, @@ -159,18 +170,6 @@ const AccessibilityInfo = { }; }, - removeEventListener: function( - eventName: ChangeEventName, - handler: Function, - ): void { - const listener = _subscriptions.get(handler); - if (!listener) { - return; - } - listener.remove(); - _subscriptions.delete(handler); - }, - /** * Set accessibility focus to a react component. * @@ -192,6 +191,23 @@ const AccessibilityInfo = { NativeAccessibilityManager.announceForAccessibility(announcement); } }, + + /** + * Remove an event handler. + * + * See http://facebook.github.io/react-native/docs/accessibilityinfo.html#removeeventlistener + */ + removeEventListener: function( + eventName: ChangeEventName, + handler: Function, + ): void { + const listener = _subscriptions.get(handler); + if (!listener) { + return; + } + listener.remove(); + _subscriptions.delete(handler); + }, }; module.exports = AccessibilityInfo; diff --git a/Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js b/Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js index b04735acf3..987d267a4a 100644 --- a/Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js +++ b/Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js @@ -12,7 +12,7 @@ 'use strict'; const React = require('react'); -/* $FlowFixMe(>=0.99.0 site=react_native_ios_fb) This comment suppresses an +/* $FlowFixMe(>=0.99.0 site=react_native_ios_fb,react_native_macos_fb) This comment suppresses an * error found when Flow v0.99 was deployed. To see the error, delete this * comment and run Flow. */ const DrawerLayoutAndroid = require('../DrawerLayoutAndroid.android'); diff --git a/Libraries/Components/ProgressBarAndroid/__tests__/ProgressBarAndroid-test.js b/Libraries/Components/ProgressBarAndroid/__tests__/ProgressBarAndroid-test.js index 88e4f25cab..a9738bf535 100644 --- a/Libraries/Components/ProgressBarAndroid/__tests__/ProgressBarAndroid-test.js +++ b/Libraries/Components/ProgressBarAndroid/__tests__/ProgressBarAndroid-test.js @@ -12,7 +12,7 @@ 'use strict'; const React = require('react'); -/* $FlowFixMe(>=0.99.0 site=react_native_ios_fb) This comment suppresses an +/* $FlowFixMe(>=0.99.0 site=react_native_ios_fb,react_native_macos_fb) This comment suppresses an * error found when Flow v0.99 was deployed. To see the error, delete this * comment and run Flow. */ const ProgressBarAndroid = require('../ProgressBarAndroid.android'); diff --git a/Libraries/Utilities/Platform.macos.js b/Libraries/Utilities/Platform.macos.js index c2bb10a585..bebcf2fbb2 100644 --- a/Libraries/Utilities/Platform.macos.js +++ b/Libraries/Utilities/Platform.macos.js @@ -14,15 +14,17 @@ import NativePlatformConstantsMacOS from './NativePlatformConstantsMacOS'; -export type PlatformSelectSpec = { +export type PlatformSelectSpec = { default?: D, + native?: N, macos?: I, + ... }; const Platform = { __constants: null, OS: 'macos', - get Version(): $FlowFixMe { + get Version(): string { return this.constants.osVersion; }, get constants(): {| @@ -50,8 +52,12 @@ const Platform = { } return false; }, - select: (spec: PlatformSelectSpec): D | I => - 'macos' in spec ? spec.macos : spec.default, + select: (spec: PlatformSelectSpec): D | N | I => + 'macos' in spec + ? spec.macos + : 'native' in spec + ? spec.native + : spec.default, }; module.exports = Platform;