Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ColorAndroid function as it adds no value over PlatfromColor #28577

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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