@umituz/react-native-subscription 2.14.97 → 2.14.98

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.
Files changed (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +462 -0
  3. package/package.json +1 -3
  4. package/src/application/README.md +229 -0
  5. package/src/application/ports/README.md +103 -0
  6. package/src/domain/README.md +402 -0
  7. package/src/domain/constants/README.md +80 -0
  8. package/src/domain/entities/README.md +176 -0
  9. package/src/domain/errors/README.md +307 -0
  10. package/src/domain/value-objects/README.md +186 -0
  11. package/src/domains/config/README.md +390 -0
  12. package/src/domains/paywall/README.md +371 -0
  13. package/src/domains/paywall/components/PaywallHeader.tsx +8 -11
  14. package/src/domains/paywall/components/README.md +185 -0
  15. package/src/domains/paywall/entities/README.md +199 -0
  16. package/src/domains/paywall/hooks/README.md +129 -0
  17. package/src/domains/wallet/README.md +292 -0
  18. package/src/domains/wallet/domain/README.md +108 -0
  19. package/src/domains/wallet/domain/entities/README.md +122 -0
  20. package/src/domains/wallet/domain/errors/README.md +157 -0
  21. package/src/domains/wallet/infrastructure/README.md +96 -0
  22. package/src/domains/wallet/presentation/components/BalanceCard.tsx +6 -12
  23. package/src/domains/wallet/presentation/components/README.md +231 -0
  24. package/src/domains/wallet/presentation/hooks/README.md +255 -0
  25. package/src/infrastructure/README.md +514 -0
  26. package/src/infrastructure/mappers/README.md +34 -0
  27. package/src/infrastructure/models/README.md +26 -0
  28. package/src/infrastructure/repositories/README.md +385 -0
  29. package/src/infrastructure/services/README.md +374 -0
  30. package/src/presentation/README.md +410 -0
  31. package/src/presentation/components/README.md +183 -0
  32. package/src/presentation/components/details/CreditRow.md +337 -0
  33. package/src/presentation/components/details/DetailRow.md +283 -0
  34. package/src/presentation/components/details/PremiumDetailsCard.md +266 -0
  35. package/src/presentation/components/details/PremiumStatusBadge.md +266 -0
  36. package/src/presentation/components/details/README.md +449 -0
  37. package/src/presentation/components/feedback/PaywallFeedbackModal.md +314 -0
  38. package/src/presentation/components/feedback/README.md +447 -0
  39. package/src/presentation/components/paywall/PaywallModal.md +444 -0
  40. package/src/presentation/components/paywall/README.md +190 -0
  41. package/src/presentation/components/sections/README.md +468 -0
  42. package/src/presentation/components/sections/SubscriptionSection.md +246 -0
  43. package/src/presentation/hooks/README.md +743 -0
  44. package/src/presentation/hooks/useAuthAwarePurchase.md +359 -0
  45. package/src/presentation/hooks/useAuthGate.md +403 -0
  46. package/src/presentation/hooks/useAuthSubscriptionSync.md +398 -0
  47. package/src/presentation/hooks/useCreditChecker.md +407 -0
  48. package/src/presentation/hooks/useCredits.md +342 -0
  49. package/src/presentation/hooks/useCreditsGate.md +346 -0
  50. package/src/presentation/hooks/useDeductCredit.md +160 -0
  51. package/src/presentation/hooks/useDevTestCallbacks.md +422 -0
  52. package/src/presentation/hooks/useFeatureGate.md +157 -0
  53. package/src/presentation/hooks/useInitializeCredits.md +458 -0
  54. package/src/presentation/hooks/usePaywall.md +334 -0
  55. package/src/presentation/hooks/usePaywallOperations.md +486 -0
  56. package/src/presentation/hooks/usePaywallVisibility.md +344 -0
  57. package/src/presentation/hooks/usePremium.md +230 -0
  58. package/src/presentation/hooks/usePremiumGate.md +423 -0
  59. package/src/presentation/hooks/usePremiumWithCredits.md +429 -0
  60. package/src/presentation/hooks/useSubscription.md +450 -0
  61. package/src/presentation/hooks/useSubscriptionDetails.md +438 -0
  62. package/src/presentation/hooks/useSubscriptionGate.md +168 -0
  63. package/src/presentation/hooks/useSubscriptionSettingsConfig.md +374 -0
  64. package/src/presentation/hooks/useSubscriptionStatus.md +424 -0
  65. package/src/presentation/hooks/useUserTier.md +356 -0
  66. package/src/presentation/hooks/useUserTierWithRepository.md +452 -0
  67. package/src/presentation/screens/README.md +194 -0
  68. package/src/presentation/types/README.md +38 -0
  69. package/src/presentation/utils/README.md +52 -0
  70. package/src/revenuecat/README.md +523 -0
  71. package/src/revenuecat/domain/README.md +147 -0
  72. package/src/revenuecat/domain/errors/README.md +197 -0
  73. package/src/revenuecat/infrastructure/config/README.md +40 -0
  74. package/src/revenuecat/infrastructure/managers/README.md +49 -0
  75. package/src/revenuecat/presentation/hooks/README.md +56 -0
  76. package/src/utils/README.md +529 -0
@@ -0,0 +1,374 @@
1
+ # useSubscriptionSettingsConfig Hook
2
+
3
+ Returns ready-to-use configuration for subscription settings screens.
4
+
5
+ ## Import
6
+
7
+ ```typescript
8
+ import {
9
+ useSubscriptionSettingsConfig,
10
+ type SubscriptionSettingsConfig
11
+ } from '@umituz/react-native-subscription';
12
+ ```
13
+
14
+ ## Signature
15
+
16
+ ```typescript
17
+ function useSubscriptionSettingsConfig(
18
+ params: UseSubscriptionSettingsConfigParams
19
+ ): SubscriptionSettingsConfig
20
+
21
+ interface UseSubscriptionSettingsConfigParams {
22
+ userId: string | undefined;
23
+ translations: SubscriptionSettingsTranslations;
24
+ creditLimit?: number;
25
+ upgradePrompt?: UpgradePromptConfig;
26
+ }
27
+
28
+ interface SubscriptionSettingsConfig {
29
+ enabled: boolean;
30
+ settingsItem: SettingsItemConfig;
31
+ sectionConfig: SectionConfig;
32
+ }
33
+ ```
34
+
35
+ ## Parameters
36
+
37
+ | Parameter | Type | Default | Description |
38
+ |-----------|------|---------|-------------|
39
+ | `userId` | `string \| undefined` | **Required** | User ID |
40
+ | `translations` | `SubscriptionSettingsTranslations` | **Required** | Localized strings |
41
+ | `creditLimit` | `number` | `undefined` | Max credits to display |
42
+ | `upgradePrompt` | `UpgradePromptConfig` | `undefined` | Upgrade prompt configuration |
43
+
44
+ ## Translations
45
+
46
+ ```typescript
47
+ interface SubscriptionSettingsTranslations {
48
+ title: string; // e.g., "Subscription"
49
+ description: string; // e.g., "Manage your subscription"
50
+ statusLabel: string; // e.g., "Status"
51
+ statusActive: string; // e.g., "Active"
52
+ statusExpired: string; // e.g., "Expired"
53
+ statusFree: string; // e.g., "Free"
54
+ statusCanceled: string; // e.g., "Canceled"
55
+ expiresLabel: string; // e.g., "Expires on"
56
+ purchasedLabel: string; // e.g., "Purchased on"
57
+ lifetimeLabel: string; // e.g., "Lifetime"
58
+ creditsTitle: string; // e.g., "Credits"
59
+ remainingLabel: string; // e.g., "remaining"
60
+ manageButton: string; // e.g., "Manage Subscription"
61
+ upgradeButton: string; // e.g., "Upgrade to Premium"
62
+ }
63
+ ```
64
+
65
+ ## Basic Usage
66
+
67
+ ```typescript
68
+ function SubscriptionSettings() {
69
+ const { user } = useAuth();
70
+
71
+ const config = useSubscriptionSettingsConfig({
72
+ userId: user?.uid,
73
+ translations: {
74
+ title: 'Subscription',
75
+ description: 'Manage your subscription',
76
+ statusLabel: 'Status',
77
+ statusActive: 'Active',
78
+ statusExpired: 'Expired',
79
+ statusFree: 'Free',
80
+ statusCanceled: 'Canceled',
81
+ expiresLabel: 'Expires on',
82
+ purchasedLabel: 'Purchased on',
83
+ lifetimeLabel: 'Lifetime',
84
+ creditsTitle: 'Credits',
85
+ remainingLabel: 'remaining',
86
+ manageButton: 'Manage Subscription',
87
+ upgradeButton: 'Upgrade to Premium',
88
+ },
89
+ });
90
+
91
+ if (!config.enabled) return null;
92
+
93
+ return (
94
+ <SettingsSection>
95
+ <SettingsItem
96
+ title={config.settingsItem.title}
97
+ description={config.settingsItem.description}
98
+ onPress={config.settingsItem.onPress}
99
+ icon={config.settingsItem.icon}
100
+ />
101
+ </SettingsSection>
102
+ );
103
+ }
104
+ ```
105
+
106
+ ## Advanced Usage
107
+
108
+ ### With Custom Translations
109
+
110
+ ```typescript
111
+ function LocalizedSettings() {
112
+ const { t } = useTranslation();
113
+ const { user } = useAuth();
114
+
115
+ const config = useSubscriptionSettingsConfig({
116
+ userId: user?.uid,
117
+ translations: {
118
+ title: t('subscription.title'),
119
+ description: t('subscription.description'),
120
+ statusLabel: t('subscription.status_label'),
121
+ statusActive: t('subscription.status_active'),
122
+ statusExpired: t('subscription.status_expired'),
123
+ statusFree: t('subscription.status_free'),
124
+ statusCanceled: t('subscription.status_canceled'),
125
+ expiresLabel: t('subscription.expires_label'),
126
+ purchasedLabel: t('subscription.purchased_label'),
127
+ lifetimeLabel: t('subscription.lifetime_label'),
128
+ creditsTitle: t('subscription.credits_title'),
129
+ remainingLabel: t('subscription.remaining_label'),
130
+ manageButton: t('subscription.manage_button'),
131
+ upgradeButton: t('subscription.upgrade_button'),
132
+ },
133
+ });
134
+
135
+ return <SubscriptionConfigView config={config} />;
136
+ }
137
+ ```
138
+
139
+ ### With Credit Limit
140
+
141
+ ```typescript
142
+ function SettingsWithCreditLimit() {
143
+ const { user } = useAuth();
144
+
145
+ const config = useSubscriptionSettingsConfig({
146
+ userId: user?.uid,
147
+ translations: englishTranslations,
148
+ creditLimit: 10, // Only show up to 10 credit items
149
+ });
150
+
151
+ return (
152
+ <ScrollView>
153
+ <SubscriptionSection config={config} />
154
+ </ScrollView>
155
+ );
156
+ }
157
+ ```
158
+
159
+ ### With Upgrade Prompt
160
+
161
+ ```typescript
162
+ function SettingsWithUpgradePrompt() {
163
+ const { user } = useAuth();
164
+
165
+ const config = useSubscriptionSettingsConfig({
166
+ userId: user?.uid,
167
+ translations: englishTranslations,
168
+ upgradePrompt: {
169
+ showPrompt: true,
170
+ highlightBenefits: [
171
+ 'Unlimited access',
172
+ 'Priority support',
173
+ 'Ad-free experience',
174
+ ],
175
+ discountOffer: 'Save 50% with annual plan',
176
+ },
177
+ });
178
+
179
+ return (
180
+ <View>
181
+ <SubscriptionSection config={config} />
182
+ {!config.sectionConfig.isPremium && config.sectionConfig.upgradePrompt && (
183
+ <UpgradePromptCard prompt={config.sectionConfig.upgradePrompt} />
184
+ )}
185
+ </View>
186
+ );
187
+ }
188
+ ```
189
+
190
+ ### Complete Subscription Settings Screen
191
+
192
+ ```typescript
193
+ function SubscriptionSettingsScreen() {
194
+ const { user } = useAuth();
195
+
196
+ const config = useSubscriptionSettingsConfig({
197
+ userId: user?.uid,
198
+ translations: {
199
+ title: 'Subscription',
200
+ description: 'Manage your subscription',
201
+ statusLabel: 'Status',
202
+ statusActive: 'Active',
203
+ statusExpired: 'Expired',
204
+ statusFree: 'Free',
205
+ statusCanceled: 'Canceled',
206
+ expiresLabel: 'Expires on',
207
+ purchasedLabel: 'Purchased on',
208
+ lifetimeLabel: 'Lifetime',
209
+ creditsTitle: 'Credits',
210
+ remainingLabel: 'remaining',
211
+ manageButton: 'Manage Subscription',
212
+ upgradeButton: 'Upgrade to Premium',
213
+ },
214
+ creditLimit: 8,
215
+ upgradePrompt: {
216
+ showPrompt: true,
217
+ highlightBenefits: [
218
+ 'Unlimited access to all features',
219
+ 'Priority customer support',
220
+ 'Ad-free experience',
221
+ ],
222
+ },
223
+ });
224
+
225
+ if (!config.enabled) return null;
226
+
227
+ const { settingsItem, sectionConfig } = config;
228
+
229
+ return (
230
+ <ScrollView style={styles.container}>
231
+ {/* Settings List Item */}
232
+ <SettingsList>
233
+ <SettingsListItem
234
+ title={settingsItem.title}
235
+ description={settingsItem.description}
236
+ icon={settingsItem.icon}
237
+ onPress={settingsItem.onPress}
238
+ badge={settingsItem.statusLabel}
239
+ />
240
+ </SettingsList>
241
+
242
+ {/* Detailed Section */}
243
+ <Card style={styles.card}>
244
+ <Card.Title>{sectionConfig.translations.title}</Card.Title>
245
+
246
+ <View style={styles.section}>
247
+ <DetailRow
248
+ label={sectionConfig.translations.statusLabel}
249
+ value={sectionConfig.statusType === 'active'
250
+ ? sectionConfig.translations.statusActive
251
+ : sectionConfig.statusType === 'expired'
252
+ ? sectionConfig.translations.statusExpired
253
+ : sectionConfig.translations.statusFree}
254
+ />
255
+
256
+ {sectionConfig.expirationDate && (
257
+ <DetailRow
258
+ label={sectionConfig.translations.expiresLabel}
259
+ value={sectionConfig.expirationDate}
260
+ />
261
+ )}
262
+
263
+ {sectionConfig.purchaseDate && (
264
+ <DetailRow
265
+ label={sectionConfig.translations.purchasedLabel}
266
+ value={sectionConfig.purchaseDate}
267
+ />
268
+ )}
269
+
270
+ {sectionConfig.isLifetime && (
271
+ <DetailRow
272
+ label=""
273
+ value={sectionConfig.translations.lifetimeLabel}
274
+ />
275
+ )}
276
+ </View>
277
+
278
+ {/* Credits Section */}
279
+ {sectionConfig.credits.length > 0 && (
280
+ <View style={styles.section}>
281
+ <Text style={styles.creditsTitle}>
282
+ {sectionConfig.translations.creditsTitle}
283
+ </Text>
284
+ {sectionConfig.credits.map((credit, index) => (
285
+ <View key={index} style={styles.creditItem}>
286
+ <Icon name="coin" size={16} />
287
+ <Text>{credit.amount}</Text>
288
+ <Text>{sectionConfig.translations.remainingLabel}</Text>
289
+ </View>
290
+ ))}
291
+ </View>
292
+ )}
293
+
294
+ {/* Actions */}
295
+ <View style={styles.actions}>
296
+ {sectionConfig.onUpgrade && !sectionConfig.isPremium && (
297
+ <Button
298
+ onPress={sectionConfig.onUpgrade}
299
+ title={sectionConfig.translations.upgradeButton}
300
+ />
301
+ )}
302
+
303
+ {sectionConfig.isPremium && (
304
+ <Button
305
+ onPress={() => Linking.openURL('https://apps.apple.com/account/subscriptions')}
306
+ title={sectionConfig.translations.manageButton}
307
+ variant="outline"
308
+ />
309
+ )}
310
+ </View>
311
+ </Card>
312
+ </ScrollView>
313
+ );
314
+ }
315
+ ```
316
+
317
+ ## Configuration Object
318
+
319
+ ### settingsItem
320
+
321
+ Quick access item for settings list:
322
+
323
+ ```typescript
324
+ interface SettingsItemConfig {
325
+ title: string; // "Subscription"
326
+ description: string; // "Manage your subscription"
327
+ isPremium: boolean; // Premium status
328
+ statusLabel: string; // "Active" or "Free"
329
+ icon: string; // "diamond"
330
+ onPress: () => void; // Open paywall
331
+ }
332
+ ```
333
+
334
+ ### sectionConfig
335
+
336
+ Detailed section configuration:
337
+
338
+ ```typescript
339
+ interface SectionConfig {
340
+ statusType: 'active' | 'expired' | 'free' | 'canceled';
341
+ isPremium: boolean;
342
+ expirationDate: string | null; // "January 15, 2024"
343
+ purchaseDate: string | null; // "January 15, 2023"
344
+ isLifetime: boolean;
345
+ daysRemaining: number | null; // 30
346
+ willRenew: boolean;
347
+ credits: CreditItem[];
348
+ translations: SubscriptionSettingsTranslations;
349
+ onUpgrade: () => void;
350
+ upgradePrompt?: UpgradePromptConfig;
351
+ }
352
+ ```
353
+
354
+ ## Best Practices
355
+
356
+ 1. **Provide all translations** - Ensure all strings are localized
357
+ 2. **Handle null values** - Dates may be null for lifetime subs
358
+ 3. **Use credit limit** - Limit credit items for better UX
359
+ 4. **Customize upgrade prompt** - Tailor to your app's benefits
360
+ 5. **Test all states** - Active, expired, free, lifetime
361
+ 6. **Handle navigation** - Implement onPress handlers
362
+ 7. **Format dates** - Use locale-appropriate formatting
363
+
364
+ ## Related Hooks
365
+
366
+ - **useSubscriptionStatus** - For subscription status details
367
+ - **useCredits** - For credits information
368
+ - **useSubscriptionDetails** - For package and pricing info
369
+
370
+ ## See Also
371
+
372
+ - [Settings Screen](../screens/README.md#settings)
373
+ - [Subscription Utilities](../utils/subscriptionDateUtils.md)
374
+ - [Config Types](../types/SubscriptionSettingsTypes.md)