@umituz/react-native-subscription 3.1.20 → 3.1.22
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": "3.1.
|
|
3
|
+
"version": "3.1.22",
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View, TouchableOpacity } from "react-native";
|
|
3
|
-
import { AtomicText } from "@umituz/react-native-design-system/atoms";
|
|
3
|
+
import { AtomicText, AtomicSpinner } from "@umituz/react-native-design-system/atoms";
|
|
4
4
|
import { useAppDesignTokens } from "@umituz/react-native-design-system/theme";
|
|
5
5
|
import type { PaywallTranslations, PaywallLegalUrls } from "../entities/types";
|
|
6
6
|
import { paywallScreenStyles as styles } from "./PaywallScreen.styles";
|
|
@@ -9,21 +9,47 @@ interface PaywallFooterProps {
|
|
|
9
9
|
translations: PaywallTranslations;
|
|
10
10
|
legalUrls: PaywallLegalUrls;
|
|
11
11
|
isProcessing: boolean;
|
|
12
|
+
onPurchase?: () => void | Promise<void>;
|
|
12
13
|
onRestore?: () => Promise<void | boolean>;
|
|
13
14
|
onLegalClick: (url: string | undefined) => void;
|
|
15
|
+
purchaseButtonText?: string;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export const PaywallFooter: React.FC<PaywallFooterProps> = React.memo(({
|
|
17
19
|
translations,
|
|
18
20
|
legalUrls,
|
|
19
21
|
isProcessing,
|
|
22
|
+
onPurchase,
|
|
20
23
|
onRestore,
|
|
21
24
|
onLegalClick,
|
|
25
|
+
purchaseButtonText,
|
|
22
26
|
}) => {
|
|
23
27
|
const tokens = useAppDesignTokens();
|
|
24
|
-
|
|
28
|
+
|
|
25
29
|
return (
|
|
26
30
|
<View style={styles.footer}>
|
|
31
|
+
{/* Purchase Button */}
|
|
32
|
+
{onPurchase && (
|
|
33
|
+
<TouchableOpacity
|
|
34
|
+
onPress={onPurchase}
|
|
35
|
+
disabled={isProcessing}
|
|
36
|
+
style={[
|
|
37
|
+
styles.purchaseButton,
|
|
38
|
+
isProcessing && styles.ctaDisabled,
|
|
39
|
+
{ backgroundColor: tokens.colors.primary }
|
|
40
|
+
]}
|
|
41
|
+
>
|
|
42
|
+
{isProcessing ? (
|
|
43
|
+
<AtomicSpinner size="sm" />
|
|
44
|
+
) : (
|
|
45
|
+
<AtomicText type="body" style={[styles.purchaseButtonText, { color: tokens.colors.textPrimary }]}>
|
|
46
|
+
{purchaseButtonText || translations.purchaseButtonText}
|
|
47
|
+
</AtomicText>
|
|
48
|
+
)}
|
|
49
|
+
</TouchableOpacity>
|
|
50
|
+
)}
|
|
51
|
+
|
|
52
|
+
{/* Restore Button */}
|
|
27
53
|
{onRestore && (
|
|
28
54
|
<TouchableOpacity onPress={onRestore} disabled={isProcessing} style={[styles.restoreButton, isProcessing && styles.ctaDisabled]}>
|
|
29
55
|
<AtomicText type="bodySmall" style={[styles.footerLink, { color: tokens.colors.textSecondary }]}>
|
|
@@ -31,6 +57,8 @@ export const PaywallFooter: React.FC<PaywallFooterProps> = React.memo(({
|
|
|
31
57
|
</AtomicText>
|
|
32
58
|
</TouchableOpacity>
|
|
33
59
|
)}
|
|
60
|
+
|
|
61
|
+
{/* Legal Links */}
|
|
34
62
|
<View style={styles.legalRow}>
|
|
35
63
|
{legalUrls.termsUrl && (
|
|
36
64
|
<TouchableOpacity onPress={() => onLegalClick(legalUrls.termsUrl)}>
|
|
@@ -123,9 +123,43 @@ export const paywallScreenStyles = StyleSheet.create({
|
|
|
123
123
|
|
|
124
124
|
// Footer Links
|
|
125
125
|
footer: {
|
|
126
|
-
|
|
126
|
+
position: "absolute",
|
|
127
|
+
bottom: 0,
|
|
128
|
+
left: 0,
|
|
129
|
+
right: 0,
|
|
130
|
+
paddingHorizontal: 24,
|
|
131
|
+
paddingTop: 20,
|
|
132
|
+
paddingBottom: 40,
|
|
133
|
+
borderTopWidth: 1,
|
|
134
|
+
borderTopColor: "rgba(255, 255, 255, 0.08)",
|
|
135
|
+
...Platform.select({
|
|
136
|
+
ios: {
|
|
137
|
+
shadowColor: "#000",
|
|
138
|
+
shadowOffset: { width: 0, height: -4 },
|
|
139
|
+
shadowOpacity: 0.1,
|
|
140
|
+
shadowRadius: 12,
|
|
141
|
+
},
|
|
142
|
+
android: {
|
|
143
|
+
elevation: 8,
|
|
144
|
+
},
|
|
145
|
+
}),
|
|
146
|
+
},
|
|
147
|
+
purchaseButton: {
|
|
148
|
+
borderRadius: 18,
|
|
149
|
+
height: 60,
|
|
150
|
+
justifyContent: "center",
|
|
127
151
|
alignItems: "center",
|
|
128
|
-
|
|
152
|
+
shadowColor: "#000",
|
|
153
|
+
shadowOffset: { width: 0, height: 4 },
|
|
154
|
+
shadowOpacity: 0.3,
|
|
155
|
+
shadowRadius: 8,
|
|
156
|
+
elevation: 6,
|
|
157
|
+
marginBottom: 16,
|
|
158
|
+
},
|
|
159
|
+
purchaseButtonText: {
|
|
160
|
+
fontWeight: "700",
|
|
161
|
+
letterSpacing: 0.5,
|
|
162
|
+
fontSize: 16,
|
|
129
163
|
},
|
|
130
164
|
restoreButton: {
|
|
131
165
|
paddingVertical: 4,
|
|
@@ -75,6 +75,7 @@ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) =>
|
|
|
75
75
|
selectedPlanId,
|
|
76
76
|
setSelectedPlanId,
|
|
77
77
|
isProcessing,
|
|
78
|
+
handlePurchase,
|
|
78
79
|
handleRestore,
|
|
79
80
|
resetState
|
|
80
81
|
} = usePaywallActions({
|
|
@@ -88,19 +89,23 @@ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) =>
|
|
|
88
89
|
onClose: handleClose
|
|
89
90
|
});
|
|
90
91
|
|
|
92
|
+
// Cleanup on unmount only - resetState is stable from useCallback
|
|
91
93
|
useEffect(() => {
|
|
92
94
|
return () => {
|
|
93
95
|
if (__DEV__) console.log('[PaywallScreen] 🧹 Cleanup: resetting state');
|
|
94
96
|
resetState();
|
|
95
97
|
};
|
|
96
|
-
|
|
98
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
99
|
+
}, []);
|
|
97
100
|
|
|
98
101
|
// Auto-select first package
|
|
99
102
|
useEffect(() => {
|
|
100
103
|
if (hasItems(packages) && !selectedPlanId) {
|
|
101
104
|
setSelectedPlanId(packages[0].product.identifier);
|
|
102
105
|
}
|
|
103
|
-
|
|
106
|
+
// setSelectedPlanId is stable from useState, packages.length is sufficient
|
|
107
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
108
|
+
}, [packages?.length, selectedPlanId]);
|
|
104
109
|
|
|
105
110
|
const handleLegalUrl = useCallback(async (url: string | undefined) => {
|
|
106
111
|
if (!url) return;
|
|
@@ -227,6 +232,7 @@ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) =>
|
|
|
227
232
|
translations={translations}
|
|
228
233
|
legalUrls={legalUrls}
|
|
229
234
|
isProcessing={isProcessing}
|
|
235
|
+
onPurchase={handlePurchase}
|
|
230
236
|
onRestore={handleRestore}
|
|
231
237
|
onLegalClick={handleLegalUrl}
|
|
232
238
|
/>
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Handlers extracted to separate modules for better maintainability.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { useState, useRef, useMemo } from "react";
|
|
8
|
+
import { useState, useRef, useMemo, useCallback } from "react";
|
|
9
9
|
import type { UsePaywallActionsParams } from "./usePaywallActions.types";
|
|
10
10
|
import { usePurchaseHandler } from "./usePaywallPurchase";
|
|
11
11
|
import { useRestoreHandler } from "./usePaywallRestore";
|
|
@@ -59,14 +59,14 @@ export function usePaywallActions({
|
|
|
59
59
|
callbacksRef,
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
// Reset state
|
|
63
|
-
const resetState = () => {
|
|
62
|
+
// Reset state - memoized with useCallback to prevent infinite loops
|
|
63
|
+
const resetState = useCallback(() => {
|
|
64
64
|
if (__DEV__) {
|
|
65
65
|
console.log('[usePaywallActions] 🧹 Resetting state');
|
|
66
66
|
}
|
|
67
67
|
setSelectedPlanId(null);
|
|
68
68
|
setIsProcessing(false);
|
|
69
|
-
};
|
|
69
|
+
}, []);
|
|
70
70
|
|
|
71
71
|
// Return API
|
|
72
72
|
return useMemo(() => ({
|
|
@@ -76,5 +76,5 @@ export function usePaywallActions({
|
|
|
76
76
|
handlePurchase,
|
|
77
77
|
handleRestore,
|
|
78
78
|
resetState,
|
|
79
|
-
}), [selectedPlanId, isProcessing, handlePurchase, handleRestore]);
|
|
79
|
+
}), [selectedPlanId, isProcessing, handlePurchase, handleRestore, resetState]);
|
|
80
80
|
}
|