diff options
author | Michael <michael.foiani@gmail.com> | 2021-07-15 16:42:10 -0400 |
---|---|---|
committer | Michael <michael.foiani@gmail.com> | 2021-07-15 16:42:10 -0400 |
commit | 05c79b11815e6544e9066aeed09199c6074f480b (patch) | |
tree | adf98c0f62335d331ef624f603a08464b947da9d /src/components/comments/ZoomInCropper.tsx | |
parent | eed51412f523cd661a2081147c7b1b0591732973 (diff) |
Incorporate trimming into the old moment flow with the cropping functionality.
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> |