@umituz/react-native-subscription 2.22.6 → 2.22.7

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.22.6",
3
+ "version": "2.22.7",
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",
@@ -129,6 +129,15 @@ export const useSubscriptionSettingsConfig = (
129
129
 
130
130
  const creditsArray = useCreditsArray(credits, dynamicCreditLimit, translations);
131
131
 
132
+ // Centralized display flags - single source of truth for UI visibility
133
+ const hasCredits = creditsArray.length > 0;
134
+ const display = useMemo(() => ({
135
+ showHeader: isPremium || hasCredits,
136
+ showCredits: hasCredits,
137
+ showUpgradePrompt: !isPremium && !hasCredits && !!upgradePrompt,
138
+ showExpirationDate: isPremium && !!expiresAtIso,
139
+ }), [isPremium, hasCredits, upgradePrompt, expiresAtIso]);
140
+
132
141
  // Build config
133
142
  const config = useMemo(
134
143
  (): SubscriptionSettingsConfig => ({
@@ -146,6 +155,7 @@ export const useSubscriptionSettingsConfig = (
146
155
  sectionConfig: {
147
156
  statusType,
148
157
  isPremium,
158
+ display,
149
159
  expirationDate: formattedExpirationDate,
150
160
  purchaseDate: formattedPurchaseDate,
151
161
  isLifetime: isPremium && !expiresAtIso,
@@ -175,6 +185,7 @@ export const useSubscriptionSettingsConfig = (
175
185
  translations,
176
186
  isPremium,
177
187
  statusType,
188
+ display,
178
189
  formattedExpirationDate,
179
190
  formattedPurchaseDate,
180
191
  expiresAtIso,
@@ -17,6 +17,7 @@ import { DevTestSection } from "./components/DevTestSection";
17
17
  import type { SubscriptionDetailScreenProps } from "../types/SubscriptionDetailTypes";
18
18
 
19
19
  export type {
20
+ SubscriptionDisplayFlags,
20
21
  SubscriptionDetailTranslations,
21
22
  SubscriptionDetailConfig,
22
23
  SubscriptionDetailScreenProps,
@@ -31,8 +32,7 @@ export const SubscriptionDetailScreen: React.FC<
31
32
  SubscriptionDetailScreenProps
32
33
  > = ({ config }) => {
33
34
  const tokens = useAppDesignTokens();
34
- const showCredits = config.credits && config.credits.length > 0;
35
- const showUpgradePrompt = !config.isPremium && config.upgradePrompt && !showCredits;
35
+ const { showHeader, showCredits, showUpgradePrompt, showExpirationDate } = config.display;
36
36
 
37
37
  const styles = useMemo(
38
38
  () =>
@@ -69,10 +69,10 @@ export const SubscriptionDetailScreen: React.FC<
69
69
  }
70
70
  >
71
71
  <View style={styles.cardsContainer}>
72
- {config.isPremium && (
72
+ {showHeader && (
73
73
  <SubscriptionHeader
74
74
  statusType={config.statusType}
75
- isPremium={config.isPremium}
75
+ showExpirationDate={showExpirationDate}
76
76
  isLifetime={config.isLifetime}
77
77
  expirationDate={config.expirationDate}
78
78
  purchaseDate={config.purchaseDate}
@@ -12,7 +12,7 @@ import type { SubscriptionHeaderProps } from "../../types/SubscriptionDetailType
12
12
 
13
13
  export const SubscriptionHeader: React.FC<SubscriptionHeaderProps> = ({
14
14
  statusType,
15
- isPremium,
15
+ showExpirationDate,
16
16
  isLifetime,
17
17
  expirationDate,
18
18
  purchaseDate,
@@ -85,41 +85,39 @@ export const SubscriptionHeader: React.FC<SubscriptionHeaderProps> = ({
85
85
  />
86
86
  </View>
87
87
 
88
- {isPremium && (
89
- <View style={styles.details}>
90
- {isLifetime ? (
91
- <DetailRow
92
- label={translations.statusLabel}
93
- value={translations.lifetimeLabel}
94
- style={styles.row}
95
- labelStyle={styles.label}
96
- valueStyle={styles.value}
97
- />
98
- ) : (
99
- <>
100
- {expirationDate && (
101
- <DetailRow
102
- label={translations.expiresLabel}
103
- value={expirationDate}
104
- highlight={showExpiring}
105
- style={styles.row}
106
- labelStyle={styles.label}
107
- valueStyle={styles.value}
108
- />
109
- )}
110
- {purchaseDate && (
111
- <DetailRow
112
- label={translations.purchasedLabel}
113
- value={purchaseDate}
114
- style={styles.row}
115
- labelStyle={styles.label}
116
- valueStyle={styles.value}
117
- />
118
- )}
119
- </>
120
- )}
121
- </View>
122
- )}
88
+ <View style={styles.details}>
89
+ {isLifetime ? (
90
+ <DetailRow
91
+ label={translations.statusLabel}
92
+ value={translations.lifetimeLabel}
93
+ style={styles.row}
94
+ labelStyle={styles.label}
95
+ valueStyle={styles.value}
96
+ />
97
+ ) : (
98
+ <>
99
+ {showExpirationDate && expirationDate && (
100
+ <DetailRow
101
+ label={translations.expiresLabel}
102
+ value={expirationDate}
103
+ highlight={showExpiring}
104
+ style={styles.row}
105
+ labelStyle={styles.label}
106
+ valueStyle={styles.value}
107
+ />
108
+ )}
109
+ {purchaseDate && (
110
+ <DetailRow
111
+ label={translations.purchasedLabel}
112
+ value={purchaseDate}
113
+ style={styles.row}
114
+ labelStyle={styles.label}
115
+ valueStyle={styles.value}
116
+ />
117
+ )}
118
+ </>
119
+ )}
120
+ </View>
123
121
  </View>
124
122
  );
125
123
  };
@@ -53,10 +53,19 @@ export interface UpgradePromptConfig {
53
53
  benefits?: UpgradeBenefit[];
54
54
  }
55
55
 
56
+ /** Display flags - centralized UI visibility control */
57
+ export interface SubscriptionDisplayFlags {
58
+ showHeader: boolean;
59
+ showCredits: boolean;
60
+ showUpgradePrompt: boolean;
61
+ showExpirationDate: boolean;
62
+ }
63
+
56
64
  /** Configuration for subscription detail screen */
57
65
  export interface SubscriptionDetailConfig {
58
66
  statusType: SubscriptionStatusType;
59
67
  isPremium: boolean;
68
+ display: SubscriptionDisplayFlags;
60
69
  expirationDate?: string | null;
61
70
  purchaseDate?: string | null;
62
71
  isLifetime?: boolean;
@@ -78,7 +87,7 @@ export interface SubscriptionDetailScreenProps {
78
87
  /** Props for subscription header component */
79
88
  export interface SubscriptionHeaderProps {
80
89
  statusType: SubscriptionStatusType;
81
- isPremium: boolean;
90
+ showExpirationDate: boolean;
82
91
  isLifetime?: boolean;
83
92
  expirationDate?: string | null;
84
93
  purchaseDate?: string | null;