Skip to content

Commit

Permalink
Moves the literal strings out of SubscriptionInformation.
Browse files Browse the repository at this point in the history
  • Loading branch information
JayShortway committed Jul 19, 2024
1 parent 222741b commit 124e143
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
19 changes: 2 additions & 17 deletions RevenueCatUI/CustomerCenter/Data/SubscriptionInformation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,8 @@ struct SubscriptionInformation {
let price: String
let expirationDateString: String?
let productIdentifier: String

var expirationString: String {
return active ? (
willRenew ? String(localized: "Next billing date") : String(localized: "Expires")
) : String(localized: "Expired")
}

var explanation: String {
return active ? (
willRenew ?
String(localized: "This is your subscription with the earliest billing date.") :
String(localized: "This is your subscription with the earliest expiration date.")
) : String(localized: "This subscription has expired.")
}

private let willRenew: Bool
private let active: Bool
let willRenew: Bool
let active: Bool

init(title: String,
durationTitle: String,
Expand Down
22 changes: 20 additions & 2 deletions RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,16 @@ struct SubscriptionDetailsView: View {
VStack(alignment: .leading) {
Text("\(subscriptionInformation.title)")
.font(.headline)
Text("\(subscriptionInformation.explanation)")

var explanation: String {
return subscriptionInformation.active ? (
subscriptionInformation.willRenew ?
String(localized: "This is your subscription with the earliest billing date.") :
String(localized: "This is your subscription with the earliest expiration date.")
) : String(localized: "This subscription has expired.")
}

Text("\(explanation)")
.frame(maxWidth: 200, alignment: .leading)
.font(.caption)
.foregroundColor(Color(UIColor.secondaryLabel))
Expand Down Expand Up @@ -181,12 +190,21 @@ struct SubscriptionDetailsView: View {
}

if let nextRenewal = subscriptionInformation.expirationDateString {

var expirationString: String {
return subscriptionInformation.active ? (
subscriptionInformation.willRenew ?
String(localized: "Next billing date") :
String(localized: "Expires")
) : String(localized: "Expired")
}

HStack(alignment: .center) {
Image(systemName: "calendar")
.accessibilityHidden(true)
.frame(width: iconWidth)
VStack(alignment: .leading) {
Text("\(subscriptionInformation.expirationString)")
Text("\(expirationString)")
.font(.caption2)
.foregroundColor(Color(UIColor.secondaryLabel))
Text("\(String(describing: nextRenewal))")
Expand Down

0 comments on commit 124e143

Please sign in to comment.