Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support react-native 0.60+ and bug fixes #194

Merged
merged 8 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 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
minSdkVersion 18
thanhcuong1990 marked this conversation as resolved.
Show resolved Hide resolved
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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thanhcuong1990 Given zoom scale range is [0.1, 3]
if the zoom scale is 2, MIN(MAX(minZoom, zoomScale), minZoom) returns 0.1

can you share the reason for this change?

}
}
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