Skip to content

Commit

Permalink
feat: Add debug section for purchase detail (#4702)
Browse files Browse the repository at this point in the history
  • Loading branch information
facumenzella authored Jan 27, 2025
1 parent 28d957e commit ab62be6
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ final class PurchaseDetailViewModel: ObservableObject {
private var localization: CustomerCenterConfigData.Localization

@Published var items: [PurchaseDetailItem] = []
var debugItems: [PurchaseDetailItem] = []

var localizedOwnership: String? {
switch purchaseInfo {
Expand Down Expand Up @@ -70,10 +71,11 @@ private extension PurchaseDetailViewModel {

await MainActor.run {
var items: [PurchaseDetailItem] = [
.productName(product.localizedTitle)
]
.productName(product.localizedTitle)
]

items.append(contentsOf: purchaseInfo.purchaseDetailItems)
items.append(contentsOf: purchaseInfo.purchaseDetailItems)
self.debugItems = purchaseInfo.purchaseDetailDebugItems
self.items = items
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ enum PurchaseInfo: Identifiable {
}
}

var purchaseDetailDebugItems: [PurchaseDetailItem] {
#if DEBUG
debugItems
#else
[]
#endif
}

var purchaseDetailItems: [PurchaseDetailItem] {
var items: [PurchaseDetailItem] = []
switch self {
Expand Down Expand Up @@ -130,10 +138,6 @@ enum PurchaseInfo: Identifiable {

}

#if DEBUG
items.append(contentsOf: debugItems)
#endif

return items
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ struct ManageSubscriptionsView: View {
} label: {
Text(localization[.seeAllPurchases])
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ struct PurchaseDetailView: View {
Text(ownership)
}
}

if !viewModel.debugItems.isEmpty {
Section(localization[.debugHeaderTitle]) {
ForEach(viewModel.debugItems) { detailItem in
CompatibilityLabeledContent(
localization[detailItem.label],
content: content(detailItem: detailItem)
)
}
}
}
}
.listStyle(.insetGrouped)
.navigationBarTitleDisplayMode(.inline)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct PurchaseLinkView: View {
Image(systemName: "chevron.forward")
.foregroundStyle(.secondary)
}
.contentShape(Rectangle())
.onAppear {
Task {
guard
Expand Down
3 changes: 3 additions & 0 deletions Sources/CustomerCenter/CustomerCenterConfigData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public struct CustomerCenterConfigData {
case storeRCBilling = "store_web"
case storeExternal = "store_external"
case storeUnknownStore = "store_unknown"
case debugHeaderTitle = "Debug"

var defaultValue: String {
switch self {
Expand Down Expand Up @@ -315,6 +316,8 @@ public struct CustomerCenterConfigData {
return "External Purchases"
case .storeUnknownStore:
return "Unknown Store"
case .debugHeaderTitle:
return "Debug"
}
}
}
Expand Down

0 comments on commit ab62be6

Please sign in to comment.