From d165bc24f9ccd4ac4ac2453091e4187ca0fff960 Mon Sep 17 00:00:00 2001 From: Tom Underhill Date: Thu, 9 Apr 2020 14:23:11 -0700 Subject: [PATCH] Remove ColorAndroid --- .../PlatformColorValueTypes.android.js | 4 -- .../PlatformColorValueTypesAndroid.android.js | 18 --------- .../PlatformColorValueTypesAndroid.js | 17 --------- .../PlatformColor/PlatformColorExample.js | 37 ++----------------- index.js | 5 --- .../__tests__/platform-colors-test.js | 10 ----- .../platform-colors.js | 13 +------ 7 files changed, 4 insertions(+), 100 deletions(-) delete mode 100644 Libraries/StyleSheet/PlatformColorValueTypesAndroid.android.js delete mode 100644 Libraries/StyleSheet/PlatformColorValueTypesAndroid.js diff --git a/Libraries/StyleSheet/PlatformColorValueTypes.android.js b/Libraries/StyleSheet/PlatformColorValueTypes.android.js index 1458a9b4396d54..16772d2d6832ba 100644 --- a/Libraries/StyleSheet/PlatformColorValueTypes.android.js +++ b/Libraries/StyleSheet/PlatformColorValueTypes.android.js @@ -21,10 +21,6 @@ export const PlatformColor = (...names: Array): ColorValue => { return {resource_paths: names}; }; -export const ColorAndroidPrivate = (color: string): ColorValue => { - return {resource_paths: [color]}; -}; - export const normalizeColorObject = ( color: NativeColorValue, ): ?ProcessedColorValue => { diff --git a/Libraries/StyleSheet/PlatformColorValueTypesAndroid.android.js b/Libraries/StyleSheet/PlatformColorValueTypesAndroid.android.js deleted file mode 100644 index 58f551098fb5db..00000000000000 --- a/Libraries/StyleSheet/PlatformColorValueTypesAndroid.android.js +++ /dev/null @@ -1,18 +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 - */ - -'use strict'; - -import type {ColorValue} from './StyleSheetTypes'; -import {ColorAndroidPrivate} from './PlatformColorValueTypes'; - -export const ColorAndroid = (color: string): ColorValue => { - return ColorAndroidPrivate(color); -}; diff --git a/Libraries/StyleSheet/PlatformColorValueTypesAndroid.js b/Libraries/StyleSheet/PlatformColorValueTypesAndroid.js deleted file mode 100644 index 647000b3b1e9d0..00000000000000 --- a/Libraries/StyleSheet/PlatformColorValueTypesAndroid.js +++ /dev/null @@ -1,17 +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 - */ - -'use strict'; - -import type {ColorValue} from './StyleSheetTypes'; - -export const ColorAndroid = (color: string): ColorValue => { - throw new Error('ColorAndroid is not available on this platform.'); -}; diff --git a/RNTester/js/examples/PlatformColor/PlatformColorExample.js b/RNTester/js/examples/PlatformColor/PlatformColorExample.js index 8417ff6d2d8062..d0b04e21930087 100644 --- a/RNTester/js/examples/PlatformColor/PlatformColorExample.js +++ b/RNTester/js/examples/PlatformColor/PlatformColorExample.js @@ -13,14 +13,7 @@ const React = require('react'); const ReactNative = require('react-native'); import Platform from '../../../../Libraries/Utilities/Platform'; -const { - ColorAndroid, - DynamicColorIOS, - PlatformColor, - StyleSheet, - Text, - View, -} = ReactNative; +const {DynamicColorIOS, PlatformColor, StyleSheet, Text, View} = ReactNative; function PlatformColorsExample() { function createTable() { @@ -263,24 +256,6 @@ function DynamicColorsExample() { ); } -function AndroidColorsExample() { - return Platform.OS === 'android' ? ( - - - ColorAndroid('?attr/colorAccent') - - - - ) : ( - Not applicable on this platform - ); -} - function VariantColorsExample() { return ( @@ -288,7 +263,7 @@ function VariantColorsExample() { {Platform.OS === 'ios' ? "DynamicColorIOS({light: 'red', dark: 'blue'})" - : "ColorAndroid('?attr/colorAccent')"} + : "PlatformColor('?attr/colorAccent')"} @@ -340,12 +315,6 @@ exports.examples = [ return ; }, }, - { - title: 'Android Colors', - render(): React.Element { - return ; - }, - }, { title: 'Variant Colors', render(): React.Element { diff --git a/index.js b/index.js index c8f7ae4656f156..c1f4bb41280c9f 100644 --- a/index.js +++ b/index.js @@ -96,7 +96,6 @@ import typeof Platform from './Libraries/Utilities/Platform'; import typeof processColor from './Libraries/StyleSheet/processColor'; import typeof {PlatformColor} from './Libraries/StyleSheet/PlatformColorValueTypes'; import typeof {DynamicColorIOS} from './Libraries/StyleSheet/PlatformColorValueTypesIOS'; -import typeof {ColorAndroid} from './Libraries/StyleSheet/PlatformColorValueTypesAndroid'; import typeof RootTagContext from './Libraries/ReactNative/RootTagContext'; import typeof DeprecatedColorPropType from './Libraries/DeprecatedPropTypes/DeprecatedColorPropType'; import typeof DeprecatedEdgeInsetsPropType from './Libraries/DeprecatedPropTypes/DeprecatedEdgeInsetsPropType'; @@ -473,10 +472,6 @@ module.exports = { return require('./Libraries/StyleSheet/PlatformColorValueTypesIOS') .DynamicColorIOS; }, - get ColorAndroid(): ColorAndroid { - return require('./Libraries/StyleSheet/PlatformColorValueTypesAndroid') - .ColorAndroid; - }, get requireNativeComponent(): ( uiViewClassName: string, ) => HostComponent { diff --git a/packages/eslint-plugin-react-native-community/__tests__/platform-colors-test.js b/packages/eslint-plugin-react-native-community/__tests__/platform-colors-test.js index 9d1168272ecdc6..75343c25864993 100644 --- a/packages/eslint-plugin-react-native-community/__tests__/platform-colors-test.js +++ b/packages/eslint-plugin-react-native-community/__tests__/platform-colors-test.js @@ -22,7 +22,6 @@ eslintTester.run('../platform-colors', rule, { "const color = PlatformColor('controlAccentColor', 'controlColor');", "const color = DynamicColorIOS({light: 'black', dark: 'white'});", "const color = DynamicColorIOS({light: PlatformColor('black'), dark: PlatformColor('white')});", - "const color = ColorAndroid('?attr/colorAccent')", ], invalid: [ { @@ -49,14 +48,5 @@ eslintTester.run('../platform-colors', rule, { "const white = 'white'; const color = DynamicColorIOS({light: 'black', dark: white});", errors: [{message: rule.meta.messages.dynamicColorIOSDark}], }, - { - code: 'const color = ColorAndroid();', - errors: [{message: rule.meta.messages.colorAndroidArg}], - }, - { - code: - "const colorAccent = '?attr/colorAccent'; const color = ColorAndroid(colorAccent);", - errors: [{message: rule.meta.messages.colorAndroidArg}], - }, ], }); diff --git a/packages/eslint-plugin-react-native-community/platform-colors.js b/packages/eslint-plugin-react-native-community/platform-colors.js index 4d20496f8772d8..d2d720527e64a6 100644 --- a/packages/eslint-plugin-react-native-community/platform-colors.js +++ b/packages/eslint-plugin-react-native-community/platform-colors.js @@ -12,7 +12,7 @@ module.exports = { type: 'problem', docs: { description: - 'Ensure that PlatformColor(), DynamicColorIOS(), and ColorAndroid() are passed literals of the expected shape.', + 'Ensure that PlatformColor() and DynamicColorIOS() are passed literals of the expected shape.', }, messages: { platformColorArgsLength: @@ -25,8 +25,6 @@ module.exports = { 'DynamicColorIOS() light value must be either a literal or a PlatformColor() call.', dynamicColorIOSDark: 'DynamicColorIOS() dark value must be either a literal or a PlatformColor() call.', - colorAndroidArg: - 'ColorAndroid() must take a single argument that is a literal.', }, schema: [], }, @@ -103,15 +101,6 @@ module.exports = { }); return; } - } else if (node.callee.name === 'ColorAndroid') { - const args = node.arguments; - if (!(args.length === 1 && args[0].type === 'Literal')) { - context.report({ - node, - messageId: 'colorAndroidArg', - }); - return; - } } }, };