Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add debug section for purchase detail #4702

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -86,6 +86,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