@umituz/react-native-subscription 2.37.130 → 2.38.1

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.37.130",
3
+ "version": "2.38.1",
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",
@@ -0,0 +1,214 @@
1
+ /**
2
+ * Paywall Screen Component
3
+ *
4
+ * Full-screen paywall (not modal). Use when you want the paywall
5
+ * to be a standalone screen instead of a modal overlay.
6
+ */
7
+
8
+ import React, { useCallback, useEffect } from "react";
9
+ import { View, ScrollView, TouchableOpacity, Linking, StyleSheet } from "react-native";
10
+ import { AtomicText, AtomicIcon, AtomicSpinner } from "@umituz/react-native-design-system/atoms";
11
+ import { useSafeAreaInsets } from "@umituz/react-native-design-system/safe-area";
12
+ import { useAppDesignTokens } from "@umituz/react-native-design-system/theme";
13
+ import { Image } from "expo-image";
14
+ import { PlanCard } from "./PlanCard";
15
+ import { paywallModalStyles as styles } from "./PaywallModal.styles";
16
+ import { PaywallFeatures } from "./PaywallFeatures";
17
+ import { PaywallFooter } from "./PaywallFooter";
18
+ import { usePaywallActions } from "../hooks/usePaywallActions";
19
+ import { PaywallScreenProps } from "./PaywallScreen.types";
20
+
21
+ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) => {
22
+ const {
23
+ onClose,
24
+ translations,
25
+ packages = [],
26
+ features = [],
27
+ legalUrls = {},
28
+ bestValueIdentifier,
29
+ creditAmounts,
30
+ creditsLabel,
31
+ heroImage,
32
+ onPurchase,
33
+ onRestore,
34
+ onPurchaseSuccess,
35
+ onPurchaseError,
36
+ onAuthRequired,
37
+ source,
38
+ isLoadingPackages
39
+ } = props;
40
+
41
+ const tokens = useAppDesignTokens();
42
+ const insets = useSafeAreaInsets();
43
+
44
+ if (__DEV__) {
45
+ console.log("[PaywallScreen] Render:", {
46
+ packagesCount: packages.length,
47
+ isLoadingPackages,
48
+ source,
49
+ });
50
+ }
51
+
52
+ const { selectedPlanId, setSelectedPlanId, isProcessing, handlePurchase, handleRestore } = usePaywallActions({
53
+ packages,
54
+ onPurchase,
55
+ onRestore,
56
+ source,
57
+ onPurchaseSuccess,
58
+ onPurchaseError,
59
+ onAuthRequired,
60
+ onClose
61
+ });
62
+
63
+ // Auto-select first package when packages load and none is selected
64
+ useEffect(() => {
65
+ if (packages.length > 0 && !selectedPlanId) {
66
+ setSelectedPlanId(packages[0].product.identifier);
67
+ }
68
+ }, [packages, selectedPlanId, setSelectedPlanId]);
69
+
70
+ const handleLegalUrl = useCallback(async (url: string | undefined) => {
71
+ if (!url) return;
72
+ try {
73
+ if (await Linking.canOpenURL(url)) await Linking.openURL(url);
74
+ } catch (error) {
75
+ console.error('[PaywallScreen] Failed to open URL:', error instanceof Error ? error.message : String(error));
76
+ }
77
+ }, []);
78
+
79
+ return (
80
+ <View style={[styles.container, { backgroundColor: tokens.colors.backgroundPrimary }]}>
81
+ {/* Close button */}
82
+ <TouchableOpacity
83
+ onPress={onClose}
84
+ style={[screenStyles.closeBtn, { backgroundColor: tokens.colors.surfaceSecondary, top: Math.max(insets.top, 12) }]}
85
+ hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
86
+ >
87
+ <AtomicIcon name="close-outline" size="md" customColor={tokens.colors.textPrimary} />
88
+ </TouchableOpacity>
89
+
90
+ {/* Scrollable content */}
91
+ <ScrollView
92
+ style={screenStyles.scrollContainer}
93
+ contentContainerStyle={screenStyles.scroll}
94
+ showsVerticalScrollIndicator={false}
95
+ >
96
+ {/* Hero Image */}
97
+ {heroImage && (
98
+ <View style={styles.heroContainer}>
99
+ <Image source={heroImage} style={styles.heroImage} contentFit="cover" transition={0} />
100
+ </View>
101
+ )}
102
+
103
+ {/* Header */}
104
+ <View style={styles.header}>
105
+ <AtomicText
106
+ type="headlineMedium"
107
+ adjustsFontSizeToFit
108
+ numberOfLines={2}
109
+ minimumFontScale={0.75}
110
+ style={[styles.title, { color: tokens.colors.textPrimary }]}
111
+ >
112
+ {translations.title}
113
+ </AtomicText>
114
+ {translations.subtitle && (
115
+ <AtomicText
116
+ type="bodyMedium"
117
+ adjustsFontSizeToFit
118
+ numberOfLines={3}
119
+ minimumFontScale={0.8}
120
+ style={[styles.subtitle, { color: tokens.colors.textSecondary }]}
121
+ >
122
+ {translations.subtitle}
123
+ </AtomicText>
124
+ )}
125
+ </View>
126
+
127
+ {/* Features */}
128
+ <PaywallFeatures features={features} />
129
+
130
+ {/* Plans */}
131
+ <View style={styles.plans}>
132
+ {isLoadingPackages ? (
133
+ <View style={styles.loading}>
134
+ <AtomicSpinner size="md" />
135
+ {translations.processingText && (
136
+ <AtomicText
137
+ type="bodySmall"
138
+ style={[styles.loadingText, { color: tokens.colors.textSecondary }]}
139
+ >
140
+ {translations.processingText}
141
+ </AtomicText>
142
+ )}
143
+ </View>
144
+ ) : packages.length === 0 ? (
145
+ <View style={styles.loading}>
146
+ <AtomicText
147
+ type="bodyMedium"
148
+ style={{ color: tokens.colors.textSecondary, textAlign: "center" }}
149
+ >
150
+ {translations.emptyText ?? "No packages available"}
151
+ </AtomicText>
152
+ </View>
153
+ ) : (
154
+ packages.map((pkg) => {
155
+ const pid = pkg.product.identifier;
156
+ const isSelected = selectedPlanId === pid;
157
+ const isBestValue = bestValueIdentifier === pid;
158
+ const credits = creditAmounts?.[pid];
159
+
160
+ return (
161
+ <PlanCard
162
+ key={pid}
163
+ package={pkg}
164
+ selected={isSelected}
165
+ isBestValue={isBestValue}
166
+ credits={credits}
167
+ creditsLabel={creditsLabel}
168
+ onPress={() => setSelectedPlanId(pid)}
169
+ />
170
+ );
171
+ })
172
+ )}
173
+ </View>
174
+
175
+ {/* Footer - CTA and Legal */}
176
+ <PaywallFooter
177
+ selectedPlanId={selectedPlanId}
178
+ packages={packages}
179
+ isProcessing={isProcessing}
180
+ onPurchase={handlePurchase}
181
+ onRestore={handleRestore}
182
+ legalUrls={legalUrls}
183
+ translations={translations}
184
+ onLegalUrl={handleLegalUrl}
185
+ />
186
+ </ScrollView>
187
+ </View>
188
+ );
189
+ });
190
+
191
+ PaywallScreen.displayName = "PaywallScreen";
192
+
193
+ const screenStyles = StyleSheet.create({
194
+ container: {
195
+ flex: 1,
196
+ },
197
+ closeBtn: {
198
+ position: 'absolute',
199
+ top: 12,
200
+ right: 12,
201
+ width: 36,
202
+ height: 36,
203
+ borderRadius: 18,
204
+ zIndex: 1000,
205
+ justifyContent: 'center',
206
+ alignItems: 'center',
207
+ },
208
+ scrollContainer: {
209
+ flex: 1,
210
+ },
211
+ scroll: {
212
+ paddingBottom: 100,
213
+ },
214
+ });
@@ -0,0 +1,23 @@
1
+ import type { ImageSourcePropType } from "react-native";
2
+ import type { PurchasesPackage } from "react-native-purchases";
3
+ import type { SubscriptionFeature, PaywallTranslations, PaywallLegalUrls } from "../entities/types";
4
+ import type { PurchaseSource } from "../../subscription/core/SubscriptionConstants";
5
+
6
+ export interface PaywallScreenProps {
7
+ onClose: () => void;
8
+ translations: PaywallTranslations;
9
+ packages?: PurchasesPackage[];
10
+ features?: SubscriptionFeature[];
11
+ legalUrls?: PaywallLegalUrls;
12
+ bestValueIdentifier?: string;
13
+ creditAmounts?: Record<string, number>;
14
+ creditsLabel?: string;
15
+ heroImage?: ImageSourcePropType;
16
+ onPurchase?: (pkg: PurchasesPackage) => Promise<void | boolean>;
17
+ onRestore?: () => Promise<void | boolean>;
18
+ onPurchaseSuccess?: () => void;
19
+ onPurchaseError?: (error: Error | string) => void;
20
+ onAuthRequired?: () => void;
21
+ source?: PurchaseSource;
22
+ isLoadingPackages?: boolean;
23
+ }
package/src/index.ts CHANGED
@@ -61,6 +61,8 @@ export type {
61
61
  UpgradePromptConfig,
62
62
  } from "./domains/subscription/presentation/screens/SubscriptionDetailScreen.types";
63
63
  export * from "./domains/paywall/components/PaywallContainer";
64
+ export { PaywallScreen } from "./domains/paywall/components/PaywallScreen";
65
+ export type { PaywallScreenProps } from "./domains/paywall/components/PaywallScreen.types";
64
66
 
65
67
  export type {
66
68
  CreditType,