@umituz/react-native-subscription 2.14.17 → 2.14.19

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.14.17",
3
+ "version": "2.14.19",
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",
package/src/index.ts CHANGED
@@ -172,9 +172,17 @@ export {
172
172
  type SubscriptionDetailScreenProps,
173
173
  type SubscriptionDetailConfig,
174
174
  type SubscriptionDetailTranslations,
175
+ type DevTestActions,
176
+ type DevToolsConfig,
175
177
  } from "./presentation/screens/SubscriptionDetailScreen";
176
178
 
177
- export { type DevTestActions } from "./presentation/screens/components/DevTestSection";
179
+ export type {
180
+ SubscriptionHeaderProps,
181
+ CreditsListProps,
182
+ CreditItemProps,
183
+ SubscriptionActionsProps,
184
+ DevTestSectionProps,
185
+ } from "./presentation/types/SubscriptionDetailTypes";
178
186
 
179
187
 
180
188
  // =============================================================================
@@ -63,10 +63,10 @@ export const PremiumDetailsCard: React.FC<PremiumDetailsCardProps> = ({
63
63
 
64
64
  {isPremium && (
65
65
  <View style={styles.detailsSection}>
66
- {isLifetime ? (
66
+ {isLifetime && translations.lifetimeLabel ? (
67
67
  <DetailRow
68
68
  label={translations.statusLabel}
69
- value={translations.lifetimeLabel || "Lifetime"}
69
+ value={translations.lifetimeLabel}
70
70
  />
71
71
  ) : (
72
72
  <>
@@ -3,10 +3,11 @@
3
3
  * Displays subscription status as a colored badge
4
4
  */
5
5
 
6
- import React from "react";
6
+ import React, { useMemo } from "react";
7
7
  import { View, StyleSheet } from "react-native";
8
8
  import { useAppDesignTokens, AtomicText } from "@umituz/react-native-design-system";
9
- import { SubscriptionStatusType } from '../../../domain/entities/SubscriptionStatus';
9
+ import type { SubscriptionStatusType } from "../../../domain/entities/SubscriptionStatus";
10
+
10
11
  export type { SubscriptionStatusType };
11
12
 
12
13
  export interface PremiumStatusBadgeProps {
@@ -17,9 +18,6 @@ export interface PremiumStatusBadgeProps {
17
18
  canceledLabel: string;
18
19
  }
19
20
 
20
- /**
21
- * Badge component showing subscription status
22
- */
23
21
  export const PremiumStatusBadge: React.FC<PremiumStatusBadgeProps> = ({
24
22
  status,
25
23
  activeLabel,
@@ -36,32 +34,38 @@ export const PremiumStatusBadge: React.FC<PremiumStatusBadgeProps> = ({
36
34
  canceled: canceledLabel,
37
35
  };
38
36
 
39
- const colors: Record<SubscriptionStatusType, string> = {
40
- active: tokens.colors.success,
41
- expired: tokens.colors.error,
42
- none: tokens.colors.textTertiary,
43
- canceled: tokens.colors.warning,
44
- };
37
+ const backgroundColor = useMemo(() => {
38
+ const colors: Record<SubscriptionStatusType, string> = {
39
+ active: tokens.colors.success,
40
+ expired: tokens.colors.error,
41
+ none: tokens.colors.textTertiary,
42
+ canceled: tokens.colors.warning,
43
+ };
44
+ return colors[status];
45
+ }, [status, tokens.colors]);
45
46
 
46
- const backgroundColor = colors[status];
47
- const label = labels[status];
47
+ const styles = useMemo(
48
+ () =>
49
+ StyleSheet.create({
50
+ badge: {
51
+ paddingHorizontal: tokens.spacing.sm,
52
+ paddingVertical: tokens.spacing.xs,
53
+ borderRadius: tokens.borderRadius.xs,
54
+ backgroundColor,
55
+ },
56
+ badgeText: {
57
+ fontWeight: "600",
58
+ color: tokens.colors.onPrimary,
59
+ },
60
+ }),
61
+ [tokens, backgroundColor]
62
+ );
48
63
 
49
64
  return (
50
- <View style={[styles.badge, { backgroundColor }]}>
51
- <AtomicText type="labelSmall" style={[styles.badgeText, { color: tokens.colors.onPrimary }]}>
52
- {label}
65
+ <View style={styles.badge}>
66
+ <AtomicText type="labelSmall" style={styles.badgeText}>
67
+ {labels[status]}
53
68
  </AtomicText>
54
69
  </View>
55
70
  );
56
71
  };
57
-
58
- const styles = StyleSheet.create({
59
- badge: {
60
- paddingHorizontal: 8,
61
- paddingVertical: 4,
62
- borderRadius: 4,
63
- },
64
- badgeText: {
65
- fontWeight: "600",
66
- },
67
- });
@@ -78,9 +78,6 @@ export const useSubscriptionSettingsConfig = (
78
78
  [expiresAtIso]
79
79
  );
80
80
 
81
- // Subscription press handler - always opens paywall for upgrade
82
- const handleSubscriptionPress = openPaywall;
83
-
84
81
  // Status type
85
82
  const statusType: SubscriptionStatusType = isPremium ? "active" : "none";
86
83
 
@@ -112,7 +109,7 @@ export const useSubscriptionSettingsConfig = (
112
109
  ? translations.statusActive
113
110
  : translations.statusFree,
114
111
  icon: "diamond",
115
- onPress: handleSubscriptionPress,
112
+ onPress: openPaywall,
116
113
  },
117
114
  sectionConfig: {
118
115
  statusType,
@@ -58,7 +58,7 @@ export const useSubscriptionStatus = ({
58
58
 
59
59
  return status;
60
60
  },
61
- enabled: enabled && !!userId && SubscriptionManager.isInitialized(),
61
+ enabled: enabled && !!userId && SubscriptionManager.isInitializedForUser(userId),
62
62
  staleTime: 30 * 1000,
63
63
  gcTime: 5 * 60 * 1000,
64
64
  });
@@ -10,123 +10,90 @@ import { useAppDesignTokens, ScreenLayout } from "@umituz/react-native-design-sy
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";
14
- import type { SubscriptionStatusType } from "../components/details/PremiumStatusBadge";
15
- import type { CreditInfo } from "../components/details/PremiumDetailsCard";
13
+ import { DevTestSection } from "./components/DevTestSection";
14
+ import type { SubscriptionDetailScreenProps } from "../types/SubscriptionDetailTypes";
16
15
 
17
- export interface SubscriptionDetailTranslations {
18
- title: string;
19
- statusLabel: string;
20
- statusActive: string;
21
- statusExpired: string;
22
- statusFree: string;
23
- statusCanceled: string;
24
- expiresLabel: string;
25
- purchasedLabel: string;
26
- lifetimeLabel: string;
27
- creditsTitle: string;
28
- remainingLabel: string;
29
- usageTitle?: string;
30
- manageButton: string;
31
- upgradeButton: string;
32
- creditsResetInfo?: string;
33
- }
16
+ export type {
17
+ SubscriptionDetailTranslations,
18
+ SubscriptionDetailConfig,
19
+ SubscriptionDetailScreenProps,
20
+ DevTestActions,
21
+ DevToolsConfig,
22
+ } from "../types/SubscriptionDetailTypes";
34
23
 
35
- export interface SubscriptionDetailConfig {
36
- statusType: SubscriptionStatusType;
37
- isPremium: boolean;
38
- expirationDate?: string | null;
39
- purchaseDate?: string | null;
40
- isLifetime?: boolean;
41
- daysRemaining?: number | null;
42
- willRenew?: boolean;
43
- credits?: CreditInfo[];
44
- translations: SubscriptionDetailTranslations;
45
- onManageSubscription?: () => void;
46
- onUpgrade?: () => void;
47
- devTools?: {
48
- actions: DevTestActions;
49
- title?: string;
50
- };
51
- }
24
+ export const SubscriptionDetailScreen: React.FC<SubscriptionDetailScreenProps> = ({
25
+ config,
26
+ }) => {
27
+ const tokens = useAppDesignTokens();
28
+ const showCredits = config.credits && config.credits.length > 0;
29
+ const showUpgradeButton = !config.isPremium && config.onUpgrade;
52
30
 
53
- export interface SubscriptionDetailScreenProps {
54
- config: SubscriptionDetailConfig;
55
- }
31
+ const styles = useMemo(
32
+ () =>
33
+ StyleSheet.create({
34
+ content: {
35
+ flexGrow: 1,
36
+ padding: tokens.spacing.lg,
37
+ gap: tokens.spacing.lg,
38
+ },
39
+ cardsContainer: {
40
+ gap: tokens.spacing.lg,
41
+ },
42
+ spacer: {
43
+ flex: 1,
44
+ minHeight: tokens.spacing.xl,
45
+ },
46
+ }),
47
+ [tokens]
48
+ );
56
49
 
57
- export const SubscriptionDetailScreen: React.FC<
58
- SubscriptionDetailScreenProps
59
- > = ({ config }) => {
60
- const tokens = useAppDesignTokens();
61
- const showCredits = config.credits && config.credits.length > 0;
62
- const showUpgradeButton = !config.isPremium && config.onUpgrade;
50
+ return (
51
+ <ScreenLayout
52
+ scrollable={true}
53
+ edges={["bottom"]}
54
+ backgroundColor={tokens.colors.backgroundPrimary}
55
+ contentContainerStyle={styles.content}
56
+ footer={
57
+ config.devTools ? (
58
+ <DevTestSection
59
+ actions={config.devTools.actions}
60
+ title={config.devTools.title}
61
+ />
62
+ ) : undefined
63
+ }
64
+ >
65
+ <View style={styles.cardsContainer}>
66
+ <SubscriptionHeader
67
+ statusType={config.statusType}
68
+ isPremium={config.isPremium}
69
+ isLifetime={config.isLifetime}
70
+ expirationDate={config.expirationDate}
71
+ purchaseDate={config.purchaseDate}
72
+ daysRemaining={config.daysRemaining}
73
+ translations={config.translations}
74
+ />
63
75
 
64
- const styles = useMemo(
65
- () =>
66
- StyleSheet.create({
67
- content: {
68
- flexGrow: 1,
69
- padding: tokens.spacing.lg,
70
- gap: tokens.spacing.lg,
71
- },
72
- cardsContainer: {
73
- gap: tokens.spacing.lg,
74
- },
75
- spacer: {
76
- flex: 1,
77
- minHeight: tokens.spacing.xl,
78
- },
79
- }),
80
- [tokens]
81
- );
82
-
83
- return (
84
- <ScreenLayout
85
- scrollable={true}
86
- edges={['bottom']}
87
- backgroundColor={tokens.colors.backgroundPrimary}
88
- contentContainerStyle={styles.content}
89
- footer={
90
- config.devTools ? (
91
- <DevTestSection
92
- actions={config.devTools.actions}
93
- title={config.devTools.title}
94
- />
95
- ) : undefined
76
+ {showCredits && (
77
+ <CreditsList
78
+ credits={config.credits!}
79
+ title={
80
+ config.translations.usageTitle || config.translations.creditsTitle
96
81
  }
97
- >
98
- <View style={styles.cardsContainer}>
99
- <SubscriptionHeader
100
- statusType={config.statusType}
101
- isPremium={config.isPremium}
102
- isLifetime={config.isLifetime}
103
- expirationDate={config.expirationDate}
104
- purchaseDate={config.purchaseDate}
105
- daysRemaining={config.daysRemaining}
106
- translations={config.translations}
107
- />
108
-
109
- {showCredits && (
110
- <CreditsList
111
- credits={config.credits!}
112
- title={
113
- config.translations.usageTitle || config.translations.creditsTitle
114
- }
115
- description={config.translations.creditsResetInfo}
116
- remainingLabel={config.translations.remainingLabel}
117
- />
118
- )}
119
- </View>
82
+ description={config.translations.creditsResetInfo}
83
+ remainingLabel={config.translations.remainingLabel}
84
+ />
85
+ )}
86
+ </View>
120
87
 
121
- <View style={styles.spacer} />
88
+ <View style={styles.spacer} />
122
89
 
123
- {showUpgradeButton && (
124
- <SubscriptionActions
125
- isPremium={config.isPremium}
126
- upgradeButtonLabel={config.translations.upgradeButton}
127
- onUpgrade={config.onUpgrade}
128
- />
129
- )}
130
- </ScreenLayout>
131
- );
90
+ {showUpgradeButton && (
91
+ <SubscriptionActions
92
+ isPremium={config.isPremium}
93
+ upgradeButtonLabel={config.translations.upgradeButton}
94
+ onUpgrade={config.onUpgrade}
95
+ />
96
+ )}
97
+ </ScreenLayout>
98
+ );
132
99
  };
@@ -3,98 +3,93 @@
3
3
  * Displays individual credit usage with progress bar
4
4
  */
5
5
 
6
- import React from "react";
6
+ import React, { useMemo } from "react";
7
7
  import { View, StyleSheet } from "react-native";
8
8
  import { useAppDesignTokens, AtomicText } from "@umituz/react-native-design-system";
9
-
10
- interface CreditItemProps {
11
- label: string;
12
- current: number;
13
- total: number;
14
- remainingLabel?: string;
15
- }
9
+ import type { CreditItemProps } from "../../types/SubscriptionDetailTypes";
16
10
 
17
11
  export const CreditItem: React.FC<CreditItemProps> = ({
18
- label,
19
- current,
20
- total,
21
- remainingLabel = "remaining",
12
+ label,
13
+ current,
14
+ total,
15
+ remainingLabel,
22
16
  }) => {
23
- const tokens = useAppDesignTokens();
24
- const percentage = total > 0 ? (current / total) * 100 : 0;
25
- const isLow = percentage <= 20;
26
- const isMedium = percentage > 20 && percentage <= 50;
17
+ const tokens = useAppDesignTokens();
18
+ const percentage = total > 0 ? (current / total) * 100 : 0;
19
+ const isLow = percentage <= 20;
20
+ const isMedium = percentage > 20 && percentage <= 50;
21
+
22
+ const progressColor = useMemo(() => {
23
+ if (isLow) return tokens.colors.error;
24
+ if (isMedium) return tokens.colors.warning;
25
+ return tokens.colors.success;
26
+ }, [isLow, isMedium, tokens.colors]);
27
27
 
28
- const getColor = () => {
29
- if (isLow) return tokens.colors.error;
30
- if (isMedium) return tokens.colors.warning;
31
- return tokens.colors.success;
32
- };
28
+ const styles = useMemo(
29
+ () =>
30
+ StyleSheet.create({
31
+ container: {
32
+ gap: tokens.spacing.sm,
33
+ },
34
+ header: {
35
+ flexDirection: "row",
36
+ justifyContent: "space-between",
37
+ alignItems: "center",
38
+ },
39
+ label: {
40
+ fontWeight: "500",
41
+ },
42
+ badge: {
43
+ paddingHorizontal: tokens.spacing.md,
44
+ paddingVertical: tokens.spacing.xs,
45
+ borderRadius: tokens.borderRadius.md,
46
+ backgroundColor: tokens.colors.surfaceSecondary,
47
+ },
48
+ count: {
49
+ fontWeight: "600",
50
+ },
51
+ progressBar: {
52
+ height: 8,
53
+ borderRadius: tokens.borderRadius.xs,
54
+ overflow: "hidden",
55
+ backgroundColor: tokens.colors.surfaceSecondary,
56
+ },
57
+ progressFill: {
58
+ height: "100%",
59
+ borderRadius: tokens.borderRadius.xs,
60
+ width: `${percentage}%`,
61
+ backgroundColor: progressColor,
62
+ },
63
+ }),
64
+ [tokens, percentage, progressColor]
65
+ );
33
66
 
34
- return (
35
- <View style={styles.container}>
36
- <View style={styles.header}>
37
- <AtomicText type="bodyMedium" style={[styles.label, { color: tokens.colors.textPrimary }]}>
38
- {label}
39
- </AtomicText>
40
- <View style={[styles.badge, { backgroundColor: tokens.colors.surfaceSecondary }]}>
41
- <AtomicText type="labelSmall" style={[styles.count, { color: getColor() }]}>
42
- {current} / {total}
43
- </AtomicText>
44
- </View>
45
- </View>
46
- <View
47
- style={[
48
- styles.progressBar,
49
- { backgroundColor: tokens.colors.surfaceSecondary },
50
- ]}
51
- >
52
- <View
53
- style={[
54
- styles.progressFill,
55
- {
56
- width: `${percentage}%`,
57
- backgroundColor: getColor(),
58
- },
59
- ]}
60
- />
61
- </View>
62
- <AtomicText type="bodySmall" style={[styles.remaining, { color: tokens.colors.textSecondary }]}>
63
- {current} {remainingLabel}
64
- </AtomicText>
67
+ return (
68
+ <View style={styles.container}>
69
+ <View style={styles.header}>
70
+ <AtomicText
71
+ type="bodyMedium"
72
+ style={[styles.label, { color: tokens.colors.textPrimary }]}
73
+ >
74
+ {label}
75
+ </AtomicText>
76
+ <View style={styles.badge}>
77
+ <AtomicText
78
+ type="labelSmall"
79
+ style={[styles.count, { color: progressColor }]}
80
+ >
81
+ {current} / {total}
82
+ </AtomicText>
65
83
  </View>
66
- );
84
+ </View>
85
+ <View style={styles.progressBar}>
86
+ <View style={styles.progressFill} />
87
+ </View>
88
+ {remainingLabel && (
89
+ <AtomicText type="bodySmall" style={{ color: tokens.colors.textSecondary }}>
90
+ {current} {remainingLabel}
91
+ </AtomicText>
92
+ )}
93
+ </View>
94
+ );
67
95
  };
68
-
69
- const styles = StyleSheet.create({
70
- container: {
71
- gap: 8,
72
- },
73
- header: {
74
- flexDirection: "row",
75
- justifyContent: "space-between",
76
- alignItems: "center",
77
- },
78
- label: {
79
- fontWeight: "500",
80
- },
81
- badge: {
82
- paddingHorizontal: 12,
83
- paddingVertical: 4,
84
- borderRadius: 12,
85
- },
86
- count: {
87
- fontWeight: "600",
88
- },
89
- progressBar: {
90
- height: 8,
91
- borderRadius: 4,
92
- overflow: "hidden",
93
- },
94
- progressFill: {
95
- height: "100%",
96
- borderRadius: 4,
97
- },
98
- remaining: {
99
- },
100
- });
@@ -3,69 +3,71 @@
3
3
  * Displays list of credit usages
4
4
  */
5
5
 
6
- import React from "react";
7
- import { View, Text, StyleSheet } from "react-native";
8
- import { useAppDesignTokens } from "@umituz/react-native-design-system";
6
+ import React, { useMemo } from "react";
7
+ import { View, StyleSheet } from "react-native";
8
+ import { useAppDesignTokens, AtomicText } from "@umituz/react-native-design-system";
9
9
  import { CreditItem } from "./CreditItem";
10
- import type { CreditInfo } from "../../components/details/PremiumDetailsCard";
11
-
12
- interface CreditsListProps {
13
- credits: CreditInfo[];
14
- title?: string;
15
- description?: string;
16
- remainingLabel?: string;
17
- }
10
+ import type { CreditsListProps } from "../../types/SubscriptionDetailTypes";
18
11
 
19
12
  export const CreditsList: React.FC<CreditsListProps> = ({
20
- credits,
21
- title,
22
- description,
23
- remainingLabel,
13
+ credits,
14
+ title,
15
+ description,
16
+ remainingLabel,
24
17
  }) => {
25
- const tokens = useAppDesignTokens();
18
+ const tokens = useAppDesignTokens();
26
19
 
27
- return (
28
- <View style={[styles.container, { backgroundColor: tokens.colors.surface }]}>
29
- {title && (
30
- <Text style={[styles.title, { color: tokens.colors.textPrimary }]}>
31
- {title}
32
- </Text>
33
- )}
34
- {description && (
35
- <Text style={[styles.description, { color: tokens.colors.textSecondary }]}>
36
- {description}
37
- </Text>
38
- )}
39
- <View style={styles.list}>
40
- {credits.map((credit) => (
41
- <CreditItem
42
- key={credit.id}
43
- label={credit.label}
44
- current={credit.current}
45
- total={credit.total}
46
- remainingLabel={remainingLabel}
47
- />
48
- ))}
49
- </View>
50
- </View>
51
- );
52
- };
20
+ const styles = useMemo(
21
+ () =>
22
+ StyleSheet.create({
23
+ container: {
24
+ borderRadius: tokens.borderRadius.lg,
25
+ padding: tokens.spacing.lg,
26
+ gap: tokens.spacing.lg,
27
+ backgroundColor: tokens.colors.surface,
28
+ },
29
+ title: {
30
+ fontWeight: "700",
31
+ },
32
+ description: {
33
+ marginTop: -tokens.spacing.sm,
34
+ },
35
+ list: {
36
+ gap: tokens.spacing.lg,
37
+ },
38
+ }),
39
+ [tokens]
40
+ );
53
41
 
54
- const styles = StyleSheet.create({
55
- container: {
56
- borderRadius: 16,
57
- padding: 20,
58
- gap: 16,
59
- },
60
- title: {
61
- fontSize: 18,
62
- fontWeight: "700",
63
- },
64
- description: {
65
- fontSize: 14,
66
- marginTop: -8,
67
- },
68
- list: {
69
- gap: 16,
70
- },
71
- });
42
+ return (
43
+ <View style={styles.container}>
44
+ {title && (
45
+ <AtomicText
46
+ type="titleMedium"
47
+ style={[styles.title, { color: tokens.colors.textPrimary }]}
48
+ >
49
+ {title}
50
+ </AtomicText>
51
+ )}
52
+ {description && (
53
+ <AtomicText
54
+ type="bodySmall"
55
+ style={[styles.description, { color: tokens.colors.textSecondary }]}
56
+ >
57
+ {description}
58
+ </AtomicText>
59
+ )}
60
+ <View style={styles.list}>
61
+ {credits.map((credit) => (
62
+ <CreditItem
63
+ key={credit.id}
64
+ label={credit.label}
65
+ current={credit.current}
66
+ total={credit.total}
67
+ remainingLabel={remainingLabel}
68
+ />
69
+ ))}
70
+ </View>
71
+ </View>
72
+ );
73
+ };