@umituz/react-native-subscription 2.2.22 → 2.2.24

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.2.22",
3
+ "version": "2.2.24",
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",
@@ -27,28 +27,33 @@
27
27
  "url": "git+https://github.com/umituz/react-native-subscription.git"
28
28
  },
29
29
  "peerDependencies": {
30
- "react": ">=18.2.0",
31
- "react-native": ">=0.74.0",
32
- "react-native-purchases": ">=8.0.0",
33
- "react-native-safe-area-context": ">=4.0.0",
34
30
  "@tanstack/react-query": ">=5.0.0",
35
- "@umituz/react-native-firestore": "*",
36
31
  "@umituz/react-native-design-system-atoms": "*",
37
32
  "@umituz/react-native-design-system-theme": "*",
33
+ "@umituz/react-native-firestore": "*",
38
34
  "@umituz/react-native-legal": "*",
35
+ "expo-constants": ">=18.0.0",
39
36
  "firebase": ">=10.0.0",
40
- "expo-constants": ">=18.0.0"
37
+ "react": ">=18.2.0",
38
+ "react-native": ">=0.74.0",
39
+ "react-native-purchases": ">=8.0.0",
40
+ "react-native-safe-area-context": ">=4.0.0"
41
41
  },
42
42
  "devDependencies": {
43
+ "@tanstack/react-query": "^5.0.0",
44
+ "@types/node": "^25.0.3",
43
45
  "@types/react": "~19.1.0",
44
- "typescript": "~5.9.2",
45
- "react-native": "~0.76.0",
46
+ "@umituz/react-native-design-system-atoms": "^1.19.0",
46
47
  "@umituz/react-native-design-system-theme": "latest",
47
48
  "@umituz/react-native-firestore": "latest",
48
- "@tanstack/react-query": "^5.0.0",
49
- "firebase": "^11.0.0",
49
+ "@umituz/react-native-legal": "^2.1.2",
50
+ "@umituz/react-native-localization": "^3.5.8",
50
51
  "expo-constants": "~18.0.0",
51
- "react-native-purchases": "~9.6.0"
52
+ "firebase": "^11.0.0",
53
+ "react-native": "~0.76.0",
54
+ "react-native-purchases": "~9.6.0",
55
+ "react-native-safe-area-context": "^5.6.2",
56
+ "typescript": "~5.9.2"
52
57
  },
53
58
  "publishConfig": {
54
59
  "access": "public"
@@ -58,4 +63,4 @@
58
63
  "README.md",
59
64
  "LICENSE"
60
65
  ]
61
- }
66
+ }
@@ -3,7 +3,7 @@
3
3
  * Orchestrates subscription flow using decomposed components
4
4
  */
5
5
 
6
- import React, { useState, useCallback } from "react";
6
+ import React from "react";
7
7
  import { View, StyleSheet, ScrollView } from "react-native";
8
8
  import { SafeAreaView } from "react-native-safe-area-context";
9
9
  import { useAppDesignTokens } from "@umituz/react-native-design-system-theme";
@@ -14,6 +14,7 @@ import { SubscriptionModalOverlay, SubscriptionModalVariant } from "./Subscripti
14
14
  import { PaywallFeaturesList } from "./PaywallFeaturesList";
15
15
  import { SubscriptionPackageList } from "./SubscriptionPackageList";
16
16
  import { SubscriptionFooter } from "./SubscriptionFooter";
17
+ import { useSubscriptionModal } from "../../hooks/useSubscriptionModal";
17
18
 
18
19
  export interface SubscriptionModalProps {
19
20
  visible: boolean;
@@ -64,37 +65,17 @@ export const SubscriptionModal: React.FC<SubscriptionModalProps> = React.memo((p
64
65
  } = props;
65
66
 
66
67
  const tokens = useAppDesignTokens();
67
- const [selectedPkg, setSelectedPkg] = useState<PurchasesPackage | null>(null);
68
- const [isProcessing, setIsProcessing] = useState(false);
69
-
70
- if (__DEV__ && visible) {
71
- console.log("[SubscriptionModal] Props Info:", {
72
- packagesCount: packages.length,
73
- featuresCount: features.length,
74
- variant,
75
- hasPrivacyUrl: !!privacyUrl,
76
- });
77
- }
78
-
79
- const handlePurchase = useCallback(async () => {
80
- if (!selectedPkg || isProcessing) return;
81
- setIsProcessing(true);
82
- try {
83
- if (await onPurchase(selectedPkg)) onClose();
84
- } finally {
85
- setIsProcessing(false);
86
- }
87
- }, [selectedPkg, isProcessing, onPurchase, onClose]);
88
-
89
- const handleRestore = useCallback(async () => {
90
- if (isProcessing) return;
91
- setIsProcessing(true);
92
- try {
93
- if (await onRestore()) onClose();
94
- } finally {
95
- setIsProcessing(false);
96
- }
97
- }, [isProcessing, onRestore, onClose]);
68
+ const {
69
+ selectedPkg,
70
+ setSelectedPkg,
71
+ isProcessing,
72
+ handlePurchase,
73
+ handleRestore,
74
+ } = useSubscriptionModal({
75
+ onPurchase,
76
+ onRestore,
77
+ onClose,
78
+ });
98
79
 
99
80
  if (!visible) return null;
100
81
 
@@ -0,0 +1,45 @@
1
+ import { useState, useCallback } from "react";
2
+ import type { PurchasesPackage } from "react-native-purchases";
3
+
4
+ interface UseSubscriptionModalProps {
5
+ onPurchase: (pkg: PurchasesPackage) => Promise<boolean>;
6
+ onRestore: () => Promise<boolean>;
7
+ onClose: () => void;
8
+ }
9
+
10
+ export const useSubscriptionModal = ({
11
+ onPurchase,
12
+ onRestore,
13
+ onClose,
14
+ }: UseSubscriptionModalProps) => {
15
+ const [selectedPkg, setSelectedPkg] = useState<PurchasesPackage | null>(null);
16
+ const [isProcessing, setIsProcessing] = useState(false);
17
+
18
+ const handlePurchase = useCallback(async () => {
19
+ if (!selectedPkg || isProcessing) return;
20
+ setIsProcessing(true);
21
+ try {
22
+ if (await onPurchase(selectedPkg)) onClose();
23
+ } finally {
24
+ setIsProcessing(false);
25
+ }
26
+ }, [selectedPkg, isProcessing, onPurchase, onClose]);
27
+
28
+ const handleRestore = useCallback(async () => {
29
+ if (isProcessing) return;
30
+ setIsProcessing(true);
31
+ try {
32
+ if (await onRestore()) onClose();
33
+ } finally {
34
+ setIsProcessing(false);
35
+ }
36
+ }, [isProcessing, onRestore, onClose]);
37
+
38
+ return {
39
+ selectedPkg,
40
+ setSelectedPkg,
41
+ isProcessing,
42
+ handlePurchase,
43
+ handleRestore,
44
+ };
45
+ };