mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-06 07:06:11 +00:00
Changed `requireNativeComponent` to `codegenNativeComponent` so that upcoming changes (Static View Configs, Bridgeless Mode and idk what more) in `react-native` are available in the library. Also, types and native components are now taken directly from `fabric` folder to make sure the values passed to the native components are the ones defined in props. It should work on all supported versions since `codegenNativeComponent` function exists from RN v. 0.61.0. Suggested by @RSNara and @cipolleschi Reason for [`5394bbb` (#1847)](5394bbbced): - on `Paper`, `Animated` uses `setNativeProps` method when we set `useNativeDriver` to `false`, and does not rerender the component. Therefore, new transform lands only in `SvgView` and is parsed in `RCTViewManager.m` . - on `Fabric`, the same code makes the components rerender. Due to this, information about new transform is passed to the `SvgView` child: `G` , making it apply translations from the transform in its `updateProps` method. - other than `Animated` use-case, on both archs, if we just passed `transform` prop to `Svg` component, it would end up in double transformations now as well. All of those changes are due to https://github.com/software-mansion/react-native-svg/pull/1895, which added proper parsing of RN style `transform` prop (array of transformations objects) therefore making `G` properly handle `transform` prop passed from `Svg`. Reason for [`19bcb24` (#1847)](19bcb2464b): Same as https://github.com/software-mansion/react-native-screens/pull/1624
91 lines
2.6 KiB
Groovy
91 lines
2.6 KiB
Groovy
buildscript {
|
|
// The Android Gradle plugin is only required when opening the android folder stand-alone.
|
|
// This avoids unnecessary downloads and potential conflicts when the library is included as a
|
|
// module dependency in an application project.
|
|
if (project == rootProject) {
|
|
repositories {
|
|
mavenCentral()
|
|
google()
|
|
}
|
|
|
|
dependencies {
|
|
classpath("com.android.tools.build:gradle:3.6.1")
|
|
classpath "com.diffplug.spotless:spotless-plugin-gradle:5.15.0"
|
|
}
|
|
}
|
|
}
|
|
|
|
def isNewArchitectureEnabled() {
|
|
// To opt-in for the New Architecture, you can either:
|
|
// - Set `newArchEnabled` to true inside the `gradle.properties` file
|
|
// - Invoke gradle with `-newArchEnabled=true`
|
|
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
|
|
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
}
|
|
|
|
if (isNewArchitectureEnabled()) {
|
|
apply plugin: "com.facebook.react"
|
|
}
|
|
|
|
if (project == rootProject) {
|
|
apply from: 'spotless.gradle'
|
|
}
|
|
|
|
apply plugin: 'com.android.library'
|
|
|
|
def safeExtGet(prop, fallback) {
|
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
}
|
|
|
|
android {
|
|
compileSdkVersion safeExtGet('compileSdkVersion', 28)
|
|
|
|
// Used to override the NDK path/version on internal CI or by allowing
|
|
// users to customize the NDK path/version from their root project (e.g. for M1 support)
|
|
if (rootProject.hasProperty("ndkPath")) {
|
|
ndkPath rootProject.ext.ndkPath
|
|
}
|
|
if (rootProject.hasProperty("ndkVersion")) {
|
|
ndkVersion rootProject.ext.ndkVersion
|
|
}
|
|
|
|
defaultConfig {
|
|
minSdkVersion safeExtGet('minSdkVersion', 16)
|
|
//noinspection OldTargetApi
|
|
targetSdkVersion safeExtGet('targetSdkVersion', 28)
|
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
}
|
|
lintOptions {
|
|
abortOnError false
|
|
}
|
|
|
|
sourceSets.main {
|
|
java {
|
|
if (!isNewArchitectureEnabled()) {
|
|
srcDirs += [
|
|
"src/paper/java",
|
|
"build/generated/source/codegen/java"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
mavenLocal()
|
|
google()
|
|
maven {
|
|
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
url "$rootDir/../node_modules/react-native/android"
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
if (isNewArchitectureEnabled()) {
|
|
implementation project(":ReactAndroid")
|
|
} else {
|
|
implementation 'com.facebook.react:react-native:+'
|
|
}
|
|
}
|