@umituz/react-native-ai-generation-content 1.61.9 → 1.61.11
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 +1 -1
- package/src/domains/creations/infrastructure/repositories/CreationsWriter.ts +16 -2
- package/src/domains/creations/presentation/hooks/useGalleryCallbacks.ts +11 -0
- package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +28 -2
- package/src/domains/creations/presentation/screens/creations-gallery.styles.ts +16 -0
- package/src/domains/creations/presentation/screens/creations-gallery.types.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.61.
|
|
3
|
+
"version": "1.61.11",
|
|
4
4
|
"description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -112,12 +112,26 @@ export class CreationsWriter {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
async updateFavorite(userId: string, creationId: string, isFavorite: boolean): Promise<boolean> {
|
|
115
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
116
|
+
console.log("[CreationsWriter] updateFavorite()", { userId, creationId, isFavorite });
|
|
117
|
+
}
|
|
115
118
|
const docRef = this.pathResolver.getDocRef(userId, creationId);
|
|
116
|
-
if (!docRef)
|
|
119
|
+
if (!docRef) {
|
|
120
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
121
|
+
console.log("[CreationsWriter] updateFavorite() - no docRef");
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
117
125
|
try {
|
|
118
126
|
await updateDoc(docRef, { isFavorite });
|
|
127
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
128
|
+
console.log("[CreationsWriter] updateFavorite() success");
|
|
129
|
+
}
|
|
119
130
|
return true;
|
|
120
|
-
} catch {
|
|
131
|
+
} catch (error) {
|
|
132
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
133
|
+
console.error("[CreationsWriter] updateFavorite() error", error);
|
|
134
|
+
}
|
|
121
135
|
return false;
|
|
122
136
|
}
|
|
123
137
|
}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* Extracts callback handlers from CreationsGalleryScreen
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
declare const __DEV__: boolean;
|
|
7
|
+
|
|
6
8
|
import { useCallback } from "react";
|
|
7
9
|
import { useAlert, AlertType, AlertMode, useSharing } from "@umituz/react-native-design-system";
|
|
8
10
|
import type { Creation } from "../../domain/entities/Creation";
|
|
@@ -72,10 +74,19 @@ export function useGalleryCallbacks(props: UseGalleryCallbacksProps) {
|
|
|
72
74
|
const handleFavorite = useCallback(
|
|
73
75
|
(c: Creation) => {
|
|
74
76
|
void (async () => {
|
|
77
|
+
if (__DEV__) {
|
|
78
|
+
console.log("[handleFavorite] Called", { id: c.id, currentFavorite: c.isFavorite, userId });
|
|
79
|
+
}
|
|
75
80
|
if (!userId) return;
|
|
76
81
|
// Toggle the favorite status
|
|
77
82
|
const newFavoriteStatus = !c.isFavorite;
|
|
83
|
+
if (__DEV__) {
|
|
84
|
+
console.log("[handleFavorite] Toggling", { newFavoriteStatus });
|
|
85
|
+
}
|
|
78
86
|
const success = await repository.updateFavorite(userId, c.id, newFavoriteStatus);
|
|
87
|
+
if (__DEV__) {
|
|
88
|
+
console.log("[handleFavorite] Update result", { success });
|
|
89
|
+
}
|
|
79
90
|
if (success) void refetch();
|
|
80
91
|
})();
|
|
81
92
|
},
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React, { useState, useMemo, useCallback, useEffect, useRef } from "react";
|
|
2
|
-
import { View, FlatList, RefreshControl } from "react-native";
|
|
2
|
+
import { View, FlatList, RefreshControl, TouchableOpacity } from "react-native";
|
|
3
3
|
import {
|
|
4
4
|
useAppDesignTokens,
|
|
5
5
|
FilterSheet,
|
|
6
6
|
ScreenLayout,
|
|
7
7
|
useAppFocusEffect,
|
|
8
|
+
AtomicIcon,
|
|
9
|
+
AtomicText,
|
|
8
10
|
} from "@umituz/react-native-design-system";
|
|
9
11
|
import { useCreations } from "../hooks/useCreations";
|
|
10
12
|
import { useDeleteCreation } from "../hooks/useDeleteCreation";
|
|
@@ -30,6 +32,7 @@ export function CreationsGalleryScreen({
|
|
|
30
32
|
onEmptyAction,
|
|
31
33
|
emptyActionLabel,
|
|
32
34
|
showFilter = config.showFilter ?? true,
|
|
35
|
+
onBack,
|
|
33
36
|
}: CreationsGalleryScreenProps) {
|
|
34
37
|
const tokens = useAppDesignTokens();
|
|
35
38
|
const [selectedCreation, setSelectedCreation] = useState<Creation | null>(null);
|
|
@@ -170,9 +173,32 @@ export function CreationsGalleryScreen({
|
|
|
170
173
|
/>
|
|
171
174
|
);
|
|
172
175
|
}
|
|
176
|
+
|
|
177
|
+
const screenHeader = useMemo(() => {
|
|
178
|
+
if (!onBack) return undefined;
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<View style={styles.screenHeader}>
|
|
182
|
+
<TouchableOpacity onPress={onBack} style={styles.backButton}>
|
|
183
|
+
<AtomicIcon
|
|
184
|
+
name="chevron-left"
|
|
185
|
+
customSize={28}
|
|
186
|
+
customColor={tokens.colors.textPrimary}
|
|
187
|
+
/>
|
|
188
|
+
</TouchableOpacity>
|
|
189
|
+
<AtomicText
|
|
190
|
+
type="titleLarge"
|
|
191
|
+
style={{ color: tokens.colors.textPrimary }}
|
|
192
|
+
>
|
|
193
|
+
{t(config.translations.title)}
|
|
194
|
+
</AtomicText>
|
|
195
|
+
<View style={styles.placeholder} />
|
|
196
|
+
</View>
|
|
197
|
+
);
|
|
198
|
+
}, [onBack, tokens, t, config]);
|
|
173
199
|
|
|
174
200
|
return (
|
|
175
|
-
<ScreenLayout scrollable={false}>
|
|
201
|
+
<ScreenLayout scrollable={false} header={screenHeader}>
|
|
176
202
|
<FlatList
|
|
177
203
|
data={filters.filtered}
|
|
178
204
|
renderItem={renderItem}
|
|
@@ -8,4 +8,20 @@ export const creationsGalleryStyles = StyleSheet.create({
|
|
|
8
8
|
header: { borderBottomWidth: 1 },
|
|
9
9
|
listContent: { paddingHorizontal: 16, paddingTop: 16 },
|
|
10
10
|
emptyContent: { flexGrow: 1 },
|
|
11
|
+
screenHeader: {
|
|
12
|
+
flexDirection: "row",
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
justifyContent: "space-between",
|
|
15
|
+
paddingHorizontal: 16,
|
|
16
|
+
height: 56,
|
|
17
|
+
},
|
|
18
|
+
backButton: {
|
|
19
|
+
width: 40,
|
|
20
|
+
height: 40,
|
|
21
|
+
justifyContent: "center",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
},
|
|
24
|
+
placeholder: {
|
|
25
|
+
width: 40,
|
|
26
|
+
},
|
|
11
27
|
});
|
|
@@ -14,4 +14,6 @@ export interface CreationsGalleryScreenProps {
|
|
|
14
14
|
readonly onEmptyAction?: () => void;
|
|
15
15
|
readonly emptyActionLabel?: string;
|
|
16
16
|
readonly showFilter?: boolean;
|
|
17
|
+
/** Callback for back navigation - if provided, shows back button in header */
|
|
18
|
+
readonly onBack?: () => void;
|
|
17
19
|
}
|