From b682bd5648a0001c63bda7abcf010f23c96d305f Mon Sep 17 00:00:00 2001 From: Ivan Sekovanikj Date: Tue, 17 Dec 2024 17:03:44 +0100 Subject: [PATCH] fix: bring back animations for opening and closing of the gallery header/footer --- .../components/ImageGalleryFooter.tsx | 8 ++++++-- .../components/ImageGalleryHeader.tsx | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/package/src/components/ImageGallery/components/ImageGalleryFooter.tsx b/package/src/components/ImageGallery/components/ImageGalleryFooter.tsx index 252732e8c..e2bd876f9 100644 --- a/package/src/components/ImageGallery/components/ImageGalleryFooter.tsx +++ b/package/src/components/ImageGallery/components/ImageGalleryFooter.tsx @@ -21,6 +21,10 @@ import { VideoType, } from '../../../native'; +const ReanimatedSafeAreaView = Animated.createAnimatedComponent + ? Animated.createAnimatedComponent(SafeAreaView) + : SafeAreaView; + import { DefaultStreamChatGenerics, FileTypes } from '../../../types/types'; import type { Photo } from '../ImageGallery'; @@ -160,7 +164,7 @@ export const ImageGalleryFooterWithContext = < pointerEvents={'box-none'} style={styles.wrapper} > - + {photo.type === FileTypes.Video ? ( videoControlElement ? ( videoControlElement({ duration, onPlayPause, paused, progress, videoRef }) @@ -202,7 +206,7 @@ export const ImageGalleryFooterWithContext = < )} - + ); }; diff --git a/package/src/components/ImageGallery/components/ImageGalleryHeader.tsx b/package/src/components/ImageGallery/components/ImageGalleryHeader.tsx index 7aee82ee0..a2afec24d 100644 --- a/package/src/components/ImageGallery/components/ImageGalleryHeader.tsx +++ b/package/src/components/ImageGallery/components/ImageGalleryHeader.tsx @@ -1,6 +1,11 @@ import React, { useMemo, useState } from 'react'; import { Pressable, SafeAreaView, StyleSheet, Text, View, ViewStyle } from 'react-native'; -import { Extrapolation, interpolate, SharedValue, useAnimatedStyle } from 'react-native-reanimated'; +import Animated, { + Extrapolation, + interpolate, + SharedValue, + useAnimatedStyle, +} from 'react-native-reanimated'; import { useOverlayContext } from '../../../contexts/overlayContext/OverlayContext'; import { useTheme } from '../../../contexts/themeContext/ThemeContext'; @@ -11,6 +16,10 @@ import type { DefaultStreamChatGenerics } from '../../../types/types'; import { getDateString } from '../../../utils/i18n/getDateString'; import type { Photo } from '../ImageGallery'; +const ReanimatedSafeAreaView = Animated.createAnimatedComponent + ? Animated.createAnimatedComponent(SafeAreaView) + : SafeAreaView; + export type ImageGalleryHeaderCustomComponent< StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, > = ({ @@ -93,7 +102,7 @@ export const ImageGalleryHeader = < onLayout={(event) => setHeight(event.nativeEvent.layout.height)} pointerEvents={'box-none'} > - + {leftElement ? ( leftElement({ hideOverlay, photo }) @@ -120,7 +129,7 @@ export const ImageGalleryHeader = < )} - + ); };