Skip to content

Commit

Permalink
Support react-native 0.60+ and bug fixes (#194)
Browse files Browse the repository at this point in the history
* Fix android build warning.

* Fix gradle build.

* Fix photodraweeview version.

* rollback photodraweeview version.

* Update photodraweeview:1.1.3

* replaced deprecated bridge.imageLoader calls with moduleForClass API

* Rollback minSdkVersion.

* fix: Xcode 12 compatibility
  • Loading branch information
thanhcuong1990 authored Oct 16, 2020
1 parent e28f541 commit ef532a3
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 30 deletions.
19 changes: 9 additions & 10 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:3.3.2'
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "25.0.0"
compileSdkVersion 28
buildToolsVersion "28.0.3"

defaultConfig {
minSdkVersion 16
targetSdkVersion 22
targetSdkVersion 28
versionCode 1
}
lintOptions {
Expand All @@ -30,11 +28,12 @@ android {

repositories {
mavenCentral()
google()
jcenter()
}

dependencies {
compile 'com.facebook.react:react-native:+'
compile 'com.facebook.fresco:fresco:0.11.0'
compile 'me.relex:photodraweeview:1.0.0'
implementation 'com.facebook.react:react-native:+'
implementation 'com.facebook.fresco:fresco:1.12.1'
implementation 'me.relex:photodraweeview:1.1.3'
}
4 changes: 2 additions & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
android:minSdkVersion="18"
android:targetSdkVersion="28" />

<application
android:name=".MainApplication"
Expand Down
11 changes: 6 additions & 5 deletions ios/RNPhotoView.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ - (void)view:(UIView *)view doubleTapDetected:(UITouch *)touch {
#pragma mark - Setup

- (CGFloat)initialZoomScaleWithMinScale {
CGFloat minZoom = self.minimumZoomScale;
CGFloat zoomScale = self.minimumZoomScale;
if (_photoImageView) {
// Zoom image to fill if the aspect ratios are fairly similar
Expand All @@ -153,7 +154,7 @@ - (CGFloat)initialZoomScaleWithMinScale {
if (ABS(boundsAR - imageAR) < 0.17) {
zoomScale = MAX(xScale, yScale);
// Ensure we don't zoom in or out too far, just in case
zoomScale = MIN(MAX(self.minimumZoomScale, zoomScale), self.maximumZoomScale);
zoomScale = MIN(MAX(minZoom, zoomScale), minZoom);
}
}
return zoomScale;
Expand Down Expand Up @@ -295,7 +296,7 @@ - (void)setSource:(NSDictionary *)source {
}
_source = source;
NSURL *imageURL = [NSURL URLWithString:uri];

if (![[uri substringToIndex:4] isEqualToString:@"http"]) {
@try {
UIImage *image = RCTImageFromLocalAssetURL(imageURL);
Expand All @@ -316,10 +317,10 @@ - (void)setSource:(NSDictionary *)source {
}

NSURLRequest *request = [[NSURLRequest alloc] initWithURL:imageURL];

if (source[@"headers"]) {
NSMutableURLRequest *mutableRequest = [request mutableCopy];

NSDictionary *headers = source[@"headers"];
NSEnumerator *enumerator = [headers keyEnumerator];
id key;
Expand All @@ -334,7 +335,7 @@ - (void)setSource:(NSDictionary *)source {
}

// use default values from [imageLoader loadImageWithURLRequest:request callback:callback] method
[_bridge.imageLoader loadImageWithURLRequest:request
[[_bridge moduleForClass:[RCTImageLoader class]] loadImageWithURLRequest:request
size:CGSizeZero
scale:1
clipped:YES
Expand Down
40 changes: 30 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-photo-view",
"version": "1.5.2",
"version": "1.5.3",
"description": "Displaying photos with pinch-to-zoom",
"main": "index.js",
"author": {
Expand Down
4 changes: 2 additions & 2 deletions react-native-photo-view.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ Pod::Spec.new do |s|
s.name = "react-native-photo-view"
s.version = package["version"]
s.summary = package['description']
s.author = package['author']
s.author = package['author']
s.homepage = package['homepage']
s.license = package['license']
s.ios.deployment_target = "7.0"
s.tvos.deployment_target = "9.0"
s.source = { :git => "https://github.com/alwx/react-native-photo-view.git", :tag => "v#{s.version}" }
s.source_files = "ios/*.{h,m}"
s.dependency "React"
s.dependency "React-Core"
end

0 comments on commit ef532a3

Please sign in to comment.