Skip to content

Commit

Permalink
Remove ColorAndroid
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-un committed Apr 9, 2020
1 parent ccb7dbe commit d165bc2
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 100 deletions.
4 changes: 0 additions & 4 deletions Libraries/StyleSheet/PlatformColorValueTypes.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ export const PlatformColor = (...names: Array<string>): ColorValue => {
return {resource_paths: names};
};

export const ColorAndroidPrivate = (color: string): ColorValue => {
return {resource_paths: [color]};
};

export const normalizeColorObject = (
color: NativeColorValue,
): ?ProcessedColorValue => {
Expand Down
18 changes: 0 additions & 18 deletions Libraries/StyleSheet/PlatformColorValueTypesAndroid.android.js

This file was deleted.

17 changes: 0 additions & 17 deletions Libraries/StyleSheet/PlatformColorValueTypesAndroid.js

This file was deleted.

37 changes: 3 additions & 34 deletions RNTester/js/examples/PlatformColor/PlatformColorExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -263,40 +256,22 @@ function DynamicColorsExample() {
);
}

function AndroidColorsExample() {
return Platform.OS === 'android' ? (
<View style={styles.column}>
<View style={styles.row}>
<Text style={styles.labelCell}>ColorAndroid('?attr/colorAccent')</Text>
<View
style={{
...styles.colorCell,
backgroundColor: ColorAndroid('?attr/colorAccent'),
}}
/>
</View>
</View>
) : (
<Text style={styles.labelCell}>Not applicable on this platform</Text>
);
}

function VariantColorsExample() {
return (
<View style={styles.column}>
<View style={styles.row}>
<Text style={styles.labelCell}>
{Platform.OS === 'ios'
? "DynamicColorIOS({light: 'red', dark: 'blue'})"
: "ColorAndroid('?attr/colorAccent')"}
: "PlatformColor('?attr/colorAccent')"}
</Text>
<View
style={{
...styles.colorCell,
backgroundColor:
Platform.OS === 'ios'
? DynamicColorIOS({light: 'red', dark: 'blue'})
: ColorAndroid('?attr/colorAccent'),
: PlatformColor('?attr/colorAccent'),
}}
/>
</View>
Expand Down Expand Up @@ -340,12 +315,6 @@ exports.examples = [
return <DynamicColorsExample />;
},
},
{
title: 'Android Colors',
render(): React.Element<any> {
return <AndroidColorsExample />;
},
},
{
title: 'Variant Colors',
render(): React.Element<any> {
Expand Down
5 changes: 0 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -473,10 +472,6 @@ module.exports = {
return require('./Libraries/StyleSheet/PlatformColorValueTypesIOS')
.DynamicColorIOS;
},
get ColorAndroid(): ColorAndroid {
return require('./Libraries/StyleSheet/PlatformColorValueTypesAndroid')
.ColorAndroid;
},
get requireNativeComponent(): <T>(
uiViewClassName: string,
) => HostComponent<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand All @@ -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}],
},
],
});
13 changes: 1 addition & 12 deletions packages/eslint-plugin-react-native-community/platform-colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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: [],
},
Expand Down Expand Up @@ -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;
}
}
},
};
Expand Down

0 comments on commit d165bc2

Please sign in to comment.