@umituz/react-native-subscription 2.12.6 → 2.12.8

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.6",
3
+ "version": "2.12.8",
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,26 +1,15 @@
1
1
  /**
2
2
  * Paywall Modal
3
- * Mode-based paywall: subscription, credits, or hybrid
3
+ * Modern paywall with responsive design and theme support
4
4
  */
5
5
 
6
6
  import React, { useState, useCallback } from "react";
7
- import { View, ScrollView, StyleSheet, ActivityIndicator } from "react-native";
8
- import { BaseModal, useAppDesignTokens, AtomicText } from "@umituz/react-native-design-system";
7
+ import { View, ScrollView, StyleSheet, TouchableOpacity, ActivityIndicator } from "react-native";
8
+ import { BaseModal, useAppDesignTokens, AtomicText, AtomicIcon } from "@umituz/react-native-design-system";
9
9
  import type { PurchasesPackage } from "react-native-purchases";
10
- import { PaywallHeader } from "./PaywallHeader";
11
- import { PaywallTabBar } from "./PaywallTabBar";
12
- import { PaywallFooter } from "./PaywallFooter";
13
- import { FeatureList } from "./FeatureList";
14
10
  import { PlanCard } from "./PlanCard";
15
11
  import { CreditCard } from "./CreditCard";
16
- import type {
17
- PaywallMode,
18
- PaywallTabType,
19
- CreditsPackage,
20
- SubscriptionFeature,
21
- PaywallTranslations,
22
- PaywallLegalUrls,
23
- } from "../entities";
12
+ import type { PaywallMode, CreditsPackage, SubscriptionFeature, PaywallTranslations, PaywallLegalUrls } from "../entities";
24
13
 
25
14
  export interface PaywallModalProps {
26
15
  visible: boolean;
@@ -60,15 +49,12 @@ export const PaywallModal: React.FC<PaywallModalProps> = React.memo((props) => {
60
49
  } = props;
61
50
 
62
51
  const tokens = useAppDesignTokens();
63
- const initialTab: PaywallTabType = mode === "credits" ? "credits" : "subscription";
64
- const [activeTab, setActiveTab] = useState<PaywallTabType>(initialTab);
65
52
  const [selectedPlanId, setSelectedPlanId] = useState<string | null>(null);
66
53
  const [selectedCreditId, setSelectedCreditId] = useState<string | null>(null);
67
54
  const [isProcessing, setIsProcessing] = useState(false);
68
55
 
69
- const showTabs = mode === "hybrid";
70
- const showCredits = mode === "credits" || (mode === "hybrid" && activeTab === "credits");
71
- const showSubscription = mode === "subscription" || (mode === "hybrid" && activeTab === "subscription");
56
+ const showCredits = mode === "credits";
57
+ const showSubscription = mode === "subscription" || mode === "hybrid";
72
58
 
73
59
  const handlePurchase = useCallback(async () => {
74
60
  setIsProcessing(true);
@@ -85,44 +71,64 @@ export const PaywallModal: React.FC<PaywallModalProps> = React.memo((props) => {
85
71
  }, [showSubscription, showCredits, selectedPlanId, selectedCreditId, subscriptionPackages, onSubscriptionPurchase, onCreditsPurchase]);
86
72
 
87
73
  const handleRestore = useCallback(async () => {
88
- if (onRestore) {
89
- setIsProcessing(true);
90
- try {
91
- await onRestore();
92
- } finally {
93
- setIsProcessing(false);
94
- }
74
+ if (!onRestore || isProcessing) return;
75
+ setIsProcessing(true);
76
+ try {
77
+ await onRestore();
78
+ } finally {
79
+ setIsProcessing(false);
95
80
  }
96
- }, [onRestore]);
81
+ }, [onRestore, isProcessing]);
97
82
 
98
83
  const isPurchaseDisabled = showSubscription ? !selectedPlanId : !selectedCreditId;
99
84
 
100
85
  return (
101
- <BaseModal visible={visible} onClose={onClose}>
102
- <View style={styles.container}>
103
- <PaywallHeader title={translations.title} subtitle={translations.subtitle} onClose={onClose} />
104
-
105
- {showTabs && (
106
- <PaywallTabBar
107
- activeTab={activeTab}
108
- onTabChange={setActiveTab}
109
- creditsLabel={translations.creditsTabLabel ?? "Credits"}
110
- subscriptionLabel={translations.subscriptionTabLabel ?? "Subscription"}
111
- />
112
- )}
113
-
114
- <ScrollView style={styles.scroll} contentContainerStyle={styles.scrollContent} showsVerticalScrollIndicator={false}>
115
- <FeatureList features={features} />
86
+ <BaseModal visible={visible} onClose={onClose} contentStyle={styles.modalContent}>
87
+ <View style={[styles.container, { backgroundColor: tokens.colors.surface }]}>
88
+ <TouchableOpacity
89
+ onPress={onClose}
90
+ style={[styles.closeBtn, { backgroundColor: tokens.colors.surfaceSecondary }]}
91
+ hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
92
+ >
93
+ <AtomicIcon name="close-outline" size="md" customColor={tokens.colors.textPrimary} />
94
+ </TouchableOpacity>
95
+
96
+ <ScrollView showsVerticalScrollIndicator={false} contentContainerStyle={styles.scroll}>
97
+ <View style={styles.header}>
98
+ <AtomicText type="headlineLarge" style={[styles.title, { color: tokens.colors.textPrimary }]}>
99
+ {translations.title}
100
+ </AtomicText>
101
+ {translations.subtitle && (
102
+ <AtomicText type="bodyLarge" style={[styles.subtitle, { color: tokens.colors.textSecondary }]}>
103
+ {translations.subtitle}
104
+ </AtomicText>
105
+ )}
106
+ </View>
107
+
108
+ {features.length > 0 && (
109
+ <View style={[styles.features, { backgroundColor: tokens.colors.surfaceSecondary }]}>
110
+ {features.map((feature, idx) => (
111
+ <View key={idx} style={styles.featureRow}>
112
+ <View style={[styles.featureIcon, { backgroundColor: tokens.colors.primaryLight }]}>
113
+ <AtomicIcon name={feature.icon} customSize={20} customColor={tokens.colors.primary} />
114
+ </View>
115
+ <AtomicText type="bodyLarge" style={[styles.featureText, { color: tokens.colors.textPrimary }]}>
116
+ {feature.text}
117
+ </AtomicText>
118
+ </View>
119
+ ))}
120
+ </View>
121
+ )}
116
122
 
117
123
  {isLoading ? (
118
- <View style={styles.loadingContainer}>
124
+ <View style={styles.loading}>
119
125
  <ActivityIndicator color={tokens.colors.primary} />
120
- <AtomicText type="bodyMedium" style={{ color: tokens.colors.textSecondary, marginTop: 12 }}>
126
+ <AtomicText type="bodyMedium" style={[styles.loadingText, { color: tokens.colors.textSecondary }]}>
121
127
  {translations.loadingText}
122
128
  </AtomicText>
123
129
  </View>
124
130
  ) : (
125
- <>
131
+ <View style={styles.plans}>
126
132
  {showSubscription &&
127
133
  subscriptionPackages.map((pkg) => (
128
134
  <PlanCard
@@ -135,33 +141,48 @@ export const PaywallModal: React.FC<PaywallModalProps> = React.memo((props) => {
135
141
  creditsLabel={creditsLabel}
136
142
  />
137
143
  ))}
138
-
139
144
  {showCredits &&
140
145
  creditsPackages.map((pkg) => (
141
- <CreditCard
142
- key={pkg.id}
143
- pkg={pkg}
144
- isSelected={selectedCreditId === pkg.id}
145
- onSelect={() => setSelectedCreditId(pkg.id)}
146
- />
146
+ <CreditCard key={pkg.id} pkg={pkg} isSelected={selectedCreditId === pkg.id} onSelect={() => setSelectedCreditId(pkg.id)} />
147
147
  ))}
148
- </>
148
+ </View>
149
149
  )}
150
- </ScrollView>
151
150
 
152
- <PaywallFooter
153
- isProcessing={isProcessing}
154
- isDisabled={isPurchaseDisabled}
155
- purchaseButtonText={showSubscription ? (translations.subscribeButtonText ?? translations.purchaseButtonText) : translations.purchaseButtonText}
156
- processingText={translations.processingText}
157
- restoreButtonText={translations.restoreButtonText}
158
- privacyText={translations.privacyText}
159
- termsText={translations.termsOfServiceText}
160
- privacyUrl={legalUrls.privacyUrl}
161
- termsUrl={legalUrls.termsUrl}
162
- onPurchase={handlePurchase}
163
- onRestore={handleRestore}
164
- />
151
+ <TouchableOpacity
152
+ onPress={handlePurchase}
153
+ disabled={isPurchaseDisabled || isProcessing}
154
+ style={[styles.cta, { backgroundColor: tokens.colors.primary }, (isPurchaseDisabled || isProcessing) && styles.ctaDisabled]}
155
+ activeOpacity={0.8}
156
+ >
157
+ <AtomicText type="titleLarge" style={[styles.ctaText, { color: tokens.colors.onPrimary }]}>
158
+ {isProcessing ? translations.processingText : showSubscription ? translations.subscribeButtonText : translations.purchaseButtonText}
159
+ </AtomicText>
160
+ </TouchableOpacity>
161
+
162
+ <View style={styles.footer}>
163
+ {legalUrls.termsUrl && (
164
+ <TouchableOpacity onPress={() => {}}>
165
+ <AtomicText type="bodySmall" style={[styles.footerLink, { color: tokens.colors.textSecondary }]}>
166
+ {translations.termsOfServiceText}
167
+ </AtomicText>
168
+ </TouchableOpacity>
169
+ )}
170
+ {onRestore && (
171
+ <TouchableOpacity onPress={handleRestore}>
172
+ <AtomicText type="bodySmall" style={[styles.footerLink, { color: tokens.colors.textSecondary }]}>
173
+ {translations.restoreButtonText}
174
+ </AtomicText>
175
+ </TouchableOpacity>
176
+ )}
177
+ {legalUrls.privacyUrl && (
178
+ <TouchableOpacity onPress={() => {}}>
179
+ <AtomicText type="bodySmall" style={[styles.footerLink, { color: tokens.colors.textSecondary }]}>
180
+ {translations.privacyText}
181
+ </AtomicText>
182
+ </TouchableOpacity>
183
+ )}
184
+ </View>
185
+ </ScrollView>
165
186
  </View>
166
187
  </BaseModal>
167
188
  );
@@ -170,18 +191,23 @@ export const PaywallModal: React.FC<PaywallModalProps> = React.memo((props) => {
170
191
  PaywallModal.displayName = "PaywallModal";
171
192
 
172
193
  const styles = StyleSheet.create({
173
- container: {
174
- flex: 1,
175
- width: "100%",
176
- },
177
- scroll: {
178
- flex: 1,
179
- },
180
- scrollContent: {
181
- paddingBottom: 20,
182
- },
183
- loadingContainer: {
184
- alignItems: "center",
185
- paddingVertical: 40,
186
- },
194
+ modalContent: { padding: 0, borderWidth: 0, overflow: "hidden" },
195
+ container: { flex: 1 },
196
+ closeBtn: { position: "absolute", top: 16, right: 16, width: 36, height: 36, borderRadius: 18, justifyContent: "center", alignItems: "center", zIndex: 10 },
197
+ scroll: { padding: 24, paddingTop: 56 },
198
+ header: { alignItems: "center", marginBottom: 24 },
199
+ title: { fontWeight: "700", textAlign: "center", marginBottom: 8 },
200
+ subtitle: { textAlign: "center", lineHeight: 24 },
201
+ features: { borderRadius: 16, padding: 16, marginBottom: 20, gap: 12 },
202
+ featureRow: { flexDirection: "row", alignItems: "center" },
203
+ featureIcon: { width: 40, height: 40, borderRadius: 20, justifyContent: "center", alignItems: "center", marginRight: 12 },
204
+ featureText: { flex: 1, fontWeight: "500" },
205
+ loading: { alignItems: "center", paddingVertical: 40 },
206
+ loadingText: { marginTop: 12 },
207
+ plans: { marginBottom: 20 },
208
+ cta: { borderRadius: 16, paddingVertical: 18, alignItems: "center", marginBottom: 16 },
209
+ ctaDisabled: { opacity: 0.5 },
210
+ ctaText: { fontWeight: "700" },
211
+ footer: { flexDirection: "row", justifyContent: "space-between", paddingHorizontal: 8 },
212
+ footerLink: {},
187
213
  });