diff options
author | Ivan Chen <ivan@tagg.id> | 2021-06-24 18:50:00 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-06-24 18:50:00 -0400 |
commit | a6bc1f1a06a08bd842ba0b3bd00a88cea9bd9971 (patch) | |
tree | a53e523aa19731de6952cc128805cd34bd08c9ce /src | |
parent | e4d73a338d7cffd92cc40e44629cc035337d6e3a (diff) |
Fix video layout while viewing
Diffstat (limited to 'src')
-rw-r--r-- | src/components/moments/MomentPost.tsx | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/src/components/moments/MomentPost.tsx b/src/components/moments/MomentPost.tsx index f030c41e..770cdcee 100644 --- a/src/components/moments/MomentPost.tsx +++ b/src/components/moments/MomentPost.tsx @@ -133,13 +133,15 @@ const MomentPost: React.FC<MomentPostProps> = ({ * determine if image must be displayed in full screen or not */ useEffect(() => { - Image.getSize( - moment.moment_url, - (w, h) => { - setAspectRatio(w / h); - }, - (err) => console.log(err), - ); + if (!isVideo) { + Image.getSize( + moment.moment_url, + (w, h) => { + setAspectRatio(w / h); + }, + (err) => console.log(err), + ); + } }, []); /* @@ -186,15 +188,31 @@ const MomentPost: React.FC<MomentPostProps> = ({ <View style={styles.mainContainer}> <View style={styles.imageContainer}> {isVideo ? ( - <View ref={imageRef}> + <View + ref={imageRef} + style={[ + styles.media, + { + height: SCREEN_WIDTH / aspectRatio, + }, + ]}> <Video source={{ uri: moment.moment_url, }} volume={1} - style={styles.media} + style={[ + styles.media, + { + height: SCREEN_WIDTH / aspectRatio, + }, + ]} repeat={true} resizeMode={'contain'} + onLoad={(response) => { + const {width, height} = response.naturalSize; + setAspectRatio(width / height); + }} /> </View> ) : ( |