@umituz/react-native-subscription 2.27.15 → 2.27.17

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.27.15",
3
+ "version": "2.27.17",
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",
@@ -4,6 +4,14 @@
4
4
  * Public API for wallet functionality.
5
5
  */
6
6
 
7
+ // Config
8
+ export {
9
+ configureWallet,
10
+ getWalletConfig,
11
+ resetWalletConfig,
12
+ type WalletConfiguration,
13
+ } from "./infrastructure/config/walletConfig";
14
+
7
15
  // Types
8
16
  export type {
9
17
  TransactionReason,
@@ -114,3 +122,8 @@ export {
114
122
  type WalletScreenConfig,
115
123
  type WalletScreenTranslations,
116
124
  } from "./presentation/screens/WalletScreen";
125
+
126
+ export {
127
+ WalletScreenContainer,
128
+ type WalletScreenContainerProps,
129
+ } from "./presentation/screens/WalletScreenContainer";
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Wallet Configuration
3
+ *
4
+ * Global configuration for wallet feature.
5
+ * Set once at app init, used by WalletScreen automatically.
6
+ */
7
+
8
+ import type { WalletScreenTranslations } from "../../presentation/screens/WalletScreen";
9
+
10
+ export interface WalletConfiguration {
11
+ translations: WalletScreenTranslations;
12
+ transactionCollection: string;
13
+ useUserSubcollection: boolean;
14
+ transactionLimit: number;
15
+ balanceIconName: string;
16
+ }
17
+
18
+ const DEFAULT_CONFIG: WalletConfiguration = {
19
+ translations: {
20
+ screenTitle: "Wallet",
21
+ balanceLabel: "Your Balance",
22
+ availableCredits: "Available Credits",
23
+ title: "Transaction History",
24
+ empty: "No transactions yet",
25
+ loading: "Loading...",
26
+ purchase: "Purchase",
27
+ usage: "Usage",
28
+ refund: "Refund",
29
+ bonus: "Bonus",
30
+ subscription: "Subscription",
31
+ admin: "Admin",
32
+ reward: "Reward",
33
+ expired: "Expired",
34
+ },
35
+ transactionCollection: "credit_logs",
36
+ useUserSubcollection: true,
37
+ transactionLimit: 50,
38
+ balanceIconName: "wallet",
39
+ };
40
+
41
+ let walletConfig: WalletConfiguration = { ...DEFAULT_CONFIG };
42
+
43
+ /**
44
+ * Configure wallet settings globally
45
+ * Call this once during app initialization
46
+ */
47
+ export function configureWallet(config: Partial<WalletConfiguration>): void {
48
+ walletConfig = {
49
+ ...DEFAULT_CONFIG,
50
+ ...config,
51
+ translations: {
52
+ ...DEFAULT_CONFIG.translations,
53
+ ...config.translations,
54
+ },
55
+ };
56
+ }
57
+
58
+ /**
59
+ * Get current wallet configuration
60
+ */
61
+ export function getWalletConfig(): WalletConfiguration {
62
+ return walletConfig;
63
+ }
64
+
65
+ /**
66
+ * Reset wallet configuration to defaults
67
+ */
68
+ export function resetWalletConfig(): void {
69
+ walletConfig = { ...DEFAULT_CONFIG };
70
+ }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Wallet Screen Container
3
+ *
4
+ * Self-contained wallet screen.
5
+ * Uses global config from configureWallet() - no props needed!
6
+ *
7
+ * Usage:
8
+ * 1. Call configureWallet() during app init
9
+ * 2. Use WalletScreenContainer directly in navigation
10
+ *
11
+ * ```tsx
12
+ * // In init
13
+ * configureWallet({ translations: myTranslations });
14
+ *
15
+ * // In navigation
16
+ * <Stack.Screen name="Wallet" component={WalletScreenContainer} />
17
+ * ```
18
+ */
19
+
20
+ import React, { useMemo } from "react";
21
+ import { useNavigation } from "@react-navigation/native";
22
+ import { WalletScreen, type WalletScreenTranslations } from "./WalletScreen";
23
+ import { useWallet } from "../hooks/useWallet";
24
+ import { getWalletConfig } from "../../infrastructure/config/walletConfig";
25
+
26
+ export interface WalletScreenContainerProps {
27
+ /** Translations (overrides global config) */
28
+ translations?: WalletScreenTranslations;
29
+ /** Override onBack handler (default: navigation.goBack) */
30
+ onBack?: () => void;
31
+ /** Custom date formatter */
32
+ dateFormatter?: (timestamp: number) => string;
33
+ /** Footer component */
34
+ footer?: React.ReactNode;
35
+ }
36
+
37
+ export const WalletScreenContainer: React.FC<WalletScreenContainerProps> = ({
38
+ translations,
39
+ onBack,
40
+ dateFormatter,
41
+ footer,
42
+ }) => {
43
+ const navigation = useNavigation();
44
+ const config = getWalletConfig();
45
+
46
+ const {
47
+ balance,
48
+ balanceLoading,
49
+ transactions,
50
+ transactionsLoading,
51
+ } = useWallet({
52
+ transactionConfig: {
53
+ collectionName: config.transactionCollection,
54
+ useUserSubcollection: config.useUserSubcollection,
55
+ },
56
+ transactionLimit: config.transactionLimit,
57
+ });
58
+
59
+ const screenConfig = useMemo(
60
+ () => ({
61
+ balance,
62
+ balanceLoading,
63
+ transactions,
64
+ transactionsLoading,
65
+ translations: translations ?? config.translations,
66
+ onBack: onBack ?? (() => navigation.goBack()),
67
+ dateFormatter,
68
+ balanceIconName: config.balanceIconName,
69
+ footer,
70
+ }),
71
+ [
72
+ balance,
73
+ balanceLoading,
74
+ transactions,
75
+ transactionsLoading,
76
+ translations,
77
+ config,
78
+ onBack,
79
+ navigation,
80
+ dateFormatter,
81
+ footer,
82
+ ],
83
+ );
84
+
85
+ return <WalletScreen config={screenConfig} />;
86
+ };
87
+
88
+ export default WalletScreenContainer;