@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,266 @@
|
|
|
1
|
+
# PremiumDetailsCard Component
|
|
2
|
+
|
|
3
|
+
Premium subscription details card component.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { PremiumDetailsCard } from '@umituz/react-native-subscription';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
interface PremiumDetailsCardProps {
|
|
15
|
+
status: SubscriptionStatus;
|
|
16
|
+
onUpgradePress?: () => void;
|
|
17
|
+
onManagePress?: () => void;
|
|
18
|
+
style?: ViewStyle;
|
|
19
|
+
translations?: PremiumDetailsCardTranslations;
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Props Reference
|
|
24
|
+
|
|
25
|
+
| Property | Type | Required | Description |
|
|
26
|
+
|----------|------|----------|-------------|
|
|
27
|
+
| `status` | `SubscriptionStatus` | Yes | Subscription status object |
|
|
28
|
+
| `onUpgradePress` | `() => void` | No | Callback when upgrade button pressed |
|
|
29
|
+
| `onManagePress` | `() => void` | No | Callback when manage button pressed |
|
|
30
|
+
| `style` | `ViewStyle` | No | Custom container style |
|
|
31
|
+
| `translations` | `PremiumDetailsCardTranslations` | No | Custom translations |
|
|
32
|
+
|
|
33
|
+
## Basic Usage
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
function MyScreen() {
|
|
37
|
+
const { subscription } = usePremium();
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<PremiumDetailsCard
|
|
41
|
+
status={subscription}
|
|
42
|
+
onUpgradePress={() => console.log('Upgrade')}
|
|
43
|
+
onManagePress={() => console.log('Manage')}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Examples
|
|
50
|
+
|
|
51
|
+
### With Custom Translations
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
<PremiumDetailsCard
|
|
55
|
+
status={subscription}
|
|
56
|
+
translations={{
|
|
57
|
+
title: 'Premium',
|
|
58
|
+
active: 'Aktif',
|
|
59
|
+
inactive: 'Aktif Değil',
|
|
60
|
+
expires: 'Son Kullanma',
|
|
61
|
+
renews: 'Yenileniyor',
|
|
62
|
+
manage: 'Yönet',
|
|
63
|
+
upgrade: 'Yükselt',
|
|
64
|
+
lifetime: 'Ömür Boyu',
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### With Custom Styling
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const customStyles = StyleSheet.create({
|
|
73
|
+
card: {
|
|
74
|
+
backgroundColor: '#FF6B6B',
|
|
75
|
+
borderRadius: 16,
|
|
76
|
+
padding: 20,
|
|
77
|
+
},
|
|
78
|
+
title: {
|
|
79
|
+
color: '#fff',
|
|
80
|
+
fontSize: 24,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
<PremiumDetailsCard
|
|
85
|
+
status={subscription}
|
|
86
|
+
style={customStyles.card}
|
|
87
|
+
titleStyle={customStyles.title}
|
|
88
|
+
/>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Without Buttons
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
<PremiumDetailsCard
|
|
95
|
+
status={subscription}
|
|
96
|
+
showManageButton={false}
|
|
97
|
+
showUpgradeButton={false}
|
|
98
|
+
/>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Translations Interface
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
interface PremiumDetailsCardTranslations {
|
|
105
|
+
title?: string; // 'Premium'
|
|
106
|
+
status?: string; // 'Active' or 'Inactive'
|
|
107
|
+
expires?: string; // 'Expires on'
|
|
108
|
+
renews?: string; // 'Renews on'
|
|
109
|
+
manage?: string; // 'Manage Subscription'
|
|
110
|
+
upgrade?: string; // 'Upgrade to Premium'
|
|
111
|
+
lifetime?: string; // 'Lifetime Access'
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Component Structure
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
PremiumDetailsCard
|
|
119
|
+
├── Container
|
|
120
|
+
│ ├── Header
|
|
121
|
+
│ │ ├── Title (Premium Badge)
|
|
122
|
+
│ │ └── Status (Active/Inactive)
|
|
123
|
+
│ ├── Details
|
|
124
|
+
│ │ ├── Expiration Date
|
|
125
|
+
│ │ ├── Renewal Status
|
|
126
|
+
│ │ └── Product Info
|
|
127
|
+
│ └── Footer
|
|
128
|
+
│ ├── Manage Button (if premium)
|
|
129
|
+
│ └── Upgrade Button (if free)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Styling
|
|
133
|
+
|
|
134
|
+
### Default Styles
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
const defaultStyles = StyleSheet.create({
|
|
138
|
+
container: {
|
|
139
|
+
backgroundColor: '#fff',
|
|
140
|
+
borderRadius: 12,
|
|
141
|
+
padding: 16,
|
|
142
|
+
margin: 16,
|
|
143
|
+
shadowColor: '#000',
|
|
144
|
+
shadowOffset: { width: 0, height: 2 },
|
|
145
|
+
shadowOpacity: 0.1,
|
|
146
|
+
shadowRadius: 4,
|
|
147
|
+
elevation: 3,
|
|
148
|
+
},
|
|
149
|
+
header: {
|
|
150
|
+
flexDirection: 'row',
|
|
151
|
+
alignItems: 'center',
|
|
152
|
+
marginBottom: 12,
|
|
153
|
+
},
|
|
154
|
+
title: {
|
|
155
|
+
fontSize: 20,
|
|
156
|
+
fontWeight: 'bold',
|
|
157
|
+
color: '#000',
|
|
158
|
+
},
|
|
159
|
+
badge: {
|
|
160
|
+
backgroundColor: '#FFD700',
|
|
161
|
+
paddingHorizontal: 8,
|
|
162
|
+
paddingVertical: 4,
|
|
163
|
+
borderRadius: 12,
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Theme Customization
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const darkTheme = {
|
|
172
|
+
container: {
|
|
173
|
+
backgroundColor: '#1a1a1a',
|
|
174
|
+
},
|
|
175
|
+
title: {
|
|
176
|
+
color: '#fff',
|
|
177
|
+
},
|
|
178
|
+
text: {
|
|
179
|
+
color: '#ccc',
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
<PremiumDetailsCard
|
|
184
|
+
status={subscription}
|
|
185
|
+
theme={darkTheme}
|
|
186
|
+
/>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Accessibility
|
|
190
|
+
|
|
191
|
+
The component includes:
|
|
192
|
+
|
|
193
|
+
- ✅ Accessibility label
|
|
194
|
+
- ✅ Accessibility hint
|
|
195
|
+
- ✅ Screen reader support
|
|
196
|
+
- ✅ Minimum touch target size (44x44)
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
<PremiumDetailsCard
|
|
200
|
+
status={subscription}
|
|
201
|
+
accessibilityLabel="Premium subscription details"
|
|
202
|
+
accessibilityHint="Shows your premium subscription status and options"
|
|
203
|
+
/>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Best Practices
|
|
207
|
+
|
|
208
|
+
1. **Provide callbacks** - Always handle upgrade/manage presses
|
|
209
|
+
2. **Show for premium users** - Display current subscription info
|
|
210
|
+
3. **Show for free users** - Encourage upgrade
|
|
211
|
+
4. **Update on purchase** - Refetch after subscription change
|
|
212
|
+
5. **Handle loading** - Show skeleton while loading
|
|
213
|
+
|
|
214
|
+
## Complete Example
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
function SubscriptionScreen() {
|
|
218
|
+
const { subscription, isLoading, refetch } = usePremium();
|
|
219
|
+
|
|
220
|
+
useFocusEffect(
|
|
221
|
+
useCallback(() => {
|
|
222
|
+
refetch();
|
|
223
|
+
}, [refetch])
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
if (isLoading) {
|
|
227
|
+
return <PremiumDetailsCardSkeleton />;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (!subscription?.isPremium) {
|
|
231
|
+
return (
|
|
232
|
+
<PremiumDetailsCard
|
|
233
|
+
status={{
|
|
234
|
+
type: 'free',
|
|
235
|
+
isActive: false,
|
|
236
|
+
isPremium: false,
|
|
237
|
+
}}
|
|
238
|
+
onUpgradePress={() => navigation.navigate('Paywall')}
|
|
239
|
+
/>
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return (
|
|
244
|
+
<ScrollView>
|
|
245
|
+
<PremiumDetailsCard
|
|
246
|
+
status={subscription}
|
|
247
|
+
onManagePress={handleManageSubscription}
|
|
248
|
+
/>
|
|
249
|
+
|
|
250
|
+
{/* Additional premium features */}
|
|
251
|
+
<PremiumFeaturesList />
|
|
252
|
+
</ScrollView>
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Related Components
|
|
258
|
+
|
|
259
|
+
- **PremiumStatusBadge** - Compact premium badge
|
|
260
|
+
- **SubscriptionSection** - Full subscription section
|
|
261
|
+
- **PaywallModal** - Upgrade paywall
|
|
262
|
+
|
|
263
|
+
## See Also
|
|
264
|
+
|
|
265
|
+
- [Details Components README](../details/README.md)
|
|
266
|
+
- [PremiumStatusBadge](./PremiumStatusBadge.md)
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# PremiumStatusBadge Component
|
|
2
|
+
|
|
3
|
+
Displays subscription status as a colored badge component.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { PremiumStatusBadge } from '@umituz/react-native-subscription';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Signature
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
interface PremiumStatusBadgeProps {
|
|
15
|
+
status: SubscriptionStatusType;
|
|
16
|
+
activeLabel: string;
|
|
17
|
+
expiredLabel: string;
|
|
18
|
+
noneLabel: string;
|
|
19
|
+
canceledLabel: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type SubscriptionStatusType = 'active' | 'expired' | 'none' | 'canceled';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Props
|
|
26
|
+
|
|
27
|
+
| Prop | Type | Default | Description |
|
|
28
|
+
|------|------|---------|-------------|
|
|
29
|
+
| `status` | `SubscriptionStatusType` | **Required** | Current subscription status |
|
|
30
|
+
| `activeLabel` | `string` | **Required** | Label for active status |
|
|
31
|
+
| `expiredLabel` | `string` | **Required** | Label for expired status |
|
|
32
|
+
| `noneLabel` | `string` | **Required** | Label for no subscription |
|
|
33
|
+
| `canceledLabel` | `string` | **Required** | Label for canceled status |
|
|
34
|
+
|
|
35
|
+
## Basic Usage
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
function SubscriptionStatus() {
|
|
39
|
+
const { isPremium } = usePremium();
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<PremiumStatusBadge
|
|
43
|
+
status={isPremium ? 'active' : 'none'}
|
|
44
|
+
activeLabel="Active"
|
|
45
|
+
expiredLabel="Expired"
|
|
46
|
+
noneLabel="Free"
|
|
47
|
+
canceledLabel="Canceled"
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Advanced Usage
|
|
54
|
+
|
|
55
|
+
### With Dynamic Status
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
function DynamicStatusBadge() {
|
|
59
|
+
const { status, isActive, isExpired } = useSubscriptionStatus();
|
|
60
|
+
|
|
61
|
+
const getStatusType = (): SubscriptionStatusType => {
|
|
62
|
+
if (!status) return 'none';
|
|
63
|
+
if (isExpired) return 'expired';
|
|
64
|
+
if (isActive) return 'active';
|
|
65
|
+
return 'canceled';
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<PremiumStatusBadge
|
|
70
|
+
status={getStatusType()}
|
|
71
|
+
activeLabel="Active"
|
|
72
|
+
expiredLabel="Expired"
|
|
73
|
+
noneLabel="Free"
|
|
74
|
+
canceledLabel="Canceled"
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### With Custom Labels
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
function CustomStatusBadge() {
|
|
84
|
+
const { isActive } = usePremium();
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<PremiumStatusBadge
|
|
88
|
+
status={isActive ? 'active' : 'none'}
|
|
89
|
+
activeLabel="✨ Premium"
|
|
90
|
+
expiredLabel="⚠️ Expired"
|
|
91
|
+
noneLabel="Free Tier"
|
|
92
|
+
canceledLabel="❌ Canceled"
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### With Localization
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
function LocalizedStatusBadge() {
|
|
102
|
+
const { t } = useTranslation();
|
|
103
|
+
const { status } = useSubscriptionStatus();
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<PremiumStatusBadge
|
|
107
|
+
status={status.type}
|
|
108
|
+
activeLabel={t('subscription.status.active')}
|
|
109
|
+
expiredLabel={t('subscription.status.expired')}
|
|
110
|
+
noneLabel={t('subscription.status.free')}
|
|
111
|
+
canceledLabel={t('subscription.status.canceled')}
|
|
112
|
+
/>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Badge Colors
|
|
118
|
+
|
|
119
|
+
The component automatically applies appropriate colors based on status:
|
|
120
|
+
|
|
121
|
+
| Status | Background Color | Text Color |
|
|
122
|
+
|--------|-----------------|------------|
|
|
123
|
+
| `active` | Success (green) | On-primary |
|
|
124
|
+
| `expired` | Error (red) | On-primary |
|
|
125
|
+
| `none` | Tertiary text | On-primary |
|
|
126
|
+
| `canceled` | Warning (orange) | On-primary |
|
|
127
|
+
|
|
128
|
+
## Examples
|
|
129
|
+
|
|
130
|
+
### In Header
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
function SubscriptionHeader() {
|
|
134
|
+
const { status } = useSubscriptionStatus();
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<View style={styles.header}>
|
|
138
|
+
<Text style={styles.title}>My Subscription</Text>
|
|
139
|
+
|
|
140
|
+
<PremiumStatusBadge
|
|
141
|
+
status={status.type}
|
|
142
|
+
activeLabel="Active"
|
|
143
|
+
expiredLabel="Expired"
|
|
144
|
+
noneLabel="Free"
|
|
145
|
+
canceledLabel="Canceled"
|
|
146
|
+
/>
|
|
147
|
+
</View>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### With Icon
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
function StatusWithIcon() {
|
|
156
|
+
const { isActive } = usePremium();
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<View style={styles.container}>
|
|
160
|
+
<Icon
|
|
161
|
+
name={isActive ? 'check-circle' : 'circle'}
|
|
162
|
+
size={20}
|
|
163
|
+
color={isActive ? 'green' : 'gray'}
|
|
164
|
+
/>
|
|
165
|
+
|
|
166
|
+
<PremiumStatusBadge
|
|
167
|
+
status={isActive ? 'active' : 'none'}
|
|
168
|
+
activeLabel="Active"
|
|
169
|
+
expiredLabel="Expired"
|
|
170
|
+
noneLabel="Free"
|
|
171
|
+
canceledLabel="Canceled"
|
|
172
|
+
/>
|
|
173
|
+
</View>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Status List
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
function StatusList() {
|
|
182
|
+
const statuses: SubscriptionStatusType[] = ['active', 'expired', 'none', 'canceled'];
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<View>
|
|
186
|
+
{statuses.map((status) => (
|
|
187
|
+
<View key={status} style={styles.row}>
|
|
188
|
+
<Text>{status}</Text>
|
|
189
|
+
|
|
190
|
+
<PremiumStatusBadge
|
|
191
|
+
status={status}
|
|
192
|
+
activeLabel="Active"
|
|
193
|
+
expiredLabel="Expired"
|
|
194
|
+
noneLabel="Free"
|
|
195
|
+
canceledLabel="Canceled"
|
|
196
|
+
/>
|
|
197
|
+
</View>
|
|
198
|
+
))}
|
|
199
|
+
</View>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Compact Badge
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
function CompactBadge() {
|
|
208
|
+
const { isActive } = usePremium();
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<View style={styles.compactContainer}>
|
|
212
|
+
<PremiumStatusBadge
|
|
213
|
+
status={isActive ? 'active' : 'none'}
|
|
214
|
+
activeLabel="Premium"
|
|
215
|
+
expiredLabel="Expired"
|
|
216
|
+
noneLabel="Free"
|
|
217
|
+
canceledLabel="Canceled"
|
|
218
|
+
/>
|
|
219
|
+
</View>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const styles = StyleSheet.create({
|
|
224
|
+
compactContainer: {
|
|
225
|
+
transform: [{ scale: 0.85 }], // Smaller size
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Styling
|
|
231
|
+
|
|
232
|
+
The badge uses design tokens for consistent styling:
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
// Internal styles (simplified)
|
|
236
|
+
badge: {
|
|
237
|
+
paddingHorizontal: tokens.spacing.sm,
|
|
238
|
+
paddingVertical: tokens.spacing.xs,
|
|
239
|
+
borderRadius: tokens.radius.xs,
|
|
240
|
+
backgroundColor: statusColor, // Dynamic based on status
|
|
241
|
+
},
|
|
242
|
+
badgeText: {
|
|
243
|
+
fontWeight: '600',
|
|
244
|
+
color: tokens.colors.onPrimary,
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Best Practices
|
|
249
|
+
|
|
250
|
+
1. **Provide all labels** - Ensure all four status labels are provided
|
|
251
|
+
2. **Use consistent labels** - Keep labels consistent across app
|
|
252
|
+
3. **Localize labels** - Translate labels for i18n
|
|
253
|
+
4. **Check status first** - Determine correct status type
|
|
254
|
+
5. **Handle all states** - Cover active, expired, none, canceled
|
|
255
|
+
6. **Test colors** - Verify colors work with your theme
|
|
256
|
+
|
|
257
|
+
## Related Components
|
|
258
|
+
|
|
259
|
+
- **PremiumDetailsCard** - Uses this badge component
|
|
260
|
+
- **SubscriptionSection** - Displays badge in settings
|
|
261
|
+
- **DetailRow** - Displays status as detail row
|
|
262
|
+
|
|
263
|
+
## See Also
|
|
264
|
+
|
|
265
|
+
- [SubscriptionStatus Entity](../../../domain/entities/SubscriptionStatus.md)
|
|
266
|
+
- [Status Utilities](../../../utils/subscriptionUtils.md)
|