Added job select on Camera

This commit is contained in:
Patrick Fic
2021-02-08 19:19:23 -08:00
parent 280b8e38b5
commit 3a0c8b9a5a
13 changed files with 12506 additions and 8055 deletions

View File

@@ -12,6 +12,7 @@ import {
} 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,
@@ -62,16 +63,14 @@ export function ScreenCamera({ cameraJobId, cameraJob, addPhoto }) {
const handleShortCapture = async () => {
if (cameraRef.current) {
const options = {
//quality: 0.5,
quality: 0.8,
//base64: true,
//skipProcessing: true,
skipProcessing: true,
};
console.log("Taking a picture!");
let photo = await cameraRef.current.takePictureAsync(options);
console.log("ScreenCamera -> photo", photo);
const filename = photo.uri.substring(photo.uri.lastIndexOf("/") + 1);
const newUri = FileSystem.documentDirectory + "photos/" + filename;
await FileSystem.moveAsync({
@@ -79,7 +78,7 @@ export function ScreenCamera({ cameraJobId, cameraJob, addPhoto }) {
to: newUri,
});
setState({ ...state, capturing: false });
console.log("Adding photo to cache...");
addPhoto({
...photo,
id: filename,
@@ -119,51 +118,27 @@ export function ScreenCamera({ cameraJobId, cameraJob, addPhoto }) {
}
if (hasPermission === false) {
return <Text>No access to camera</Text>;
return <Text>No access to camera. Please ensure that you allow it.</Text>;
}
const { flashMode, cameraType, capturing } = state;
return (
<View style={{ display: "flex", flex: 1 }}>
<SafeAreaView
style={{ display: "flex", flex: 1, backgroundColor: "tomato" }}
>
<Camera
style={{ flex: 1, display: "flex" }}
type={state.cameraType}
ref={cameraRef}
ratio={"16:9"}
>
<SafeAreaView
<View
style={{
flex: 1,
}}
>
<TouchableOpacity
onPress={() => navigation.push("CameraJobSearch")}
style={{
display: "flex",
width: "100%",
alignSelf: "flex-start",
alignItems: "center",
backgroundColor: "rgba(112, 128, 144, 0.3)",
fontSize: 20,
fontWeight: "bold",
}}
>
<Text
style={{
fontSize: 20,
fontWeight: "bold",
}}
>
{cameraJob && cameraJob.ro_number}
</Text>
<Text>
{cameraJob &&
`${cameraJob && cameraJob.ownr_fn} ${
cameraJob && cameraJob.ownr_ln
}`}
</Text>
<Text>{cameraJobId}</Text>
</TouchableOpacity>
<CameraSelectJob />
<TouchableOpacity
onPress={() => {
navigation.push("MediaCache");
@@ -192,9 +167,9 @@ export function ScreenCamera({ cameraJobId, cameraJob, addPhoto }) {
onLongCapture={handleLongCapture}
onShortCapture={handleShortCapture}
/>
</SafeAreaView>
</View>
</Camera>
</View>
</SafeAreaView>
);
}
export default connect(mapStateToProps, mapDispatchToProps)(ScreenCamera);