Skip to content

Commit

Permalink
feat: move react native image resizer to the native package natively
Browse files Browse the repository at this point in the history
  • Loading branch information
khushal87 committed Nov 1, 2024
1 parent 4366578 commit 27b34ed
Show file tree
Hide file tree
Showing 24 changed files with 1,998 additions and 27 deletions.
16 changes: 8 additions & 8 deletions examples/TypeScriptMessaging/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,6 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-image-resizer (3.0.10):
- React-Core
- react-native-netinfo (11.3.2):
- React-Core
- react-native-safe-area-context (4.11.1):
Expand Down Expand Up @@ -1735,6 +1733,8 @@ PODS:
- RNSVG (15.8.0):
- React-Core
- SocketRocket (0.7.0)
- stream-chat-react-native (5.39.5):
- React-Core
- Yoga (0.0.0)

DEPENDENCIES:
Expand Down Expand Up @@ -1779,7 +1779,6 @@ DEPENDENCIES:
- react-native-blob-util (from `../node_modules/react-native-blob-util`)
- react-native-document-picker (from `../node_modules/react-native-document-picker`)
- react-native-image-picker (from `../node_modules/react-native-image-picker`)
- "react-native-image-resizer (from `../node_modules/@bam.tech/react-native-image-resizer`)"
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
- react-native-video (from `../node_modules/react-native-video`)
Expand Down Expand Up @@ -1817,6 +1816,7 @@ DEPENDENCIES:
- RNScreens (from `../node_modules/react-native-screens`)
- RNShare (from `../node_modules/react-native-share`)
- RNSVG (from `../node_modules/react-native-svg`)
- stream-chat-react-native (from `../node_modules/stream-chat-react-native`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
Expand Down Expand Up @@ -1903,8 +1903,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-document-picker"
react-native-image-picker:
:path: "../node_modules/react-native-image-picker"
react-native-image-resizer:
:path: "../node_modules/@bam.tech/react-native-image-resizer"
react-native-netinfo:
:path: "../node_modules/@react-native-community/netinfo"
react-native-safe-area-context:
Expand Down Expand Up @@ -1979,6 +1977,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-share"
RNSVG:
:path: "../node_modules/react-native-svg"
stream-chat-react-native:
:path: "../node_modules/stream-chat-react-native"
Yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"

Expand All @@ -1990,7 +1990,7 @@ SPEC CHECKSUMS:
glog: 69ef571f3de08433d766d614c73a9838a06bf7eb
hermes-engine: ea92f60f37dba025e293cbe4b4a548fd26b610a0
op-sqlite: 5688336af53053aa37f0ec3496487dc2734c91cc
RCT-Folly: 02617c592a293bd6d418e0a88ff4ee1f88329b47
RCT-Folly: 4464f4d875961fce86008d45f4ecf6cef6de0740
RCTDeprecation: 726d24248aeab6d7180dac71a936bbca6a994ed1
RCTRequired: a94e7febda6db0345d207e854323c37e3a31d93b
RCTTypeSafety: 28e24a6e44f5cbf912c66dde6ab7e07d1059a205
Expand Down Expand Up @@ -2022,7 +2022,6 @@ SPEC CHECKSUMS:
react-native-blob-util: 18b510205c080a453574a7d2344d64673d0ad9af
react-native-document-picker: 7343222102ece8aec51390717f47ad7119c7921f
react-native-image-picker: 2fbbafdae7a7c6db9d25df2f2b1db4442d2ca2ad
react-native-image-resizer: fd0c333eca55147bd55c5e054cac95dcd0da6814
react-native-netinfo: 076df4f9b07f6670acf4ce9a75aac8d34c2e2ccc
react-native-safe-area-context: 5141f11858b033636f1788b14f32eaba92cee810
react-native-video: b0584a6d2271cb163f817c7412708263f9893ed5
Expand Down Expand Up @@ -2061,8 +2060,9 @@ SPEC CHECKSUMS:
RNShare: 0fad69ae2d71de9d1f7b9a43acf876886a6cb99c
RNSVG: 8b1a777d54096b8c2a0fd38fc9d5a454332bbb4d
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
stream-chat-react-native: 489a6a053480ab8556883de05a28df2c7387ede6
Yoga: 055f92ad73f8c8600a93f0e25ac0b2344c3b07e6

PODFILE CHECKSUM: 6b7a4b74915b42bfe4ffddaf67cbf5e7a2bfeab3

COCOAPODS: 1.15.2
COCOAPODS: 1.16.2
1 change: 0 additions & 1 deletion examples/TypeScriptMessaging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"clean-all": "yarn clean && rm -rf node_modules && rm -rf ios/Pods && rm -rf vendor && bundle install && yarn install && cd ios && bundle exec pod install && cd -"
},
"dependencies": {
"@bam.tech/react-native-image-resizer": "^3.0.10",
"@op-engineering/op-sqlite": "^6.0.4",
"@react-native-clipboard/clipboard": "^1.10.0",
"@react-native-community/netinfo": "^11.3.2",
Expand Down
5 changes: 0 additions & 5 deletions examples/TypeScriptMessaging/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1777,11 +1777,6 @@
"@babel/helper-string-parser" "^7.25.9"
"@babel/helper-validator-identifier" "^7.25.9"

"@bam.tech/react-native-image-resizer@^3.0.10":
version "3.0.10"
resolved "https://registry.yarnpkg.com/@bam.tech/react-native-image-resizer/-/react-native-image-resizer-3.0.10.tgz#03395a29cb61cd819ce1e7730fb137ab6e75618a"
integrity sha512-IVIBRkgy8eq4g51RjAzh7zk8KpGhiQH6GqLC7SgAUJ0plh2bdqG2l8+D+Q/A0uFe85YutUmHyFioyDEsRGXaCQ==

"@bcoe/v8-coverage@^0.2.3":
version "0.2.3"
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
Expand Down
103 changes: 103 additions & 0 deletions package/native-package/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
buildscript {
repositories {
google()
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:7.2.1"

}
}

def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}

apply plugin: "com.android.library"


def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}

def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["ImageResizer_" + name]
}

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ImageResizer_" + name]).toInteger()
}

android {
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
def agpMajorVersion = agpVersion.tokenize('.')[0].toInteger()
def agpMinorVersion = agpVersion.tokenize('.')[1].toInteger()
/**
* Namespace should be declared here starting from AGP 8.x, Starting AGP 7.3 it is also supported.
* For AGP < 7.3, namespace should be declared in AndroidManifest.
* See: https://developer.android.com/build/releases/past-releases/agp-8-0-0-release-notes#namespace-dsl
*/
if (agpMajorVersion >= 7 && agpMinorVersion >= 3) {
namespace "com.reactnativeimageresizer"
}

defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
}
buildTypes {
release {
minifyEnabled false
}
}

lintOptions {
disable "GradleCompatible"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
main {
if (isNewArchitectureEnabled()) {
java.srcDirs += [
"src/newarch",
// This is needed to build Kotlin project with NewArch enabled
"${project.buildDir}/generated/source/codegen/java"
]
} else {
java.srcDirs += ["src/oldarch"]
}
}
}
}

repositories {
mavenCentral()
google()
}


dependencies {
// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "androidx.exifinterface:exifinterface:1.3.2"
}

if (isNewArchitectureEnabled()) {
react {
jsRootDir = file("../src/")
libraryName = "ImageResizer"
codegenJavaPackageName = "com.reactnativeimageresizer"
}
}
5 changes: 5 additions & 0 deletions package/native-package/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ImageResizer_kotlinVersion=1.7.0
ImageResizer_minSdkVersion=21
ImageResizer_targetSdkVersion=31
ImageResizer_compileSdkVersion=31
ImageResizer_ndkversion=21.4.7075529
Binary file not shown.
3 changes: 3 additions & 0 deletions package/native-package/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.reactnativeimageresizer">

</manifest>
Loading

0 comments on commit 27b34ed

Please sign in to comment.