React-native Demo (31)-Access the album API

Source: Internet
Author: User
Tags require

Cameraroll Method

name function
Saveimagewithtag Save pictures to albums
Getphotos Get pictures from albums
Example
' Use strict ';
var React = require (' react-native ');

var {cameraroll, Image, Sliderios, StyleSheet, Switchios, Text, View, touchableopacity} = React;
var Camerarollview = require ('./camerarollview.ios ');

var Assetscaledimageexampleview = require ('./assetscaledimageexample ');

var camera_roll_view = ' Camera_roll_view '; var camerarollexample = React.createclass ({getinitialstate () {return {grouptypes: ' Savedphotos ', SLI
  Dervalue:1, Bigimages:true,};
          }, Render () {return (<View> <switchios Onvaluechange={this._onswitchchange} Value={this.state.bigimages}/> <text>{(this.state.bigImages? ' Big ': ' Small ') + ' Images '}</text> <sliderios value={this.state.slidervalue} onvalu
        Echange={this._onsliderchange}/> <text>{' Group Type: ' + this.state.grouptypes}</text> <camerarollview Ref={camEra_roll_view} batchsize={20} grouptypes={this.state.grouptypes} Renderimage={this._renderim
  Age}/> </View>); }, Loadasset (asset) {This.props.navigator.push ({title: ' Camera roll Image ', Component:assetscaledimag
  Eexampleview, 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?
    Json.stringify (asset.node.location): ' Unknown location '; Return (<touchableopacity onpress={this.loadAsset.bind (this, asset)}> <view Key={asset} style=
          {styles.row}> <image source={asset.node.image} Style={imagestyle}/> <view style={styles.info}> <text Style={styles.url}>{asset.node.Image.uri}</text> <Text>{location}</Text> <text>{asset.node.group_name}&lt
        ;/text> <text>{new Date (asset.node.timestamp). toString ()}</text> </View>
  </View> </TouchableOpacity>);
    }, _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, margin

Bottom:14,}, Image: {Margin:4,}, Info: {flex:1,},});
Exports.title = ' Camera roll '; exports.description = ' Example component that uses cameRaroll to list user\ ' s photos ';
  Exports.examples = [{title: ' Photos ', Render (): reactelement {return <camerarollexample/>;}
 }
];
effect

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.