taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit acf36f6af1c6641a65ffed578375b62eadbb7252
parent 39356f69a4ab9b82a0dd490b487f0c2577826178
Author: Marc Stibane <marc@taler.net>
Date:   Sat, 12 Oct 2024 11:20:12 +0200

ScopePicker

Diffstat:
MTalerWallet1/Helper/Font+Taler.swift | 1+
MTalerWallet1/Views/HelperViews/ScopePicker.swift | 32+++++++++++++++-----------------
2 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/TalerWallet1/Helper/Font+Taler.swift b/TalerWallet1/Helper/Font+Taler.swift @@ -174,6 +174,7 @@ extension TalerFont { // old running static var title: TalerFont { TalerFont(fontName, size: 28, relativeTo: .title) } // 28 -> 31 static var title2: TalerFont { TalerFont(fontName, size: 22, relativeTo: .title2) } // 22 -> 25 static var title3: TalerFont { TalerFont(fontName, size: 20, relativeTo: .title3) } // 20 -> 23 + static var picker: TalerFont { TalerFont(fontName, size: 18, relativeTo: .body) } // picker uses a different size! static var headline: TalerFont { TalerFont(fontName, size: 17, relativeTo: .headline, isBold: true) } // 17 bold -> 19 bold static var body: TalerFont { TalerFont(fontName, size: 17, relativeTo: .body) } // 17 -> 19 static var callout: TalerFont { TalerFont(fontName, size: 16, relativeTo: .callout) } // 16 -> 18 diff --git a/TalerWallet1/Views/HelperViews/ScopePicker.swift b/TalerWallet1/Views/HelperViews/ScopePicker.swift @@ -19,34 +19,32 @@ struct ScopePicker: View { return amount.formatted(isNegative: false, useISO: false) } - func label(balance: Balance) -> String { - let label = balance.scopeInfo.url?.trimURL - ?? balance.scopeInfo.currency - return String("\(label):\t\(formattedAmount(balance).nbs)") + func row(_ balance: Balance) -> String { + let urlOrCurrency = balance.scopeInfo.url?.trimURL + ?? balance.scopeInfo.currency + return String("\(urlOrCurrency):\t\(formattedAmount(balance).nbs)") } var body: some View { - HStack { - Text("Use: ", comment: "ScopePicker") - Spacer() - if (balances.count > 0) { + if (balances.count > 0) { + Group { Picker(EMPTYSTRING, selection: $selected) { ForEach(0..<balances.count, id: \.self) { index in - Text(label(balance: balances[index])) + Text(row(balances[index])) .tag(index) } } + .frame(width: .infinity) .pickerStyle(.menu) - .onAppear() { - withAnimation { selected = value } - } - .onChange(of: selected) { newValue in - action(newValue) - } + .labelsHidden() + } + .onAppear() { + withAnimation { selected = value } + } + .onChange(of: selected) { newValue in + action(newValue) } } - .padding(.leading) - .talerFont(.title3) } } // MARK: -