aboutsummaryrefslogtreecommitdiff
path: root/src/components/moments/Moment.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/moments/Moment.tsx')
-rw-r--r--src/components/moments/Moment.tsx116
1 files changed, 13 insertions, 103 deletions
diff --git a/src/components/moments/Moment.tsx b/src/components/moments/Moment.tsx
index ec9129c5..108ea100 100644
--- a/src/components/moments/Moment.tsx
+++ b/src/components/moments/Moment.tsx
@@ -11,9 +11,9 @@ import BigPlusIcon from '../../assets/icons/plus-icon-white.svg';
import PlusIcon from '../../assets/icons/plus-icon.svg';
import UpIcon from '../../assets/icons/up_icon.svg';
import {TAGG_LIGHT_BLUE} from '../../constants';
-import {ERROR_UPLOAD} from '../../constants/strings';
import {MomentType, ScreenType} from '../../types';
import {normalize, SCREEN_WIDTH} from '../../utils';
+import {navigateToVideoPicker} from '../../utils/camera';
import MomentTile from './MomentTile';
interface MomentProps {
@@ -43,115 +43,25 @@ const Moment: React.FC<MomentProps> = ({
}) => {
const navigation = useNavigation();
+ // TODO: remove this later, tmp solution for handling videos
const navigateToCaptionScreenForVideo = (uri: string) => {
- const randHash = Math.random().toString(36).substring(7);
navigation.navigate('CaptionScreen', {
screenType,
title,
media: {
- filename: `poc_${randHash}.mov`,
uri,
isVideo: true,
},
});
};
- /**
- * This function opens the ImagePicker, only lets you select video files,
- * formats the file extension, then makes a call to the server to get the presigned URL,
- * after which it makes a POST request to the returned URL to upload the file directly to S3.
- * params: none
- * @returns: none
- */
- const navigateToVideoPicker = () => {
- ImagePicker.openPicker({
- mediaType: 'video',
- })
- .then(async (vid) => {
- console.log(vid);
- if (vid.path) {
- navigateToCaptionScreenForVideo(vid.path);
- }
- })
- .catch((err) => {
- if (err.code && err.code !== 'E_PICKER_CANCELLED') {
- Alert.alert(ERROR_UPLOAD);
- }
- });
- };
- const navigateToImagePicker = () => {
- ImagePicker.openPicker({
- smartAlbums: [
- 'Favorites',
- 'RecentlyAdded',
- 'SelfPortraits',
- 'Screenshots',
- 'UserLibrary',
- ],
- mediaType: 'any',
- })
- .then((picture) => {
- if (
- picture.path &&
- picture.filename &&
- (picture.filename.endsWith('gif') || picture.filename.endsWith('GIF'))
- ) {
- showGIFFailureAlert(picture);
- } else if (picture.path && picture.filename) {
- navigation.navigate('ZoomInCropper', {
- screenType,
- title,
- media: {
- filename: picture.filename,
- uri: picture.path,
- isVideo: false,
- },
- });
- }
- })
- .catch((err) => {
- if (err.code && err.code !== 'E_PICKER_CANCELLED') {
- Alert.alert(ERROR_UPLOAD);
- }
- });
+ const navigateToCameraScreen = () => {
+ navigation.navigate('CameraScreen', {
+ title,
+ screenType,
+ });
};
- /* Handles GIF files */
- const showGIFFailureAlert = (picture) =>
- Alert.alert(
- 'Warning',
- 'The app currently cannot handle GIFs, and will only save a static image.',
- [
- {
- text: 'Cancel',
- onPress: () => {},
- style: 'cancel',
- },
- {
- text: 'Post',
- onPress: () => {
- navigation.navigate('ZoomInCropper', {
- screenType,
- title,
- media: {
- filename: picture.filename,
- uri: picture.path,
- isVideo: false,
- },
- });
- },
- style: 'default',
- },
- ],
- {
- cancelable: true,
- onDismiss: () =>
- Alert.alert(
- 'This alert was dismissed by tapping outside of the alert dialog.',
- ),
- },
- );
-
return (
<View style={[styles.container, externalStyles?.container]}>
<View style={[styles.header, externalStyles?.header]}>
@@ -192,7 +102,10 @@ const Moment: React.FC<MomentProps> = ({
Alert.alert('Video Upload', 'pick one', [
{
text: 'gallery',
- onPress: navigateToVideoPicker,
+ onPress: () =>
+ navigateToVideoPicker((vid) =>
+ navigateToCaptionScreenForVideo(vid.path),
+ ),
},
{
text: 'camera (simulator will not work)',
@@ -216,7 +129,7 @@ const Moment: React.FC<MomentProps> = ({
<PlusIcon
width={23}
height={23}
- onPress={() => navigateToImagePicker()}
+ onPress={navigateToCameraScreen}
color={TAGG_LIGHT_BLUE}
style={styles.horizontalMargin}
/>
@@ -246,7 +159,7 @@ const Moment: React.FC<MomentProps> = ({
/>
))}
{(images === undefined || images.length === 0) && !userXId && (
- <TouchableOpacity onPress={() => navigateToImagePicker()}>
+ <TouchableOpacity onPress={navigateToCameraScreen}>
<LinearGradient
colors={['rgba(105, 141, 211, 1)', 'rgba(105, 141, 211, 0.3)']}>
<View style={styles.defaultImage}>
@@ -282,9 +195,6 @@ const styles = StyleSheet.create({
color: TAGG_LIGHT_BLUE,
maxWidth: '70%',
},
- flexer: {
- flex: 1,
- },
scrollContainer: {
height: SCREEN_WIDTH / 3.25,
backgroundColor: '#eee',