Improve "Purchased" view (#979)
- Show eligible features first - Render ineligible features as secondary
This commit is contained in:
parent
4ef47dfd77
commit
d8f5caa2f7
|
@ -73,7 +73,14 @@ private extension PurchasedView {
|
||||||
}
|
}
|
||||||
|
|
||||||
var allFeatures: [AppFeature] {
|
var allFeatures: [AppFeature] {
|
||||||
AppFeature.allCases.sorted()
|
AppFeature.allCases.sorted {
|
||||||
|
let lRank = $0.rank(with: iapManager)
|
||||||
|
let rRank = $1.rank(with: iapManager)
|
||||||
|
if lRank != rRank {
|
||||||
|
return lRank < rRank
|
||||||
|
}
|
||||||
|
return $0 < $1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,18 +131,41 @@ private extension PurchasedView {
|
||||||
var featuresSection: some View {
|
var featuresSection: some View {
|
||||||
Group {
|
Group {
|
||||||
ForEach(allFeatures, id: \.self) { feature in
|
ForEach(allFeatures, id: \.self) { feature in
|
||||||
HStack {
|
FeatureView(text: feature.localizedDescription, isEligible: iapManager.isEligible(for: feature))
|
||||||
Text(feature.localizedDescription)
|
.scrollableOnTV()
|
||||||
Spacer()
|
|
||||||
ThemeImage(iapManager.isEligible(for: feature) ? .marked : .close)
|
|
||||||
}
|
|
||||||
.scrollableOnTV()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.themeSection(header: Strings.Views.Purchased.Sections.Features.header)
|
.themeSection(header: Strings.Views.Purchased.Sections.Features.header)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private struct FeatureView: View {
|
||||||
|
let text: String
|
||||||
|
|
||||||
|
let isEligible: Bool
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
HStack {
|
||||||
|
Text(text)
|
||||||
|
Spacer()
|
||||||
|
ThemeImage(isEligible ? .marked : .close)
|
||||||
|
}
|
||||||
|
.foregroundStyle(isEligible ? .primary : .secondary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: -
|
||||||
|
|
||||||
|
private extension AppFeature {
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
func rank(with iapManager: IAPManager) -> Int {
|
||||||
|
iapManager.isEligible(for: self) ? 0 : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Previews
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
PurchasedView()
|
PurchasedView()
|
||||||
.withMockEnvironment()
|
.withMockEnvironment()
|
||||||
|
|
Loading…
Reference in New Issue