diff --git a/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js b/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js index b569ae2bea5..99e5d92c051 100644 --- a/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js +++ b/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js @@ -56,5 +56,5 @@ export const Commands: NativeCommands = codegenNativeCommands({ export default (codegenNativeComponent('DatePicker', { paperComponentName: 'RCTDatePicker', - excludedPlatform: 'android', + excludedPlatforms: ['android'], }): HostComponent); diff --git a/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js b/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js index adf8ba966db..7f97db35b61 100644 --- a/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js +++ b/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js @@ -61,5 +61,5 @@ export const Commands: NativeCommands = codegenNativeCommands({ export default (codegenNativeComponent('PullToRefreshView', { paperComponentName: 'RCTRefreshControl', - excludedPlatform: 'android', + excludedPlatforms: ['android'], }): HostComponent); diff --git a/Libraries/Components/Switch/SwitchNativeComponent.js b/Libraries/Components/Switch/SwitchNativeComponent.js index c9bbe253bf3..82e3be7dbbd 100644 --- a/Libraries/Components/Switch/SwitchNativeComponent.js +++ b/Libraries/Components/Switch/SwitchNativeComponent.js @@ -54,5 +54,5 @@ export const Commands: NativeCommands = codegenNativeCommands({ export default (codegenNativeComponent('Switch', { paperComponentName: 'RCTSwitch', - excludedPlatform: 'android', + excludedPlatforms: ['android'], }): ComponentType); diff --git a/Libraries/Utilities/codegenNativeComponent.js b/Libraries/Utilities/codegenNativeComponent.js index 3847be3b4db..809cdce1965 100644 --- a/Libraries/Utilities/codegenNativeComponent.js +++ b/Libraries/Utilities/codegenNativeComponent.js @@ -21,7 +21,7 @@ type Options = $ReadOnly<{| interfaceOnly?: boolean, paperComponentName?: string, paperComponentNameDeprecated?: string, - excludedPlatform?: 'iOS' | 'android', + excludedPlatforms?: $ReadOnlyArray<'iOS' | 'android'>, |}>; export type NativeComponentType = HostComponent; diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/DatePickerManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/DatePickerManagerDelegate.java new file mode 100644 index 00000000000..29288a63c89 --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/DatePickerManagerDelegate.java @@ -0,0 +1,62 @@ +/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.bridge.ReadableArray; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class DatePickerManagerDelegate & DatePickerManagerInterface> extends BaseViewManagerDelegate { + public DatePickerManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + switch (propName) { + case "date": + mViewManager.setDate(view, value == null ? 0f : ((Double) value).floatValue()); + break; + case "initialDate": + mViewManager.setInitialDate(view, value == null ? 0f : ((Double) value).floatValue()); + break; + case "locale": + mViewManager.setLocale(view, value == null ? null : (String) value); + break; + case "maximumDate": + mViewManager.setMaximumDate(view, value == null ? 0f : ((Double) value).floatValue()); + break; + case "minimumDate": + mViewManager.setMinimumDate(view, value == null ? 0f : ((Double) value).floatValue()); + break; + case "minuteInterval": + mViewManager.setMinuteInterval(view, value == null ? 1 : ((Double) value).intValue()); + break; + case "mode": + mViewManager.setMode(view, (String) value); + break; + case "timeZoneOffsetInMinutes": + mViewManager.setTimeZoneOffsetInMinutes(view, value == null ? 0f : ((Double) value).floatValue()); + break; + default: + super.setProperty(view, propName, value); + } + } + + public void receiveCommand(DatePickerManagerInterface viewManager, T view, String commandName, ReadableArray args) { + switch (commandName) { + case "setNativeDate": + viewManager.setNativeDate(view, (float) args.getDouble(0)); + break; + } + } +} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/DatePickerManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/DatePickerManagerInterface.java new file mode 100644 index 00000000000..9df911c7284 --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/DatePickerManagerInterface.java @@ -0,0 +1,25 @@ +/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; + +public interface DatePickerManagerInterface { + void setDate(T view, float value); + void setInitialDate(T view, float value); + void setLocale(T view, @Nullable String value); + void setMaximumDate(T view, float value); + void setMinimumDate(T view, float value); + void setMinuteInterval(T view, @Nullable Integer value); + void setMode(T view, @Nullable String value); + void setTimeZoneOffsetInMinutes(T view, float value); + void setNativeDate(T view, float date); +} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/PullToRefreshViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/PullToRefreshViewManagerDelegate.java new file mode 100644 index 00000000000..2d6732ee8d3 --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/PullToRefreshViewManagerDelegate.java @@ -0,0 +1,51 @@ +/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.bridge.ColorPropConverter; +import com.facebook.react.bridge.ReadableArray; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class PullToRefreshViewManagerDelegate & PullToRefreshViewManagerInterface> extends BaseViewManagerDelegate { + public PullToRefreshViewManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + switch (propName) { + case "tintColor": + mViewManager.setTintColor(view, ColorPropConverter.getColor(value, view.getContext())); + break; + case "titleColor": + mViewManager.setTitleColor(view, ColorPropConverter.getColor(value, view.getContext())); + break; + case "title": + mViewManager.setTitle(view, value == null ? null : (String) value); + break; + case "refreshing": + mViewManager.setRefreshing(view, value == null ? false : (boolean) value); + break; + default: + super.setProperty(view, propName, value); + } + } + + public void receiveCommand(PullToRefreshViewManagerInterface viewManager, T view, String commandName, ReadableArray args) { + switch (commandName) { + case "setNativeRefreshing": + viewManager.setNativeRefreshing(view, args.getBoolean(0)); + break; + } + } +} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/PullToRefreshViewManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/PullToRefreshViewManagerInterface.java new file mode 100644 index 00000000000..4f40ee89cbb --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/PullToRefreshViewManagerInterface.java @@ -0,0 +1,21 @@ +/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; + +public interface PullToRefreshViewManagerInterface { + void setTintColor(T view, @Nullable Integer value); + void setTitleColor(T view, @Nullable Integer value); + void setTitle(T view, @Nullable String value); + void setRefreshing(T view, boolean value); + void setNativeRefreshing(T view, boolean refreshing); +} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SwitchManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SwitchManagerDelegate.java index bee0b8c54f2..5e419f8bd3f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SwitchManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SwitchManagerDelegate.java @@ -11,6 +11,8 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.ColorPropConverter; +import com.facebook.react.bridge.ReadableArray; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; import com.facebook.react.uimanager.LayoutShadowNode; @@ -29,25 +31,33 @@ public class SwitchManagerDelegate viewManager, T view, String commandName, ReadableArray args) { + switch (commandName) { + case "setValue": + viewManager.setValue(view, args.getBoolean(0)); + break; + } + } } diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 51d96416ff7..17fb0d7df9c 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -10,6 +10,8 @@ 'use strict'; +export type PlatformType = 'iOS' | 'android'; + export type CommandsFunctionTypeAnnotation = $ReadOnly<{| type: 'FunctionTypeAnnotation', params: $ReadOnlyArray, @@ -309,8 +311,8 @@ export type OptionsShape = $ReadOnly<{| // Does not check for new name paperComponentName?: string, - // Use for components that are not used on one or the other platform. - excludedPlatform?: 'iOS' | 'android', + // Use for components that are not used on other platforms. + excludedPlatforms?: $ReadOnlyArray, // Use for components currently being renamed in paper // Will use new name if it is available and fallback to this name diff --git a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js index 6ecc358b381..af61b2675e7 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js @@ -337,7 +337,10 @@ module.exports = { return Object.keys(components) .filter(componentName => { const component = components[componentName]; - return component.excludedPlatform !== 'iOS'; + return !( + component.excludedPlatforms && + component.excludedPlatforms.includes('iOS') + ); }) .map(componentName => { return [ diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js b/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js index 0cfe41fa8c6..b6b03eb7d36 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js @@ -101,7 +101,10 @@ module.exports = { return Object.keys(components) .filter(componentName => { const component = components[componentName]; - return component.excludedPlatform !== 'iOS'; + return !( + component.excludedPlatforms && + component.excludedPlatforms.includes('iOS') + ); }) .map(componentName => { const component = components[componentName]; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js index adb94d16f44..a7ff3f9d77c 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js @@ -768,7 +768,10 @@ module.exports = { return Object.keys(components) .filter(componentName => { const component = components[componentName]; - return component.excludedPlatform !== 'iOS'; + return !( + component.excludedPlatforms && + component.excludedPlatforms.includes('iOS') + ); }) .map(componentName => { const component = components[componentName]; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js index 17f587b0145..08c99a48791 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js @@ -274,7 +274,10 @@ module.exports = { return Object.keys(components) .filter(componentName => { const component = components[componentName]; - return component.excludedPlatform !== 'android'; + return !( + component.excludedPlatforms && + component.excludedPlatforms.includes('android') + ); }) .forEach(componentName => { const component = components[componentName]; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js index bf4f42bbfc8..af41763c82c 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js @@ -221,7 +221,10 @@ module.exports = { return Object.keys(components) .filter(componentName => { const component = components[componentName]; - return component.excludedPlatform !== 'android'; + return !( + component.excludedPlatforms && + component.excludedPlatforms.includes('android') + ); }) .forEach(componentName => { const component = components[componentName]; diff --git a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js index 6f3bf1becb8..31689b483dc 100644 --- a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js @@ -1524,7 +1524,28 @@ const EXCLUDE_ANDROID: SchemaType = { ExcludedAndroid: { components: { ExcludedAndroidComponent: { - excludedPlatform: 'android', + excludedPlatforms: ['android'], + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [], + commands: [], + }, + }, + }, + }, +}; + +const EXCLUDE_ANDROID_IOS: SchemaType = { + modules: { + ExcludedAndroidIos: { + components: { + ExcludedAndroidIosComponent: { + excludedPlatforms: ['android', 'iOS'], extendsProps: [ { type: 'ReactNativeBuiltInType', @@ -1566,4 +1587,5 @@ module.exports = { COMMANDS, COMMANDS_AND_PROPS, EXCLUDE_ANDROID, + EXCLUDE_ANDROID_IOS, }; diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap index 4c64141b0fb..e23ae48953f 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap @@ -286,6 +286,32 @@ using ExcludedAndroidComponentComponentDescriptor = ConcreteComponentDescriptor< } `; +exports[`GenerateComponentDescriptorH can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * 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. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using ExcludedAndroidIosComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GenerateComponentDescriptorH can generate fixture FLOAT_PROPS 1`] = ` Map { "ComponentDescriptors.h" => " diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap index 93b0a8b7f0f..a921411cbe0 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap @@ -385,6 +385,27 @@ NS_ASSUME_NONNULL_BEGIN @end +NS_ASSUME_NONNULL_END", +} +`; + +exports[`GenerateComponentHObjCpp can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* 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. +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + + + NS_ASSUME_NONNULL_END", } `; diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap index a13aedb1303..c70dc86ce28 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap @@ -304,6 +304,29 @@ namespace react { +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * 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. + */ + +#include + +namespace facebook { +namespace react { + + + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap index 6b007623805..229c08c3f15 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap @@ -330,6 +330,30 @@ namespace react { +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` +Map { + "EventEmitters.h" => " +/** + * 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. + */ +#pragma once + +#include + +namespace facebook { +namespace react { + + + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap index 2d17c7496dc..27ce7d45df9 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap @@ -329,6 +329,30 @@ ExcludedAndroidComponentProps::ExcludedAndroidComponentProps( {} +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsCpp can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` +Map { + "Props.cpp" => " +/** + * 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. + */ + +#include +#include + +namespace facebook { +namespace react { + + + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap index 687290a402e..3071e0e70ed 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap @@ -574,6 +574,30 @@ class ExcludedAndroidComponentProps final : public ViewProps { }; +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GeneratePropsH can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` +Map { + "Props.h" => " +/** + * 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. + */ +#pragma once + + + +namespace facebook { +namespace react { + + + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap index 6ae0cd6f4f2..914f8e56da7 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap @@ -442,6 +442,8 @@ public class InterfaceOnlyComponentManagerDelegate "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap index 45873d75b22..b064446f35b 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap @@ -247,6 +247,8 @@ public interface InterfaceOnlyComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture EXCLUDE_ANDROID 1`] = `Map {}`; +exports[`GeneratePropsJavaInterface can generate fixture EXCLUDE_ANDROID_IOS 1`] = `Map {}`; + exports[`GeneratePropsJavaInterface can generate fixture FLOAT_PROPS 1`] = ` Map { "FloatPropNativeComponentManagerInterface.java" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap index 053638bd5b0..22043570482 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap @@ -253,6 +253,29 @@ extern const char ExcludedAndroidComponentComponentName[] = \\"ExcludedAndroidCo } `; +exports[`GenerateShadowNodeCpp can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * 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. + */ + +#include + +namespace facebook { +namespace react { + +extern const char ExcludedAndroidIosComponentComponentName[] = \\"ExcludedAndroidIosComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GenerateShadowNodeCpp can generate fixture FLOAT_PROPS 1`] = ` Map { "ShadowNodes.cpp" => " diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap index 679337e818c..5327702796d 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap @@ -360,6 +360,39 @@ using ExcludedAndroidComponentShadowNode = ConcreteViewShadowNode< } `; +exports[`GenerateShadowNodeH can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * 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. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +extern const char ExcludedAndroidIosComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using ExcludedAndroidIosComponentShadowNode = ConcreteViewShadowNode< + ExcludedAndroidIosComponentComponentName, + ExcludedAndroidIosComponentProps>; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GenerateShadowNodeH can generate fixture FLOAT_PROPS 1`] = ` Map { "ShadowNodes.h" => " diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap index 63141765868..8f73a0c8250 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap @@ -354,6 +354,34 @@ TEST(ExcludedAndroidComponentProps_DoesNotDie, etc) { } `; +exports[`GenerateTests can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` +Map { + "Tests.cpp" => "/** + * 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. + */ + +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(ExcludedAndroidIosComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = ExcludedAndroidIosComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + rawProps.parse(propParser); + ExcludedAndroidIosComponentProps(sourceProps, rawProps); +}", +} +`; + exports[`GenerateTests can generate fixture FLOAT_PROPS 1`] = ` Map { "Tests.cpp" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap index f7e1722e545..d92c6470d7c 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap @@ -483,6 +483,38 @@ export default nativeComponentName; } `; +exports[`GenerateViewConfigJs can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` +Map { + "EXCLUDE_ANDROID_IOSNativeViewConfig.js" => " +/** + * 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. + * + * @flow + */ + +'use strict'; + +const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); + +const ExcludedAndroidIosComponentViewConfig = { + uiViewClassName: 'ExcludedAndroidIosComponent', + validAttributes: {}, +}; + +let nativeComponentName = 'ExcludedAndroidIosComponent'; + +registerGeneratedViewConfig(nativeComponentName, ExcludedAndroidIosComponentViewConfig); + +export const __INTERNAL_VIEW_CONFIG = ExcludedAndroidIosComponentViewConfig; + +export default nativeComponentName; +", +} +`; + exports[`GenerateViewConfigJs can generate fixture FLOAT_PROPS 1`] = ` Map { "FLOAT_PROPSNativeViewConfig.js" => " diff --git a/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/fixtures.js index 13e51319533..851257da1d0 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/fixtures.js @@ -144,6 +144,7 @@ type ModuleProps = $ReadOnly<{| export default codegenNativeComponent('Module', { interfaceOnly: true, + excludedPlatforms: ['android'], paperComponentName: 'RCTModule', }); `; diff --git a/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap b/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap index 8192bb77cdf..6437404dd14 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap +++ b/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap @@ -5935,6 +5935,9 @@ Object { }, }, ], + "excludedPlatforms": Array [ + "android", + ], "extendsProps": Array [ Object { "knownTypeName": "ReactNativeCoreViewProps", diff --git a/packages/react-native-codegen/src/parsers/flow/components/options.js b/packages/react-native-codegen/src/parsers/flow/components/options.js index f455a5f060a..8044575db15 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/options.js +++ b/packages/react-native-codegen/src/parsers/flow/components/options.js @@ -54,7 +54,13 @@ function getOptions(optionsExpression: OptionsAST): ?OptionsShape { let foundOptions; try { foundOptions = optionsExpression.properties.reduce((options, prop) => { - options[prop.key.name] = prop.value.value; + if (prop.value.type === 'ArrayExpression') { + options[prop.key.name] = prop.value.elements.map( + element => element.value, + ); + } else { + options[prop.key.name] = prop.value.value; + } return options; }, {}); } catch (e) {