@umituz/react-native-ai-creations 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-creations",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "AI-generated creations gallery with filtering, sharing, and management for React Native apps",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -31,6 +31,7 @@
31
31
  "@tanstack/react-query": ">=5.0.0",
32
32
  "@umituz/react-native-design-system": "latest",
33
33
  "@umituz/react-native-firestore": "latest",
34
+ "@umituz/react-native-image": "latest",
34
35
  "@umituz/react-native-sharing": "latest",
35
36
  "firebase": ">=11.0.0",
36
37
  "react": ">=18.2.0",
@@ -40,6 +41,7 @@
40
41
  "devDependencies": {
41
42
  "@tanstack/react-query": "^5.62.16",
42
43
  "@types/react": "^19.0.0",
44
+ "@umituz/react-native-image": "^1.1.1",
43
45
  "firebase": "^11.0.0",
44
46
  "react": "^19.0.0",
45
47
  "react-native": "^0.76.0",
@@ -16,6 +16,7 @@ import type { CreationType } from "../../domain/value-objects/CreationsConfig";
16
16
  interface CreationCardProps {
17
17
  readonly creation: Creation;
18
18
  readonly types: readonly CreationType[];
19
+ readonly onView?: (creation: Creation) => void;
19
20
  readonly onShare: (creation: Creation) => void;
20
21
  readonly onDelete: (creation: Creation) => void;
21
22
  }
@@ -23,6 +24,7 @@ interface CreationCardProps {
23
24
  export function CreationCard({
24
25
  creation,
25
26
  types,
27
+ onView,
26
28
  onShare,
27
29
  onDelete,
28
30
  }: CreationCardProps) {
@@ -32,6 +34,7 @@ export function CreationCard({
32
34
  const icon = typeConfig?.icon || "🎨";
33
35
  const label = typeConfig?.labelKey || creation.type;
34
36
 
37
+ const handleView = useCallback(() => onView?.(creation), [creation, onView]);
35
38
  const handleShare = useCallback(() => onShare(creation), [creation, onShare]);
36
39
  const handleDelete = useCallback(
37
40
  () => onDelete(creation),
@@ -114,6 +117,11 @@ export function CreationCard({
114
117
  <AtomicText style={styles.dateText}>{formattedDate}</AtomicText>
115
118
  </View>
116
119
  <View style={styles.actions}>
120
+ {onView && (
121
+ <TouchableOpacity style={styles.actionBtn} onPress={handleView}>
122
+ <AtomicIcon name="eye" size="sm" color="primary" />
123
+ </TouchableOpacity>
124
+ )}
117
125
  <TouchableOpacity style={styles.actionBtn} onPress={handleShare}>
118
126
  <AtomicIcon name="share-social" size="sm" color="primary" />
119
127
  </TouchableOpacity>
@@ -3,8 +3,6 @@
3
3
  * Fetches user's creations from repository
4
4
  */
5
5
 
6
- declare const __DEV__: boolean;
7
-
8
6
  import { useQuery } from "@tanstack/react-query";
9
7
  import type { ICreationsRepository } from "../../domain/repositories/ICreationsRepository";
10
8
 
@@ -24,21 +22,11 @@ export function useCreations({
24
22
  repository,
25
23
  enabled = true,
26
24
  }: UseCreationsProps) {
27
- const result = useQuery({
25
+ return useQuery({
28
26
  queryKey: ["creations", userId ?? ""],
29
27
  queryFn: () => repository.getAll(userId!),
30
28
  enabled: !!userId && enabled,
31
29
  staleTime: CACHE_CONFIG.staleTime,
32
30
  gcTime: CACHE_CONFIG.gcTime,
33
31
  });
34
-
35
- if (__DEV__) {
36
- console.log("[useCreations] State:", {
37
- isLoading: result.isLoading,
38
- count: result.data?.length ?? 0,
39
- enabled: !!userId && enabled,
40
- });
41
- }
42
-
43
- return result;
44
32
  }
@@ -3,12 +3,11 @@
3
3
  * Full gallery view with filtering
4
4
  */
5
5
 
6
- declare const __DEV__: boolean;
7
-
8
- import React, { useMemo, useCallback } from "react";
6
+ import React, { useMemo, useCallback, useState } from "react";
9
7
  import { View, FlatList, StyleSheet, RefreshControl, Alert } from "react-native";
10
8
  import { useAppDesignTokens } from "@umituz/react-native-design-system";
11
9
  import { useSharing } from "@umituz/react-native-sharing";
10
+ import { ImageGallery } from "@umituz/react-native-image";
12
11
  import { useSafeAreaInsets } from "react-native-safe-area-context";
13
12
  import type { Creation } from "../../domain/entities/Creation";
14
13
  import type { CreationsConfig } from "../../domain/value-objects/CreationsConfig";
@@ -36,6 +35,8 @@ export function CreationsGalleryScreen({
36
35
  const tokens = useAppDesignTokens();
37
36
  const insets = useSafeAreaInsets();
38
37
  const { share } = useSharing();
38
+ const [viewerVisible, setViewerVisible] = useState(false);
39
+ const [viewerIndex, setViewerIndex] = useState(0);
39
40
 
40
41
  const { data: creations, isLoading, refetch } = useCreations({
41
42
  userId,
@@ -46,13 +47,16 @@ export function CreationsGalleryScreen({
46
47
  const { filtered, selectedType, availableTypes, selectType } =
47
48
  useCreationsFilter({ creations });
48
49
 
49
- if (__DEV__) {
50
- console.log("[CreationsGalleryScreen] Render:", {
51
- count: creations?.length ?? 0,
52
- filtered: filtered.length,
53
- selectedType,
54
- });
55
- }
50
+ const handleView = useCallback(
51
+ (creation: Creation) => {
52
+ const index = filtered.findIndex((c) => c.id === creation.id);
53
+ if (index >= 0) {
54
+ setViewerIndex(index);
55
+ setViewerVisible(true);
56
+ }
57
+ },
58
+ [filtered],
59
+ );
56
60
 
57
61
  const handleShare = useCallback(
58
62
  async (creation: Creation) => {
@@ -102,16 +106,22 @@ export function CreationsGalleryScreen({
102
106
  [tokens, insets.bottom],
103
107
  );
104
108
 
109
+ const viewerImages = useMemo(
110
+ () => filtered.map((creation) => ({ uri: creation.uri })),
111
+ [filtered],
112
+ );
113
+
105
114
  const renderItem = useCallback(
106
115
  ({ item }: { item: Creation }) => (
107
116
  <CreationCard
108
117
  creation={item}
109
118
  types={config.types}
119
+ onView={handleView}
110
120
  onShare={handleShare}
111
121
  onDelete={handleDelete}
112
122
  />
113
123
  ),
114
- [config.types, handleShare, handleDelete],
124
+ [config.types, handleView, handleShare, handleDelete],
115
125
  );
116
126
 
117
127
  if (!isLoading && (!creations || creations.length === 0)) {
@@ -149,6 +159,13 @@ export function CreationsGalleryScreen({
149
159
  />
150
160
  }
151
161
  />
162
+ <ImageGallery
163
+ images={viewerImages}
164
+ visible={viewerVisible}
165
+ index={viewerIndex}
166
+ onDismiss={() => setViewerVisible(false)}
167
+ onIndexChange={setViewerIndex}
168
+ />
152
169
  </View>
153
170
  );
154
171
  }