@umituz/react-native-ai-generation-content 1.26.46 → 1.26.48

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.26.46",
3
+ "version": "1.26.48",
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",
@@ -12,7 +12,7 @@
12
12
  * NO feature-specific code here - everything driven by configuration!
13
13
  */
14
14
 
15
- import React, { useMemo, useCallback, useEffect, useRef } from "react";
15
+ import React, { useMemo, useCallback, useEffect, useRef, useState } from "react";
16
16
  import { View, StyleSheet } from "react-native";
17
17
  import { useAppDesignTokens } from "@umituz/react-native-design-system";
18
18
  import { useFlow } from "../../../infrastructure/flow/useFlow";
@@ -23,6 +23,11 @@ import { useWizardGeneration, type WizardScenarioData } from "../hooks/useWizard
23
23
  import type { AlertMessages } from "../../../../../presentation/hooks/generation/types";
24
24
  import type { UploadedImage } from "../../../../../presentation/hooks/generation/useAIGenerateState";
25
25
  import { GenericPhotoUploadScreen } from "../screens/GenericPhotoUploadScreen";
26
+ import { GeneratingScreen } from "../screens/GeneratingScreen";
27
+ import { ScenarioPreviewScreen } from "../../../../scenarios/presentation/screens/ScenarioPreviewScreen";
28
+ import { ResultPreviewScreen } from "../../../../result-preview/presentation/components/ResultPreviewScreen";
29
+ import { useResultActions } from "../../../../result-preview/presentation/hooks/useResultActions";
30
+ import type { Creation } from "../../../../creations/domain/entities/Creation";
26
31
 
27
32
  export interface GenericWizardFlowProps {
28
33
  readonly featureConfig: WizardFeatureConfig;
@@ -35,6 +40,7 @@ export interface GenericWizardFlowProps {
35
40
  readonly onGenerationError?: (error: string) => void;
36
41
  readonly onCreditsExhausted?: () => void;
37
42
  readonly onBack?: () => void;
43
+ readonly onTryAgain?: () => void;
38
44
  readonly t: (key: string) => string;
39
45
  readonly translations?: Record<string, string>;
40
46
  readonly renderPreview?: (onContinue: () => void) => React.ReactElement | null;
@@ -53,6 +59,7 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
53
59
  onGenerationError,
54
60
  onCreditsExhausted,
55
61
  onBack,
62
+ onTryAgain,
56
63
  t,
57
64
  translations: _translations,
58
65
  renderPreview,
@@ -60,14 +67,14 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
60
67
  renderResult,
61
68
  }) => {
62
69
  const tokens = useAppDesignTokens();
70
+ const [currentCreation, setCurrentCreation] = useState<Creation | null>(null);
63
71
 
64
- // Build flow steps from wizard config
65
72
  const flowSteps = useMemo<StepDefinition[]>(() => {
66
73
  return buildFlowStepsFromWizard(featureConfig, {
67
- includePreview: !!renderPreview,
68
- includeGenerating: !!renderGenerating,
74
+ includePreview: true,
75
+ includeGenerating: true,
69
76
  });
70
- }, [featureConfig, renderPreview, renderGenerating]);
77
+ }, [featureConfig]);
71
78
 
72
79
  // Initialize flow and destructure to prevent infinite loops
73
80
  const flow = useFlow({
@@ -89,7 +96,11 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
89
96
  setResult,
90
97
  } = flow;
91
98
 
92
- // Handle progress change - memoized to prevent infinite loops
99
+ const resultImageUrl = currentCreation?.output?.imageUrl || currentCreation?.uri || "";
100
+ const { isSaving, isSharing, handleDownload, handleShare } = useResultActions({
101
+ imageUrl: resultImageUrl,
102
+ });
103
+
93
104
  const handleProgressChange = useCallback(
94
105
  (progress: number) => {
95
106
  updateProgress(progress);
@@ -97,17 +108,14 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
97
108
  [updateProgress],
98
109
  );
99
110
 
100
- // Handle generation complete - saves result and advances to result preview
101
111
  const handleGenerationComplete = useCallback(
102
112
  (result: unknown) => {
103
113
  if (typeof __DEV__ !== "undefined" && __DEV__) {
104
114
  console.log("[GenericWizardFlow] Generation completed, saving result and advancing to result preview");
105
115
  }
106
- // Save result in flow state
107
116
  setResult(result);
108
- // Advance to result preview step
117
+ setCurrentCreation(result as Creation);
109
118
  nextStep();
110
- // Notify parent
111
119
  onGenerationComplete?.(result);
112
120
  },
113
121
  [setResult, nextStep, onGenerationComplete],
@@ -251,17 +259,66 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
251
259
  });
252
260
  }
253
261
 
254
- // Special steps with custom renderers
255
262
  switch (step.type) {
256
- case StepType.SCENARIO_PREVIEW:
257
- // Preview continues to next step automatically
258
- return renderPreview?.(nextStep) || null;
263
+ case StepType.SCENARIO_PREVIEW: {
264
+ if (renderPreview) {
265
+ return renderPreview(nextStep);
266
+ }
267
+ return (
268
+ <ScenarioPreviewScreen
269
+ scenario={scenario}
270
+ translations={{
271
+ continueButton: t("common.continue"),
272
+ whatToExpect: t("scenarioPreview.whatToExpect"),
273
+ }}
274
+ onContinue={nextStep}
275
+ onBack={handleBack}
276
+ t={t}
277
+ />
278
+ );
279
+ }
259
280
 
260
- case StepType.GENERATING:
261
- return renderGenerating?.(generationProgress) || null;
281
+ case StepType.GENERATING: {
282
+ if (renderGenerating) {
283
+ return renderGenerating(generationProgress);
284
+ }
285
+ return (
286
+ <GeneratingScreen
287
+ progress={generationProgress}
288
+ scenario={scenario}
289
+ t={t}
290
+ />
291
+ );
292
+ }
262
293
 
263
- case StepType.RESULT_PREVIEW:
264
- return renderResult?.(generationResult) || null;
294
+ case StepType.RESULT_PREVIEW: {
295
+ if (renderResult) {
296
+ return renderResult(generationResult);
297
+ }
298
+ const creation = generationResult as Creation;
299
+ const imageUrl = creation?.output?.imageUrl || creation?.uri || "";
300
+ if (!imageUrl) return null;
301
+ return (
302
+ <ResultPreviewScreen
303
+ imageUrl={imageUrl}
304
+ isSaving={isSaving}
305
+ isSharing={isSharing}
306
+ onDownload={handleDownload}
307
+ onShare={handleShare}
308
+ onTryAgain={onTryAgain || onBack || (() => {})}
309
+ onNavigateBack={onTryAgain || onBack || (() => {})}
310
+ translations={{
311
+ title: t("generation.result.title"),
312
+ yourResult: t("generation.result.yourResult"),
313
+ saveButton: t("generation.result.save"),
314
+ saving: t("generation.result.saving"),
315
+ shareButton: t("generation.result.share"),
316
+ sharing: t("generation.result.sharing"),
317
+ tryAnother: t("generation.result.tryAnother"),
318
+ }}
319
+ />
320
+ );
321
+ }
265
322
 
266
323
  case StepType.PARTNER_UPLOAD: {
267
324
  // Get wizard step config
@@ -318,6 +375,13 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
318
375
  renderResult,
319
376
  handlePhotoContinue,
320
377
  handleBack,
378
+ isSaving,
379
+ isSharing,
380
+ handleDownload,
381
+ handleShare,
382
+ onTryAgain,
383
+ onBack,
384
+ scenario,
321
385
  t,
322
386
  ]);
323
387