Permalink
Browse files

Open sourced Camera Roll module

Reviewed By: mkonicek

Differential Revision: D2827804

fb-gh-sync-id: c1f06f148855bc4f69da8e19b8445988f1b022b3
  • Loading branch information...
bestander authored and facebook-github-bot-6 committed Jan 14, 2016
1 parent f8c384f commit 892497408c14b61687cb823a144bd80996023404
@@ -15,24 +15,25 @@
*/
'use strict';
-var React = require('react-native');
-var {
+const React = require('react-native');
+const {
CameraRoll,
Image,
SliderIOS,
StyleSheet,
- SwitchIOS,
+ Switch,
Text,
View,
TouchableOpacity
} = React;
-var CameraRollView = require('./CameraRollView.ios');
-var AssetScaledImageExampleView = require('./AssetScaledImageExample');
+const CameraRollView = require('./CameraRollView');
-var CAMERA_ROLL_VIEW = 'camera_roll_view';
+const AssetScaledImageExampleView = require('./AssetScaledImageExample');
-var CameraRollExample = React.createClass({
+const CAMERA_ROLL_VIEW = 'camera_roll_view';
+
+const CameraRollExample = React.createClass({
getInitialState() {
return {
@@ -45,7 +46,7 @@ var CameraRollExample = React.createClass({
render() {
return (
<View>
- <SwitchIOS
+ <Switch
onValueChange={this._onSwitchChange}
value={this.state.bigImages} />
<Text>{(this.state.bigImages ? 'Big' : 'Small') + ' Images'}</Text>
@@ -65,18 +66,20 @@ var CameraRollExample = React.createClass({
},
loadAsset(asset){
- this.props.navigator.push({
- title: 'Camera Roll Image',
- component: AssetScaledImageExampleView,
- backButtonTitle: 'Back',
- passProps: { asset: asset },
- });
+ if (this.props.navigator) {
+ this.props.navigator.push({
+ title: 'Camera Roll Image',
+ component: AssetScaledImageExampleView,
+ backButtonTitle: 'Back',
+ passProps: { asset: asset },
+ });
+ }
},
_renderImage(asset) {
- var imageSize = this.state.bigImages ? 150 : 75;
- var imageStyle = [styles.image, {width: imageSize, height: imageSize}];
- var location = asset.node.location.longitude ?
+ const imageSize = this.state.bigImages ? 150 : 75;
+ const imageStyle = [styles.image, {width: imageSize, height: imageSize}];
+ const location = asset.node.location.longitude ?
JSON.stringify(asset.node.location) : 'Unknown location';
return (
<TouchableOpacity key={asset} onPress={ this.loadAsset.bind( this, asset ) }>
@@ -97,9 +100,9 @@ var CameraRollExample = React.createClass({
},
_onSliderChange(value) {
- var options = CameraRoll.GroupTypesOptions;
- var index = Math.floor(value * options.length * 0.99);
- var groupTypes = options[index];
+ const options = CameraRoll.GroupTypesOptions;
+ const index = Math.floor(value * options.length * 0.99);
+ const groupTypes = options[index];
if (groupTypes !== this.state.groupTypes) {
this.setState({groupTypes: groupTypes});
}
@@ -111,7 +114,7 @@ var CameraRollExample = React.createClass({
}
});
-var styles = StyleSheet.create({
+const styles = StyleSheet.create({
row: {
flexDirection: 'row',
flex: 1,
@@ -22,6 +22,7 @@ var {
CameraRoll,
Image,
ListView,
+ Platform,
StyleSheet,
View,
} = React;
@@ -139,6 +140,10 @@ var CameraRollView = React.createClass({
groupTypes: this.props.groupTypes,
assetType: this.props.assetType,
};
+ if (Platform.OS === "android") {
+ // not supported in android
+ delete fetchParams.groupTypes;
+ }
if (this.state.lastCursor) {
fetchParams.after = this.state.lastCursor;
}
@@ -43,6 +43,7 @@ var APIS = [
require('./AccessibilityAndroidExample.android'),
require('./AlertExample').AlertExample,
require('./BorderExample'),
+ require('./CameraRollExample'),
require('./ClipboardExample'),
require('./GeolocationExample'),
require('./IntentAndroidExample.android'),
@@ -66,7 +66,7 @@ var APIS = [
require('./AppStateIOSExample'),
require('./AsyncStorageExample'),
require('./BorderExample'),
- require('./CameraRollExample.ios'),
+ require('./CameraRollExample'),
require('./ClipboardExample'),
require('./GeolocationExample'),
require('./LayoutExample'),
Oops, something went wrong.

0 comments on commit 8924974

Please sign in to comment.