Skip to content
Merged
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
1 change: 1 addition & 0 deletions .flowconfig.android
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[ignore]
; We fork some components by platform
.*/*[.]ios.js
.*/*[.]macos.js

; Ignore templates for 'react-native init'
<PROJECT_ROOT>/template/.*
Expand Down
37 changes: 9 additions & 28 deletions Libraries/Color/normalizeColor.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,16 @@
/* eslint no-bitwise: 0 */
'use strict';

const Platform = require('Platform'); // [TODO(macOS ISS#2323203)

export type SemanticOrDynamicColorType = {
semantic?: string,
dynamic?: {
light: ?(string | number | SemanticOrDynamicColorType),
dark: ?(string | number | SemanticOrDynamicColorType),
},
}; // ]TODO(macOS ISS#2323203)
const normalizeColorObject = require('normalizeColorObject'); // TODO(macOS ISS#2323203)
import type {NativeOrDynamicColorType} from 'normalizeColorObject'; // TODO(macOS ISS#2323203)

function normalizeColor(
color: ?(
| string
| number
| SemanticOrDynamicColorType
| NativeOrDynamicColorType
) /* TODO(macOS ISS#2323203) */,
): ?(number | SemanticOrDynamicColorType) /* TODO(macOS ISS#2323203) */ {
): ?(number | NativeOrDynamicColorType) /* TODO(macOS ISS#2323203) */ {
const matchers = getMatchers();
let match;

Expand All @@ -39,26 +32,14 @@ function normalizeColor(
}

// [TODO(macOS ISS#2323203)
if (
typeof color === 'object' &&
color !== null &&
(Platform.OS === 'macos' || Platform.OS === 'ios')
) {
if ('semantic' in color) {
// a macos semantic color
if (typeof color === 'object' && color !== null) {
const normalizedColorObj = normalizeColorObject(color);

if (normalizedColorObj !== null) {
return color;
} else if ('dynamic' in color && color.dynamic !== undefined) {
// a dynamic, appearance aware color
const dynamic = color.dynamic;
const dynamicColor: SemanticOrDynamicColorType = {
dynamic: {
light: normalizeColor(dynamic.light),
dark: normalizeColor(dynamic.dark),
},
};
return dynamicColor;
}
}

if (typeof color !== 'string') {
return null;
} // ]TODO(macOS ISS#2323203)
Expand Down
22 changes: 22 additions & 0 deletions Libraries/Color/normalizeColorObject.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* 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
*/
// [TODO(macOS ISS#2323203)
'use strict';

export type NativeOrDynamicColorType = {};

function normalizeColorObject(
color: NativeOrDynamicColorType,
): ?(number | NativeOrDynamicColorType) {
return null;
}

module.exports = normalizeColorObject;
// ]TODO(macOS ISS#2323203)
45 changes: 45 additions & 0 deletions Libraries/Color/normalizeColorObject.ios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* 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
*/
// [TODO(macOS ISS#2323203)
'use strict';

export type NativeOrDynamicColorType = {
semantic?: string,
dynamic?: {
light: ?(string | number | NativeOrDynamicColorType),
dark: ?(string | number | NativeOrDynamicColorType),
},
};

function normalizeColorObject(
color: NativeOrDynamicColorType,
): ?(number | NativeOrDynamicColorType) {
if ('semantic' in color) {
// a macos semantic color
return color;
} else if ('dynamic' in color && color.dynamic !== undefined) {
const normalizeColor = require('normalizeColor');

// a dynamic, appearance aware color
const dynamic = color.dynamic;
const dynamicColor: NativeOrDynamicColorType = {
dynamic: {
light: normalizeColor(dynamic.light),
dark: normalizeColor(dynamic.dark),
},
};
return dynamicColor;
}

return null;
}

module.exports = normalizeColorObject;
// ]TODO(macOS ISS#2323203)
45 changes: 45 additions & 0 deletions Libraries/Color/normalizeColorObject.macos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* 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
*/
// [TODO(macOS ISS#2323203)
'use strict';

const normalizeColor = require('normalizeColor');

export type NativeOrDynamicColorType = {
semantic?: string,
dynamic?: {
light: ?(string | number | NativeOrDynamicColorType),
dark: ?(string | number | NativeOrDynamicColorType),
},
};

function normalizeColorObject(
color: NativeOrDynamicColorType,
): ?(number | NativeOrDynamicColorType) {
if ('semantic' in color) {
// a macos semantic color
return color;
} else if ('dynamic' in color && color.dynamic !== undefined) {
// a dynamic, appearance aware color
const dynamic = color.dynamic;
const dynamicColor: NativeOrDynamicColorType = {
dynamic: {
light: normalizeColor(dynamic.light),
dark: normalizeColor(dynamic.dark),
},
};
return dynamicColor;
}

return null;
}

module.exports = normalizeColorObject;
// ]TODO(macOS ISS#2323203)
4 changes: 2 additions & 2 deletions Libraries/Components/ActivityIndicator/ActivityIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const RCTActivityIndicatorViewNativeComponent = require('RCTActivityIndicatorVie

import type {NativeComponent} from 'ReactNative';
import type {ViewProps} from 'ViewPropTypes';
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // ]TODO(macOS ISS#2323203)
import type {NativeOrDynamicColorType} from 'normalizeColorObject'; // TODO(macOS ISS#2323203)

const RCTActivityIndicator =
Platform.OS === 'android'
Expand Down Expand Up @@ -54,7 +54,7 @@ type Props = $ReadOnly<{|
*
* See http://facebook.github.io/react-native/docs/activityindicator.html#color
*/
color?: ?(string | SemanticOrDynamicColorType), // ]TODO(macOS ISS#2323203)
color?: ?(string | NativeOrDynamicColorType), // TODO(macOS ISS#2323203)

/**
* Size of the indicator (default is 'small').
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const requireNativeComponent = require('requireNativeComponent');
import type {ViewProps} from 'ViewPropTypes';
import type {ViewStyleProp} from 'StyleSheet';
import type {NativeComponent} from 'ReactNative';
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // ]TODO(macOS ISS#2323203)
import type {NativeOrDynamicColorType} from 'normalizeColorObject'; // TODO(macOS ISS#2323203)

type NativeProps = $ReadOnly<{|
...ViewProps,
Expand All @@ -39,7 +39,7 @@ type NativeProps = $ReadOnly<{|
*
* See http://facebook.github.io/react-native/docs/activityindicator.html#color
*/
color?: ?(string | SemanticOrDynamicColorType),
color?: ?(string | NativeOrDynamicColorType), // TODO(macOS ISS#2323203)

/**
* Size of the indicator (default is 'small').
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import type {NativeComponent} from 'ReactNative';
import type {SyntheticEvent} from 'CoreEventTypes';
import type {ViewStyleProp} from 'StyleSheet';
import type React from 'React';
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // ]TODO(macOS ISS#2323203)
import type {NativeOrDynamicColorType} from 'normalizeColorObject'; // TODO(macOS ISS#2323203)

type ColorValue = null | string | SemanticOrDynamicColorType;
type ColorValue = null | string | NativeOrDynamicColorType; // TODO(macOS ISS#2323203)

type DrawerStates = 'Idle' | 'Dragging' | 'Settling';

Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/Picker/PickerIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import type {SyntheticEvent} from 'CoreEventTypes';
import type {ColorValue} from 'StyleSheetTypes';
import type {ViewProps} from 'ViewPropTypes';
import type {TextStyleProp} from 'StyleSheet';
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // ]TODO(macOS ISS#2323203)
import type {NativeOrDynamicColorType} from 'normalizeColorObject'; // TODO(macOS ISS#2323203)

type PickerIOSChangeEvent = SyntheticEvent<
$ReadOnly<{|
Expand All @@ -36,7 +36,7 @@ type PickerIOSChangeEvent = SyntheticEvent<
type RCTPickerIOSItemType = $ReadOnly<{|
label: ?Label,
value: ?(number | string),
textColor: ?(number | SemanticOrDynamicColorType), // ]TODO(macOS ISS#2323203)
textColor: ?(number | NativeOrDynamicColorType), // TODO(macOS ISS#2323203)
|}>;

type RCTPickerIOSType = Class<
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/Picker/RCTPickerNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const requireNativeComponent = require('requireNativeComponent');
import type {SyntheticEvent} from 'CoreEventTypes';
import type {TextStyleProp} from 'StyleSheet';
import type {NativeComponent} from 'ReactNative';
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // ]TODO(macOS ISS#2323203)
import type {NativeOrDynamicColorType} from 'normalizeColorObject'; // TODO(macOS ISS#2323203)

type PickerIOSChangeEvent = SyntheticEvent<
$ReadOnly<{|
Expand All @@ -26,7 +26,7 @@ type PickerIOSChangeEvent = SyntheticEvent<
type RCTPickerIOSItemType = $ReadOnly<{|
label: ?Label,
value: ?(number | string),
textColor: ?(number | SemanticOrDynamicColorType),
textColor: ?(number | NativeOrDynamicColorType), // TODO(macOS ISS#2323203)
|}>;

type Label = Stringish | number;
Expand Down
12 changes: 6 additions & 6 deletions Libraries/Components/Switch/SwitchNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const requireNativeComponent = require('requireNativeComponent');

import type {SwitchChangeEvent} from 'CoreEventTypes';
import type {ViewProps} from 'ViewPropTypes';
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // TODO(macOS ISS#2323203)
import type {NativeOrDynamicColorType} from 'normalizeColorObject'; // TODO(macOS ISS#2323203)

type SwitchProps = $ReadOnly<{|
...ViewProps,
Expand All @@ -35,17 +35,17 @@ export type NativeAndroidProps = $ReadOnly<{|

enabled?: ?boolean,
on?: ?boolean,
thumbTintColor?: ?(string | SemanticOrDynamicColorType),
trackTintColor?: ?(string | SemanticOrDynamicColorType),
thumbTintColor?: ?(string | NativeOrDynamicColorType), // TODO(macOS ISS#2323203)
trackTintColor?: ?(string | NativeOrDynamicColorType), // TODO(macOS ISS#2323203)
|}>;

// @see RCTSwitchManager.m
export type NativeIOSProps = $ReadOnly<{|
...SwitchProps,

onTintColor?: ?(string | SemanticOrDynamicColorType),
thumbTintColor?: ?(string | SemanticOrDynamicColorType),
tintColor?: ?(string | SemanticOrDynamicColorType),
onTintColor?: ?(string | NativeOrDynamicColorType), // TODO(macOS ISS#2323203)
thumbTintColor?: ?(string | NativeOrDynamicColorType), // TODO(macOS ISS#2323203)
tintColor?: ?(string | NativeOrDynamicColorType), // TODO(macOS ISS#2323203)
|}>;

type SwitchNativeComponentType = Class<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {SyntheticEvent} from 'CoreEventTypes';
import type {ImageSource} from 'ImageSource';
import type {ViewProps} from 'ViewPropTypes';
import type {NativeComponent} from 'ReactNative';
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // ]TODO(macOS ISS#2323203)
import type {NativeOrDynamicColorType} from 'normalizeColorObject'; // TODO(macOS ISS#2323203)

type Action = $ReadOnly<{|
title: string,
Expand All @@ -36,7 +36,7 @@ type NativeProps = $ReadOnly<{|
nativeActions?: Array<Action>,
|}>;

type ColorValue = null | string | SemanticOrDynamicColorType;
type ColorValue = null | string | NativeOrDynamicColorType; // TODO(macOS ISS#2323203)

type ToolbarAndroidProps = $ReadOnly<{|
...ViewProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const ensurePositiveDelayProps = require('ensurePositiveDelayProps');
const processColor = require('processColor');

import type {PressEvent} from 'CoreEventTypes';
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // ]TODO(macOS ISS#2323203)
import type {NativeOrDynamicColorType} from 'normalizeColorObject'; // TODO(macOS ISS#2323203)

const rippleBackgroundPropType = PropTypes.shape({
type: PropTypes.oneOf(['RippleAndroid']),
Expand Down Expand Up @@ -146,7 +146,7 @@ const TouchableNativeFeedback = createReactClass({
borderless: boolean,
): {
type: 'RippleAndroid',
color: ?(number | SemanticOrDynamicColorType),
color: ?(number | NativeOrDynamicColorType), // TODO(macOS ISS#2323203)
borderless: boolean,
} {
return {
Expand Down
4 changes: 2 additions & 2 deletions Libraries/ReactNative/getNativeComponentAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const resolveAssetSource = require('resolveAssetSource');
const sizesDiffer = require('sizesDiffer');
const invariant = require('invariant');
const warning = require('fbjs/lib/warning');
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // ]TODO(macOS ISS#2323203)
import type {NativeOrDynamicColorType} from 'normalizeColorObject'; // TODO(macOS ISS#2323203)

function getNativeComponentAttributes(uiViewClassName: string) {
const viewConfig = UIManager.getViewManagerConfig(uiViewClassName);
Expand Down Expand Up @@ -184,7 +184,7 @@ function getProcessorForType(typeName: string): ?(nextProp: any) => any {

function processColorArray(
colors: ?Array<any>,
): ?Array<?(number | SemanticOrDynamicColorType)> {
): ?Array<?(number | NativeOrDynamicColorType)> /* TODO(macOS ISS#2323203) */ {
// ]TODO(macOS ISS#2323203)
return colors == null ? null : colors.map(processColor);
}
Expand Down
4 changes: 2 additions & 2 deletions Libraries/StyleSheet/StyleSheetTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
'use strict';

const AnimatedNode = require('AnimatedNode');
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // TODO(macOS ISS#2323203)
import type {NativeOrDynamicColorType} from 'normalizeColorObject'; // TODO(macOS ISS#2323203)

export type ColorValue = null | string | SemanticOrDynamicColorType; // TODO(macOS ISS#2323203)
export type ColorValue = null | string | NativeOrDynamicColorType; // TODO(macOS ISS#2323203)
export type DimensionValue = null | number | string | AnimatedNode;

/**
Expand Down
Loading