@umituz/react-native-subscription 2.14.97 → 2.14.99
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/LICENSE +21 -0
- package/README.md +461 -0
- package/package.json +1 -3
- package/src/application/README.md +229 -0
- package/src/application/ports/README.md +103 -0
- package/src/domain/README.md +402 -0
- package/src/domain/constants/README.md +80 -0
- package/src/domain/entities/README.md +176 -0
- package/src/domain/errors/README.md +307 -0
- package/src/domain/value-objects/README.md +186 -0
- package/src/domains/README.md +240 -0
- package/src/domains/config/README.md +390 -0
- package/src/domains/config/domain/README.md +390 -0
- package/src/domains/config/domain/entities/README.md +350 -0
- package/src/domains/paywall/README.md +371 -0
- package/src/domains/paywall/components/PaywallHeader.tsx +8 -11
- package/src/domains/paywall/components/README.md +185 -0
- package/src/domains/paywall/entities/README.md +199 -0
- package/src/domains/paywall/hooks/README.md +129 -0
- package/src/domains/wallet/README.md +292 -0
- package/src/domains/wallet/domain/README.md +108 -0
- package/src/domains/wallet/domain/entities/README.md +122 -0
- package/src/domains/wallet/domain/errors/README.md +157 -0
- package/src/domains/wallet/infrastructure/README.md +96 -0
- package/src/domains/wallet/presentation/components/BalanceCard.tsx +6 -12
- package/src/domains/wallet/presentation/components/README.md +231 -0
- package/src/domains/wallet/presentation/hooks/README.md +255 -0
- package/src/infrastructure/README.md +514 -0
- package/src/infrastructure/mappers/README.md +34 -0
- package/src/infrastructure/models/README.md +26 -0
- package/src/infrastructure/repositories/README.md +385 -0
- package/src/infrastructure/services/README.md +374 -0
- package/src/presentation/README.md +410 -0
- package/src/presentation/components/README.md +183 -0
- package/src/presentation/components/details/CreditRow.md +337 -0
- package/src/presentation/components/details/DetailRow.md +283 -0
- package/src/presentation/components/details/PremiumDetailsCard.md +266 -0
- package/src/presentation/components/details/PremiumStatusBadge.md +266 -0
- package/src/presentation/components/details/README.md +449 -0
- package/src/presentation/components/feedback/PaywallFeedbackModal.md +314 -0
- package/src/presentation/components/feedback/README.md +447 -0
- package/src/presentation/components/paywall/PaywallModal.md +444 -0
- package/src/presentation/components/paywall/README.md +190 -0
- package/src/presentation/components/sections/README.md +468 -0
- package/src/presentation/components/sections/SubscriptionSection.md +246 -0
- package/src/presentation/hooks/README.md +743 -0
- package/src/presentation/hooks/useAuthAwarePurchase.md +359 -0
- package/src/presentation/hooks/useAuthGate.md +403 -0
- package/src/presentation/hooks/useAuthSubscriptionSync.md +398 -0
- package/src/presentation/hooks/useCreditChecker.md +407 -0
- package/src/presentation/hooks/useCredits.md +342 -0
- package/src/presentation/hooks/useCreditsGate.md +346 -0
- package/src/presentation/hooks/useDeductCredit.md +176 -0
- package/src/presentation/hooks/useDevTestCallbacks.md +422 -0
- package/src/presentation/hooks/useFeatureGate.md +157 -0
- package/src/presentation/hooks/useInitializeCredits.md +458 -0
- package/src/presentation/hooks/usePaywall.md +334 -0
- package/src/presentation/hooks/usePaywallOperations.md +486 -0
- package/src/presentation/hooks/usePaywallVisibility.md +344 -0
- package/src/presentation/hooks/usePremium.md +230 -0
- package/src/presentation/hooks/usePremiumGate.md +423 -0
- package/src/presentation/hooks/usePremiumWithCredits.md +429 -0
- package/src/presentation/hooks/useSubscription.md +450 -0
- package/src/presentation/hooks/useSubscriptionDetails.md +438 -0
- package/src/presentation/hooks/useSubscriptionGate.md +168 -0
- package/src/presentation/hooks/useSubscriptionSettingsConfig.md +374 -0
- package/src/presentation/hooks/useSubscriptionStatus.md +424 -0
- package/src/presentation/hooks/useUserTier.md +356 -0
- package/src/presentation/hooks/useUserTierWithRepository.md +452 -0
- package/src/presentation/screens/README.md +194 -0
- package/src/presentation/types/README.md +38 -0
- package/src/presentation/utils/README.md +52 -0
- package/src/revenuecat/README.md +523 -0
- package/src/revenuecat/application/README.md +158 -0
- package/src/revenuecat/application/ports/README.md +169 -0
- package/src/revenuecat/domain/README.md +147 -0
- package/src/revenuecat/domain/constants/README.md +183 -0
- package/src/revenuecat/domain/entities/README.md +382 -0
- package/src/revenuecat/domain/errors/README.md +197 -0
- package/src/revenuecat/domain/types/README.md +373 -0
- package/src/revenuecat/domain/value-objects/README.md +441 -0
- package/src/revenuecat/infrastructure/README.md +50 -0
- package/src/revenuecat/infrastructure/config/README.md +40 -0
- package/src/revenuecat/infrastructure/handlers/README.md +218 -0
- package/src/revenuecat/infrastructure/managers/README.md +49 -0
- package/src/revenuecat/infrastructure/services/README.md +325 -0
- package/src/revenuecat/infrastructure/utils/README.md +382 -0
- package/src/revenuecat/presentation/README.md +184 -0
- package/src/revenuecat/presentation/hooks/README.md +56 -0
- package/src/utils/README.md +529 -0
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
# Sections Components
|
|
2
|
+
|
|
3
|
+
Abonelik ile ilgili section ve kart bileşenleri.
|
|
4
|
+
|
|
5
|
+
## Bileşenler
|
|
6
|
+
|
|
7
|
+
- [SubscriptionSection](#subscriptionsection) - Abonelik bölümü
|
|
8
|
+
|
|
9
|
+
## SubscriptionSection
|
|
10
|
+
|
|
11
|
+
Abonelik durumunu gösteren ve yönetim işlemlerini sağlayan section bileşeni.
|
|
12
|
+
|
|
13
|
+
### Kullanım
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { SubscriptionSection } from '@umituz/react-native-subscription';
|
|
17
|
+
|
|
18
|
+
<SubscriptionSection
|
|
19
|
+
title="Subscription"
|
|
20
|
+
subscription={{
|
|
21
|
+
type: 'premium',
|
|
22
|
+
isActive: true,
|
|
23
|
+
expirationDate: '2025-12-31T23:59:59Z',
|
|
24
|
+
productId: 'com.app.premium.annual',
|
|
25
|
+
}}
|
|
26
|
+
onPress={() => navigation.navigate('SubscriptionDetail')}
|
|
27
|
+
translations={{
|
|
28
|
+
title: 'Subscription',
|
|
29
|
+
status: 'Active',
|
|
30
|
+
manage: 'Manage Subscription',
|
|
31
|
+
upgrade: 'Upgrade to Premium',
|
|
32
|
+
expires: 'Expires on',
|
|
33
|
+
}}
|
|
34
|
+
/>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Props
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
interface SubscriptionSectionProps {
|
|
41
|
+
title?: string;
|
|
42
|
+
subscription: SubscriptionStatus | null;
|
|
43
|
+
onPress?: () => void;
|
|
44
|
+
onUpgradePress?: () => void;
|
|
45
|
+
onManagePress?: () => void;
|
|
46
|
+
style?: ViewStyle;
|
|
47
|
+
translations?: SubscriptionSectionTranslations;
|
|
48
|
+
showStatus?: boolean;
|
|
49
|
+
showExpiration?: boolean;
|
|
50
|
+
showManageButton?: boolean;
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Özellikler
|
|
55
|
+
|
|
56
|
+
- Abonelik durumunu gösterir
|
|
57
|
+
- Son kullanma tarihini görüntüler
|
|
58
|
+
- Yönetim butonu sağlar
|
|
59
|
+
- Upgrade butonu (free kullanıcılar için)
|
|
60
|
+
- Özelleştirilebilir çeviri desteği
|
|
61
|
+
- Press action ile detay sayfasına navigasyon
|
|
62
|
+
|
|
63
|
+
### Detaylı Kullanım
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import React from 'react';
|
|
67
|
+
import { View, ScrollView } from 'react-native';
|
|
68
|
+
import { SubscriptionSection } from '@umituz/react-native-subscription';
|
|
69
|
+
|
|
70
|
+
function SettingsScreen() {
|
|
71
|
+
const { subscription, isPremium } = useSubscription();
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<ScrollView>
|
|
75
|
+
{/* Abonelik Section */}
|
|
76
|
+
<SubscriptionSection
|
|
77
|
+
title="My Subscription"
|
|
78
|
+
subscription={subscription}
|
|
79
|
+
showStatus={true}
|
|
80
|
+
showExpiration={true}
|
|
81
|
+
showManageButton={isPremium}
|
|
82
|
+
onPress={() => {
|
|
83
|
+
navigation.navigate('SubscriptionDetail');
|
|
84
|
+
}}
|
|
85
|
+
onUpgradePress={() => {
|
|
86
|
+
// Paywall göster
|
|
87
|
+
showPaywall();
|
|
88
|
+
}}
|
|
89
|
+
onManagePress={() => {
|
|
90
|
+
// Subscription yönetimi (Apple/Google subscription management)
|
|
91
|
+
if (Platform.OS === 'ios') {
|
|
92
|
+
Linking.openURL('https://apps.apple.com/account/subscriptions');
|
|
93
|
+
} else {
|
|
94
|
+
Linking.openURL('https://play.google.com/store/account/subscriptions');
|
|
95
|
+
}
|
|
96
|
+
}}
|
|
97
|
+
translations={{
|
|
98
|
+
title: 'Subscription',
|
|
99
|
+
active: 'Active',
|
|
100
|
+
inactive: 'Inactive',
|
|
101
|
+
expires: 'Expires on',
|
|
102
|
+
renews: 'Renews on',
|
|
103
|
+
manage: 'Manage Subscription',
|
|
104
|
+
upgrade: 'Upgrade to Premium',
|
|
105
|
+
lifetime: 'Lifetime Access',
|
|
106
|
+
}}
|
|
107
|
+
/>
|
|
108
|
+
|
|
109
|
+
{/* Diğer settingler */}
|
|
110
|
+
{/* ... */}
|
|
111
|
+
</ScrollView>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Özelleştirme
|
|
117
|
+
|
|
118
|
+
### Custom Styling
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
import { StyleSheet } from 'react-native';
|
|
122
|
+
import { SubscriptionSection } from '@umituz/react-native-subscription';
|
|
123
|
+
|
|
124
|
+
const customStyles = StyleSheet.create({
|
|
125
|
+
container: {
|
|
126
|
+
backgroundColor: '#FF6B6B',
|
|
127
|
+
borderRadius: 12,
|
|
128
|
+
padding: 16,
|
|
129
|
+
margin: 16,
|
|
130
|
+
shadowColor: '#000',
|
|
131
|
+
shadowOffset: { width: 0, height: 2 },
|
|
132
|
+
shadowOpacity: 0.1,
|
|
133
|
+
shadowRadius: 4,
|
|
134
|
+
elevation: 3,
|
|
135
|
+
},
|
|
136
|
+
title: {
|
|
137
|
+
fontSize: 20,
|
|
138
|
+
fontWeight: 'bold',
|
|
139
|
+
color: '#FFFFFF',
|
|
140
|
+
},
|
|
141
|
+
status: {
|
|
142
|
+
fontSize: 14,
|
|
143
|
+
color: '#FFFFFF',
|
|
144
|
+
opacity: 0.9,
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
<SubscriptionSection
|
|
149
|
+
subscription={subscription}
|
|
150
|
+
onPress={handlePress}
|
|
151
|
+
style={customStyles.container}
|
|
152
|
+
titleStyle={customStyles.title}
|
|
153
|
+
statusStyle={customStyles.status}
|
|
154
|
+
/>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Custom Actions
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import { SubscriptionSection } from '@umituz/react-native-subscription';
|
|
161
|
+
|
|
162
|
+
function CustomSubscriptionSection() {
|
|
163
|
+
const { subscription } = useSubscription();
|
|
164
|
+
|
|
165
|
+
const handlePress = () => {
|
|
166
|
+
if (subscription?.isPremium) {
|
|
167
|
+
// Premium kullanıcı: Detayları göster
|
|
168
|
+
navigation.navigate('SubscriptionDetail');
|
|
169
|
+
} else {
|
|
170
|
+
// Free kullanıcı: Paywall göster
|
|
171
|
+
navigation.navigate('Paywall');
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const handleLongPress = () => {
|
|
176
|
+
// Long press ile hızlı yönetim
|
|
177
|
+
if (subscription?.isPremium) {
|
|
178
|
+
showManageOptions();
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<SubscriptionSection
|
|
184
|
+
subscription={subscription}
|
|
185
|
+
onPress={handlePress}
|
|
186
|
+
onLongPress={handleLongPress}
|
|
187
|
+
translations={{
|
|
188
|
+
title: 'My Plan',
|
|
189
|
+
status: subscription?.isActive ? 'Active' : 'Inactive',
|
|
190
|
+
manage: 'Manage',
|
|
191
|
+
upgrade: 'Upgrade',
|
|
192
|
+
}}
|
|
193
|
+
/>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Durum Bazlı Gösterim
|
|
199
|
+
|
|
200
|
+
Farklı durumlar için farklı görünümler:
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
import { SubscriptionSection } from '@umituz/react-native-subscription';
|
|
204
|
+
|
|
205
|
+
function StatusBasedSections() {
|
|
206
|
+
const { subscription } = useSubscription();
|
|
207
|
+
|
|
208
|
+
if (!subscription) {
|
|
209
|
+
// Loading state
|
|
210
|
+
return <SubscriptionSection.Loading />;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (subscription.isPremium) {
|
|
214
|
+
// Premium kullanıcı
|
|
215
|
+
return (
|
|
216
|
+
<SubscriptionSection
|
|
217
|
+
subscription={subscription}
|
|
218
|
+
showStatus={true}
|
|
219
|
+
showExpiration={true}
|
|
220
|
+
showManageButton={true}
|
|
221
|
+
onPress={() => navigation.navigate('PremiumDetail')}
|
|
222
|
+
translations={{
|
|
223
|
+
title: 'Premium Plan',
|
|
224
|
+
active: 'Active',
|
|
225
|
+
manage: 'Manage Subscription',
|
|
226
|
+
}}
|
|
227
|
+
/>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Free kullanıcı
|
|
232
|
+
return (
|
|
233
|
+
<SubscriptionSection
|
|
234
|
+
subscription={subscription}
|
|
235
|
+
showStatus={false}
|
|
236
|
+
onUpgradePress={() => navigation.navigate('Paywall')}
|
|
237
|
+
translations={{
|
|
238
|
+
title: 'Free Plan',
|
|
239
|
+
upgrade: 'Upgrade to Premium',
|
|
240
|
+
}}
|
|
241
|
+
/>
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Birden Fazla Section
|
|
247
|
+
|
|
248
|
+
Farklı abonelik türleri için:
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
import { SubscriptionSection } from '@umituz/react-native-subscription';
|
|
252
|
+
|
|
253
|
+
function MultipleSections() {
|
|
254
|
+
const { subscription } = useSubscription();
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<ScrollView>
|
|
258
|
+
{/* Ana Abonelik */}
|
|
259
|
+
<SubscriptionSection
|
|
260
|
+
title="Main Subscription"
|
|
261
|
+
subscription={subscription}
|
|
262
|
+
onPress={() => navigation.navigate('MainSubscription')}
|
|
263
|
+
/>
|
|
264
|
+
|
|
265
|
+
{/* Kredi Paketi */}
|
|
266
|
+
<SubscriptionSection
|
|
267
|
+
title="Credits Balance"
|
|
268
|
+
subscription={{
|
|
269
|
+
type: 'credits',
|
|
270
|
+
isActive: true,
|
|
271
|
+
credits: 150,
|
|
272
|
+
}}
|
|
273
|
+
onPress={() => navigation.navigate('Credits')}
|
|
274
|
+
translations={{
|
|
275
|
+
title: 'Credits',
|
|
276
|
+
status: '150 credits available',
|
|
277
|
+
}}
|
|
278
|
+
/>
|
|
279
|
+
|
|
280
|
+
{/* Lifetime Plan */}
|
|
281
|
+
{subscription?.type === 'lifetime' && (
|
|
282
|
+
<SubscriptionSection
|
|
283
|
+
title="Lifetime Access"
|
|
284
|
+
subscription={subscription}
|
|
285
|
+
showExpiration={false}
|
|
286
|
+
translations={{
|
|
287
|
+
title: 'Lifetime',
|
|
288
|
+
status: 'Owned forever',
|
|
289
|
+
}}
|
|
290
|
+
/>
|
|
291
|
+
)}
|
|
292
|
+
</ScrollView>
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Refresh Support
|
|
298
|
+
|
|
299
|
+
Pull-to-refresh desteği:
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
import React, { useState } from 'react';
|
|
303
|
+
import { ScrollView, RefreshControl } from 'react-native';
|
|
304
|
+
import { SubscriptionSection } from '@umituz/react-native-subscription';
|
|
305
|
+
|
|
306
|
+
function RefreshableSection() {
|
|
307
|
+
const { subscription, refetch, isLoading } = useSubscription();
|
|
308
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
309
|
+
|
|
310
|
+
const handleRefresh = async () => {
|
|
311
|
+
setRefreshing(true);
|
|
312
|
+
await refetch();
|
|
313
|
+
setRefreshing(false);
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
return (
|
|
317
|
+
<ScrollView
|
|
318
|
+
refreshControl={
|
|
319
|
+
<RefreshControl
|
|
320
|
+
refreshing={refreshing || isLoading}
|
|
321
|
+
onRefresh={handleRefresh}
|
|
322
|
+
/>
|
|
323
|
+
}
|
|
324
|
+
>
|
|
325
|
+
<SubscriptionSection
|
|
326
|
+
subscription={subscription}
|
|
327
|
+
onPress={() => navigation.navigate('SubscriptionDetail')}
|
|
328
|
+
/>
|
|
329
|
+
</ScrollView>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## Best Practices
|
|
335
|
+
|
|
336
|
+
1. **Clear Status**: Durumun açık ve net olduğundan emin olun
|
|
337
|
+
2. **Action Buttons**: Uygun aksiyon butonları sağlayın
|
|
338
|
+
3. **Loading States**: Yüklenme durumlarını gösterin
|
|
339
|
+
4. **Error Handling**: Hata durumlarını graceful şekilde handle edin
|
|
340
|
+
5. **Accessibility**: Accessibility özelliklerini ekleyin
|
|
341
|
+
6. **Consistent Design**: Tüm section'larda tutarlı tasarım kullanın
|
|
342
|
+
7. **Deep Links**: Yönetim sayfalarına deep link ekleyin
|
|
343
|
+
|
|
344
|
+
## Örnek: Complete Implementation
|
|
345
|
+
|
|
346
|
+
```typescript
|
|
347
|
+
import React from 'react';
|
|
348
|
+
import {
|
|
349
|
+
View,
|
|
350
|
+
StyleSheet,
|
|
351
|
+
ScrollView,
|
|
352
|
+
RefreshControl,
|
|
353
|
+
Linking,
|
|
354
|
+
Platform,
|
|
355
|
+
} from 'react-native';
|
|
356
|
+
import {
|
|
357
|
+
SubscriptionSection,
|
|
358
|
+
useSubscription,
|
|
359
|
+
} from '@umituz/react-native-subscription';
|
|
360
|
+
|
|
361
|
+
export default function SettingsScreen() {
|
|
362
|
+
const { subscription, isLoading, refetch } = useSubscription();
|
|
363
|
+
const [refreshing, setRefreshing] = React.useState(false);
|
|
364
|
+
|
|
365
|
+
const handleRefresh = async () => {
|
|
366
|
+
setRefreshing(true);
|
|
367
|
+
await refetch();
|
|
368
|
+
setRefreshing(false);
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
const handleManageSubscription = () => {
|
|
372
|
+
const url =
|
|
373
|
+
Platform.OS === 'ios'
|
|
374
|
+
? 'https://apps.apple.com/account/subscriptions'
|
|
375
|
+
: 'https://play.google.com/store/account/subscriptions';
|
|
376
|
+
|
|
377
|
+
Linking.openURL(url).catch((err) =>
|
|
378
|
+
console.error('Cannot open URL:', err)
|
|
379
|
+
);
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
return (
|
|
383
|
+
<ScrollView
|
|
384
|
+
style={styles.container}
|
|
385
|
+
refreshControl={
|
|
386
|
+
<RefreshControl refreshing={refreshing} onRefresh={handleRefresh} />
|
|
387
|
+
}
|
|
388
|
+
>
|
|
389
|
+
{/* Header */}
|
|
390
|
+
<View style={styles.header}>
|
|
391
|
+
<Text style={styles.headerTitle}>Settings</Text>
|
|
392
|
+
</View>
|
|
393
|
+
|
|
394
|
+
{/* Subscription Section */}
|
|
395
|
+
<SubscriptionSection
|
|
396
|
+
title="Subscription"
|
|
397
|
+
subscription={subscription}
|
|
398
|
+
showStatus={true}
|
|
399
|
+
showExpiration={true}
|
|
400
|
+
showManageButton={subscription?.isPremium}
|
|
401
|
+
onPress={() => navigation.navigate('SubscriptionDetail')}
|
|
402
|
+
onManagePress={handleManageSubscription}
|
|
403
|
+
onUpgradePress={() => navigation.navigate('Paywall')}
|
|
404
|
+
translations={{
|
|
405
|
+
title: 'Subscription',
|
|
406
|
+
active: 'Active',
|
|
407
|
+
inactive: 'Inactive',
|
|
408
|
+
expires: 'Expires on',
|
|
409
|
+
renews: 'Renews on',
|
|
410
|
+
manage: 'Manage Subscription',
|
|
411
|
+
upgrade: 'Upgrade to Premium',
|
|
412
|
+
lifetime: 'Lifetime Access',
|
|
413
|
+
}}
|
|
414
|
+
/>
|
|
415
|
+
|
|
416
|
+
{/* Diğer ayarlar */}
|
|
417
|
+
{/* ... */}
|
|
418
|
+
</ScrollView>
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
const styles = StyleSheet.create({
|
|
423
|
+
container: {
|
|
424
|
+
flex: 1,
|
|
425
|
+
backgroundColor: '#F5F5F5',
|
|
426
|
+
},
|
|
427
|
+
header: {
|
|
428
|
+
padding: 20,
|
|
429
|
+
backgroundColor: '#fff',
|
|
430
|
+
borderBottomWidth: 1,
|
|
431
|
+
borderBottomColor: '#E0E0E0',
|
|
432
|
+
},
|
|
433
|
+
headerTitle: {
|
|
434
|
+
fontSize: 28,
|
|
435
|
+
fontWeight: 'bold',
|
|
436
|
+
},
|
|
437
|
+
});
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
## Translations
|
|
441
|
+
|
|
442
|
+
Çoklu dil desteği:
|
|
443
|
+
|
|
444
|
+
```typescript
|
|
445
|
+
const translations = {
|
|
446
|
+
'en': {
|
|
447
|
+
title: 'Subscription',
|
|
448
|
+
active: 'Active',
|
|
449
|
+
inactive: 'Inactive',
|
|
450
|
+
expires: 'Expires on',
|
|
451
|
+
manage: 'Manage',
|
|
452
|
+
upgrade: 'Upgrade',
|
|
453
|
+
},
|
|
454
|
+
'tr': {
|
|
455
|
+
title: 'Abonelik',
|
|
456
|
+
active: 'Aktif',
|
|
457
|
+
inactive: 'Aktif değil',
|
|
458
|
+
expires: 'Son kullanma',
|
|
459
|
+
manage: 'Yönet',
|
|
460
|
+
upgrade: 'Yükselt',
|
|
461
|
+
},
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
<SubscriptionSection
|
|
465
|
+
subscription={subscription}
|
|
466
|
+
translations={translations[userLanguage]}
|
|
467
|
+
/>
|
|
468
|
+
```
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# SubscriptionSection Component
|
|
2
|
+
|
|
3
|
+
Generic section component that renders subscription/premium details in settings screens.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { SubscriptionSection } from '@umituz/react-native-subscription';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Signature
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
interface SubscriptionSectionConfig {
|
|
15
|
+
statusType: 'active' | 'expired' | 'none' | 'canceled';
|
|
16
|
+
isPremium: boolean;
|
|
17
|
+
expirationDate?: string | null;
|
|
18
|
+
purchaseDate?: string | null;
|
|
19
|
+
isLifetime?: boolean;
|
|
20
|
+
daysRemaining?: number | null;
|
|
21
|
+
credits?: CreditInfo[];
|
|
22
|
+
translations: PremiumDetailsTranslations;
|
|
23
|
+
onManageSubscription?: () => void;
|
|
24
|
+
onUpgrade?: () => void;
|
|
25
|
+
onPress?: () => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface SubscriptionSectionProps {
|
|
29
|
+
config: SubscriptionSectionConfig;
|
|
30
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Props
|
|
35
|
+
|
|
36
|
+
| Prop | Type | Default | Description |
|
|
37
|
+
|------|------|---------|-------------|
|
|
38
|
+
| `config` | `SubscriptionSectionConfig` | **Required** | Subscription configuration |
|
|
39
|
+
| `containerStyle` | `StyleProp<ViewStyle>` | `undefined` | Optional container style |
|
|
40
|
+
|
|
41
|
+
## Basic Usage
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
function SettingsScreen() {
|
|
45
|
+
const config = useSubscriptionSettingsConfig({
|
|
46
|
+
userId: user?.uid,
|
|
47
|
+
translations: englishTranslations,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<ScrollView>
|
|
52
|
+
<SubscriptionSection config={config.sectionConfig} />
|
|
53
|
+
</ScrollView>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Advanced Usage
|
|
59
|
+
|
|
60
|
+
### With Navigation
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
function SettingsScreen() {
|
|
64
|
+
const config = useSubscriptionSettingsConfig({
|
|
65
|
+
userId: user?.uid,
|
|
66
|
+
translations: englishTranslations,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<SubscriptionSection
|
|
71
|
+
config={config.sectionConfig}
|
|
72
|
+
onPress={() => navigation.navigate('SubscriptionDetails')}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### With Custom Styling
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
function StyledSettings() {
|
|
82
|
+
const config = useSubscriptionSettingsConfig({
|
|
83
|
+
userId: user?.uid,
|
|
84
|
+
translations: englishTranslations,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<SubscriptionSection
|
|
89
|
+
config={config.sectionConfig}
|
|
90
|
+
containerStyle={{
|
|
91
|
+
marginHorizontal: 16,
|
|
92
|
+
marginVertical: 8,
|
|
93
|
+
borderRadius: 12,
|
|
94
|
+
overflow: 'hidden',
|
|
95
|
+
}}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Complete Configuration
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
function CompleteSubscriptionSection() {
|
|
105
|
+
const { user } = useAuth();
|
|
106
|
+
const { isPremium } = usePremium();
|
|
107
|
+
const { credits } = useCredits();
|
|
108
|
+
|
|
109
|
+
const config = {
|
|
110
|
+
statusType: isPremium ? 'active' : 'none',
|
|
111
|
+
isPremium,
|
|
112
|
+
expirationDate: isPremium ? 'January 15, 2025' : null,
|
|
113
|
+
purchaseDate: isPremium ? 'January 15, 2024' : null,
|
|
114
|
+
isLifetime: false,
|
|
115
|
+
daysRemaining: isPremium ? 30 : null,
|
|
116
|
+
credits: [
|
|
117
|
+
{
|
|
118
|
+
id: 'monthly',
|
|
119
|
+
label: 'Monthly Credits',
|
|
120
|
+
current: credits,
|
|
121
|
+
total: 100,
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
translations: {
|
|
125
|
+
title: 'Subscription',
|
|
126
|
+
statusLabel: 'Status',
|
|
127
|
+
statusActive: 'Active',
|
|
128
|
+
statusExpired: 'Expired',
|
|
129
|
+
statusFree: 'Free',
|
|
130
|
+
statusCanceled: 'Canceled',
|
|
131
|
+
expiresLabel: 'Expires on',
|
|
132
|
+
purchasedLabel: 'Purchased on',
|
|
133
|
+
lifetimeLabel: 'Lifetime Access',
|
|
134
|
+
creditsTitle: 'Credits',
|
|
135
|
+
remainingLabel: 'remaining',
|
|
136
|
+
manageButton: 'Manage Subscription',
|
|
137
|
+
upgradeButton: 'Upgrade to Premium',
|
|
138
|
+
freeDescription: 'Upgrade to access all features',
|
|
139
|
+
},
|
|
140
|
+
onManageSubscription: () => {
|
|
141
|
+
Linking.openURL('https://apps.apple.com/account/subscriptions');
|
|
142
|
+
},
|
|
143
|
+
onUpgrade: () => {
|
|
144
|
+
navigation.navigate('Paywall');
|
|
145
|
+
},
|
|
146
|
+
onPress: () => {
|
|
147
|
+
navigation.navigate('SubscriptionDetails');
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return <SubscriptionSection config={config} />;
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Examples
|
|
156
|
+
|
|
157
|
+
### Settings Integration
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
function AppSettings() {
|
|
161
|
+
const { user } = useAuth();
|
|
162
|
+
|
|
163
|
+
const config = useSubscriptionSettingsConfig({
|
|
164
|
+
userId: user?.uid,
|
|
165
|
+
translations: {
|
|
166
|
+
title: 'Subscription',
|
|
167
|
+
description: 'Manage your subscription',
|
|
168
|
+
statusLabel: 'Status',
|
|
169
|
+
statusActive: 'Active',
|
|
170
|
+
statusExpired: 'Expired',
|
|
171
|
+
statusFree: 'Free',
|
|
172
|
+
statusCanceled: 'Canceled',
|
|
173
|
+
expiresLabel: 'Expires',
|
|
174
|
+
purchasedLabel: 'Purchased',
|
|
175
|
+
lifetimeLabel: 'Lifetime',
|
|
176
|
+
creditsTitle: 'Credits',
|
|
177
|
+
remainingLabel: 'remaining',
|
|
178
|
+
manageButton: 'Manage',
|
|
179
|
+
upgradeButton: 'Upgrade',
|
|
180
|
+
freeDescription: 'Upgrade for premium features',
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<ScrollView>
|
|
186
|
+
<Section title="Account">
|
|
187
|
+
<SettingsItem label="Email" value={user?.email} />
|
|
188
|
+
<SettingsItem label="Subscription" value={config.settingsItem.statusLabel} />
|
|
189
|
+
</Section>
|
|
190
|
+
|
|
191
|
+
<SubscriptionSection
|
|
192
|
+
config={config.sectionConfig}
|
|
193
|
+
onPress={() => navigation.navigate('SubscriptionDetails')}
|
|
194
|
+
/>
|
|
195
|
+
</ScrollView>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### With Conditional Display
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
function ConditionalSubscriptionSection() {
|
|
204
|
+
const { user } = useAuth();
|
|
205
|
+
const { isPremium } = usePremium();
|
|
206
|
+
|
|
207
|
+
const config = useSubscriptionSettingsConfig({
|
|
208
|
+
userId: user?.uid,
|
|
209
|
+
translations: englishTranslations,
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// Only show if user is authenticated
|
|
213
|
+
if (!user) return null;
|
|
214
|
+
|
|
215
|
+
return (
|
|
216
|
+
<SubscriptionSection
|
|
217
|
+
config={config.sectionConfig}
|
|
218
|
+
containerStyle={{
|
|
219
|
+
backgroundColor: isPremium ? '#FFF8E1' : '#F5F5F5',
|
|
220
|
+
}}
|
|
221
|
+
/>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Best Practices
|
|
227
|
+
|
|
228
|
+
1. **Use hook** - Get config from `useSubscriptionSettingsConfig`
|
|
229
|
+
2. **Provide translations** - Ensure all strings are localized
|
|
230
|
+
3. **Handle navigation** - Implement onPress for detail screen
|
|
231
|
+
4. **Test states** - Active, expired, free, lifetime
|
|
232
|
+
5. **Style consistently** - Match app design system
|
|
233
|
+
6. **Handle actions** - Implement manage and upgrade handlers
|
|
234
|
+
|
|
235
|
+
## Related Components
|
|
236
|
+
|
|
237
|
+
- **PremiumDetailsCard** - The card component rendered inside
|
|
238
|
+
- **PremiumStatusBadge** - Status badge component
|
|
239
|
+
- **DetailRow** - Row component for details
|
|
240
|
+
- **CreditRow** - Row component for credits
|
|
241
|
+
|
|
242
|
+
## See Also
|
|
243
|
+
|
|
244
|
+
- [useSubscriptionSettingsConfig](../../hooks/useSubscriptionSettingsConfig.md)
|
|
245
|
+
- [Settings Screen](../../screens/README.md)
|
|
246
|
+
- [Config Types](../../types/SubscriptionSettingsTypes.md)
|