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';
|
|
|
|
|
2018-03-15 14:37:58 +00:00
|
|
|
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-08-15 07:15:50 +00:00
|
|
|
|
2017-02-26 14:58:08 +00:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
example: undefined
|
|
|
|
};
|
|
|
|
}
|
2017-08-15 07:15:50 +00:00
|
|
|
|
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 }}>
|
2017-08-15 07:15:50 +00:00
|
|
|
<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>
|
2017-08-15 07:15:50 +00:00
|
|
|
</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 })}>
|
2017-08-15 07:15:50 +00:00
|
|
|
<Text style={styles.buttonText}>
|
|
|
|
Camera Screen
|
|
|
|
</Text>
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
2018-01-29 15:22:02 +00:00
|
|
|
<TouchableOpacity onPress={() => this.setState({ example: AlbumsScreen })}>
|
2017-08-15 07:15:50 +00:00
|
|
|
<Text style={styles.buttonText}>
|
|
|
|
Albums Screen
|
|
|
|
</Text>
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
2018-01-29 15:22:02 +00:00
|
|
|
<TouchableOpacity onPress={() => this.setState({ example: GalleryScreen })}>
|
2017-08-15 07:15:50 +00:00
|
|
|
<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-08-15 07:15:50 +00:00
|
|
|
|
2017-02-26 14:58:08 +00:00
|
|
|
);
|
|
|
|
}
|
2017-08-15 07:15:50 +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-08-15 07:15:50 +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,
|
2017-08-15 07:15:50 +00:00
|
|
|
// justifyContent: 'center',
|
|
|
|
paddingTop: 60,
|
2017-02-26 14:58:08 +00:00
|
|
|
alignItems: 'center',
|
|
|
|
backgroundColor: '#F5FCFF',
|
|
|
|
},
|
2017-08-15 07:15:50 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-15 14:37:58 +00:00
|
|
|
AppRegistry.registerComponent('CameraKit', () => example);
|