diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components/camera/GalleryIcon.tsx | 4 | ||||
-rw-r--r-- | src/components/moments/TrimmerPlayer.tsx | 2 | ||||
-rw-r--r-- | src/routes/main/MainStackNavigator.tsx | 2 | ||||
-rw-r--r-- | src/screens/upload/EditMedia.tsx | 14 | ||||
-rw-r--r-- | src/store/reducers/userReducer.ts | 5 | ||||
-rw-r--r-- | src/types/types.ts | 2 | ||||
-rw-r--r-- | src/utils/camera.ts | 2 |
7 files changed, 21 insertions, 10 deletions
diff --git a/src/components/camera/GalleryIcon.tsx b/src/components/camera/GalleryIcon.tsx index ca2d2559..44297d6d 100644 --- a/src/components/camera/GalleryIcon.tsx +++ b/src/components/camera/GalleryIcon.tsx @@ -1,6 +1,6 @@ import React from 'react'; import {Image, Text, TouchableOpacity, View} from 'react-native'; -import {navigateToImagePicker} from '../../utils/camera'; +import {navigateToMediaPicker} from '../../utils/camera'; import {ImageOrVideo} from 'react-native-image-crop-picker'; import {styles} from './styles'; @@ -19,7 +19,7 @@ export const GalleryIcon: React.FC<GalleryIconProps> = ({ }) => { return ( <TouchableOpacity - onPress={() => navigateToImagePicker(callback)} + onPress={() => navigateToMediaPicker(callback)} style={styles.saveButton}> {mostRecentPhotoUri !== '' ? ( <Image diff --git a/src/components/moments/TrimmerPlayer.tsx b/src/components/moments/TrimmerPlayer.tsx index b28df590..8729fde8 100644 --- a/src/components/moments/TrimmerPlayer.tsx +++ b/src/components/moments/TrimmerPlayer.tsx @@ -71,7 +71,7 @@ const TrimmerPlayer: React.FC<TrimmerPlayerProps> = ({ repeat={true} onLoad={(payload) => { setEnd(payload.duration); - handleLoad(payload.naturalSize); + handleLoad(payload.naturalSize, payload.duration); }} onProgress={(e) => { if (!paused) { diff --git a/src/routes/main/MainStackNavigator.tsx b/src/routes/main/MainStackNavigator.tsx index 11e9d08d..585980b5 100644 --- a/src/routes/main/MainStackNavigator.tsx +++ b/src/routes/main/MainStackNavigator.tsx @@ -46,7 +46,7 @@ export type MainStackParams = { }; CaptionScreen: { screenType: ScreenType; - media?: {uri: string; isVideo: boolean}; + media?: {uri: string; isVideo: boolean; videoDuration: number | undefined}; selectedCategory?: string; selectedTags?: MomentTagType[]; moment?: MomentType; diff --git a/src/screens/upload/EditMedia.tsx b/src/screens/upload/EditMedia.tsx index 1dc408ee..38450337 100644 --- a/src/screens/upload/EditMedia.tsx +++ b/src/screens/upload/EditMedia.tsx @@ -43,6 +43,7 @@ export const EditMedia: React.FC<EditMediaProps> = ({route, navigation}) => { const vidRef = useRef<View>(null); const [cropLoading, setCropLoading] = useState<boolean>(false); const [hideTrimmer, setHideTrimmer] = useState<boolean>(true); + const [videoDuration, setVideoDuration] = useState<number | undefined>(); // Stores the coordinates of the cropped image const [x0, setX0] = useState<number>(); @@ -139,7 +140,7 @@ export const EditMedia: React.FC<EditMediaProps> = ({route, navigation}) => { mediaUri, (croppedURL: string) => { setCropLoading(false); - // Pass the trimmed/cropped video + // Pass the cropped video callback(croppedURL); }, videoCrop, @@ -334,8 +335,12 @@ export const EditMedia: React.FC<EditMediaProps> = ({route, navigation}) => { height: SCREEN_WIDTH / aspectRatio, }, ]} - handleLoad={(response: {width: number; height: number}) => { + handleLoad={( + response: {width: number; height: number}, + duration: number, + ) => { const {width, height} = response; + setVideoDuration(duration); setOrigDimensions([width, height]); setAspectRatio(width / height); }} @@ -383,8 +388,9 @@ export const EditMedia: React.FC<EditMediaProps> = ({route, navigation}) => { navigation.navigate('CaptionScreen', { screenType, media: { - uri: uri, - isVideo: isVideo, + uri, + isVideo, + videoDuration, }, selectedCategory, }), diff --git a/src/store/reducers/userReducer.ts b/src/store/reducers/userReducer.ts index 4692c5d3..617c60be 100644 --- a/src/store/reducers/userReducer.ts +++ b/src/store/reducers/userReducer.ts @@ -85,6 +85,10 @@ const userDataSlice = createSlice({ state.avatar = ''; state.cover = ''; }, + + setMomentUploadProgressBar: (state, action) => { + state.momentUploadProgressBar = action.payload.momentUploadProgressBar; + }, }, }); @@ -102,5 +106,6 @@ export const { clearHeaderAndProfileImages, profileBadgesUpdated, profileBadgeRemoved, + setMomentUploadProgressBar, } = userDataSlice.actions; export const userDataReducer = userDataSlice.reducer; diff --git a/src/types/types.ts b/src/types/types.ts index 2001426a..34bf73ac 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -63,8 +63,8 @@ export interface ProfileInfoType { export interface MomentUploadProgressBarType { status: MomentUploadStatusType; - originalVideoDuration: number; momentId: string; + originalVideoDuration: number | undefined; } export enum MomentUploadStatusType { diff --git a/src/utils/camera.ts b/src/utils/camera.ts index 9d7ff67f..97592fe5 100644 --- a/src/utils/camera.ts +++ b/src/utils/camera.ts @@ -57,7 +57,7 @@ export const saveImageToGallery = ( .catch((_err) => Alert.alert('Failed to save to device!')); }; -export const navigateToImagePicker = ( +export const navigateToMediaPicker = ( callback: (media: ImageOrVideo) => void, ) => { ImagePicker.openPicker({ |