1- /**
2- * Sample React Native App
3- * https://github.com/facebook/react-native
4- * @flow
5- */
6-
1+ console . debug = console . debug || console . log ;
72import React , { Component } from 'react' ;
8- import { AppRegistry , StyleSheet , Text , View , Image } from 'react-native' ;
9- import RNPhotosFramework from './react-native-photos-framework' ;
10- import { postAsset , postAssets } from './react-native-photos-framework/src/ajax-helper' ;
11-
12- export default class Example extends Component {
13-
14- constructor ( ) {
15- super ( ) ;
16- this . state = {
17- images : [ ]
18- } ;
19- }
3+ import { AppRegistry , StyleSheet , Text , View , TouchableOpacity , AlertIOS } from 'react-native' ;
4+ import AlbumList from './album-list' ;
5+ import { Scene , Router } from 'react-native-router-flux' ;
6+ import CameraRollPicker from './react-native-camera-roll-picker' ;
7+ import { Actions } from 'react-native-router-flux'
208
21- componentDidMount ( ) {
22- RNPhotosFramework . requestAuthorization ( ) . then ( ( statusObj ) => {
23- if ( statusObj . isAuthorized ) {
24- RNPhotosFramework . getAlbums ( {
25- type : 'smartAlbum' ,
26- subType : 'smartAlbumUserLibrary' ,
27- assetCount : 'exact' ,
28- fetchOptions : {
29- sortDescriptors : [
30- {
31- key : 'title' ,
32- ascending : true
33- }
34- ] ,
35- includeHiddenAssets : false ,
36- includeAllBurstAssets : false
37- } ,
38- //When you say 'trackInsertsAndDeletes or trackChanges' for an albums query result,
39- //They will be cached and tracking will start.
40- //Call queryResult.stopTracking() to stop this. ex. on componentDidUnmount
41- trackInsertsAndDeletes : true ,
42- trackChanges : false
439
44- } ) . then ( ( queryResult ) => {
45- const album = queryResult . albums [ 0 ] ;
46- return album . getAssets ( {
47- fetchOptions : {
48- // mediaTypes: ['video']
49- } ,
50- includeResourcesMetadata : true ,
51-
52- //The fetch-options from the outer query will apply here, if we get
53- startIndex : 0 ,
54- endIndex : 10 ,
55- //When you say 'trackInsertsAndDeletes or trackAssetsChange' for an albums assets,
56- //They will be cached and tracking will start.
57- //Call album.stopTracking() to stop this. ex. on componentDidUnmount
58- trackInsertsAndDeletes : true ,
59- trackChanges : false
60- } ) . then ( ( response ) => {
61- /* response.assets[1].getImageMetadata().then((asset) => {
62- debugger;
63- });*/
64- setTimeout ( ( ) => {
65- const assets = [ response . assets [ 0 ] , response . assets [ 1 ] ] ;
66- postAssets ( assets , {
67- url : 'http://localhost:3000/upload' ,
68- headers : { } ,
69- onProgress : ( progressPercentage , details ) => {
70- console . log ( 'On Progress called' , progressPercentage ) ;
71- } ,
72- onComplete : ( asset , status , responseText , xhr ) => {
73- console . log ( 'Asset upload completed successfully' ) ;
74- } ,
75- onError : ( asset , status , responseText , xhr ) => {
76- console . log ( 'Asset upload failed' ) ;
77- } ,
78- onFinnished : ( completedItems ) => {
79- console . log ( 'Operation complete' ) ;
80- } ,
81- modifyAssetData : ( postableAsset , asset ) => {
82- postableAsset . name = `${ postableAsset . name } -special-name-maybe-guid.jpg` ;
83- return postableAsset ;
84- }
85- } ) . then ( ( result ) => {
86- console . log ( 'Operation complete, promise resolved' , result ) ;
87- } ) ;
88- } , 2000 ) ;
89-
90- this . setState ( {
91- images : [ response . assets [ 0 ] ]
92- } ) ;
93- } ) ;
94- } ) ;
95- }
96- } ) ;
97- }
98-
99- renderImage ( asset , index ) {
100- return (
101- < Image key = { index } source = { asset . image } style = { { width : 100 , height : 100 } } > </ Image >
102- ) ;
103- }
10+ export default class Example extends Component {
10411
105- render ( ) {
106- return (
107- < View style = { styles . container } >
108- { this . state . images . map ( this . renderImage . bind ( this ) ) }
109- </ View >
110- ) ;
111- }
12+ constructor ( ) {
13+ super ( ) ;
14+ this . state = {
15+ albumEditMode : false
16+ } ;
17+ }
18+
19+ render ( ) {
20+ return (
21+ < Router >
22+ < Scene key = "root" >
23+ < Scene
24+ key = "albumList"
25+ component = { AlbumList }
26+ title = "Album" />
27+ < Scene key = "cameraRollPicker" component = { CameraRollPicker } title = "Bilder" />
28+ </ Scene >
29+ </ Router >
30+ ) ;
31+ }
11232}
11333
11434const styles = StyleSheet . create ( {
115- container : {
116- flex : 1 ,
117- justifyContent : 'center' ,
118- alignItems : 'center' ,
119- backgroundColor : '#F5FCFF'
120- } ,
121- welcome : {
122- fontSize : 20 ,
123- textAlign : 'center' ,
124- margin : 10
125- } ,
126- instructions : {
127- textAlign : 'center' ,
128- color : '#333333' ,
129- marginBottom : 5
130- }
35+ container : {
36+ flex : 1
37+ }
13138} ) ;
13239
133- AppRegistry . registerComponent ( 'Example' , ( ) => Example ) ;
40+ AppRegistry . registerComponent ( 'Example' , ( ) => Example ) ;
0 commit comments