@umituz/react-native-subscription 2.3.7 → 2.4.0

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.3.7",
3
+ "version": "2.4.0",
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,48 @@
1
+ /**
2
+ * Best Value Badge Component
3
+ * Single Responsibility: Display a "Best Value" badge for subscription packages
4
+ */
5
+
6
+ import React from "react";
7
+ import { View, StyleSheet } from "react-native";
8
+ import { AtomicText, useAppDesignTokens } from "@umituz/react-native-design-system";
9
+
10
+ interface BestValueBadgeProps {
11
+ text: string;
12
+ visible?: boolean;
13
+ }
14
+
15
+ export const BestValueBadge: React.FC<BestValueBadgeProps> = React.memo(
16
+ ({ text, visible = true }) => {
17
+ const tokens = useAppDesignTokens();
18
+
19
+ if (!visible) return null;
20
+
21
+ return (
22
+ <View
23
+ style={[styles.badge, { backgroundColor: tokens.colors.primary }]}
24
+ >
25
+ <AtomicText
26
+ type="labelSmall"
27
+ style={{ color: tokens.colors.onPrimary, fontWeight: "700" }}
28
+ >
29
+ {text}
30
+ </AtomicText>
31
+ </View>
32
+ );
33
+ }
34
+ );
35
+
36
+ BestValueBadge.displayName = "BestValueBadge";
37
+
38
+ const styles = StyleSheet.create({
39
+ badge: {
40
+ position: "absolute",
41
+ top: -12,
42
+ right: 16,
43
+ paddingHorizontal: 16,
44
+ paddingVertical: 7,
45
+ borderRadius: 16,
46
+ zIndex: 1,
47
+ },
48
+ });
@@ -10,6 +10,7 @@ import { AtomicText } from "@umituz/react-native-design-system";
10
10
  import { useAppDesignTokens } from "@umituz/react-native-design-system";
11
11
  import { formatPrice } from "../../../utils/priceUtils";
12
12
  import { useLocalization } from "@umituz/react-native-localization";
13
+ import { BestValueBadge } from "./BestValueBadge";
13
14
 
14
15
  interface SubscriptionPlanCardProps {
15
16
  package: PurchasesPackage;
@@ -63,18 +64,10 @@ export const SubscriptionPlanCard: React.FC<SubscriptionPlanCardProps> =
63
64
  },
64
65
  ]}
65
66
  >
66
- {isBestValue && (
67
- <View
68
- style={[styles.badge, { backgroundColor: tokens.colors.primary }]}
69
- >
70
- <AtomicText
71
- type="labelSmall"
72
- style={{ color: tokens.colors.onPrimary, fontWeight: "700" }}
73
- >
74
- {t("paywall.bestValue")}
75
- </AtomicText>
76
- </View>
77
- )}
67
+ <BestValueBadge
68
+ text={t("paywall.bestValue")}
69
+ visible={isBestValue}
70
+ />
78
71
 
79
72
  <View style={styles.content}>
80
73
  <View style={styles.leftSection}>
@@ -138,14 +131,6 @@ const styles = StyleSheet.create({
138
131
  padding: 18,
139
132
  position: "relative",
140
133
  },
141
- badge: {
142
- position: "absolute",
143
- top: -12,
144
- right: 16,
145
- paddingHorizontal: 16,
146
- paddingVertical: 7,
147
- borderRadius: 16,
148
- },
149
134
  content: {
150
135
  flexDirection: "row",
151
136
  justifyContent: "space-between",
@@ -38,15 +38,16 @@ export function shouldUseTestStore(config: RevenueCatConfig): boolean {
38
38
  export function resolveApiKey(config: RevenueCatConfig): string | null {
39
39
  const useTestStore = shouldUseTestStore(config);
40
40
 
41
- if (__DEV__) {
42
- console.log("[RevenueCat] resolveApiKey:", {
43
- platform: Platform.OS,
44
- useTestStore,
45
- hasTestKey: !!config.testStoreKey,
46
- hasIosKey: !!config.iosApiKey,
47
- hasAndroidKey: !!config.androidApiKey,
48
- });
49
- }
41
+ // Always log in development, log warnings in production for debugging
42
+ /* eslint-disable-next-line no-console */
43
+ console.log("[RevenueCat] resolveApiKey:", {
44
+ platform: Platform.OS,
45
+ useTestStore,
46
+ hasTestKey: !!config.testStoreKey,
47
+ hasIosKey: !!config.iosApiKey,
48
+ hasAndroidKey: !!config.androidApiKey,
49
+ isProduction: isProductionBuild(),
50
+ });
50
51
 
51
52
  if (useTestStore) {
52
53
  return config.testStoreKey ?? null;
@@ -59,9 +60,8 @@ export function resolveApiKey(config: RevenueCatConfig): string | null {
59
60
  : config.iosApiKey;
60
61
 
61
62
  if (!key || key === "" || key.includes("YOUR_")) {
62
- if (__DEV__) {
63
- console.warn("[RevenueCat] No valid API key found for platform:", Platform.OS);
64
- }
63
+ /* eslint-disable-next-line no-console */
64
+ console.warn("[RevenueCat] ⚠️ NO API KEY - packages will not load. Check env vars.");
65
65
  return null;
66
66
  }
67
67