@umituz/react-native-subscription 2.12.14 โ 2.12.16
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.12.
|
|
3
|
+
"version": "2.12.16",
|
|
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",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import React, { useState, useCallback } from "react";
|
|
7
|
-
import { View, ScrollView, StyleSheet, TouchableOpacity, ActivityIndicator } from "react-native";
|
|
7
|
+
import { View, ScrollView, StyleSheet, TouchableOpacity, ActivityIndicator, Linking } from "react-native";
|
|
8
8
|
import { BaseModal, useAppDesignTokens, AtomicText, AtomicIcon } from "@umituz/react-native-design-system";
|
|
9
9
|
import type { PurchasesPackage } from "react-native-purchases";
|
|
10
10
|
import { PlanCard } from "./PlanCard";
|
|
@@ -80,6 +80,18 @@ export const PaywallModal: React.FC<PaywallModalProps> = React.memo((props) => {
|
|
|
80
80
|
}
|
|
81
81
|
}, [onRestore, isProcessing]);
|
|
82
82
|
|
|
83
|
+
const handleLegalUrl = useCallback(async (url: string | undefined) => {
|
|
84
|
+
if (!url) return;
|
|
85
|
+
try {
|
|
86
|
+
const supported = await Linking.canOpenURL(url);
|
|
87
|
+
if (supported) {
|
|
88
|
+
await Linking.openURL(url);
|
|
89
|
+
}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
// Silent fail
|
|
92
|
+
}
|
|
93
|
+
}, []);
|
|
94
|
+
|
|
83
95
|
const isPurchaseDisabled = showSubscription ? !selectedPlanId : !selectedCreditId;
|
|
84
96
|
|
|
85
97
|
return (
|
|
@@ -161,22 +173,26 @@ export const PaywallModal: React.FC<PaywallModalProps> = React.memo((props) => {
|
|
|
161
173
|
|
|
162
174
|
<View style={styles.footer}>
|
|
163
175
|
{onRestore && (
|
|
164
|
-
<TouchableOpacity
|
|
176
|
+
<TouchableOpacity
|
|
177
|
+
onPress={handleRestore}
|
|
178
|
+
disabled={isProcessing}
|
|
179
|
+
style={[styles.restoreButton, isProcessing && styles.restoreButtonDisabled]}
|
|
180
|
+
>
|
|
165
181
|
<AtomicText type="bodySmall" style={[styles.footerLink, { color: tokens.colors.textSecondary }]}>
|
|
166
|
-
{translations.restoreButtonText}
|
|
182
|
+
{isProcessing ? translations.processingText : translations.restoreButtonText}
|
|
167
183
|
</AtomicText>
|
|
168
184
|
</TouchableOpacity>
|
|
169
185
|
)}
|
|
170
186
|
<View style={styles.legalRow}>
|
|
171
187
|
{legalUrls.termsUrl && (
|
|
172
|
-
<TouchableOpacity onPress={() =>
|
|
188
|
+
<TouchableOpacity onPress={() => handleLegalUrl(legalUrls.termsUrl)}>
|
|
173
189
|
<AtomicText type="bodySmall" style={[styles.footerLink, { color: tokens.colors.textSecondary }]}>
|
|
174
190
|
{translations.termsOfServiceText}
|
|
175
191
|
</AtomicText>
|
|
176
192
|
</TouchableOpacity>
|
|
177
193
|
)}
|
|
178
194
|
{legalUrls.privacyUrl && (
|
|
179
|
-
<TouchableOpacity onPress={() =>
|
|
195
|
+
<TouchableOpacity onPress={() => handleLegalUrl(legalUrls.privacyUrl)}>
|
|
180
196
|
<AtomicText type="bodySmall" style={[styles.footerLink, { color: tokens.colors.textSecondary }]}>
|
|
181
197
|
{translations.privacyText}
|
|
182
198
|
</AtomicText>
|
|
@@ -212,6 +228,7 @@ const styles = StyleSheet.create({
|
|
|
212
228
|
ctaText: { fontWeight: "700" },
|
|
213
229
|
footer: { flexDirection: "column", alignItems: "center", gap: 8 },
|
|
214
230
|
restoreButton: { marginBottom: 8 },
|
|
231
|
+
restoreButtonDisabled: { opacity: 0.5 },
|
|
215
232
|
legalRow: { flexDirection: "row", justifyContent: "center", gap: 16 },
|
|
216
233
|
footerLink: {},
|
|
217
234
|
});
|
package/src/index.ts
CHANGED
|
@@ -120,6 +120,8 @@ export {
|
|
|
120
120
|
type SubscriptionDetailTranslations,
|
|
121
121
|
} from "./presentation/screens/SubscriptionDetailScreen";
|
|
122
122
|
|
|
123
|
+
export { type DevTestActions } from "./presentation/screens/components/DevTestSection";
|
|
124
|
+
|
|
123
125
|
|
|
124
126
|
// =============================================================================
|
|
125
127
|
// UTILS - Date & Price
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import React from "react";
|
|
8
|
-
import { ScrollView, StyleSheet } from "react-native";
|
|
8
|
+
import { View, ScrollView, StyleSheet } from "react-native";
|
|
9
9
|
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
10
10
|
import { SubscriptionHeader } from "./components/SubscriptionHeader";
|
|
11
11
|
import { CreditsList } from "./components/CreditsList";
|
|
12
12
|
import { SubscriptionActions } from "./components/SubscriptionActions";
|
|
13
|
+
import { DevTestSection, type DevTestActions } from "./components/DevTestSection";
|
|
13
14
|
import type { SubscriptionStatusType } from "../components/details/PremiumStatusBadge";
|
|
14
15
|
import type { CreditInfo } from "../components/details/PremiumDetailsCard";
|
|
15
16
|
|
|
@@ -41,6 +42,10 @@ export interface SubscriptionDetailConfig {
|
|
|
41
42
|
translations: SubscriptionDetailTranslations;
|
|
42
43
|
onManageSubscription?: () => void;
|
|
43
44
|
onUpgrade?: () => void;
|
|
45
|
+
devTools?: {
|
|
46
|
+
actions: DevTestActions;
|
|
47
|
+
title?: string;
|
|
48
|
+
};
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
export interface SubscriptionDetailScreenProps {
|
|
@@ -54,39 +59,48 @@ export const SubscriptionDetailScreen: React.FC<
|
|
|
54
59
|
const showCredits = config.credits && config.credits.length > 0;
|
|
55
60
|
|
|
56
61
|
return (
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
<View style={{ flex: 1 }}>
|
|
63
|
+
<ScrollView
|
|
64
|
+
style={[styles.container, { backgroundColor: tokens.colors.backgroundPrimary }]}
|
|
65
|
+
contentContainerStyle={styles.content}
|
|
66
|
+
>
|
|
67
|
+
<SubscriptionHeader
|
|
68
|
+
statusType={config.statusType}
|
|
69
|
+
isPremium={config.isPremium}
|
|
70
|
+
isLifetime={config.isLifetime}
|
|
71
|
+
expirationDate={config.expirationDate}
|
|
72
|
+
purchaseDate={config.purchaseDate}
|
|
73
|
+
daysRemaining={config.daysRemaining}
|
|
74
|
+
translations={config.translations}
|
|
75
|
+
/>
|
|
76
|
+
|
|
77
|
+
{showCredits && (
|
|
78
|
+
<CreditsList
|
|
79
|
+
credits={config.credits!}
|
|
80
|
+
title={
|
|
81
|
+
config.translations.usageTitle || config.translations.creditsTitle
|
|
82
|
+
}
|
|
83
|
+
description={config.translations.creditsResetInfo}
|
|
84
|
+
remainingLabel={config.translations.remainingLabel}
|
|
85
|
+
/>
|
|
86
|
+
)}
|
|
70
87
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
description={config.translations.creditsResetInfo}
|
|
78
|
-
remainingLabel={config.translations.remainingLabel}
|
|
88
|
+
<SubscriptionActions
|
|
89
|
+
isPremium={config.isPremium}
|
|
90
|
+
manageButtonLabel={config.translations.manageButton}
|
|
91
|
+
upgradeButtonLabel={config.translations.upgradeButton}
|
|
92
|
+
onManage={config.onManageSubscription}
|
|
93
|
+
onUpgrade={config.onUpgrade}
|
|
79
94
|
/>
|
|
80
|
-
|
|
95
|
+
</ScrollView>
|
|
81
96
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
</ScrollView>
|
|
97
|
+
{config.devTools && (
|
|
98
|
+
<DevTestSection
|
|
99
|
+
actions={config.devTools.actions}
|
|
100
|
+
title={config.devTools.title}
|
|
101
|
+
/>
|
|
102
|
+
)}
|
|
103
|
+
</View>
|
|
90
104
|
);
|
|
91
105
|
};
|
|
92
106
|
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev Test Section
|
|
3
|
+
* Developer testing tools for subscription renewals
|
|
4
|
+
* Only visible in __DEV__ mode
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { View, TouchableOpacity, StyleSheet } from "react-native";
|
|
9
|
+
import { AtomicText, useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
10
|
+
|
|
11
|
+
export interface DevTestActions {
|
|
12
|
+
onTestRenewal: () => Promise<void>;
|
|
13
|
+
onCheckCredits: () => void;
|
|
14
|
+
onTestDuplicate: () => Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface DevTestSectionProps {
|
|
18
|
+
actions: DevTestActions;
|
|
19
|
+
title?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const DevTestSection: React.FC<DevTestSectionProps> = ({
|
|
23
|
+
actions,
|
|
24
|
+
title = "๐งช Developer Testing",
|
|
25
|
+
}) => {
|
|
26
|
+
const tokens = useAppDesignTokens();
|
|
27
|
+
|
|
28
|
+
if (!__DEV__) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<View
|
|
34
|
+
style={[
|
|
35
|
+
styles.container,
|
|
36
|
+
{
|
|
37
|
+
backgroundColor: tokens.colors.surfaceSecondary,
|
|
38
|
+
borderTopColor: tokens.colors.border,
|
|
39
|
+
},
|
|
40
|
+
]}
|
|
41
|
+
>
|
|
42
|
+
<AtomicText
|
|
43
|
+
type="titleMedium"
|
|
44
|
+
style={[styles.title, { color: tokens.colors.textPrimary }]}
|
|
45
|
+
>
|
|
46
|
+
{title}
|
|
47
|
+
</AtomicText>
|
|
48
|
+
|
|
49
|
+
<TouchableOpacity
|
|
50
|
+
style={[styles.button, { backgroundColor: tokens.colors.primary }]}
|
|
51
|
+
onPress={actions.onTestRenewal}
|
|
52
|
+
>
|
|
53
|
+
<AtomicText
|
|
54
|
+
type="bodyMedium"
|
|
55
|
+
style={[styles.buttonText, { color: tokens.colors.onPrimary }]}
|
|
56
|
+
>
|
|
57
|
+
โก Test Auto-Renewal (Add Credits)
|
|
58
|
+
</AtomicText>
|
|
59
|
+
</TouchableOpacity>
|
|
60
|
+
|
|
61
|
+
<TouchableOpacity
|
|
62
|
+
style={[
|
|
63
|
+
styles.button,
|
|
64
|
+
{
|
|
65
|
+
backgroundColor: tokens.colors.surfaceSecondary,
|
|
66
|
+
borderWidth: 1,
|
|
67
|
+
borderColor: tokens.colors.border,
|
|
68
|
+
},
|
|
69
|
+
]}
|
|
70
|
+
onPress={actions.onCheckCredits}
|
|
71
|
+
>
|
|
72
|
+
<AtomicText
|
|
73
|
+
type="bodyMedium"
|
|
74
|
+
style={[styles.buttonText, { color: tokens.colors.textPrimary }]}
|
|
75
|
+
>
|
|
76
|
+
๐ Check Current Credits
|
|
77
|
+
</AtomicText>
|
|
78
|
+
</TouchableOpacity>
|
|
79
|
+
|
|
80
|
+
<TouchableOpacity
|
|
81
|
+
style={[
|
|
82
|
+
styles.button,
|
|
83
|
+
{
|
|
84
|
+
backgroundColor: tokens.colors.surfaceSecondary,
|
|
85
|
+
borderWidth: 1,
|
|
86
|
+
borderColor: tokens.colors.border,
|
|
87
|
+
},
|
|
88
|
+
]}
|
|
89
|
+
onPress={actions.onTestDuplicate}
|
|
90
|
+
>
|
|
91
|
+
<AtomicText
|
|
92
|
+
type="bodyMedium"
|
|
93
|
+
style={[styles.buttonText, { color: tokens.colors.textPrimary }]}
|
|
94
|
+
>
|
|
95
|
+
๐ Test Duplicate Protection
|
|
96
|
+
</AtomicText>
|
|
97
|
+
</TouchableOpacity>
|
|
98
|
+
</View>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const styles = StyleSheet.create({
|
|
103
|
+
container: {
|
|
104
|
+
padding: 16,
|
|
105
|
+
gap: 12,
|
|
106
|
+
borderTopWidth: 1,
|
|
107
|
+
},
|
|
108
|
+
title: {
|
|
109
|
+
fontWeight: "600",
|
|
110
|
+
marginBottom: 4,
|
|
111
|
+
},
|
|
112
|
+
button: {
|
|
113
|
+
paddingVertical: 12,
|
|
114
|
+
paddingHorizontal: 16,
|
|
115
|
+
borderRadius: 8,
|
|
116
|
+
alignItems: "center",
|
|
117
|
+
},
|
|
118
|
+
buttonText: {
|
|
119
|
+
fontWeight: "500",
|
|
120
|
+
},
|
|
121
|
+
});
|