diff --git a/Example/.babelrc b/Example/.babelrc new file mode 100644 index 0000000..d4b74b5 --- /dev/null +++ b/Example/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["module:metro-react-native-babel-preset"] +} diff --git a/Example/.buckconfig b/Example/.buckconfig new file mode 100644 index 0000000..934256c --- /dev/null +++ b/Example/.buckconfig @@ -0,0 +1,6 @@ + +[android] + target = Google Inc.:Google APIs:23 + +[maven_repositories] + central = https://repo1.maven.org/maven2 diff --git a/Example/.flowconfig b/Example/.flowconfig index 66b57e0..1ac2a7b 100644 --- a/Example/.flowconfig +++ b/Example/.flowconfig @@ -1,89 +1,48 @@ [ignore] +; We fork some components by platform +.*/*[.]android.js -# We fork some components by platform. -.*/*.web.js -.*/*.android.js +; Ignore "BUCK" generated dirs +/\.buckd/ -# Some modules have their own node_modules with overlap -.*/node_modules/node-haste/.* +; Ignore unexpected extra "@providesModule" +.*/node_modules/.*/node_modules/fbjs/.* -# Ugh -.*/node_modules/babel.* -.*/node_modules/babylon.* -.*/node_modules/invariant.* +; Ignore duplicate module providers +; For RN Apps installed via npm, "Libraries" folder is inside +; "node_modules/react-native" but in the source repo it is in the root +.*/Libraries/react-native/React.js -# Ignore react and fbjs where there are overlaps, but don't ignore -# anything that react-native relies on -.*/node_modules/fbjs/lib/Map.js -.*/node_modules/fbjs/lib/fetch.js -.*/node_modules/fbjs/lib/ExecutionEnvironment.js -.*/node_modules/fbjs/lib/ErrorUtils.js - -# Flow has a built-in definition for the 'react' module which we prefer to use -# over the currently-untyped source -.*/node_modules/react/react.js -.*/node_modules/react/lib/React.js -.*/node_modules/react/lib/ReactDOM.js - -.*/__mocks__/.* -.*/__tests__/.* - -.*/commoner/test/source/widget/share.js - -# Ignore commoner tests -.*/node_modules/commoner/test/.* - -# See https://github.com/facebook/flow/issues/442 -.*/react-tools/node_modules/commoner/lib/reader.js - -# Ignore jest -.*/node_modules/jest-cli/.* - -# Ignore Website -.*/website/.* - -.*/node_modules/is-my-json-valid/test/.*\.json -.*/node_modules/iconv-lite/encodings/tables/.*\.json -.*/node_modules/y18n/test/.*\.json -.*/node_modules/spdx-license-ids/spdx-license-ids.json -.*/node_modules/spdx-exceptions/index.json -.*/node_modules/resolve/test/subdirs/node_modules/a/b/c/x.json -.*/node_modules/resolve/lib/core.json -.*/node_modules/jsonparse/samplejson/.*\.json -.*/node_modules/json5/test/.*\.json -.*/node_modules/ua-parser-js/test/.*\.json -.*/node_modules/builtin-modules/builtin-modules.json -.*/node_modules/binary-extensions/binary-extensions.json -.*/node_modules/url-regex/tlds.json -.*/node_modules/joi/.*\.json -.*/node_modules/isemail/.*\.json -.*/node_modules/tr46/.*\.json +; Ignore polyfills +.*/Libraries/polyfills/.* [include] [libs] node_modules/react-native/Libraries/react-native/react-native-interface.js -node_modules/react-native/flow -flow/ +node_modules/react-native/flow/ [options] -module.system=haste +emoji=true -esproposal.class_static_fields=enable -esproposal.class_instance_fields=enable +module.system=haste munge_underscores=true -module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub' -module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\)$' -> 'RelativeImageStub' +module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' suppress_type=$FlowIssue suppress_type=$FlowFixMe +suppress_type=$FlowFixMeProps +suppress_type=$FlowFixMeState suppress_type=$FixMe -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-2]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-2]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ +suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) +suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy +suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError + +unsafe.enable_getters_and_setters=true [version] -0.22.0 +^0.56.0 diff --git a/Example/.gitattributes b/Example/.gitattributes new file mode 100644 index 0000000..d42ff18 --- /dev/null +++ b/Example/.gitattributes @@ -0,0 +1 @@ +*.pbxproj -text diff --git a/Example/.gitignore b/Example/.gitignore index 94fc867..0826423 100644 --- a/Example/.gitignore +++ b/Example/.gitignore @@ -22,13 +22,32 @@ DerivedData *.xcuserstate project.xcworkspace -# Android/IJ +# Android/IntelliJ # +build/ .idea .gradle local.properties +*.iml # node.js # node_modules/ npm-debug.log +yarn-error.log + +# BUCK +buck-out/ +\.buckd/ +*.keystore + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/ + +*/fastlane/report.xml +*/fastlane/Preview.html +*/fastlane/screenshots diff --git a/Example/DetailScreen.js b/Example/DetailScreen.js new file mode 100644 index 0000000..6f00b76 --- /dev/null +++ b/Example/DetailScreen.js @@ -0,0 +1,89 @@ +import React, { Component } from 'react'; +import { ActionSheetIOS, Platform, Button } from 'react-native'; + +import PhotoBrowser from 'react-native-photo-browser'; + +export default class HomeScreen extends Component { + static navigationOptions = { + header: null, + }; + + state = { + mediaList: this.props.navigation.state.params.example.media, + selected: new Set(), + } + + onSelectionChanged = (media, index, selected) => { + this.setState(prevState => { + const copy = new Set(prevState.selected); + if (selected) { + copy.add(index); + } else { + copy.delete(index); + } + return { + selected: copy, + }; + }); + }; + + onActionButton = (media, index) => { + if (Platform.OS === 'ios') { + ActionSheetIOS.showShareActionSheetWithOptions( + { + url: media.photo, + message: media.caption, + }, + () => {}, + () => {}, + ); + } else { + alert(`handle sharing on android for ${media.photo}, index: ${index}`); + } + }; + + render() { + const { + initialIndex, + displayNavArrows, + displayActionButton, + displaySelectionButtons, + startOnGrid, + enableGrid, + alwaysDisplayStatusBar, + } = this.props.navigation.state.params.example; + + const { mediaList, selected } = this.state; + + return ( + <> + `${index} sur ${rowCount}`} + /> + {selected.size > 0 && ( +