/** * Copyright 2004-present Facebook. All Rights Reserved. */ 'use strict'; var React = require('react-native'); var { CameraRoll, Image, SliderIOS, StyleSheet, SwitchIOS, Text, View, } = React; var CameraRollView = require('./CameraRollView.ios'); var CAMERA_ROLL_VIEW = 'camera_roll_view'; var CameraRollExample = React.createClass({ getInitialState() { return { groupTypes: 'SavedPhotos', sliderValue: 1, bigImages: true, }; }, render() { return ( {(this.state.bigImages ? 'Big' : 'Small') + ' Images'} {'Group Type: ' + this.state.groupTypes} ); }, _renderImage(asset) { var imageSize = this.state.bigImages ? 150 : 75; var imageStyle = [styles.image, {width: imageSize, height: imageSize}]; var location = asset.node.location.longitude ? JSON.stringify(asset.node.location) : 'Unknown location'; return ( {asset.node.image.uri} {location} {asset.node.group_name} {new Date(asset.node.timestamp).toString()} ); }, _onSliderChange(value) { var options = CameraRoll.GroupTypesOptions; var index = Math.floor(value * options.length * 0.99); var groupTypes = options[index]; if (groupTypes !== this.state.groupTypes) { this.setState({groupTypes: groupTypes}); } }, _onSwitchChange(value) { this.refs[CAMERA_ROLL_VIEW].rendererChanged(); this.setState({ bigImages: value }); } }); var styles = StyleSheet.create({ row: { flexDirection: 'row', flex: 1, }, url: { fontSize: 9, marginBottom: 14, }, image: { margin: 4, }, info: { flex: 1, }, }); exports.title = ''; exports.description = 'Example component that uses CameraRoll to list user\'s photos'; exports.examples = [ { title: 'Photos', render() { return ; } } ];