@@ -5,7 +5,6 @@ import { Gesture, GestureDetector } from 'react-native-gesture-handler';
55
66import Animated , {
77 Easing ,
8- SharedValue ,
98 useAnimatedReaction ,
109 useAnimatedStyle ,
1110 useDerivedValue ,
@@ -35,7 +34,14 @@ import {
3534
3635import { useImageGalleryGestures } from './hooks/useImageGalleryGestures' ;
3736
38- import { useImageGalleryContext } from '../../contexts/imageGalleryContext/ImageGalleryContext' ;
37+ import {
38+ ImageGalleryProviderProps ,
39+ useImageGalleryContext ,
40+ } from '../../contexts/imageGalleryContext/ImageGalleryContext' ;
41+ import {
42+ OverlayContextValue ,
43+ useOverlayContext ,
44+ } from '../../contexts/overlayContext/OverlayContext' ;
3945import { useTheme } from '../../contexts/themeContext/ThemeContext' ;
4046import { useStateStore } from '../../hooks' ;
4147import { useViewport } from '../../hooks/useViewport' ;
@@ -99,25 +105,30 @@ const imageGallerySelector = (state: ImageGalleryState) => ({
99105 currentIndex : state . currentIndex ,
100106} ) ;
101107
102- type Props = {
103- overlayOpacity : SharedValue < number > ;
104- } ;
108+ type ImageGalleryWithContextProps = Pick <
109+ ImageGalleryProviderProps ,
110+ | 'imageGalleryCustomComponents'
111+ | 'imageGalleryGridSnapPoints'
112+ | 'imageGalleryGridHandleHeight'
113+ | 'numberOfImageGalleryGridColumns'
114+ > &
115+ Pick < OverlayContextValue , 'overlayOpacity' > ;
105116
106- export const ImageGallery = ( props : Props ) => {
107- const { overlayOpacity } = props ;
117+ export const ImageGalleryWithContext = ( props : ImageGalleryWithContextProps ) => {
118+ const {
119+ imageGalleryGridHandleHeight,
120+ imageGalleryGridSnapPoints,
121+ imageGalleryCustomComponents,
122+ numberOfImageGalleryGridColumns,
123+ overlayOpacity,
124+ } = props ;
108125 const {
109126 theme : {
110127 colors : { white_snow } ,
111128 imageGallery : { backgroundColor, pager, slide } ,
112129 } ,
113130 } = useTheme ( ) ;
114- const {
115- imageGalleryStateStore,
116- imageGalleryCustomComponents,
117- imageGalleryGridHandleHeight,
118- imageGalleryGridSnapPoints,
119- numberOfImageGalleryGridColumns,
120- } = useImageGalleryContext ( ) ;
131+ const { imageGalleryStateStore } = useImageGalleryContext ( ) ;
121132 const { currentIndex } = useStateStore ( imageGalleryStateStore . state , imageGallerySelector ) ;
122133 const { assets, videoPlayerPool } = imageGalleryStateStore ;
123134
@@ -436,6 +447,28 @@ export const ImageGallery = (props: Props) => {
436447 ) ;
437448} ;
438449
450+ export type ImageGalleryProps = Partial < ImageGalleryWithContextProps > ;
451+
452+ export const ImageGallery = ( props : ImageGalleryProps ) => {
453+ const {
454+ imageGalleryCustomComponents,
455+ imageGalleryGridHandleHeight,
456+ imageGalleryGridSnapPoints,
457+ numberOfImageGalleryGridColumns,
458+ } = useImageGalleryContext ( ) ;
459+ const { overlayOpacity } = useOverlayContext ( ) ;
460+ return (
461+ < ImageGalleryWithContext
462+ imageGalleryCustomComponents = { imageGalleryCustomComponents }
463+ imageGalleryGridHandleHeight = { imageGalleryGridHandleHeight }
464+ imageGalleryGridSnapPoints = { imageGalleryGridSnapPoints }
465+ numberOfImageGalleryGridColumns = { numberOfImageGalleryGridColumns }
466+ overlayOpacity = { overlayOpacity }
467+ { ...props }
468+ />
469+ ) ;
470+ } ;
471+
439472/**
440473 * Clamping worklet to clamp the scaling
441474 */
0 commit comments