@umituz/react-native-ai-generation-content 1.26.63 → 1.26.64

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.63",
3
+ "version": "1.26.64",
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",
@@ -26,6 +26,7 @@ import type { Creation } from "../../../../creations/domain/entities/Creation";
26
26
  import { useResultActions } from "../../../../result-preview/presentation/hooks/useResultActions";
27
27
  import { validateScenario } from "../utilities/validateScenario";
28
28
  import { WizardStepRenderer } from "./WizardStepRenderer";
29
+ import { StarRatingPicker } from "../../../../result-preview/presentation/components/StarRatingPicker";
29
30
 
30
31
  export interface GenericWizardFlowProps {
31
32
  readonly featureConfig: WizardFeatureConfig;
@@ -37,6 +38,7 @@ export interface GenericWizardFlowProps {
37
38
  readonly onGenerationComplete?: (result: unknown) => void;
38
39
  readonly onGenerationError?: (error: string) => void;
39
40
  readonly onCreditsExhausted?: () => void;
41
+ readonly onRate?: (creationId: string, rating: number, description: string) => Promise<boolean>;
40
42
  readonly onBack?: () => void;
41
43
  readonly onTryAgain?: () => void;
42
44
  readonly t: (key: string) => string;
@@ -56,6 +58,7 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
56
58
  onGenerationComplete,
57
59
  onGenerationError,
58
60
  onCreditsExhausted,
61
+ onRate,
59
62
  onBack,
60
63
  onTryAgain,
61
64
  t,
@@ -66,6 +69,8 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
66
69
  }) => {
67
70
  const tokens = useAppDesignTokens();
68
71
  const [currentCreation, setCurrentCreation] = useState<Creation | null>(null);
72
+ const [showRatingPicker, setShowRatingPicker] = useState(false);
73
+ const [hasRated, setHasRated] = useState(false);
69
74
  const prevStepIdRef = useRef<string | undefined>(undefined);
70
75
 
71
76
  const flowSteps = useMemo<StepDefinition[]>(() => {
@@ -155,6 +160,21 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
155
160
  nextStep();
156
161
  }, [currentStepIndex, flowSteps.length, customData, setCustomData, nextStep, onGenerationStart]);
157
162
 
163
+ const handleOpenRatingPicker = useCallback(() => {
164
+ setShowRatingPicker(true);
165
+ }, []);
166
+
167
+ const handleSubmitRating = useCallback(async (rating: number, description: string) => {
168
+ if (!currentCreation?.id || !onRate) return;
169
+ const success = await onRate(currentCreation.id, rating, description);
170
+ if (success) {
171
+ setHasRated(true);
172
+ }
173
+ setShowRatingPicker(false);
174
+ }, [currentCreation, onRate]);
175
+
176
+ const showRatingButton = Boolean(onRate) && !hasRated;
177
+
158
178
  return (
159
179
  <View style={[styles.container, { backgroundColor: tokens.colors.backgroundPrimary }]}>
160
180
  <WizardStepRenderer
@@ -165,17 +185,28 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
165
185
  generationResult={generationResult}
166
186
  isSaving={isSaving}
167
187
  isSharing={isSharing}
188
+ showRating={showRatingButton}
168
189
  onNext={nextStep}
169
190
  onBack={handleBack}
170
191
  onPhotoContinue={handlePhotoContinue}
171
192
  onDownload={handleDownload}
172
193
  onShare={handleShare}
194
+ onRate={handleOpenRatingPicker}
173
195
  onTryAgain={onTryAgain}
174
196
  t={t}
175
197
  renderPreview={renderPreview}
176
198
  renderGenerating={renderGenerating}
177
199
  renderResult={renderResult}
178
200
  />
201
+ <StarRatingPicker
202
+ visible={showRatingPicker}
203
+ onClose={() => setShowRatingPicker(false)}
204
+ onRate={handleSubmitRating}
205
+ title={t("result.rateTitle")}
206
+ submitLabel={t("common.submit")}
207
+ cancelLabel={t("common.cancel")}
208
+ descriptionPlaceholder={t("result.feedbackPlaceholder")}
209
+ />
179
210
  </View>
180
211
  );
181
212
  };
@@ -18,11 +18,13 @@ export const WizardStepRenderer: React.FC<WizardStepRendererProps> = ({
18
18
  generationResult,
19
19
  isSaving,
20
20
  isSharing,
21
+ showRating = true,
21
22
  onNext,
22
23
  onBack,
23
24
  onPhotoContinue,
24
25
  onDownload,
25
26
  onShare,
27
+ onRate,
26
28
  onTryAgain,
27
29
  t,
28
30
  renderPreview,
@@ -77,11 +79,13 @@ export const WizardStepRenderer: React.FC<WizardStepRendererProps> = ({
77
79
  isSharing={isSharing}
78
80
  onDownload={onDownload}
79
81
  onShare={onShare}
82
+ onRate={onRate}
80
83
  onTryAgain={handleTryAgain}
81
84
  onNavigateBack={handleTryAgain}
82
85
  hideLabel
83
86
  iconOnly
84
87
  showTryAgain
88
+ showRating={showRating}
85
89
  translations={{
86
90
  title: t("generation.result.title"),
87
91
  saveButton: t("generation.result.save"),
@@ -10,11 +10,13 @@ export interface WizardStepRendererProps {
10
10
  readonly generationResult: unknown;
11
11
  readonly isSaving: boolean;
12
12
  readonly isSharing: boolean;
13
+ readonly showRating?: boolean;
13
14
  readonly onNext: () => void;
14
15
  readonly onBack: () => void;
15
16
  readonly onPhotoContinue: (stepId: string, image: UploadedImage) => void;
16
17
  readonly onDownload: () => void;
17
18
  readonly onShare: () => void;
19
+ readonly onRate?: () => void;
18
20
  readonly onTryAgain?: () => void;
19
21
  readonly t: (key: string) => string;
20
22
  readonly renderPreview?: (onContinue: () => void) => React.ReactElement | null;