Skip to content

Commit 9cce4cb

Browse files
committed
chore: update package.json and add types for ImageViewer and Gallery components
1 parent 67f3d8f commit 9cce4cb

File tree

4 files changed

+650
-525
lines changed

4 files changed

+650
-525
lines changed

package.json

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"version": "1.1.5",
44
"description": "This library provides a highly customizable and performant image viewer component for React Native applications. Itsupport advanced gestures such as pinch-to-zoom, panning, and double-tap to zoom in and out, making it ideal for creating rich, interactive image viewing experiences.",
55
"source": "./src/index.tsx",
6-
"main": "./lib/commonjs/index.js",
7-
"module": "./lib/module/index.js",
8-
"types": "./lib/typescript/src/index.d.ts",
6+
"main": "./src/index.tsx",
7+
"module": "./src/index.tsx",
8+
"types": "./src/types.d.ts",
99
"files": [
1010
"src",
1111
"lib",
@@ -178,18 +178,6 @@
178178
"source": "src",
179179
"output": "lib",
180180
"targets": [
181-
[
182-
"commonjs",
183-
{
184-
"configFile": "./babel.config.js"
185-
}
186-
],
187-
[
188-
"module",
189-
{
190-
"configFile": "./babel.config.js"
191-
}
192-
],
193181
[
194182
"typescript",
195183
{

src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
} from 'react';
77
import GalleryComponent from './Gallery';
88
import ImageViewerComponent from './ImageViewer';
9+
import 'react-native-gesture-handler';
910

1011
const Gallery: ForwardRefExoticComponent<
1112
GalleryProps & RefAttributes<GalleryRef>

src/types.d.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import type {
2+
ImageStyle,
3+
ImageSourcePropType,
4+
ViewStyle,
5+
FlatListProps,
6+
} from 'react-native';
7+
import type { SharedValue } from 'react-native-reanimated';
8+
9+
/**
10+
* Props for the ImageViewer component
11+
*/
12+
export interface ImageViewerProps {
13+
/** The image source to display */
14+
source: ImageSourcePropType;
15+
/** Optional styles to apply to the image */
16+
imageStyle?: ImageStyle;
17+
/** Whether to enable pan down to close gesture */
18+
enablePanDownToClose?: boolean;
19+
/** Shared value for layout translation on Y axis */
20+
layoutTranslateY: SharedValue<number>;
21+
/** Callback function when the viewer is closed */
22+
onClose?: () => void;
23+
}
24+
25+
/**
26+
* Props for the Gallery component
27+
*/
28+
export interface GalleryProps
29+
extends Omit<FlatListProps<ImageSourcePropType>, 'data' | 'renderItem'> {
30+
/** Array of image sources to display in the gallery */
31+
data: ImageSourcePropType[];
32+
/** Optional styles to apply to the gallery container */
33+
style?: ViewStyle;
34+
/** Optional styles to apply to each image */
35+
imageStyle?: ImageStyle;
36+
/** Optional styles to apply to the gallery container */
37+
containerStyle?: ViewStyle;
38+
/** Optional styles to apply to the content container */
39+
contentContainerStyle?: ViewStyle;
40+
/** Color of the backdrop (default: 'black') */
41+
backdropColor?: string;
42+
/** Initial index to display (default: 0) */
43+
initialIndex?: number;
44+
/** Whether to enable pan down to close gesture */
45+
enablePanDownToClose?: boolean;
46+
/** Function to render header content */
47+
renderHeader?: () => React.ReactNode;
48+
/** Function to render footer content */
49+
renderFooter?: () => React.ReactNode;
50+
}
51+
52+
/**
53+
* Reference methods for the Gallery component
54+
*/
55+
export interface GalleryRef {
56+
/** Show the gallery at the specified index */
57+
show: (index?: number) => void;
58+
/** Hide the gallery */
59+
hide: () => void;
60+
/** Whether the gallery is currently visible */
61+
isVisible: boolean;
62+
}

0 commit comments

Comments
 (0)