commit 9757d293139e1d9a6dcc9bec54d464f41271a9eb
parent fedfe8e2ebc90664b9751c37628a651344b7ef95
Author: Marc Stibane <marc@taler.net>
Date: Tue, 25 Aug 2026 17:15:15 +0200
Only show dicounts/passes if the user has some
Diffstat:
1 file changed, 39 insertions(+), 32 deletions(-)
diff --git a/TalerWallet1/Views/Balances/DiscountPasses.swift b/TalerWallet1/Views/Balances/DiscountPasses.swift
@@ -236,39 +236,46 @@ struct DiscountPassesSection: View {
let passText = String(localized: "Passes")
let activeColor = WalletColors().primaryAccent
let inactiveColor = WalletColors().secondary(colorScheme, colorSchemeContrast)
- Section {
- let discCount = controller.discounts.count
- let discColor = discCount > 0 ? activeColor : inactiveColor
- let discountsLabel = Label {
- Text(discText)
- } icon: {
- Image(ICONNAME_DISCOUNTS, SYSTEM_DISCOUNTS)
- .renderingMode(.template)
- .foregroundColor(discColor)
- }
-
- let passCount = controller.subscriptions.count
- let passColor = passCount > 0 ? activeColor : inactiveColor
- let passesLabel = Label {
- Text(passText)
- } icon: {
- Image(ICONNAME_PASSES, SYSTEM_PASSES)
- .renderingMode(.template)
- .foregroundColor(passColor)
- }
+ let discCount = controller.discounts.count
+ let passCount = controller.subscriptions.count
+ if discCount > 0 || passCount > 0 {
+ Section {
+ if discCount > 0 {
+ // TODO: only show active color if at least 1 discount is active
+ let discColor = discCount > 0 ? activeColor : inactiveColor
+ let discountsLabel = Label {
+ Text(discText)
+ } icon: {
+ Image(ICONNAME_DISCOUNTS, SYSTEM_DISCOUNTS)
+ .renderingMode(.template)
+ .foregroundColor(discColor)
+ }
+ let discountsDest = DiscountsPassesList(stack: stack.push(),
+ isPass: false,
+ navTitle: discText)
+ NavigationLink(destination: discountsDest) { discountsLabel }
+ // TODO: a11y for discCount > 0
+ }
+ if passCount > 0 {
+ // TODO: only show active color if at least 1 pass is active
+ let passColor = passCount > 0 ? activeColor : inactiveColor
+ let passesLabel = Label {
+ Text(passText)
+ } icon: {
+ Image(ICONNAME_PASSES, SYSTEM_PASSES)
+ .renderingMode(.template)
+ .foregroundColor(passColor)
+ }
- let discountsDest = DiscountsPassesList(stack: stack.push(),
- isPass: false,
- navTitle: discText)
- let passesDest = DiscountsPassesList(stack: stack.push(),
- isPass: true,
- navTitle: passText)
- NavigationLink(destination: discountsDest) { discountsLabel }
- // TODO: a11y for discCount > 0
- NavigationLink(destination: passesDest) { passesLabel }
- // TODO: a11y for passCount > 0
+ let passesDest = DiscountsPassesList(stack: stack.push(),
+ isPass: true,
+ navTitle: passText)
+ NavigationLink(destination: passesDest) { passesLabel }
+ // TODO: a11y for passCount > 0
+ }
+ }
+ .listRowSeparator(.hidden)
+ .talerFont(.title2)
}
- .listRowSeparator(.hidden)
- .talerFont(.title2)
}
}