diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components/camera/GalleryIcon.tsx | 24 | ||||
-rw-r--r-- | src/components/camera/SaveButton.tsx | 4 | ||||
-rw-r--r-- | src/components/moments/Moment.tsx | 4 | ||||
-rw-r--r-- | src/screens/moments/CameraScreen.tsx | 20 | ||||
-rw-r--r-- | src/utils/camera.ts | 4 |
5 files changed, 26 insertions, 30 deletions
diff --git a/src/components/camera/GalleryIcon.tsx b/src/components/camera/GalleryIcon.tsx index bc8b1d41..8d396550 100644 --- a/src/components/camera/GalleryIcon.tsx +++ b/src/components/camera/GalleryIcon.tsx @@ -1,14 +1,12 @@ -import {useNavigation} from '@react-navigation/native'; import React from 'react'; import {Image, Text, TouchableOpacity, View} from 'react-native'; -import {ScreenType} from '../../types'; import {navigateToImagePicker} from '../../utils/camera'; +import {Image as ImageType} from 'react-native-image-crop-picker'; import {styles} from './styles'; interface GalleryIconProps { - screenType: ScreenType; - title: string; mostRecentPhotoUri: string; + callback: (pic: ImageType) => void; } /* @@ -16,26 +14,12 @@ interface GalleryIconProps { * On click, navigates to the image picker */ export const GalleryIcon: React.FC<GalleryIconProps> = ({ - screenType, - title, mostRecentPhotoUri, + callback, }) => { - const navigation = useNavigation(); return ( <TouchableOpacity - onPress={() => - navigateToImagePicker((pic) => - navigation.navigate('ZoomInCropper', { - screenType, - title, - media: { - filename: pic.filename, - uri: pic.path, - isVideo: false, - }, - }), - ) - } + onPress={() => navigateToImagePicker(callback)} style={styles.saveButton}> {mostRecentPhotoUri !== '' ? ( <Image diff --git a/src/components/camera/SaveButton.tsx b/src/components/camera/SaveButton.tsx index 840cc804..0e220497 100644 --- a/src/components/camera/SaveButton.tsx +++ b/src/components/camera/SaveButton.tsx @@ -1,7 +1,7 @@ import React from 'react'; import {Text, TouchableOpacity} from 'react-native'; import SaveIcon from '../../assets/icons/camera/save.svg'; -import {downloadImage} from '../../utils/camera'; +import {saveImageToGallery} from '../../utils/camera'; import {styles} from './styles'; interface SaveButtonProps { @@ -15,7 +15,7 @@ interface SaveButtonProps { export const SaveButton: React.FC<SaveButtonProps> = ({capturedImageURI}) => ( <TouchableOpacity onPress={() => { - downloadImage(capturedImageURI); + saveImageToGallery(capturedImageURI); }} style={styles.saveButton}> <SaveIcon width={40} height={40} /> diff --git a/src/components/moments/Moment.tsx b/src/components/moments/Moment.tsx index 25d69fba..f057b329 100644 --- a/src/components/moments/Moment.tsx +++ b/src/components/moments/Moment.tsx @@ -55,6 +55,7 @@ const Moment: React.FC<MomentProps> = ({ }, }); }; + const navigateToCameraScreen = () => { navigation.navigate('CameraScreen', { title, @@ -195,9 +196,6 @@ const styles = StyleSheet.create({ color: TAGG_LIGHT_BLUE, maxWidth: '70%', }, - flexer: { - flex: 1, - }, scrollContainer: { height: SCREEN_WIDTH / 3.25, backgroundColor: '#eee', diff --git a/src/screens/moments/CameraScreen.tsx b/src/screens/moments/CameraScreen.tsx index 1826f9d7..b3275764 100644 --- a/src/screens/moments/CameraScreen.tsx +++ b/src/screens/moments/CameraScreen.tsx @@ -15,7 +15,7 @@ import { } from '../../components'; import {MainStackParams} from '../../routes'; import {HeaderHeight, normalize, SCREEN_WIDTH} from '../../utils'; -import {takePicture} from '../../utils/camera'; +import {navigateToImagePicker, takePicture} from '../../utils/camera'; type CameraScreenRouteProps = RouteProp<MainStackParams, 'CameraScreen'>; export type CameraScreenNavigationProps = StackNavigationProp< @@ -52,6 +52,7 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => { ); }, [capturedImage]); + console.log(capturedImage); /* * Appears once a picture has been captured to navigate to the caption screen */ @@ -123,8 +124,21 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => { ) : ( <GalleryIcon mostRecentPhotoUri={mostRecentPhoto} - screenType={screenType} - title={title} + callback={() => + navigateToImagePicker((pic) => { + if (pic.filename) { + navigation.navigate('ZoomInCropper', { + screenType, + title, + media: { + filename: pic.filename, + uri: pic.path, + isVideo: false, + }, + }); + } + }) + } /> )} </View> diff --git a/src/utils/camera.ts b/src/utils/camera.ts index 1ee5dbf4..877c8c2f 100644 --- a/src/utils/camera.ts +++ b/src/utils/camera.ts @@ -6,7 +6,7 @@ import ImagePicker, {Image, Video} from 'react-native-image-crop-picker'; import {ERROR_UPLOAD} from '../constants/strings'; /* - * Captures a photo and pauses to shoe the preview of the picture taken + * Captures a photo and pauses to show the preview of the picture taken */ export const takePicture = ( cameraRef: RefObject<RNCamera>, @@ -24,7 +24,7 @@ export const takePicture = ( } }; -export const downloadImage = (capturedImageURI: string) => { +export const saveImageToGallery = (capturedImageURI: string) => { CameraRoll.save(capturedImageURI, {album: 'Recents', type: 'photo'}) .then((_res) => Alert.alert('Saved to device!')) .catch((_err) => Alert.alert('Failed to save to device!')); |