@umituz/react-native-subscription 2.37.94 → 2.37.97

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.94",
3
+ "version": "2.37.97",
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",
@@ -30,7 +30,7 @@ export const PaywallContainer: React.FC<PaywallContainerProps> = (props) => {
30
30
 
31
31
  const purchaseSource = source ?? currentSource ?? "settings";
32
32
 
33
- const { data: packages = [] } = useSubscriptionPackages();
33
+ const { data: packages = [], isLoading: isLoadingPackages } = useSubscriptionPackages();
34
34
 
35
35
  const { handlePurchase: performPurchase, handleRestore: performRestore } = useAuthAwarePurchase({
36
36
  source: purchaseSource
@@ -68,6 +68,7 @@ export const PaywallContainer: React.FC<PaywallContainerProps> = (props) => {
68
68
  onPurchaseError={onPurchaseError}
69
69
  onAuthRequired={onAuthRequired}
70
70
  source={purchaseSource}
71
+ isLoadingPackages={isLoadingPackages}
71
72
  />
72
73
  );
73
74
  };
@@ -1,5 +1,6 @@
1
1
  import { StyleSheet } from "react-native";
2
2
 
3
+
3
4
  export const paywallModalStyles = StyleSheet.create({
4
5
  modalContent: { padding: 0, borderWidth: 0, overflow: "hidden" },
5
6
  container: { flex: 1 },
@@ -34,6 +35,7 @@ export const paywallModalStyles = StyleSheet.create({
34
35
  loading: { alignItems: "center", paddingVertical: 24 },
35
36
  loadingText: { marginTop: 8 },
36
37
  plans: { marginBottom: 12 },
38
+ stickyFooter: { paddingHorizontal: 16, paddingTop: 12, borderTopWidth: StyleSheet.hairlineWidth, borderTopColor: "rgba(128,128,128,0.2)" },
37
39
  cta: { borderRadius: 12, paddingVertical: 14, alignItems: "center", marginBottom: 12 },
38
40
  ctaDisabled: { opacity: 0.5 },
39
41
  ctaText: { fontWeight: "700" },
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback, useEffect } from "react";
2
2
  import { View, TouchableOpacity, Linking } from "react-native";
3
- import { AtomicText, AtomicIcon } from "@umituz/react-native-design-system/atoms";
3
+ import { AtomicText, AtomicIcon, AtomicSpinner } from "@umituz/react-native-design-system/atoms";
4
4
  import { BaseModal } from "@umituz/react-native-design-system/molecules";
5
5
  import { useSafeAreaInsets } from "@umituz/react-native-design-system/safe-area";
6
6
  import { useAppDesignTokens } from "@umituz/react-native-design-system/theme";
@@ -14,7 +14,7 @@ import { usePaywallActions } from "../hooks/usePaywallActions";
14
14
  import { PaywallModalProps } from "./PaywallModal.types";
15
15
 
16
16
  export const PaywallModal: React.FC<PaywallModalProps> = React.memo((props) => {
17
- const { visible, onClose, translations, packages = [], features = [], legalUrls = {}, bestValueIdentifier, creditAmounts, creditsLabel, heroImage, onPurchase, onRestore, onPurchaseSuccess, onPurchaseError, onAuthRequired, source } = props;
17
+ const { visible, onClose, translations, packages = [], features = [], legalUrls = {}, bestValueIdentifier, creditAmounts, creditsLabel, heroImage, onPurchase, onRestore, onPurchaseSuccess, onPurchaseError, onAuthRequired, source, isLoadingPackages } = props;
18
18
  const tokens = useAppDesignTokens();
19
19
  const insets = useSafeAreaInsets();
20
20
  const { selectedPlanId, setSelectedPlanId, isProcessing, handlePurchase, handleRestore, resetState } = usePaywallActions({
@@ -32,6 +32,13 @@ export const PaywallModal: React.FC<PaywallModalProps> = React.memo((props) => {
32
32
  if (!visible) resetState();
33
33
  }, [visible, resetState]);
34
34
 
35
+ // Auto-select first package when packages load and none is selected
36
+ useEffect(() => {
37
+ if (packages.length > 0 && !selectedPlanId) {
38
+ setSelectedPlanId(packages[0].product.identifier);
39
+ }
40
+ }, [packages, selectedPlanId, setSelectedPlanId]);
41
+
35
42
  const handleLegalUrl = useCallback(async (url: string | undefined) => {
36
43
  if (!url) return;
37
44
  try {
@@ -48,26 +55,41 @@ export const PaywallModal: React.FC<PaywallModalProps> = React.memo((props) => {
48
55
  <TouchableOpacity onPress={onClose} style={[styles.closeBtn, { backgroundColor: tokens.colors.surfaceSecondary, top: Math.max(insets.top, 12) }]} hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}>
49
56
  <AtomicIcon name="close-outline" size="md" customColor={tokens.colors.textPrimary} />
50
57
  </TouchableOpacity>
51
- <ScreenLayout scrollable={true} edges={["bottom"]} backgroundColor="transparent" contentContainerStyle={styles.scroll}>
58
+
59
+ {/* Scrollable content — plan cards scroll, CTA is always pinned below */}
60
+ <ScreenLayout scrollable={true} edges={[]} backgroundColor="transparent" contentContainerStyle={styles.scroll}>
52
61
  {heroImage && <View style={styles.heroContainer}><Image source={heroImage} style={styles.heroImage} contentFit="cover" transition={0} /></View>}
53
62
  <View style={styles.header}>
54
- <AtomicText type="headlineMedium" style={[styles.title, { color: tokens.colors.textPrimary }]}>{translations.title}</AtomicText>
55
- {translations.subtitle && <AtomicText type="bodyMedium" style={[styles.subtitle, { color: tokens.colors.textSecondary }]}>{translations.subtitle}</AtomicText>}
63
+ <AtomicText type="headlineMedium" adjustsFontSizeToFit numberOfLines={2} minimumFontScale={0.75} style={[styles.title, { color: tokens.colors.textPrimary }]}>{translations.title}</AtomicText>
64
+ {translations.subtitle && <AtomicText type="bodyMedium" adjustsFontSizeToFit numberOfLines={3} minimumFontScale={0.8} style={[styles.subtitle, { color: tokens.colors.textSecondary }]}>{translations.subtitle}</AtomicText>}
56
65
  </View>
57
66
  <PaywallFeatures features={features} />
58
67
  <View style={styles.plans}>
59
- {packages.map((pkg) => {
60
- const pid = pkg.product.identifier;
61
- return (
62
- <PlanCard key={pid} pkg={pkg} isSelected={selectedPlanId === pid} onSelect={() => setSelectedPlanId(pid)} badge={pid === bestValueIdentifier ? translations.bestValueBadgeText : undefined} creditAmount={creditAmounts?.[pid]} creditsLabel={creditsLabel} />
63
- );
64
- })}
68
+ {isLoadingPackages ? (
69
+ <View style={styles.loading}>
70
+ <AtomicSpinner size="md" />
71
+ {translations.processingText && (
72
+ <AtomicText type="bodySmall" style={[styles.loadingText, { color: tokens.colors.textSecondary }]}>{translations.processingText}</AtomicText>
73
+ )}
74
+ </View>
75
+ ) : (
76
+ packages.map((pkg) => {
77
+ const pid = pkg.product.identifier;
78
+ return (
79
+ <PlanCard key={pid} pkg={pkg} isSelected={selectedPlanId === pid} onSelect={() => setSelectedPlanId(pid)} badge={pid === bestValueIdentifier ? translations.bestValueBadgeText : undefined} creditAmount={creditAmounts?.[pid]} creditsLabel={creditsLabel} />
80
+ );
81
+ })
82
+ )}
65
83
  </View>
66
- <TouchableOpacity onPress={handlePurchase} disabled={!selectedPlanId || isProcessing} style={[styles.cta, { backgroundColor: tokens.colors.primary }, (!selectedPlanId || isProcessing) && styles.ctaDisabled]} activeOpacity={0.8}>
84
+ </ScreenLayout>
85
+
86
+ {/* Sticky footer — always visible, never hidden behind scroll content */}
87
+ <View style={[styles.stickyFooter, { paddingBottom: Math.max(insets.bottom, 16) }]}>
88
+ <TouchableOpacity onPress={handlePurchase} disabled={isProcessing || isLoadingPackages || !selectedPlanId} style={[styles.cta, { backgroundColor: tokens.colors.primary }, (isProcessing || isLoadingPackages || !selectedPlanId) && styles.ctaDisabled]} activeOpacity={0.75}>
67
89
  <AtomicText type="titleLarge" style={[styles.ctaText, { color: tokens.colors.onPrimary }]}>{isProcessing ? translations.processingText : translations.purchaseButtonText}</AtomicText>
68
90
  </TouchableOpacity>
69
91
  <PaywallFooter translations={translations} legalUrls={legalUrls} isProcessing={isProcessing} onRestore={onRestore ? handleRestore : undefined} onLegalClick={handleLegalUrl} />
70
- </ScreenLayout>
92
+ </View>
71
93
  </View>
72
94
  </BaseModal>
73
95
  );
@@ -20,4 +20,5 @@ export interface PaywallModalProps {
20
20
  onPurchaseError?: (error: Error | string) => void;
21
21
  onAuthRequired?: () => void;
22
22
  source?: PurchaseSource;
23
+ isLoadingPackages?: boolean;
23
24
  }
@@ -28,13 +28,13 @@ export const PlanCard: React.FC<PlanCardProps> = React.memo(
28
28
  {isSelected && <AtomicIcon name="checkmark-circle-outline" customSize={12} customColor={tokens.colors.onPrimary} />}
29
29
  </View>
30
30
  <View style={styles.textSection}>
31
- <AtomicText type="titleSmall" style={{ color: tokens.colors.textPrimary, fontWeight: "600" }}>{title}</AtomicText>
31
+ <AtomicText type="titleSmall" numberOfLines={2} style={{ color: tokens.colors.textPrimary, fontWeight: "600" }}>{title}</AtomicText>
32
32
  {creditAmount != null && creditAmount > 0 && creditsLabel && (
33
33
  <AtomicText type="bodySmall" style={{ color: tokens.colors.textSecondary }}>{creditAmount} {creditsLabel}</AtomicText>
34
34
  )}
35
35
  </View>
36
36
  </View>
37
- <AtomicText type="titleMedium" style={{ color: isSelected ? tokens.colors.primary : tokens.colors.textPrimary, fontWeight: "700", fontSize: 18 }}>{price}</AtomicText>
37
+ <AtomicText type="titleMedium" numberOfLines={1} adjustsFontSizeToFit minimumFontScale={0.8} style={{ color: isSelected ? tokens.colors.primary : tokens.colors.textPrimary, fontWeight: "700", fontSize: 18, flexShrink: 0 }}>{price}</AtomicText>
38
38
  </View>
39
39
  </View>
40
40
  </TouchableOpacity>