Commit e91aa5ea authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

memperbaiki picker image

parent bcbb6fc6
......@@ -6760,6 +6760,11 @@
"resolved": "https://registry.npmjs.org/react-native-image-base64/-/react-native-image-base64-0.1.4.tgz",
"integrity": "sha512-WLdzwHdXFRLS9VStG1CG46+t+fcInjVWxKd1+AATElBhaAS3zwDHz7mYIZS1OX4VMuNClwl5G8dowuqUJ9aMGQ=="
},
"react-native-image-picker": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/react-native-image-picker/-/react-native-image-picker-2.3.1.tgz",
"integrity": "sha512-c/a2h7/T7yBo5KlNQhcSn4xf4+6Li6LfJ59+GZT1ZzzWrj/6X8DiJ/TJBOlOZMC5tJriZKuRkWSsr74k6z+brw=="
},
"react-native-image-slider-box": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/react-native-image-slider-box/-/react-native-image-slider-box-1.0.12.tgz",
......
......@@ -44,7 +44,8 @@ const ActionType = {
REMOVE_VOUCHER : 'REMOVE_VOUCHER',
SET_CHANGE_RESET_PASSWORD : 'SET_CHANGE_RESET_PASSWORD',
//set url
SET_BASE_URL :'SET_BASE_URL'
SET_BASE_URL :'SET_BASE_URL',
SET_PICKIMAGE:'SET_PICKIMAGE'
}
export default ActionType;
\ No newline at end of file
......@@ -89,6 +89,7 @@ const globalState = {
outlet_detailadress: '',
isSubmitResetPassword: false,
setpickimageSelfie: true,
BASE_URL:'https://excelsocrm.ravintoladev.com/'
......@@ -213,6 +214,13 @@ const rootReducer = (state = globalState, action) => {
proses: action.data.proses
}
}
case ActionType.SET_PICKIMAGE: {
return {
...state,
setpickimageSelfie: action.data.setpickimageSelfie
}
}
case ActionType.SET_CHANGE_EMAIL: {
return {
...state,
......
......@@ -377,7 +377,7 @@ class Account extends React.Component {
</View>
<View style={{ flex: 1, flexDirection: 'row', justifyContent: 'center' }}>
{this.state.premium === false ? (
{this.state.premium === true ? (
<TouchableOpacity onPress={() => this.props.navigation.navigate('Upgrade Premium')} style={{ marginBottom: 20, marginRight: 5, marginLeft: 5 }}>
<Card style={{ width: 200, paddingHorizontal: 10, paddingTop: 20, paddingBottom: 20 }}>
<View style={{ flex: 1, alignItems: 'center' }}>
......
......@@ -8,7 +8,8 @@ import * as FileSystem from 'expo-file-system';
import { connect } from 'react-redux';
import ActionType from '../redux/globalActionType';
class Cameras extends React.Component {
class Cameras extends React.Component {
state = {
hasPermission: null,
cameraType: Camera.Constants.Type.back,
......@@ -42,7 +43,7 @@ import ActionType from '../redux/globalActionType';
})
}
capture(){
capture() {
// console.log('IS SELFIE : ' + this.props.selfie)
// console.log('IS IDCARD : ' + this.props.idcard)
if (this.props.selfie === true) {
......@@ -56,7 +57,7 @@ import ActionType from '../redux/globalActionType';
takePictureSelfie = async () => {
if (this.camera) {
let photo = await this.camera.takePictureAsync({skipProcessing:true});
let photo = await this.camera.takePictureAsync({ skipProcessing: true });
let photo_img = photo.uri;
const base64 = await FileSystem.readAsStringAsync(photo_img, { encoding: 'base64' });
// var set_photo = photo.replace('uri','')
......@@ -73,7 +74,7 @@ import ActionType from '../redux/globalActionType';
takePictureIdCard = async () => {
if (this.camera) {
let photo = await this.camera.takePictureAsync({skipProcessing:true});
let photo = await this.camera.takePictureAsync({ skipProcessing: true });
let photo_img = photo.uri;
const base64 = await FileSystem.readAsStringAsync(photo_img, { encoding: 'base64' });
// var set_photo = photo.replace('uri','')
......@@ -87,12 +88,41 @@ import ActionType from '../redux/globalActionType';
}
}
pickImage = async () => {
if (this.props.setpickimageSelfie == true) {
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
allowsEditing: false, aspect: [4, 3],
quality: 0.1,
});
let resultImagePicker = result.uri
const base64 = await FileSystem.readAsStringAsync(resultImagePicker, { encoding: 'base64' });
let UriProps = {
URI: resultImagePicker,
}
let setpickSelfie = {
setpickimageSelfie: false
}
this.props.setUriSelfi(UriProps);
this.props.setpickimageSelfieProps(setpickSelfie);
this.props.navigation.navigate("Upgrade Premium")
//false
} else {
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images
});
let resultImagePicker = result.uri
const base64 = await FileSystem.readAsStringAsync(resultImagePicker, { encoding: 'base64' });
let UriPropsID = {
URI_IDCARD: resultImagePicker,
}
let setpickSelfie = {
setpickimageSelfie: true
}
this.props.setUriID(UriPropsID);
this.props.setpickimageSelfieProps(setpickSelfie);
this.props.navigation.navigate("Upgrade Premium")
}
}
render() {
......@@ -166,7 +196,13 @@ const mapDispatchToProps = (dispacth) => {
type: ActionType.SET_CHANGE_URI_ID,
data: {
URI_IDCARD: UriPropsID.URI_IDCARD,
BASE64_ID:UriPropsID.BASE64_ID,
BASE64_ID: UriPropsID.BASE64_ID,
}
}),
setpickimageSelfieProps: (setpickSelfie) => dispacth({
type: ActionType.SET_PICKIMAGE,
data: {
setpickimageSelfie:setpickSelfie.setpickimageSelfie
}
}),
}
......@@ -179,101 +215,10 @@ const mapStateToProps = (state) => {
img64: state.img64,
id_card64: state.id_card64,
selfie: state.selfie,
idcard: state.id_card
idcard: state.id_card,
setpickimageSelfie: state.setpickimageSelfie
}
}
export default connect(mapStateToProps, mapDispatchToProps)(Cameras);
\ No newline at end of file
// import React, { useState, useEffect } from 'react';
// import { Text, View, TouchableOpacity } from 'react-native';
// import { Camera } from 'expo-camera';
// export default function Cameras() {
// const [hasPermission, setHasPermission] = useState(null);
// const [type, setType] = useState(Camera.Constants.Type.back);
// useEffect(() => {
// (async () => {
// const { status } = await Camera.requestPermissionsAsync();
// setHasPermission(status === 'granted');
// })();
// }, []);
// if (hasPermission === null) {
// return <View />;
// }
// if (hasPermission === false) {
// return <Text>No access to camera</Text>;
// }
// return (
// <View style={{ flex: 1 }}>
// <Camera style={{ flex: 1 }} type={type}>
// <View
// style={{
// flex: 1,
// backgroundColor: 'transparent',
// flexDirection: 'row',
// }}>
// <TouchableOpacity
// style={{
// flex: 0.1,
// alignSelf: 'flex-end',
// alignItems: 'center',
// }}
// onPress={() => {
// setType(
// type === Camera.Constants.Type.back
// ? Camera.Constants.Type.front
// : Camera.Constants.Type.back
// );
// }}>
// <Text style={{ fontSize: 18, marginBottom: 10, color: 'white' }}> Flip </Text>
// </TouchableOpacity>
// </View>
// </Camera>
// </View>
// );
// }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment