aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/moments/Moment.tsx67
1 files changed, 53 insertions, 14 deletions
diff --git a/src/components/moments/Moment.tsx b/src/components/moments/Moment.tsx
index cde5b2e0..11640b5b 100644
--- a/src/components/moments/Moment.tsx
+++ b/src/components/moments/Moment.tsx
@@ -1,6 +1,7 @@
import {useNavigation} from '@react-navigation/native';
import React from 'react';
import {Alert, StyleProp, StyleSheet, View, ViewStyle} from 'react-native';
+import AsyncStorage from '@react-native-community/async-storage';
import {Text} from 'react-native-animatable';
import {ScrollView, TouchableOpacity} from 'react-native-gesture-handler';
import ImagePicker from 'react-native-image-crop-picker';
@@ -15,6 +16,10 @@ import {ERROR_UPLOAD} from '../../constants/strings';
import {MomentType, ScreenType} from '../../types';
import {normalize, SCREEN_WIDTH} from '../../utils';
import MomentTile from './MomentTile';
+import {
+ handlePresignedURL,
+ handleVideoUpload,
+} from '../../services/MomentService';
interface MomentProps {
title: string;
@@ -41,9 +46,9 @@ const Moment: React.FC<MomentProps> = ({
move,
externalStyles,
}) => {
- const navigation = useNavigation();
+ // const navigation = useNavigation();
- const navigateToImagePicker = () => {
+ const navigateToVideoPicker = () => {
ImagePicker.openPicker({
smartAlbums: [
'Favorites',
@@ -54,17 +59,20 @@ const Moment: React.FC<MomentProps> = ({
],
width: 580,
height: 580,
- cropping: true,
- cropperToolbarTitle: 'Upload a moment',
- mediaType: 'photo',
+ cropping: false,
+ cropperToolbarTitle: 'select a video',
+ mediaType: 'any',
})
- .then((picture) => {
- if ('path' in picture) {
- navigation.navigate('CaptionScreen', {
- screenType,
- title: title,
- image: picture,
- });
+ .then(async (vid) => {
+ if ('path' in vid) {
+ let fileName = vid.filename || '';
+ if (fileName.endsWith('.heic') || fileName.endsWith('.HEIC')) {
+ fileName = fileName.split('.')[0] + '.jpg';
+ }
+ const user = await AsyncStorage.getItem('username');
+ let presignedURL = await handlePresignedURL(user || '', fileName);
+ console.log('presigned' + JSON.stringify(presignedURL));
+ handleVideoUpload(vid, presignedURL);
}
})
.catch((err) => {
@@ -74,6 +82,37 @@ const Moment: React.FC<MomentProps> = ({
});
};
+ // const navigateToImagePicker = () => {
+ // ImagePicker.openPicker({
+ // smartAlbums: [
+ // 'Favorites',
+ // 'RecentlyAdded',
+ // 'SelfPortraits',
+ // 'Screenshots',
+ // 'UserLibrary',
+ // ],
+ // width: 580,
+ // height: 580,
+ // cropping: true,
+ // cropperToolbarTitle: 'Upload a moment',
+ // mediaType: 'photo',
+ // })
+ // .then((picture) => {
+ // if ('path' in picture) {
+ // navigation.navigate('CaptionScreen', {
+ // screenType,
+ // title: title,
+ // image: picture,
+ // });
+ // }
+ // })
+ // .catch((err) => {
+ // if (err.code && err.code !== 'E_PICKER_CANCELLED') {
+ // Alert.alert(ERROR_UPLOAD);
+ // }
+ // });
+ // };
+
return (
<View style={[styles.container, externalStyles?.container]}>
<View style={[styles.header, externalStyles?.header]}>
@@ -110,7 +149,7 @@ const Moment: React.FC<MomentProps> = ({
<PlusIcon
width={23}
height={23}
- onPress={() => navigateToImagePicker()}
+ onPress={() => navigateToVideoPicker()}
color={TAGG_LIGHT_BLUE}
style={styles.horizontalMargin}
/>
@@ -140,7 +179,7 @@ const Moment: React.FC<MomentProps> = ({
/>
))}
{(images === undefined || images.length === 0) && !userXId && (
- <TouchableOpacity onPress={() => navigateToImagePicker()}>
+ <TouchableOpacity onPress={() => navigateToVideoPicker()}>
<LinearGradient
colors={['rgba(105, 141, 211, 1)', 'rgba(105, 141, 211, 0.3)']}>
<View style={styles.defaultImage}>