react-native-camera-kit/example-js-code/app.js

133 lines
3.3 KiB
JavaScript
Raw Normal View History

2018-01-29 15:22:02 +00:00
import React, { Component } from 'react';
2017-02-26 14:58:08 +00:00
import {
AppRegistry,
StyleSheet,
Text,
View,
TouchableOpacity,
AlertIOS
} from 'react-native';
import {CameraKitCamera, CameraKitGallery} from '../src';
2017-02-26 14:58:08 +00:00
2017-08-14 07:04:04 +00:00
import CameraScreen from './src/CameraScreen';
2018-01-29 15:22:02 +00:00
import AlbumsScreen from './src/AlbumsScreen';
import GalleryScreen from './src/GalleryScreen';
2018-02-01 14:53:38 +00:00
import BarcodeScreen from './src/BarcodeScreen';
2017-02-26 14:58:08 +00:00
class example extends Component {
2017-02-26 14:58:08 +00:00
constructor(props) {
super(props);
this.state = {
example: undefined
};
}
2017-02-26 14:58:08 +00:00
render() {
if (this.state.example) {
const Example = this.state.example;
return <Example />;
}
return (
2018-01-29 15:22:02 +00:00
<View style={{ flex: 1 }}>
<View style={styles.headerContainer}>
<Text style={styles.headerText}>
Welcome to Camera Kit
2017-02-26 14:58:08 +00:00
</Text>
2018-01-29 15:22:02 +00:00
<Text style={{ fontSize: 40 }}>📷</Text>
</View>
<View style={styles.container}>
2018-02-01 14:53:38 +00:00
<TouchableOpacity onPress={() => this.setState({ example: BarcodeScreen })}>
<Text style={styles.buttonText}>
Barcode scanner Screen
</Text>
</TouchableOpacity>
2018-01-29 15:22:02 +00:00
<TouchableOpacity onPress={() => this.setState({ example: CameraScreen })}>
<Text style={styles.buttonText}>
Camera Screen
</Text>
</TouchableOpacity>
2018-01-29 15:22:02 +00:00
<TouchableOpacity onPress={() => this.setState({ example: AlbumsScreen })}>
<Text style={styles.buttonText}>
Albums Screen
</Text>
</TouchableOpacity>
2018-01-29 15:22:02 +00:00
<TouchableOpacity onPress={() => this.setState({ example: GalleryScreen })}>
<Text style={styles.buttonText}>
Gallery Screen
</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.onCheckCameraAuthoPressed()}>
<Text style={styles.buttonText}>
Camera Autotization Status
</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.onCheckGalleryAuthoPressed()}>
<Text style={styles.buttonText}>
Photos Autotization Status
</Text>
</TouchableOpacity>
</View>
2017-02-26 14:58:08 +00:00
</View>
2017-02-26 14:58:08 +00:00
);
}
2017-02-26 14:58:08 +00:00
async onCheckCameraAuthoPressed() {
const success = await CameraKitCamera.checkDeviceCameraAuthorizationStatus();
if (success) {
2017-08-14 07:04:04 +00:00
AlertIOS.alert('You have permission 🤗')
2017-02-26 14:58:08 +00:00
}
else {
2017-08-14 07:04:04 +00:00
AlertIOS.alert('No permission 😳')
2017-02-26 14:58:08 +00:00
}
}
2017-02-26 14:58:08 +00:00
async onCheckGalleryAuthoPressed() {
const success = await CameraKitGallery.checkDevicePhotosAuthorizationStatus();
if (success) {
2017-08-14 07:04:04 +00:00
AlertIOS.alert('You have permission 🤗')
2017-02-26 14:58:08 +00:00
}
else {
2017-08-14 07:04:04 +00:00
AlertIOS.alert('No permission 😳')
2017-02-26 14:58:08 +00:00
}
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
// justifyContent: 'center',
paddingTop: 60,
2017-02-26 14:58:08 +00:00
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
headerContainer: {
flexDirection: 'column',
backgroundColor: '#F5FCFF',
justifyContent: 'center',
alignItems: 'center',
paddingTop: 100
},
headerText: {
color: 'black',
fontSize: 24
},
2017-02-26 14:58:08 +00:00
buttonText: {
color: 'blue',
marginBottom: 20,
fontSize: 20
}
});
AppRegistry.registerComponent('CameraKit', () => example);