From 66dcf88ab09fbd73e234e209e270e2b31c867247 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Wed, 23 Jun 2021 17:01:42 -0400 Subject: Cleanup code, Add support for video tagging --- src/components/moments/Moment.tsx | 33 ++++----- src/routes/main/MainStackNavigator.tsx | 8 ++- src/screens/moments/TagFriendsScreen.tsx | 118 +++++++++++++++---------------- src/screens/profile/CaptionScreen.tsx | 92 ++++++++++++++++-------- 4 files changed, 137 insertions(+), 114 deletions(-) (limited to 'src') diff --git a/src/components/moments/Moment.tsx b/src/components/moments/Moment.tsx index a0f66cc5..6441bca3 100644 --- a/src/components/moments/Moment.tsx +++ b/src/components/moments/Moment.tsx @@ -55,28 +55,19 @@ const Moment: React.FC = ({ */ const navigateToVideoPicker = () => { ImagePicker.openPicker({ - smartAlbums: [ - 'Favorites', - 'RecentlyAdded', - 'SelfPortraits', - 'Screenshots', - 'UserLibrary', - ], - width: 580, - height: 580, - cropping: false, - cropperToolbarTitle: 'select a video', mediaType: 'video', }) .then(async (vid) => { - if ('path' in vid) { - let fileName = vid.filename || ''; - if (fileName.endsWith('.heic') || fileName.endsWith('.HEIC')) { - fileName = fileName.split('.')[0] + '.jpg'; - } - let presignedURL = await handlePresignedURL(fileName, title); - console.log('presigned' + JSON.stringify(presignedURL)); - handleVideoUpload(vid, presignedURL); + if (vid.path) { + navigation.navigate('CaptionScreen', { + screenType, + title, + media: { + filename: `poc_${Math.random().toString(36).substring(7)}.mov`, + uri: vid.path, + isVideo: true, + }, + }); } }) .catch((err) => { @@ -105,11 +96,11 @@ const Moment: React.FC = ({ if (picture.path && picture.filename) { navigation.navigate('CaptionScreen', { screenType, - title: title, + title, media: { filename: picture.filename, uri: picture.path, - type: 'image', + isVideo: false, }, }); } diff --git a/src/routes/main/MainStackNavigator.tsx b/src/routes/main/MainStackNavigator.tsx index 8157f0d7..522a18dd 100644 --- a/src/routes/main/MainStackNavigator.tsx +++ b/src/routes/main/MainStackNavigator.tsx @@ -37,13 +37,17 @@ export type MainStackParams = { }; CaptionScreen: { title?: string; - media?: {filename: string; uri: string; type: 'image' | 'video'}; + media?: {filename: string; uri: string; isVideo: boolean}; screenType: ScreenType; selectedTags?: MomentTagType[]; moment?: MomentType; }; TagFriendsScreen: { - imagePath: string; + media: { + filename: string; + uri: string; + isVideo: boolean; + }; selectedTags?: MomentTagType[]; }; TagSelectionScreen: { diff --git a/src/screens/moments/TagFriendsScreen.tsx b/src/screens/moments/TagFriendsScreen.tsx index 570c3776..bda38651 100644 --- a/src/screens/moments/TagFriendsScreen.tsx +++ b/src/screens/moments/TagFriendsScreen.tsx @@ -1,16 +1,9 @@ import {RouteProp} from '@react-navigation/core'; import {useNavigation} from '@react-navigation/native'; import React, {useEffect, useRef, useState} from 'react'; -import { - Image, - Keyboard, - KeyboardAvoidingView, - Platform, - StyleSheet, - TouchableWithoutFeedback, - View, -} from 'react-native'; +import {Image, StyleSheet, TouchableWithoutFeedback, View} from 'react-native'; import {Button} from 'react-native-elements'; +import Video from 'react-native-video'; import {MainStackParams} from 'src/routes'; import { CaptionScreenHeader, @@ -30,7 +23,7 @@ interface TagFriendsScreenProps { route: TagFriendsScreenRouteProps; } const TagFriendsScreen: React.FC = ({route}) => { - const {imagePath, selectedTags} = route.params; + const {media, selectedTags} = route.params; const navigation = useNavigation(); const imageRef = useRef(null); const [tags, setTags] = useState([]); @@ -54,58 +47,62 @@ const TagFriendsScreen: React.FC = ({route}) => { return ( - - - - -