@umituz/react-native-ai-generation-content 1.61.13 → 1.61.15

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-generation-content",
3
- "version": "1.61.13",
3
+ "version": "1.61.15",
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",
@@ -21,6 +21,7 @@ export interface UseGalleryCallbacksProps {
21
21
  readonly setSelectedCreation: (creation: Creation | null) => void;
22
22
  readonly setShowRatingPicker: (show: boolean) => void;
23
23
  readonly selectedCreation: Creation | null;
24
+ readonly onTryAgain?: () => void;
24
25
  }
25
26
 
26
27
  export function useGalleryCallbacks(props: UseGalleryCallbacksProps) {
@@ -34,6 +35,7 @@ export function useGalleryCallbacks(props: UseGalleryCallbacksProps) {
34
35
  setSelectedCreation,
35
36
  setShowRatingPicker,
36
37
  selectedCreation,
38
+ onTryAgain,
37
39
  } = props;
38
40
 
39
41
  const { share } = useSharing();
@@ -106,7 +108,8 @@ export function useGalleryCallbacks(props: UseGalleryCallbacksProps) {
106
108
 
107
109
  const handleTryAgain = useCallback(() => {
108
110
  setSelectedCreation(null);
109
- }, [setSelectedCreation]);
111
+ onTryAgain?.();
112
+ }, [setSelectedCreation, onTryAgain]);
110
113
 
111
114
  const handleOpenRatingPicker = useCallback(() => {
112
115
  setShowRatingPicker(true);
@@ -33,6 +33,8 @@ export function CreationsGalleryScreen({
33
33
  emptyActionLabel,
34
34
  showFilter = config.showFilter ?? true,
35
35
  onBack,
36
+ onTryAgain,
37
+ getCreationTitle,
36
38
  }: CreationsGalleryScreenProps) {
37
39
  const tokens = useAppDesignTokens();
38
40
  const [selectedCreation, setSelectedCreation] = useState<Creation | null>(null);
@@ -70,6 +72,7 @@ export function CreationsGalleryScreen({
70
72
  setSelectedCreation,
71
73
  setShowRatingPicker,
72
74
  selectedCreation,
75
+ onTryAgain,
73
76
  });
74
77
 
75
78
  const statusOptions = config.filterConfig?.statusOptions ?? STATUS_FILTER_OPTIONS;
@@ -104,15 +107,20 @@ export function CreationsGalleryScreen({
104
107
  return buttons;
105
108
  }, [showStatusFilter, showMediaFilter, filters, t, config.translations]);
106
109
 
107
- const getScenarioTitle = useCallback((type: string): string => {
108
- const typeConfig = config.types?.find((tc) => tc.id === type);
109
- return typeConfig?.labelKey ? t(typeConfig.labelKey) : type.split("_").map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
110
- }, [config.types, t]);
110
+ const getItemTitle = useCallback((item: Creation): string => {
111
+ // Use custom title function if provided
112
+ if (getCreationTitle) {
113
+ return getCreationTitle({ type: item.type, metadata: item.metadata });
114
+ }
115
+ // Default: use type config label
116
+ const typeConfig = config.types?.find((tc) => tc.id === item.type);
117
+ return typeConfig?.labelKey ? t(typeConfig.labelKey) : item.type.split("_").map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
118
+ }, [config.types, t, getCreationTitle]);
111
119
 
112
120
  const renderItem = useCallback(({ item }: { item: Creation }) => (
113
121
  <CreationCard
114
122
  creation={item}
115
- titleText={getScenarioTitle(item.type)}
123
+ titleText={getItemTitle(item)}
116
124
  callbacks={{
117
125
  onPress: () => callbacks.handleCardPress(item),
118
126
  onShare: async () => callbacks.handleShareCard(item),
@@ -120,7 +128,7 @@ export function CreationsGalleryScreen({
120
128
  onFavorite: () => callbacks.handleFavorite(item),
121
129
  }}
122
130
  />
123
- ), [callbacks, getScenarioTitle]);
131
+ ), [callbacks, getItemTitle]);
124
132
 
125
133
  const renderHeader = useMemo(() => {
126
134
  if (!creations?.length && !isLoading) return null;
@@ -155,25 +163,8 @@ export function CreationsGalleryScreen({
155
163
  const selectedImageUrl = selectedCreation ? (getPreviewUrl(selectedCreation.output) || selectedCreation.uri) : undefined;
156
164
  const selectedVideoUrl = selectedCreation?.output?.videoUrl;
157
165
  const hasMediaToShow = selectedImageUrl || selectedVideoUrl;
166
+ const showPreview = selectedCreation && hasMediaToShow;
158
167
 
159
- if (selectedCreation && hasMediaToShow) {
160
- return (
161
- <GalleryResultPreview
162
- selectedCreation={selectedCreation}
163
- imageUrl={selectedVideoUrl ? undefined : selectedImageUrl}
164
- videoUrl={selectedVideoUrl}
165
- showRatingPicker={showRatingPicker}
166
- config={config}
167
- t={t}
168
- onBack={callbacks.handleBack}
169
- onTryAgain={callbacks.handleTryAgain}
170
- onRate={callbacks.handleOpenRatingPicker}
171
- onSubmitRating={callbacks.handleSubmitRating}
172
- onCloseRating={() => setShowRatingPicker(false)}
173
- />
174
- );
175
- }
176
-
177
168
  const screenHeader = useMemo(() => {
178
169
  if (!onBack) return undefined;
179
170
 
@@ -197,6 +188,24 @@ export function CreationsGalleryScreen({
197
188
  );
198
189
  }, [onBack, tokens, t, config]);
199
190
 
191
+ if (showPreview) {
192
+ return (
193
+ <GalleryResultPreview
194
+ selectedCreation={selectedCreation}
195
+ imageUrl={selectedVideoUrl ? undefined : selectedImageUrl}
196
+ videoUrl={selectedVideoUrl}
197
+ showRatingPicker={showRatingPicker}
198
+ config={config}
199
+ t={t}
200
+ onBack={callbacks.handleBack}
201
+ onTryAgain={callbacks.handleTryAgain}
202
+ onRate={callbacks.handleOpenRatingPicker}
203
+ onSubmitRating={callbacks.handleSubmitRating}
204
+ onCloseRating={() => setShowRatingPicker(false)}
205
+ />
206
+ );
207
+ }
208
+
200
209
  return (
201
210
  <ScreenLayout scrollable={false} header={screenHeader}>
202
211
  <FlatList
@@ -16,4 +16,8 @@ export interface CreationsGalleryScreenProps {
16
16
  readonly showFilter?: boolean;
17
17
  /** Callback for back navigation - if provided, shows back button in header */
18
18
  readonly onBack?: () => void;
19
+ /** Callback for "Try Again" action - navigates to create new */
20
+ readonly onTryAgain?: () => void;
21
+ /** Function to get dynamic title from creation metadata */
22
+ readonly getCreationTitle?: (creation: { type: string; metadata?: Record<string, unknown> }) => string;
19
23
  }