import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
ListView,
TouchableOpacity
} from 'react-native';
import {CameraKitCamera} from 'react-native-camera-kit';
class example extends Component {
constructor(props) {
super(props);
this.state = {
albumsName: (new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})),
shouldOpenCamera: false,
}
}
render() {
//console.error(CameraKitCamera);
return (
get albums
{rowData}}
style={styles.listView}
/>
{this.state.shouldOpenCamera ? "close camera" : "open camera"}
{this._renderCameraView()}
);
}
_renderRow(rowData) {
return (
{rowData}
)
}
async onGetAlbumsPressed() {
const albumsNames = await CameraKitGallery.getAlbums();
this.setState({albumsName:this.state.albumsName.cloneWithRows(albumsNames)});
}
_renderCameraView() {
if (this.state.shouldOpenCamera) {
return (
)
}
}
onOpenCameraPressed() {
this.setState({shouldOpenCamera:!this.state.shouldOpenCamera});
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
marginTop: 20
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
row: {
flexDirection: 'row',
justifyContent: 'center',
padding: 10,
backgroundColor: '#F6F6F6',
},
text: {
flex: 1,
},
button: {
fontSize: 20
},
listView: {
flex: 1,
flexDirection:'column',
margin: 8,
backgroundColor: '#D6DAC2',
alignSelf: 'stretch'
},
});
AppRegistry.registerComponent('example', () => example);