Package updates & minor fixes.
This commit is contained in:
@@ -1,103 +1,103 @@
|
||||
// src/toolbar.component.js file
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { Camera } from "expo-camera";
|
||||
import React from "react";
|
||||
import {
|
||||
StyleSheet,
|
||||
TouchableOpacity,
|
||||
TouchableWithoutFeedback,
|
||||
View,
|
||||
} from "react-native";
|
||||
// // src/toolbar.component.js file
|
||||
// import { Ionicons } from "@expo/vector-icons";
|
||||
// import { Camera } from "expo-camera";
|
||||
// import React from "react";
|
||||
// import {
|
||||
// StyleSheet,
|
||||
// TouchableOpacity,
|
||||
// TouchableWithoutFeedback,
|
||||
// View,
|
||||
// } from "react-native";
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
alignCenter: {
|
||||
flex: 1,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
},
|
||||
bottomToolbar: {
|
||||
marginTop: "auto",
|
||||
height: 100,
|
||||
display: "flex",
|
||||
justifyContent: "space-evenly",
|
||||
alignItems: "center",
|
||||
flexDirection: "row",
|
||||
},
|
||||
captureBtn: {
|
||||
width: 60,
|
||||
height: 60,
|
||||
borderWidth: 2,
|
||||
borderRadius: 60,
|
||||
borderColor: "#FFFFFF",
|
||||
},
|
||||
captureBtnActive: {
|
||||
width: 80,
|
||||
height: 80,
|
||||
},
|
||||
captureBtnInternal: {
|
||||
width: 76,
|
||||
height: 76,
|
||||
borderWidth: 2,
|
||||
borderRadius: 76,
|
||||
backgroundColor: "red",
|
||||
borderColor: "transparent",
|
||||
},
|
||||
});
|
||||
// const styles = StyleSheet.create({
|
||||
// alignCenter: {
|
||||
// flex: 1,
|
||||
// alignItems: "center",
|
||||
// justifyContent: "center",
|
||||
// },
|
||||
// bottomToolbar: {
|
||||
// marginTop: "auto",
|
||||
// height: 100,
|
||||
// display: "flex",
|
||||
// justifyContent: "space-evenly",
|
||||
// alignItems: "center",
|
||||
// flexDirection: "row",
|
||||
// },
|
||||
// captureBtn: {
|
||||
// width: 60,
|
||||
// height: 60,
|
||||
// borderWidth: 2,
|
||||
// borderRadius: 60,
|
||||
// borderColor: "#FFFFFF",
|
||||
// },
|
||||
// captureBtnActive: {
|
||||
// width: 80,
|
||||
// height: 80,
|
||||
// },
|
||||
// captureBtnInternal: {
|
||||
// width: 76,
|
||||
// height: 76,
|
||||
// borderWidth: 2,
|
||||
// borderRadius: 76,
|
||||
// backgroundColor: "red",
|
||||
// borderColor: "transparent",
|
||||
// },
|
||||
// });
|
||||
|
||||
const { FlashMode: CameraFlashModes, Type: CameraTypes } = Camera.Constants;
|
||||
// const { FlashMode: CameraFlashModes, Type: CameraTypes } = Camera.Constants;
|
||||
|
||||
export default function CameraControls({
|
||||
capturing = false,
|
||||
cameraType = CameraTypes.back,
|
||||
flashMode = CameraFlashModes.off,
|
||||
setFlashMode,
|
||||
setCameraType,
|
||||
onCaptureIn,
|
||||
onCaptureOut,
|
||||
onLongCapture,
|
||||
onShortCapture,
|
||||
}) {
|
||||
return (
|
||||
<View style={styles.bottomToolbar}>
|
||||
<TouchableOpacity
|
||||
onPress={() =>
|
||||
setFlashMode(
|
||||
flashMode === CameraFlashModes.on
|
||||
? CameraFlashModes.off
|
||||
: CameraFlashModes.on
|
||||
)
|
||||
}
|
||||
>
|
||||
<Ionicons
|
||||
name={flashMode == CameraFlashModes.on ? "md-flash" : "md-flash-off"}
|
||||
color="white"
|
||||
size={30}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
// export default function CameraControls({
|
||||
// capturing = false,
|
||||
// cameraType = CameraTypes.back,
|
||||
// flashMode = CameraFlashModes.off,
|
||||
// setFlashMode,
|
||||
// setCameraType,
|
||||
// onCaptureIn,
|
||||
// onCaptureOut,
|
||||
// onLongCapture,
|
||||
// onShortCapture,
|
||||
// }) {
|
||||
// return (
|
||||
// <View style={styles.bottomToolbar}>
|
||||
// <TouchableOpacity
|
||||
// onPress={() =>
|
||||
// setFlashMode(
|
||||
// flashMode === CameraFlashModes.on
|
||||
// ? CameraFlashModes.off
|
||||
// : CameraFlashModes.on
|
||||
// )
|
||||
// }
|
||||
// >
|
||||
// <Ionicons
|
||||
// name={flashMode == CameraFlashModes.on ? "md-flash" : "md-flash-off"}
|
||||
// color="white"
|
||||
// size={30}
|
||||
// />
|
||||
// </TouchableOpacity>
|
||||
|
||||
<TouchableWithoutFeedback
|
||||
onPressIn={onCaptureIn}
|
||||
onPressOut={onCaptureOut}
|
||||
onLongPress={onLongCapture}
|
||||
onPress={onShortCapture}
|
||||
disabled={capturing}
|
||||
>
|
||||
<View style={[styles.captureBtn, capturing && styles.captureBtnActive]}>
|
||||
{capturing && <View style={styles.captureBtnInternal} />}
|
||||
</View>
|
||||
</TouchableWithoutFeedback>
|
||||
// <TouchableWithoutFeedback
|
||||
// onPressIn={onCaptureIn}
|
||||
// onPressOut={onCaptureOut}
|
||||
// onLongPress={onLongCapture}
|
||||
// onPress={onShortCapture}
|
||||
// disabled={capturing}
|
||||
// >
|
||||
// <View style={[styles.captureBtn, capturing && styles.captureBtnActive]}>
|
||||
// {capturing && <View style={styles.captureBtnInternal} />}
|
||||
// </View>
|
||||
// </TouchableWithoutFeedback>
|
||||
|
||||
<TouchableOpacity
|
||||
onPress={() =>
|
||||
setCameraType(
|
||||
cameraType === CameraTypes.back
|
||||
? CameraTypes.front
|
||||
: CameraTypes.back
|
||||
)
|
||||
}
|
||||
>
|
||||
<Ionicons name="md-reverse-camera" color="white" size={30} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
// <TouchableOpacity
|
||||
// onPress={() =>
|
||||
// setCameraType(
|
||||
// cameraType === CameraTypes.back
|
||||
// ? CameraTypes.front
|
||||
// : CameraTypes.back
|
||||
// )
|
||||
// }
|
||||
// >
|
||||
// <Ionicons name="md-reverse-camera" color="white" size={30} />
|
||||
// </TouchableOpacity>
|
||||
// </View>
|
||||
// );
|
||||
// }
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import * as ImagePicker from "expo-image-picker";
|
||||
import { Body, H3, Icon, ListItem, Right } from "native-base";
|
||||
import React, { useEffect } from "react";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Animated, Platform, Text } from "react-native";
|
||||
import { Animated, Text } from "react-native";
|
||||
import { TouchableOpacity } from "react-native-gesture-handler";
|
||||
import Swipeable from "react-native-gesture-handler/Swipeable";
|
||||
import { connect } from "react-redux";
|
||||
@@ -24,33 +23,33 @@ export function JobListItem({ setCameraJob, setCameraJobId, item }) {
|
||||
const { t } = useTranslation();
|
||||
const navigation = useNavigation();
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (Platform.OS !== "web") {
|
||||
const {
|
||||
status,
|
||||
} = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
||||
if (status !== "granted") {
|
||||
alert("Sorry, we need camera roll permissions to make this work!");
|
||||
}
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
// useEffect(() => {
|
||||
// (async () => {
|
||||
// if (Platform.OS !== "web") {
|
||||
// const {
|
||||
// status,
|
||||
// } = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
||||
// if (status !== "granted") {
|
||||
// alert("Sorry, we need camera roll permissions to make this work!");
|
||||
// }
|
||||
// }
|
||||
// })();
|
||||
// }, []);
|
||||
|
||||
const pickImage = async () => {
|
||||
let result = await ImagePicker.launchImageLibraryAsync({
|
||||
mediaTypes: ImagePicker.MediaTypeOptions.All,
|
||||
allowsEditing: true,
|
||||
aspect: [4, 3],
|
||||
quality: 1,
|
||||
});
|
||||
// const pickImage = async () => {
|
||||
// let result = await ImagePicker.launchImageLibraryAsync({
|
||||
// mediaTypes: ImagePicker.MediaTypeOptions.All,
|
||||
// allowsEditing: true,
|
||||
// aspect: [4, 3],
|
||||
// quality: 1,
|
||||
// });
|
||||
|
||||
console.log(result);
|
||||
// console.log(result);
|
||||
|
||||
if (!result.cancelled) {
|
||||
// setImage(result.uri);
|
||||
}
|
||||
};
|
||||
// if (!result.cancelled) {
|
||||
// // setImage(result.uri);
|
||||
// }
|
||||
// };
|
||||
|
||||
const RenderRightAction = (progress, dragX) => {
|
||||
const scale = dragX.interpolate({
|
||||
|
||||
@@ -11,7 +11,7 @@ export default function NoteListItem({ item }) {
|
||||
<Text>{item.text}</Text>
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
flexDirection: "column",
|
||||
alignSelf: "flex-end",
|
||||
alignItems: "center",
|
||||
}}
|
||||
@@ -32,6 +32,7 @@ export default function NoteListItem({ item }) {
|
||||
color="tomato"
|
||||
/>
|
||||
)}
|
||||
<Text style={{ fontSize: 12 }}>{item.created_by}</Text>
|
||||
<Text style={{ fontSize: 12 }}>
|
||||
{DateTime.fromISO(item.created_at).toLocaleString(
|
||||
DateTime.DATETIME_SHORT
|
||||
|
||||
@@ -1,213 +0,0 @@
|
||||
import React, { Component } from "react";
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Button,
|
||||
Clipboard,
|
||||
Image,
|
||||
Share,
|
||||
StatusBar,
|
||||
StyleSheet,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from "react-native";
|
||||
import { Constants } from "expo";
|
||||
import * as Permissions from "expo-permissions";
|
||||
import * as ImagePicker from "expo-image-picker";
|
||||
export default class ScreenCameraRoll extends Component {
|
||||
state = {
|
||||
image: null,
|
||||
uploading: false,
|
||||
};
|
||||
|
||||
render() {
|
||||
let { image } = this.state;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<StatusBar barStyle="default" />
|
||||
|
||||
<Text style={styles.exampleText}>
|
||||
Example: Upload ImagePicker result
|
||||
</Text>
|
||||
|
||||
<Button
|
||||
onPress={this._pickImage}
|
||||
title="Pick an image from camera roll"
|
||||
/>
|
||||
|
||||
<Button onPress={this._takePhoto} title="Take a photo" />
|
||||
|
||||
{this._maybeRenderImage()}
|
||||
{this._maybeRenderUploadingOverlay()}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
_maybeRenderUploadingOverlay = () => {
|
||||
if (this.state.uploading) {
|
||||
return (
|
||||
<View style={[StyleSheet.absoluteFill, styles.maybeRenderUploading]}>
|
||||
<ActivityIndicator color="#fff" size="large" />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
_maybeRenderImage = () => {
|
||||
let { image } = this.state;
|
||||
|
||||
if (!image) {
|
||||
return;
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.maybeRenderContainer}>
|
||||
<View style={styles.maybeRenderImageContainer}>
|
||||
<Image source={{ uri: image }} style={styles.maybeRenderImage} />
|
||||
</View>
|
||||
|
||||
<Text
|
||||
onPress={this._copyToClipboard}
|
||||
onLongPress={this._share}
|
||||
style={styles.maybeRenderImageText}
|
||||
>
|
||||
{image}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
_share = () => {
|
||||
Share.share({
|
||||
message: this.state.image,
|
||||
title: "Check out this photo",
|
||||
url: this.state.image,
|
||||
});
|
||||
};
|
||||
|
||||
_copyToClipboard = () => {
|
||||
Clipboard.setString(this.state.image);
|
||||
alert("Copied image URL to clipboard");
|
||||
};
|
||||
|
||||
_takePhoto = async () => {
|
||||
const { status: cameraPerm } = await Permissions.askAsync(
|
||||
Permissions.CAMERA
|
||||
);
|
||||
|
||||
const { status: cameraRollPerm } = await Permissions.askAsync(
|
||||
Permissions.CAMERA_ROLL
|
||||
);
|
||||
|
||||
// only if user allows permission to camera AND camera roll
|
||||
if (cameraPerm === "granted" && cameraRollPerm === "granted") {
|
||||
let pickerResult = await ImagePicker.launchCameraAsync({
|
||||
allowsMultipleSelection: true,
|
||||
quality: 0.8,
|
||||
//allowsEditing: true,
|
||||
aspect: [4, 3],
|
||||
});
|
||||
|
||||
if (!pickerResult.cancelled) {
|
||||
this.setState({ image: pickerResult.uri });
|
||||
}
|
||||
|
||||
this.uploadImageAsync(pickerResult.uri);
|
||||
}
|
||||
};
|
||||
|
||||
_pickImage = async () => {
|
||||
const { status: cameraRollPerm } = await Permissions.askAsync(
|
||||
Permissions.CAMERA_ROLL
|
||||
);
|
||||
|
||||
// only if user allows permission to camera roll
|
||||
if (cameraRollPerm === "granted") {
|
||||
let pickerResult = await ImagePicker.launchImageLibraryAsync({
|
||||
allowsEditing: true,
|
||||
base64: true,
|
||||
aspect: [4, 3],
|
||||
});
|
||||
|
||||
if (!pickerResult.cancelled) {
|
||||
this.setState({ image: pickerResult.uri });
|
||||
}
|
||||
|
||||
this.uploadImageAsync(pickerResult.uri);
|
||||
}
|
||||
};
|
||||
|
||||
uploadImageAsync(pictureuri) {
|
||||
let apiUrl = "http://123.123.123.123/ABC";
|
||||
|
||||
var data = new FormData();
|
||||
data.append("file", {
|
||||
uri: pictureuri,
|
||||
name: "file",
|
||||
type: "image/jpg",
|
||||
});
|
||||
|
||||
fetch(apiUrl, {
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
method: "POST",
|
||||
body: data,
|
||||
})
|
||||
.then((response) => {
|
||||
console.log("succ ");
|
||||
console.log(response);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log("err ");
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
alignItems: "center",
|
||||
flex: 1,
|
||||
justifyContent: "center",
|
||||
},
|
||||
exampleText: {
|
||||
fontSize: 20,
|
||||
marginBottom: 20,
|
||||
marginHorizontal: 15,
|
||||
textAlign: "center",
|
||||
},
|
||||
maybeRenderUploading: {
|
||||
alignItems: "center",
|
||||
backgroundColor: "rgba(0,0,0,0.4)",
|
||||
justifyContent: "center",
|
||||
},
|
||||
maybeRenderContainer: {
|
||||
borderRadius: 3,
|
||||
elevation: 2,
|
||||
marginTop: 30,
|
||||
shadowColor: "rgba(0,0,0,1)",
|
||||
shadowOpacity: 0.2,
|
||||
shadowOffset: {
|
||||
height: 4,
|
||||
width: 4,
|
||||
},
|
||||
shadowRadius: 5,
|
||||
width: 250,
|
||||
},
|
||||
maybeRenderImageContainer: {
|
||||
borderTopLeftRadius: 3,
|
||||
borderTopRightRadius: 3,
|
||||
overflow: "hidden",
|
||||
},
|
||||
maybeRenderImage: {
|
||||
height: 250,
|
||||
width: 250,
|
||||
},
|
||||
maybeRenderImageText: {
|
||||
paddingHorizontal: 10,
|
||||
paddingVertical: 10,
|
||||
},
|
||||
});
|
||||
@@ -1,157 +1,157 @@
|
||||
import { useFocusEffect } from "@react-navigation/native";
|
||||
import { Camera } from "expo-camera";
|
||||
import * as FileSystem from "expo-file-system";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import {
|
||||
selectCurrentCameraJob,
|
||||
selectCurrentCameraJobId,
|
||||
} from "../../redux/app/app.selectors";
|
||||
import { addPhoto } from "../../redux/photos/photos.actions";
|
||||
import CameraControls from "../camera-controls/camera-controls.component";
|
||||
import CameraSelectJob from "../camera-select-job/camera-select-job.component";
|
||||
// import { useFocusEffect } from "@react-navigation/native";
|
||||
// import { Camera } from "expo-camera";
|
||||
// import * as FileSystem from "expo-file-system";
|
||||
// import React, { useEffect, useRef, useState } from "react";
|
||||
// import { Text, View } from "react-native";
|
||||
// import { connect } from "react-redux";
|
||||
// import { createStructuredSelector } from "reselect";
|
||||
// import {
|
||||
// selectCurrentCameraJob,
|
||||
// selectCurrentCameraJobId,
|
||||
// } from "../../redux/app/app.selectors";
|
||||
// import { addPhoto } from "../../redux/photos/photos.actions";
|
||||
// import CameraControls from "../camera-controls/camera-controls.component";
|
||||
// import CameraSelectJob from "../camera-select-job/camera-select-job.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
cameraJobId: selectCurrentCameraJobId,
|
||||
cameraJob: selectCurrentCameraJob,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
addPhoto: (photo) => dispatch(addPhoto(photo)),
|
||||
});
|
||||
// const mapStateToProps = createStructuredSelector({
|
||||
// cameraJobId: selectCurrentCameraJobId,
|
||||
// cameraJob: selectCurrentCameraJob,
|
||||
// });
|
||||
// const mapDispatchToProps = (dispatch) => ({
|
||||
// addPhoto: (photo) => dispatch(addPhoto(photo)),
|
||||
// });
|
||||
|
||||
export function ScreenCamera({ cameraJobId, addPhoto }) {
|
||||
const [hasPermission, setHasPermission] = useState(null);
|
||||
const [state, setState] = useState({
|
||||
flashMode: Camera.Constants.FlashMode.off,
|
||||
capturing: null,
|
||||
cameraType: Camera.Constants.Type.back,
|
||||
tabHasFocus: null,
|
||||
});
|
||||
const cameraRef = useRef(null);
|
||||
// export function ScreenCamera({ cameraJobId, addPhoto }) {
|
||||
// const [hasPermission, setHasPermission] = useState(null);
|
||||
// const [state, setState] = useState({
|
||||
// flashMode: Camera.Constants.FlashMode.off,
|
||||
// capturing: null,
|
||||
// cameraType: Camera.Constants.Type.back,
|
||||
// tabHasFocus: null,
|
||||
// });
|
||||
// const cameraRef = useRef(null);
|
||||
|
||||
useFocusEffect(
|
||||
React.useCallback(() => {
|
||||
// Do something when the screen is focused
|
||||
setState({ ...state, tabHasFocus: true });
|
||||
return () => {
|
||||
// Do something when the screen is unfocused
|
||||
// Useful for cleanup functions
|
||||
setState({ ...state, tabHasFocus: false });
|
||||
};
|
||||
}, [])
|
||||
);
|
||||
// useFocusEffect(
|
||||
// React.useCallback(() => {
|
||||
// // Do something when the screen is focused
|
||||
// setState({ ...state, tabHasFocus: true });
|
||||
// return () => {
|
||||
// // Do something when the screen is unfocused
|
||||
// // Useful for cleanup functions
|
||||
// setState({ ...state, tabHasFocus: false });
|
||||
// };
|
||||
// }, [])
|
||||
// );
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const { status } = await Camera.requestPermissionsAsync();
|
||||
setHasPermission(status === "granted");
|
||||
})();
|
||||
}, []);
|
||||
// useEffect(() => {
|
||||
// (async () => {
|
||||
// const { status } = await Camera.requestPermissionsAsync();
|
||||
// setHasPermission(status === "granted");
|
||||
// })();
|
||||
// }, []);
|
||||
|
||||
const setFlashMode = (flashMode) => setState({ ...state, flashMode });
|
||||
const setCameraType = (cameraType) => setState({ ...state, cameraType });
|
||||
const handleCaptureIn = () => setState({ ...state, capturing: true });
|
||||
// const setFlashMode = (flashMode) => setState({ ...state, flashMode });
|
||||
// const setCameraType = (cameraType) => setState({ ...state, cameraType });
|
||||
// const handleCaptureIn = () => setState({ ...state, capturing: true });
|
||||
|
||||
const handleCaptureOut = () => {
|
||||
if (state.capturing) cameraRef.current.stopRecording();
|
||||
};
|
||||
// const handleCaptureOut = () => {
|
||||
// if (state.capturing) cameraRef.current.stopRecording();
|
||||
// };
|
||||
|
||||
const handleShortCapture = async () => {
|
||||
if (cameraRef.current) {
|
||||
const options = {
|
||||
quality: 0.8,
|
||||
//base64: true,
|
||||
skipProcessing: true,
|
||||
};
|
||||
// const handleShortCapture = async () => {
|
||||
// if (cameraRef.current) {
|
||||
// const options = {
|
||||
// quality: 0.8,
|
||||
// //base64: true,
|
||||
// skipProcessing: true,
|
||||
// };
|
||||
|
||||
let photo = await cameraRef.current.takePictureAsync(options);
|
||||
const filename = photo.uri.substring(photo.uri.lastIndexOf("/") + 1);
|
||||
const newUri = FileSystem.documentDirectory + "photos/" + filename;
|
||||
// let photo = await cameraRef.current.takePictureAsync(options);
|
||||
// const filename = photo.uri.substring(photo.uri.lastIndexOf("/") + 1);
|
||||
// const newUri = FileSystem.documentDirectory + "photos/" + filename;
|
||||
|
||||
await FileSystem.moveAsync({
|
||||
from: photo.uri,
|
||||
to: newUri,
|
||||
});
|
||||
setState({ ...state, capturing: false });
|
||||
addPhoto({
|
||||
...photo,
|
||||
id: filename,
|
||||
uri: newUri,
|
||||
jobId: cameraJobId,
|
||||
video: false,
|
||||
});
|
||||
}
|
||||
};
|
||||
// await FileSystem.moveAsync({
|
||||
// from: photo.uri,
|
||||
// to: newUri,
|
||||
// });
|
||||
// setState({ ...state, capturing: false });
|
||||
// addPhoto({
|
||||
// ...photo,
|
||||
// id: filename,
|
||||
// uri: newUri,
|
||||
// jobId: cameraJobId,
|
||||
// video: false,
|
||||
// });
|
||||
// }
|
||||
// };
|
||||
|
||||
const handleLongCapture = async () => {
|
||||
console.log("Taking a video!");
|
||||
if (cameraRef.current) {
|
||||
let video = await cameraRef.current.recordAsync();
|
||||
// const handleLongCapture = async () => {
|
||||
// console.log("Taking a video!");
|
||||
// if (cameraRef.current) {
|
||||
// let video = await cameraRef.current.recordAsync();
|
||||
|
||||
const filename = video.uri.substring(video.uri.lastIndexOf("/") + 1);
|
||||
const newUri = FileSystem.documentDirectory + "photos/" + filename;
|
||||
// const filename = video.uri.substring(video.uri.lastIndexOf("/") + 1);
|
||||
// const newUri = FileSystem.documentDirectory + "photos/" + filename;
|
||||
|
||||
await FileSystem.moveAsync({
|
||||
from: video.uri,
|
||||
to: newUri,
|
||||
});
|
||||
setState({ ...state, capturing: false });
|
||||
console.log("Adding Photo", {
|
||||
...video,
|
||||
id: filename,
|
||||
uri: newUri,
|
||||
jobId: cameraJobId,
|
||||
video: true,
|
||||
});
|
||||
addPhoto({
|
||||
...video,
|
||||
id: filename,
|
||||
uri: newUri,
|
||||
jobId: cameraJobId,
|
||||
video: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
// await FileSystem.moveAsync({
|
||||
// from: video.uri,
|
||||
// to: newUri,
|
||||
// });
|
||||
// setState({ ...state, capturing: false });
|
||||
// console.log("Adding Photo", {
|
||||
// ...video,
|
||||
// id: filename,
|
||||
// uri: newUri,
|
||||
// jobId: cameraJobId,
|
||||
// video: true,
|
||||
// });
|
||||
// addPhoto({
|
||||
// ...video,
|
||||
// id: filename,
|
||||
// uri: newUri,
|
||||
// jobId: cameraJobId,
|
||||
// video: true,
|
||||
// });
|
||||
// }
|
||||
// };
|
||||
|
||||
if (hasPermission === null || !state.tabHasFocus) {
|
||||
return <View />;
|
||||
}
|
||||
// if (hasPermission === null || !state.tabHasFocus) {
|
||||
// return <View />;
|
||||
// }
|
||||
|
||||
if (hasPermission === false) {
|
||||
return <Text>No access to camera. Please ensure that you allow it.</Text>;
|
||||
}
|
||||
// if (hasPermission === false) {
|
||||
// return <Text>No access to camera. Please ensure that you allow it.</Text>;
|
||||
// }
|
||||
|
||||
const { flashMode, cameraType, capturing } = state;
|
||||
// const { flashMode, cameraType, capturing } = state;
|
||||
|
||||
return (
|
||||
<Camera
|
||||
style={{ flex: 1, display: "flex" }}
|
||||
type={state.cameraType}
|
||||
ref={cameraRef}
|
||||
ratio={"16:9"}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
}}
|
||||
>
|
||||
<CameraSelectJob />
|
||||
// return (
|
||||
// <Camera
|
||||
// style={{ flex: 1, display: "flex" }}
|
||||
// type={state.cameraType}
|
||||
// ref={cameraRef}
|
||||
// ratio={"16:9"}
|
||||
// >
|
||||
// <View
|
||||
// style={{
|
||||
// flex: 1,
|
||||
// }}
|
||||
// >
|
||||
// <CameraSelectJob />
|
||||
|
||||
<CameraControls
|
||||
capturing={capturing}
|
||||
flashMode={flashMode}
|
||||
cameraType={cameraType}
|
||||
setFlashMode={setFlashMode}
|
||||
setCameraType={setCameraType}
|
||||
onCaptureIn={handleCaptureIn}
|
||||
onCaptureOut={handleCaptureOut}
|
||||
onLongCapture={handleLongCapture}
|
||||
onShortCapture={handleShortCapture}
|
||||
/>
|
||||
</View>
|
||||
</Camera>
|
||||
);
|
||||
}
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ScreenCamera);
|
||||
// <CameraControls
|
||||
// capturing={capturing}
|
||||
// flashMode={flashMode}
|
||||
// cameraType={cameraType}
|
||||
// setFlashMode={setFlashMode}
|
||||
// setCameraType={setCameraType}
|
||||
// onCaptureIn={handleCaptureIn}
|
||||
// onCaptureOut={handleCaptureOut}
|
||||
// onLongCapture={handleLongCapture}
|
||||
// onShortCapture={handleShortCapture}
|
||||
// />
|
||||
// </View>
|
||||
// </Camera>
|
||||
// );
|
||||
// }
|
||||
// export default connect(mapStateToProps, mapDispatchToProps)(ScreenCamera);
|
||||
|
||||
Reference in New Issue
Block a user