forked from alwx/react-native-photo-view
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use MWPhotobrowser for iOS (alwx#74)
* use MWPhotobrowser to show images in iOS, upgrade react native to v0.44.0 in example project * add showsVerticalScrollIndicator and showsHorizontalScrollIndicator for iOS, update README * showsHorizontalScrollIndicator and showsVerticalScrollIndicator * fix prop types error
- Loading branch information
Showing
44 changed files
with
4,999 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,83 @@ | ||
import React, {Component} from 'react'; | ||
import { | ||
View, | ||
ScrollView, | ||
Image, | ||
TouchableWithoutFeedback | ||
} from 'react-native'; | ||
import React, { Component, PropTypes } from 'react'; | ||
import { requireNativeComponent, View } from 'react-native'; | ||
import ViewPropTypes from 'react-native/Libraries/Components/View/ViewPropTypes'; | ||
|
||
const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource'); | ||
|
||
export default class PhotoView extends Component { | ||
static propTypes = { | ||
source: PropTypes.oneOfType([ | ||
PropTypes.shape({ | ||
uri: PropTypes.string | ||
}), | ||
// Opaque type returned by require('./image.jpg') | ||
PropTypes.number | ||
]), | ||
loadingIndicatorSource: PropTypes.oneOfType([ | ||
PropTypes.shape({ | ||
uri: PropTypes.string | ||
}), | ||
// Opaque type returned by require('./image.jpg') | ||
PropTypes.number | ||
]), | ||
fadeDuration: PropTypes.number, | ||
minimumZoomScale: PropTypes.number, | ||
maximumZoomScale: PropTypes.number, | ||
scale: PropTypes.number, | ||
onLoadStart: PropTypes.func, | ||
onLoad: PropTypes.func, | ||
onLoadEnd: PropTypes.func, | ||
onTap: PropTypes.func, | ||
onViewTap: PropTypes.func, | ||
onScale: PropTypes.func, | ||
showsHorizontalScrollIndicator: PropTypes.bool, | ||
showsVerticalScrollIndicator: PropTypes.bool, | ||
...ViewPropTypes | ||
}; | ||
|
||
render() { | ||
return ( | ||
<ScrollView | ||
contentContainerStyle={{ alignItems:'center', justifyContent:'center' }} | ||
centerContent={true} | ||
maximumZoomScale={this.props.maximumZoomScale} | ||
minimumZoomScale={this.props.minimumZoomScale} | ||
showsHorizontalScrollIndicator={this.props.showsHorizontalScrollIndicator} | ||
showsVerticalScrollIndicator={this.props.showsVerticalScrollIndicator} | ||
> | ||
const source = resolveAssetSource(this.props.source); | ||
var loadingIndicatorSource = resolveAssetSource(this.props.loadingIndicatorSource); | ||
|
||
if (source && source.uri === '') { | ||
console.warn('source.uri should not be an empty string'); | ||
} | ||
|
||
<TouchableWithoutFeedback | ||
onPress={this.props.onTap ? this.props.onTap : function() {}}> | ||
if (this.props.src) { | ||
console.warn('The <PhotoView> component requires a `source` property rather than `src`.'); | ||
} | ||
|
||
<Image {...this.props}/> | ||
if (source && source.uri) { | ||
var {onLoadStart, onLoad, onLoadEnd, onTap, onViewTap, onScale, ...props} = this.props; | ||
|
||
</TouchableWithoutFeedback> | ||
var nativeProps = { | ||
onPhotoViewerLoadStart: onLoadStart, | ||
onPhotoViewerLoad: onLoad, | ||
onPhotoViewerLoadEnd: onLoadEnd, | ||
onPhotoViewerTap: onTap, | ||
onPhotoViewerViewTap: onViewTap, | ||
onPhotoViewerScale: onScale, | ||
...props, | ||
src: source, | ||
loadingIndicatorSrc: loadingIndicatorSource ? loadingIndicatorSource.uri : null, | ||
}; | ||
|
||
</ScrollView> | ||
); | ||
return <RNPhotoView {...nativeProps} /> | ||
} | ||
return null | ||
} | ||
} | ||
|
||
var cfg = { | ||
nativeOnly: { | ||
onPhotoViewerLoadStart: true, | ||
onPhotoViewerLoad: true, | ||
onPhotoViewerLoadEnd: true, | ||
onPhotoViewerTap: true, | ||
onPhotoViewerViewTap: true, | ||
onPhotoViewerScale: true, | ||
src: true, | ||
loadingIndicatorSrc: true | ||
} | ||
}; | ||
const RNPhotoView = requireNativeComponent('RNPhotoView', PhotoView, cfg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["react-native"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.pbxproj -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,65 @@ | ||
import re | ||
|
||
# To learn about Buck see [Docs](https://buckbuild.com/). | ||
# To run your application with Buck: | ||
# - install Buck | ||
# - `npm start` - to start the packager | ||
# - `cd android` | ||
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US` | ||
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` | ||
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck | ||
# - `buck install -r android/app` - compile, install and run application | ||
# | ||
|
||
lib_deps = [] | ||
|
||
for jarfile in glob(['libs/*.jar']): | ||
name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) | ||
name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')] | ||
lib_deps.append(':' + name) | ||
prebuilt_jar( | ||
name = name, | ||
binary_jar = jarfile, | ||
) | ||
|
||
for aarfile in glob(['libs/*.aar']): | ||
name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) | ||
name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')] | ||
lib_deps.append(':' + name) | ||
android_prebuilt_aar( | ||
name = name, | ||
aar = aarfile, | ||
) | ||
|
||
android_library( | ||
name = 'all-libs', | ||
exported_deps = lib_deps | ||
name = "all-libs", | ||
exported_deps = lib_deps, | ||
) | ||
|
||
android_library( | ||
name = 'app-code', | ||
srcs = glob([ | ||
'src/main/java/**/*.java', | ||
]), | ||
deps = [ | ||
':all-libs', | ||
':build_config', | ||
':res', | ||
], | ||
name = "app-code", | ||
srcs = glob([ | ||
"src/main/java/**/*.java", | ||
]), | ||
deps = [ | ||
":all-libs", | ||
":build_config", | ||
":res", | ||
], | ||
) | ||
|
||
android_build_config( | ||
name = 'build_config', | ||
package = 'com.example', | ||
name = "build_config", | ||
package = "com.example", | ||
) | ||
|
||
android_resource( | ||
name = 'res', | ||
res = 'src/main/res', | ||
package = 'com.example', | ||
name = "res", | ||
package = "com.example", | ||
res = "src/main/res", | ||
) | ||
|
||
android_binary( | ||
name = 'app', | ||
package_type = 'debug', | ||
manifest = 'src/main/AndroidManifest.xml', | ||
keystore = '//android/keystores:debug', | ||
deps = [ | ||
':app-code', | ||
], | ||
name = "app", | ||
keystore = "//android/keystores:debug", | ||
manifest = "src/main/AndroidManifest.xml", | ||
package_type = "debug", | ||
deps = [ | ||
":app-code", | ||
], | ||
) |
Oops, something went wrong.