From dffa6b5853f573126ac14a353ab2f3b01321b16c Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 16 Jul 2021 18:32:34 -0400 Subject: Add save button --- src/components/camera/SaveButton.tsx | 11 +++-------- src/screens/upload/EditMedia.tsx | 28 +++++++++++++++++----------- 2 files changed, 20 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/components/camera/SaveButton.tsx b/src/components/camera/SaveButton.tsx index 0e220497..104e7c30 100644 --- a/src/components/camera/SaveButton.tsx +++ b/src/components/camera/SaveButton.tsx @@ -1,23 +1,18 @@ import React from 'react'; import {Text, TouchableOpacity} from 'react-native'; import SaveIcon from '../../assets/icons/camera/save.svg'; -import {saveImageToGallery} from '../../utils/camera'; import {styles} from './styles'; interface SaveButtonProps { - capturedImageURI: string; + onPress: () => void; } /* * Appears when a picture has been taken, * On click, saves the captured image to "Recents" album on device gallery */ -export const SaveButton: React.FC = ({capturedImageURI}) => ( - { - saveImageToGallery(capturedImageURI); - }} - style={styles.saveButton}> +export const SaveButton: React.FC = ({onPress}) => ( + Save diff --git a/src/screens/upload/EditMedia.tsx b/src/screens/upload/EditMedia.tsx index 0494375c..0f1062cf 100644 --- a/src/screens/upload/EditMedia.tsx +++ b/src/screens/upload/EditMedia.tsx @@ -7,13 +7,14 @@ import ImageZoom, {IOnMove} from 'react-native-image-pan-zoom'; import PhotoManipulator from 'react-native-photo-manipulator'; import TrimIcon from '../../assets/icons/trim.svg'; import CloseIcon from '../../assets/ionicons/close-outline.svg'; -import {TrimmerPlayer} from '../../components'; +import {SaveButton, TrimmerPlayer} from '../../components'; import {TaggLoadingIndicator, TaggSquareButton} from '../../components/common'; import {MainStackParams} from '../../routes'; import { cropVideo, HeaderHeight, normalize, + saveImageToGallery, SCREEN_HEIGHT, SCREEN_WIDTH, trimVideo, @@ -103,7 +104,7 @@ export const EditMedia: React.FC = ({route, navigation}) => { }, [origDimensions]); // Crops original image based of (x0, y0) and (x1, y1) coordinates - const handleNext = () => { + const processVideo = (callback: (finalUri: string) => void) => { if (checkIfUriImage(media.uri)) { if ( x0 !== undefined && @@ -154,14 +155,7 @@ export const EditMedia: React.FC = ({route, navigation}) => { trimmedURL, (croppedURL: string) => { setCropLoading(false); - navigation.navigate('CaptionScreen', { - screenType, - media: { - uri: croppedURL, - isVideo: true, - }, - selectedCategory, - }); + callback(croppedURL); }, videoCrop, ), @@ -362,8 +356,20 @@ export const EditMedia: React.FC = ({route, navigation}) => { )} + processVideo(saveImageToGallery)} /> + processVideo((uri) => + navigation.navigate('CaptionScreen', { + screenType, + media: { + uri: uri, + isVideo: true, + }, + selectedCategory, + }), + ) + } title={'Next'} buttonStyle={'normal'} buttonColor={'blue'} -- cgit v1.2.3-70-g09d2