@umituz/react-native-subscription 2.41.10 → 2.41.12

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.41.10",
3
+ "version": "2.41.12",
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",
@@ -13,6 +13,7 @@ import {
13
13
  ListRenderItem,
14
14
  StatusBar,
15
15
  } from "react-native";
16
+ import { useNavigation } from "@react-navigation/native";
16
17
  import { AtomicText, AtomicIcon, AtomicSpinner } from "@umituz/react-native-design-system/atoms";
17
18
  import { useSafeAreaInsets } from "@umituz/react-native-design-system/safe-area";
18
19
  import { useAppDesignTokens } from "@umituz/react-native-design-system/theme";
@@ -29,6 +30,8 @@ import {
29
30
  import { hasItems } from "../../../shared/utils/arrayUtils";
30
31
 
31
32
  export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) => {
33
+ const navigation = useNavigation();
34
+
32
35
  const {
33
36
  onClose,
34
37
  translations,
@@ -51,11 +54,20 @@ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) =>
51
54
  const tokens = useAppDesignTokens();
52
55
  const insets = useSafeAreaInsets();
53
56
 
54
- const {
55
- selectedPlanId,
56
- setSelectedPlanId,
57
- isProcessing,
58
- handlePurchase,
57
+ // Default close handler using navigation
58
+ const handleClose = useCallback(() => {
59
+ if (onClose) {
60
+ onClose();
61
+ } else if (navigation.canGoBack()) {
62
+ navigation.goBack();
63
+ }
64
+ }, [onClose, navigation]);
65
+
66
+ const {
67
+ selectedPlanId,
68
+ setSelectedPlanId,
69
+ isProcessing,
70
+ handlePurchase,
59
71
  handleRestore,
60
72
  resetState
61
73
  } = usePaywallActions({
@@ -66,7 +78,7 @@ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) =>
66
78
  onPurchaseSuccess,
67
79
  onPurchaseError,
68
80
  onAuthRequired,
69
- onClose
81
+ onClose: handleClose
70
82
  });
71
83
 
72
84
  // Reset state when screen is closed to avoid lockups
@@ -235,7 +247,7 @@ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) =>
235
247
  zIndex: 10,
236
248
  }}>
237
249
  <TouchableOpacity
238
- onPress={onClose}
250
+ onPress={handleClose}
239
251
  style={[styles.closeBtn, { backgroundColor: tokens.colors.surfaceSecondary }]}
240
252
  activeOpacity={0.7}
241
253
  >
@@ -4,7 +4,7 @@ import type { SubscriptionFeature, PaywallTranslations, PaywallLegalUrls } from
4
4
  import type { PurchaseSource } from "../../subscription/core/SubscriptionConstants";
5
5
 
6
6
  export interface PaywallScreenProps {
7
- onClose: () => void;
7
+ onClose?: () => void;
8
8
  translations: PaywallTranslations;
9
9
  packages?: PurchasesPackage[];
10
10
  features?: SubscriptionFeature[];
@@ -57,35 +57,6 @@ export function usePaywallOrchestrator({
57
57
  const purchasedRef = useRef(false);
58
58
  const hasNavigatedRef = useRef(false);
59
59
 
60
- const handleClose = useCallback(async () => {
61
- await closePostOnboardingPaywall();
62
- closePaywall();
63
-
64
- // Trigger feedback if user declined and isn't premium
65
- if (!isPremium && !purchasedRef.current) {
66
- setTimeout(() => setShowFeedback(true), 300);
67
- }
68
-
69
- purchasedRef.current = false;
70
- hasNavigatedRef.current = false;
71
-
72
- if (navigation.canGoBack()) {
73
- navigation.goBack();
74
- }
75
- }, [closePostOnboardingPaywall, closePaywall, isPremium, navigation, setShowFeedback]);
76
-
77
- const handleSuccess = useCallback(async () => {
78
- purchasedRef.current = true;
79
- await markPaywallShown();
80
- await closePostOnboardingPaywall();
81
-
82
- onPurchaseSuccess?.();
83
-
84
- if (navigation.canGoBack()) {
85
- navigation.goBack();
86
- }
87
- }, [markPaywallShown, closePostOnboardingPaywall, onPurchaseSuccess, navigation]);
88
-
89
60
  useEffect(() => {
90
61
  if (!isNavReady || !isLocalizationReady) return;
91
62
 
@@ -108,19 +79,14 @@ export function usePaywallOrchestrator({
108
79
  });
109
80
 
110
81
  navigation.navigate("PaywallScreen", {
111
- onClose: handleClose,
112
82
  translations,
113
83
  legalUrls,
114
84
  features,
115
85
  bestValueIdentifier,
116
86
  creditsLabel,
117
- onAuthRequired,
118
- onPurchaseSuccess: handleSuccess,
119
87
  heroImage,
120
88
  source: shouldShowPostOnboarding ? "onboarding" : "manual",
121
89
  packages,
122
- onPurchase: purchasePackage,
123
- onRestore: restorePurchase,
124
90
  });
125
91
 
126
92
  if (shouldShowPostOnboarding) {
@@ -144,20 +110,15 @@ export function usePaywallOrchestrator({
144
110
  isPremium,
145
111
  showPaywall,
146
112
  navigation,
147
- handleClose,
148
- handleSuccess,
149
113
  translations,
150
114
  legalUrls,
151
115
  features,
152
116
  heroImage,
153
117
  packages,
154
- purchasePackage,
155
- restorePurchase,
156
118
  markPaywallShown,
157
119
  closePaywall,
158
120
  bestValueIdentifier,
159
121
  creditsLabel,
160
- onAuthRequired
161
122
  ]);
162
123
 
163
124
  const completeOnboarding = useSubscriptionFlowStore((state) => state.completeOnboarding);