diff options
Diffstat (limited to 'src/components/comments/ZoomInCropper.tsx')
-rw-r--r-- | src/components/comments/ZoomInCropper.tsx | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/src/components/comments/ZoomInCropper.tsx b/src/components/comments/ZoomInCropper.tsx index 20edafd0..a4e86c35 100644 --- a/src/components/comments/ZoomInCropper.tsx +++ b/src/components/comments/ZoomInCropper.tsx @@ -9,6 +9,7 @@ import CloseIcon from '../../assets/ionicons/close-outline.svg'; import {MainStackParams} from '../../routes'; import { cropVideo, + trimVideo, HeaderHeight, numberWithCommas, SCREEN_HEIGHT, @@ -16,7 +17,6 @@ import { } from '../../utils'; import {TaggSquareButton} from '../common'; import ReactNativeZoomableView from '@dudigital/react-native-zoomable-view/src/ReactNativeZoomableView'; -import Video from 'react-native-video'; import {TrimmerPlayer} from '../moments/trimmer'; type ZoomInCropperRouteProps = RouteProp<MainStackParams, 'ZoomInCropper'>; @@ -53,6 +53,15 @@ export const ZoomInCropper: React.FC<ZoomInCropperProps> = ({ cropOffsetY?: number; }>({}); + // Stores the current trim endpoints + const [trimEnds, setTrimEnds] = useState<{ + end: number; + start: number; + }>({ + end: 60, + start: 0, + }); + const checkIfUriImage = (uri: string) => { return ( uri.endsWith('jpg') || @@ -138,19 +147,24 @@ export const ZoomInCropper: React.FC<ZoomInCropperProps> = ({ cropHeight: origDimensions[1], })); } - cropVideo( + trimVideo( media.uri, - (croppedURL: string) => { - navigation.navigate('CaptionScreen', { - screenType, - media: { - uri: croppedURL, - isVideo: true, + (trimmedURL: string) => + cropVideo( + trimmedURL, + (croppedURL: string) => { + navigation.navigate('CaptionScreen', { + screenType, + media: { + uri: croppedURL, + isVideo: true, + }, + selectedCategory, + }); }, - selectedCategory, - }); - }, - videoCrop, + videoCrop, + ), + trimEnds, ); } }; @@ -315,11 +329,14 @@ export const ZoomInCropper: React.FC<ZoomInCropperProps> = ({ height: SCREEN_WIDTH / aspectRatio, }, ]} - handleLoad={(response: Object) => { + handleLoad={(response: {width: number; height: number}) => { const {width, height} = response; setOrigDimensions([width, height]); setAspectRatio(width / height); }} + onChangedEndpoints={(response: {start: number; end: number}) => + setTrimEnds(response) + } /> </View> </ReactNativeZoomableView> |