@umituz/react-native-subscription 2.40.16 → 2.40.17

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-subscription",
3
- "version": "2.40.16",
3
+ "version": "2.40.17",
4
4
  "description": "Complete subscription management with RevenueCat, paywall UI, and credits system for React Native apps",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -1,4 +1,5 @@
1
1
  import { PaywallTranslations } from "../entities/types";
2
+ import { PaywallFeedbackTranslations } from "../../subscription/presentation/components/feedback/PaywallFeedbackScreen.types";
2
3
 
3
4
  /**
4
5
  * Creates standardized paywall translations from a translation function.
@@ -22,3 +23,24 @@ export const createPaywallTranslations = (
22
23
  plansTitle: t("paywall.plansTitle"),
23
24
  ...overrides,
24
25
  });
26
+
27
+ /**
28
+ * Creates standardized feedback translations.
29
+ */
30
+ export const createFeedbackTranslations = (
31
+ t: (key: string) => string,
32
+ overrides?: Partial<PaywallFeedbackTranslations>
33
+ ): PaywallFeedbackTranslations => ({
34
+ title: t("feedback.title"),
35
+ subtitle: t("feedback.subtitle"),
36
+ submit: t("feedback.submit"),
37
+ otherPlaceholder: t("feedback.otherPlaceholder"),
38
+ reasons: {
39
+ too_expensive: t("feedback.reasons.too_expensive"),
40
+ no_need: t("feedback.reasons.no_need"),
41
+ trying_out: t("feedback.reasons.trying_out"),
42
+ technical_issues: t("feedback.reasons.technical_issues"),
43
+ other: t("feedback.reasons.other"),
44
+ },
45
+ ...overrides,
46
+ });
@@ -0,0 +1,175 @@
1
+ import React, { useState, useEffect } from "react";
2
+ import { SplashScreen, useSplashFlow } from "@umituz/react-native-design-system/molecules";
3
+ import { OnboardingScreen } from "@umituz/react-native-design-system/onboarding";
4
+ import { OfflineBanner } from "@umituz/react-native-design-system/offline";
5
+ import { useAppDesignTokens } from "@umituz/react-native-design-system/theme";
6
+ import { usePaywallOrchestrator } from "../../../paywall/hooks/usePaywallOrchestrator";
7
+ import { PaywallFeedbackScreen } from "../../../subscription/presentation/components/feedback/PaywallFeedbackScreen";
8
+ import { PaywallFeedbackTranslations } from "../../../subscription/presentation/components/feedback/PaywallFeedbackScreen.types";
9
+ import { PaywallTranslations, PaywallLegalUrls, SubscriptionFeature } from "../../../paywall/entities/types";
10
+ import { usePaywallFeedbackSubmit } from "../../../../presentation/hooks/feedback/usePaywallFeedbackSubmit";
11
+
12
+ export interface ManagedSubscriptionFlowProps {
13
+ children: React.ReactNode;
14
+ navigation: any;
15
+ islocalizationReady: boolean;
16
+
17
+ // Splash Configuration
18
+ splash: {
19
+ appName: string;
20
+ tagline: string;
21
+ duration?: number;
22
+ };
23
+
24
+ // Onboarding Configuration
25
+ onboarding: {
26
+ slides: any[];
27
+ translations: {
28
+ nextButton: string;
29
+ getStartedButton: string;
30
+ of: string;
31
+ };
32
+ themeColors: any;
33
+ showSkipButton?: boolean;
34
+ showBackButton?: boolean;
35
+ showProgressBar?: boolean;
36
+ };
37
+
38
+ // Paywall Configuration
39
+ paywall: {
40
+ translations: PaywallTranslations;
41
+ features: SubscriptionFeature[];
42
+ legalUrls: PaywallLegalUrls;
43
+ heroImage: any;
44
+ bestValueIdentifier?: string;
45
+ creditsLabel?: string;
46
+ onAuthRequired?: () => void;
47
+ onPurchaseSuccess?: () => void;
48
+ };
49
+
50
+ // Feedback Configuration
51
+ feedback: {
52
+ translations: PaywallFeedbackTranslations;
53
+ onSubmit?: (data: { reason: string; otherText?: string }) => void | Promise<void>;
54
+ };
55
+
56
+ // Offline Configuration
57
+ offline?: {
58
+ isOffline: boolean;
59
+ message: string;
60
+ backgroundColor?: string;
61
+ position?: "top" | "bottom";
62
+ };
63
+ }
64
+
65
+ /**
66
+ * ManagedSubscriptionFlow
67
+ *
68
+ * A high-level layout component that orchestrates the entire application flow:
69
+ * Splash -> Onboarding -> [Managed Paywall Screens] -> Main Application Stack.
70
+ *
71
+ * Use this to reduce AppNavigator boilerplate to nearly zero.
72
+ */
73
+ export const ManagedSubscriptionFlow: React.FC<ManagedSubscriptionFlowProps> = ({
74
+ children,
75
+ navigation,
76
+ islocalizationReady,
77
+ splash,
78
+ onboarding,
79
+ paywall,
80
+ feedback,
81
+ offline,
82
+ }) => {
83
+ const tokens = useAppDesignTokens();
84
+ const { isInitialized: isSplashComplete } = useSplashFlow({
85
+ duration: splash.duration || 1500
86
+ });
87
+
88
+ const [isNavReady, setIsNavReady] = useState(false);
89
+
90
+ // Mark navigation tree as ready after splash and localization
91
+ useEffect(() => {
92
+ if (isSplashComplete && islocalizationReady) {
93
+ const timer = setTimeout(() => setIsNavReady(true), 500);
94
+ return () => clearTimeout(timer);
95
+ }
96
+ }, [isSplashComplete, islocalizationReady]);
97
+
98
+ const {
99
+ flowState,
100
+ setShowFeedback
101
+ } = usePaywallOrchestrator({
102
+ navigation,
103
+ isNavReady,
104
+ isLocalizationReady: islocalizationReady,
105
+ translations: paywall.translations,
106
+ features: paywall.features,
107
+ legalUrls: paywall.legalUrls,
108
+ heroImage: paywall.heroImage,
109
+ onAuthRequired: paywall.onAuthRequired,
110
+ onPurchaseSuccess: paywall.onPurchaseSuccess,
111
+ bestValueIdentifier: paywall.bestValueIdentifier,
112
+ creditsLabel: paywall.creditsLabel,
113
+ });
114
+
115
+ const { submit: internalSubmit } = usePaywallFeedbackSubmit();
116
+
117
+ const handleFeedbackSubmit = async (data: { reason: string; otherText?: string }) => {
118
+ if (feedback.onSubmit) {
119
+ await feedback.onSubmit(data);
120
+ } else {
121
+ const description = data.otherText ? `${data.reason}: ${data.otherText}` : data.reason;
122
+ await internalSubmit(description);
123
+ }
124
+ };
125
+
126
+ // 1. Loading / Splash State
127
+ if (!isSplashComplete || !flowState.isInitialized || !islocalizationReady) {
128
+ return (
129
+ <SplashScreen
130
+ appName={splash.appName}
131
+ tagline={splash.tagline}
132
+ colors={tokens.colors}
133
+ />
134
+ );
135
+ }
136
+
137
+ // 2. Onboarding State
138
+ if (!flowState.isOnboardingComplete) {
139
+ return (
140
+ <OnboardingScreen
141
+ slides={onboarding.slides}
142
+ onComplete={flowState.completeOnboarding}
143
+ showSkipButton={onboarding.showSkipButton ?? true}
144
+ showBackButton={onboarding.showBackButton ?? true}
145
+ showProgressBar={onboarding.showProgressBar ?? true}
146
+ themeColors={onboarding.themeColors}
147
+ translations={onboarding.translations}
148
+ />
149
+ );
150
+ }
151
+
152
+ // 3. Main Application State
153
+ return (
154
+ <>
155
+ {children}
156
+
157
+ {offline && (
158
+ <OfflineBanner
159
+ visible={offline.isOffline}
160
+ message={offline.message}
161
+ backgroundColor={offline.backgroundColor || tokens.colors.error}
162
+ position={offline.position || "top"}
163
+ />
164
+ )}
165
+
166
+ {flowState.showFeedback && (
167
+ <PaywallFeedbackScreen
168
+ onClose={() => setShowFeedback(false)}
169
+ onSubmit={handleFeedbackSubmit}
170
+ translations={feedback.translations}
171
+ />
172
+ )}
173
+ </>
174
+ );
175
+ };
package/src/index.ts CHANGED
@@ -92,7 +92,11 @@ export { creditsQueryKeys } from "./domains/credits/presentation/creditsQueryKey
92
92
 
93
93
  // Paywall Types & Utils
94
94
  export type { PaywallTranslations, PaywallLegalUrls, SubscriptionFeature } from "./domains/paywall/entities/types";
95
- export { createPaywallTranslations } from "./domains/paywall/utils/paywallTranslationUtils";
95
+ export { createPaywallTranslations, createFeedbackTranslations } from "./domains/paywall/utils/paywallTranslationUtils";
96
+
97
+ // Root Flow Components
98
+ export { ManagedSubscriptionFlow } from "./domains/subscription/presentation/components/ManagedSubscriptionFlow";
99
+ export type { ManagedSubscriptionFlowProps } from "./domains/subscription/presentation/components/ManagedSubscriptionFlow";
96
100
 
97
101
  // Purchase Loading Overlay
98
102
  export { PurchaseLoadingOverlay } from "./domains/subscription/presentation/components/overlay/PurchaseLoadingOverlay";