@@ -164,105 +164,103 @@ internal sealed interface SubscriptionHeaderState {
164
164
data class SupporterRenew (
165
165
override val tier : SubscriptionTier ,
166
166
override val expiresIn : Duration ? ,
167
- ) : SubscriptionHeaderState {
168
- override val isChampion = false
169
- }
167
+ override val isChampion : Boolean ,
168
+ ) : SubscriptionHeaderState
170
169
171
170
data class SupporterCancel (
172
171
override val tier : SubscriptionTier ,
173
172
override val expiresIn : Duration ? ,
174
- ) : SubscriptionHeaderState {
175
- override val isChampion = false
176
- }
173
+ override val isChampion : Boolean ,
174
+ ) : SubscriptionHeaderState
177
175
}
178
176
179
177
@Composable
180
178
private fun SubscriptionHeaderState.labels (): Labels {
181
179
val context = LocalContext .current
182
180
return remember(this ) {
183
- when (this ) {
184
- is SubscriptionHeaderState .Free -> {
185
- Labels (
186
- start = Label (
187
- text = context.getString(LR .string.profile_free_account),
188
- ),
189
- )
190
- }
181
+ if (isChampion) {
182
+ Labels (
183
+ start = Label (
184
+ text = context.getString(LR .string.plus_thanks_for_your_support_bang),
185
+ ),
186
+ end = Label (
187
+ text = context.getString(LR .string.pocket_casts_champion),
188
+ color = { support02 },
189
+ ),
190
+ )
191
+ } else {
192
+ when (this ) {
193
+ is SubscriptionHeaderState .Free -> {
194
+ Labels (
195
+ start = Label (
196
+ text = context.getString(LR .string.profile_free_account),
197
+ ),
198
+ )
199
+ }
191
200
192
- is SubscriptionHeaderState .PaidRenew -> {
193
- val expiryDate = Date (Date ().time + expiresIn.inWholeMilliseconds)
194
- Labels (
195
- start = Label (
196
- text = context.getString(LR .string.profile_next_payment, expiryDate.toLocalizedFormatLongStyle()),
197
- ),
198
- end = Label (
199
- text = when (frequency) {
200
- SubscriptionFrequency .MONTHLY -> context.getString(LR .string.profile_monthly)
201
- SubscriptionFrequency .YEARLY -> context.getString(LR .string.profile_yearly)
202
- SubscriptionFrequency .NONE -> " "
203
- },
204
- ),
205
- )
206
- }
201
+ is SubscriptionHeaderState .PaidRenew -> {
202
+ val expiryDate = Date (Date ().time + expiresIn.inWholeMilliseconds)
203
+ Labels (
204
+ start = Label (
205
+ text = context.getString(LR .string.profile_next_payment, expiryDate.toLocalizedFormatLongStyle()),
206
+ ),
207
+ end = Label (
208
+ text = when (frequency) {
209
+ SubscriptionFrequency .MONTHLY -> context.getString(LR .string.profile_monthly)
210
+ SubscriptionFrequency .YEARLY -> context.getString(LR .string.profile_yearly)
211
+ SubscriptionFrequency .NONE -> " "
212
+ },
213
+ ),
214
+ )
215
+ }
207
216
208
- is SubscriptionHeaderState .PaidCancel -> {
209
- Labels (
210
- start = Label (
211
- text = when {
212
- isChampion -> {
213
- context.getString(LR .string.plus_thanks_for_your_support_bang)
214
- }
215
- platform == SubscriptionPlatform .GIFT -> {
216
- val daysString = context.resources.getStringPluralDaysMonthsOrYears(giftDaysLeft)
217
- context.getString(LR .string.profile_time_free, daysString)
218
- }
219
- else -> {
220
- context.getString(LR .string.profile_payment_cancelled)
221
- }
222
- },
223
- ),
224
- end = Label (
225
- text = if (isChampion) {
226
- context.getString(LR .string.pocket_casts_champion)
227
- } else {
228
- val expiryDate = Date (Date ().time + expiresIn.inWholeMilliseconds)
229
- context.getString(LR .string.profile_plus_expires, expiryDate.toLocalizedFormatLongStyle())
230
- },
231
- color = {
232
- if (isChampion) {
233
- support02
234
- } else {
235
- primaryText02
236
- }
237
- },
238
- ),
239
- )
240
- }
217
+ is SubscriptionHeaderState .PaidCancel -> {
218
+ Labels (
219
+ start = Label (
220
+ text = when {
221
+ platform == SubscriptionPlatform .GIFT -> {
222
+ val daysString = context.resources.getStringPluralDaysMonthsOrYears(giftDaysLeft)
223
+ context.getString(LR .string.profile_time_free, daysString)
224
+ }
225
+ else -> {
226
+ context.getString(LR .string.profile_payment_cancelled)
227
+ }
228
+ },
229
+ ),
230
+ end = Label (
231
+ text = run {
232
+ val expiryDate = Date (Date ().time + expiresIn.inWholeMilliseconds)
233
+ context.getString(LR .string.profile_plus_expires, expiryDate.toLocalizedFormatLongStyle())
234
+ },
235
+ ),
236
+ )
237
+ }
241
238
242
- is SubscriptionHeaderState .SupporterRenew -> {
243
- Labels (
244
- start = Label (
245
- text = context.getString(LR .string.supporter),
246
- color = { support02 },
247
- ),
248
- end = Label (
249
- text = context.getString(LR .string.supporter_check_contributions),
250
- ),
251
- )
252
- }
239
+ is SubscriptionHeaderState .SupporterRenew -> {
240
+ Labels (
241
+ start = Label (
242
+ text = context.getString(LR .string.supporter),
243
+ color = { support02 },
244
+ ),
245
+ end = Label (
246
+ text = context.getString(LR .string.supporter_check_contributions),
247
+ ),
248
+ )
249
+ }
253
250
254
- is SubscriptionHeaderState .SupporterCancel -> {
255
- val expiryDate = expiresIn?.inWholeMilliseconds?.let { Date (Date ().time + it) }
256
- val expiryString = expiryDate?.toLocalizedFormatLongStyle() ? : context.getString(LR .string.profile_expiry_date_unknown)
257
- Labels (
258
- start = Label (
259
- text = context.getString(LR .string.supporter_payment_cancelled),
260
- color = { support05 },
261
- ),
262
- end = Label (
263
- text = context.getString(LR .string.supporter_subscription_ends, expiryString),
264
- ),
265
- )
251
+ is SubscriptionHeaderState .SupporterCancel -> {
252
+ val expiryDate = expiresIn?.inWholeMilliseconds?.let { Date (Date ().time + it) }
253
+ val expiryString = expiryDate?.toLocalizedFormatLongStyle() ? : context.getString(LR .string.profile_expiry_date_unknown)
254
+ Labels (
255
+ start = Label (
256
+ text = context.getString(LR .string.supporter_payment_cancelled),
257
+ color = { support05 },
258
+ ),
259
+ end = Label (
260
+ text = context.getString(LR .string.supporter_subscription_ends, expiryString),
261
+ ),
262
+ )
263
+ }
266
264
}
267
265
}
268
266
}
@@ -431,6 +429,16 @@ private class AccountHeaderStateParameterProvider : PreviewParameterProvider<Acc
431
429
subscription = SubscriptionHeaderState .SupporterRenew (
432
430
tier = SubscriptionTier .PLUS ,
433
431
expiresIn = null ,
432
+ isChampion = false ,
433
+ ),
434
+ ),
435
+ AccountHeaderState (
436
+
437
+ imageUrl = null ,
438
+ subscription = SubscriptionHeaderState .SupporterRenew (
439
+ tier = SubscriptionTier .PLUS ,
440
+ expiresIn = null ,
441
+ isChampion = true ,
434
442
),
435
443
),
436
444
AccountHeaderState (
@@ -439,6 +447,16 @@ private class AccountHeaderStateParameterProvider : PreviewParameterProvider<Acc
439
447
subscription = SubscriptionHeaderState .SupporterCancel (
440
448
tier = SubscriptionTier .PLUS ,
441
449
expiresIn = 10 .days,
450
+ isChampion = false ,
451
+ ),
452
+ ),
453
+ AccountHeaderState (
454
+
455
+ imageUrl = null ,
456
+ subscription = SubscriptionHeaderState .SupporterCancel (
457
+ tier = SubscriptionTier .PLUS ,
458
+ expiresIn = 10 .days,
459
+ isChampion = true ,
442
460
),
443
461
),
444
462
AccountHeaderState (
@@ -447,6 +465,7 @@ private class AccountHeaderStateParameterProvider : PreviewParameterProvider<Acc
447
465
subscription = SubscriptionHeaderState .SupporterCancel (
448
466
tier = SubscriptionTier .PLUS ,
449
467
expiresIn = null ,
468
+ isChampion = false ,
450
469
),
451
470
),
452
471
)
0 commit comments