diff --git a/android/build.gradle b/android/build.gradle index 07f6357..3deece3 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -35,6 +35,7 @@ android { targetSdkVersion getExtOrIntegerDefault('targetSdkVersion') buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() } + buildTypes { release { minifyEnabled false @@ -131,7 +132,7 @@ dependencies { if (isNewArchitectureEnabled()) { react { jsRootDir = file("../src/") - libraryName = "FastShadow" + libraryName = "FastShadowView" codegenJavaPackageName = "com.reactnativefastshadow" } } diff --git a/android/src/main/java/com/reactnativefastshadow/FastShadowViewManager.java b/android/src/main/java/com/reactnativefastshadow/FastShadowViewManager.java index 8341ad3..71e419d 100644 --- a/android/src/main/java/com/reactnativefastshadow/FastShadowViewManager.java +++ b/android/src/main/java/com/reactnativefastshadow/FastShadowViewManager.java @@ -11,12 +11,13 @@ import com.facebook.react.views.view.ReactViewManager; public class FastShadowViewManager extends ReactViewManager { - public static final String REACT_CLASS = "FastShadowView"; + + public static final String NAME = "FastShadowView"; @Override @NonNull public String getName() { - return REACT_CLASS; + return FastShadowViewManager.NAME; } @Override diff --git a/example/android/gradle.properties b/example/android/gradle.properties index a46a5b9..99fc223 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -34,7 +34,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 # your application. You should enable this flag either if you want # to write custom TurboModules/Fabric components OR use libraries that # are providing them. -newArchEnabled=false +newArchEnabled=true # Use this property to enable or disable the Hermes JS engine. # If set to false, you will be using JSC instead. diff --git a/example/src/App.tsx b/example/src/App.tsx index bbff416..cb149d8 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,6 +1,6 @@ import React, { useEffect } from 'react'; -import { Image, View, ScrollView } from 'react-native'; +import { Image, View, ScrollView, Text } from 'react-native'; import { ShadowedView, shadowStyle } from 'react-native-fast-shadow'; import Animated, { useSharedValue, @@ -39,8 +39,11 @@ export default function App() { height: `${animatedHeight.value}%`, })); + const uiManager = (global as any)?.nativeFabricUIManager ? 'Fabric' : 'Paper'; + return ( + This View is {uiManager} ('FastShadowView'); +const isFabricEnabled = (global as any).nativeFabricUIManager != null; + +export const FastShadowView: React.FC = isFabricEnabled + ? require('./FastShadowViewNativeComponent').default + : requireNativeComponent('FastShadowView'); diff --git a/src/FastShadowViewNativeComponent.js b/src/FastShadowViewNativeComponent.js new file mode 100644 index 0000000..cf784c9 --- /dev/null +++ b/src/FastShadowViewNativeComponent.js @@ -0,0 +1,18 @@ +// @flow +import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes'; +import type { HostComponent } from 'react-native'; +import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; + +export type FastShadowViewProps = $ReadOnly<{| + ...ViewProps, + cornerRadii: $ReadOnly<{| + topLeft: Int32, + topRight: Int32, + bottomLeft: Int32, + bottomRight: Int32, + |}>, +|}>; + +export default (codegenNativeComponent( + 'FastShadowView' +): HostComponent);