commit 6e73588e3154da90e008658414e09f591f0bf5ff parent c9e8332c3cd0a92610b046f12ca540104dcd28ff Author: Marc Stibane <marc@taler.net> Date: Thu, 26 Mar 2026 13:14:01 +0100 count => isEmpty Diffstat:
29 files changed, 54 insertions(+), 65 deletions(-)
diff --git a/TalerWallet1/Helper/CurrencySpecification.swift b/TalerWallet1/Helper/CurrencySpecification.swift @@ -197,7 +197,7 @@ public struct CurrencyInfo: Sendable { } } let currency = formatter.currency - if currency.count > 0 { + if !currency.isEmpty { let spacedName = formatter.leadingCurrencySymbol ? currency + SPACE : SPACE + currency let spacedString1 = aString.replacingOccurrences(of: formatter.currencySymbol, with: spacedName) diff --git a/TalerWallet1/Views/Actions/ActionsSheet.swift b/TalerWallet1/Views/Actions/ActionsSheet.swift @@ -60,7 +60,7 @@ struct ActionsSheet: View { if let balance = controller.balances.first, let shoppingUrls = balance.shoppingUrls, - shoppingUrls.count > 0 + !shoppingUrls.isEmpty { let currency = balance.scopeInfo.currency ShoppingView(stack: stack.push(), @@ -123,7 +123,7 @@ struct ActionsSheet: View { }.padding(.bottom, 20) } - let noBalances = controller.balances.count == 0 + let noBalances = controller.balances.isEmpty let noP2P = !self.mayP2P let sendDisabled = noP2P let recvDisabled = noBalances || noP2P diff --git a/TalerWallet1/Views/Actions/Banking/DepositAmountV.swift b/TalerWallet1/Views/Actions/Banking/DepositAmountV.swift @@ -46,7 +46,7 @@ struct DepositAmountV: View { balanceIndex = balances.firstIndex(of: balance) ?? 0 } else { balanceIndex = 0 - balance = (balances.count > 0) ? balances[0] : nil + balance = balances.isEmpty ? nil : balances[0] } } diff --git a/TalerWallet1/Views/Actions/Banking/DepositAmountView.swift b/TalerWallet1/Views/Actions/Banking/DepositAmountView.swift @@ -44,8 +44,7 @@ struct DepositAmountView: View { } private func feeLabel(_ feeString: String) -> String { - feeString.count > 0 ? String(localized: "+ \(feeString) fee") - : EMPTYSTRING + feeString.isEmpty ? EMPTYSTRING : String(localized: "+ \(feeString) fee") } private func feeIsNotZero() -> Bool? { diff --git a/TalerWallet1/Views/Actions/Banking/DepositSelectV.swift b/TalerWallet1/Views/Actions/Banking/DepositSelectV.swift @@ -77,7 +77,7 @@ struct DepositSelectV: View { } } else { ForEach(bankAccounts, id: \.self) { account in -// let disabled = (accountHolder.count < 1) || paytoUri == nil // TODO: check amountAvailable +// let disabled = accountHolder.isEmpty || paytoUri == nil // TODO: check amountAvailable BankSectionView(stack: stack.push(), account: account, selectedBalance: selectedBalance, diff --git a/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift b/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift @@ -39,7 +39,7 @@ struct ManualWithdraw: View { balanceIndex = controller.balances.firstIndex(of: selectedBalance) ?? 0 } else { balanceIndex = 0 - balance = (controller.balances.count > 0) ? controller.balances[0] : nil + balance = controller.balances.isEmpty ? nil : controller.balances[0] } if let balance { currencyInfo = controller.info(for: balance.scopeInfo, controller.currencyTicker) diff --git a/TalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift b/TalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift @@ -98,7 +98,7 @@ struct P2PSubjectV: View { let scrollView = ScrollView { VStack (alignment: .leading, spacing: 6) { if let feeIsNotZero { // don't show fee if nil let label = feeLabel ?? myFeeLabel - if label.0.count > 0 { + if !label.0.isEmpty { Text(label.0) .accessibilityLabel(label.1) .frame(maxWidth: .infinity, alignment: .trailing) diff --git a/TalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift b/TalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift @@ -72,7 +72,7 @@ struct RequestPayment: View { balanceIndex = balances.firstIndex(of: balance) ?? 0 } else { balanceIndex = 0 - balance = (balances.count > 0) ? balances[0] : nil + balance = balances.isEmpty ? nil : balances[0] } } @@ -174,8 +174,7 @@ struct RequestPaymentContent: View { private func buttonAction() { buttonSelected = true } private func feeLabel(_ feeStr: String) -> String { - feeStr.count > 0 ? String(localized: "- \(feeStr) fee") - : EMPTYSTRING + feeStr.isEmpty ? EMPTYSTRING : String(localized: "- \(feeStr) fee") } private func fee(raw: Amount, effective: Amount) -> Amount? { diff --git a/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift b/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift @@ -77,7 +77,7 @@ struct SendAmountV: View { balanceIndex = balances.firstIndex(of: balance) ?? 0 } else { balanceIndex = 0 - balance = (balances.count > 0) ? balances[0] : nil + balance = balances.isEmpty ? nil : balances[0] } } diff --git a/TalerWallet1/Views/Actions/Peer2peer/SendAmountView.swift b/TalerWallet1/Views/Actions/Peer2peer/SendAmountView.swift @@ -51,8 +51,7 @@ struct SendAmountView: View { } private func feeLabel(_ feeStr: String) -> String { - feeStr.count > 0 ? String(localized: "+ \(feeStr) fee") - : EMPTYSTRING + feeStr.isEmpty ? EMPTYSTRING : String(localized: "+ \(feeStr) fee") } private func fee(raw: Amount, effective: Amount) -> Amount? { diff --git a/TalerWallet1/Views/Actions/TwoRowButtons.swift b/TalerWallet1/Views/Actions/TwoRowButtons.swift @@ -52,7 +52,8 @@ struct TypeButton: View { let vLayout = VStack { let fragments = title.components(separatedBy: "\n") - if fragments.count > 1 { + let fragCount = fragments.count + if fragCount > 1 { Text(fragments[0]) HStack { badge @@ -64,7 +65,7 @@ struct TypeButton: View { #if DEBUG .border(orange) #endif - if fragments.count > 2 { + if fragCount > 2 { Text(fragments[2]) // .fixedSize(horizontal: true, vertical: false) #if DEBUG diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift b/TalerWallet1/Views/Balances/BalancesSectionView.swift @@ -126,7 +126,7 @@ extension BalancesSectionView: View { // .listRowSeparator(.hidden) // .border(.red) - if pendingTransactions.count > 0 { + if !pendingTransactions.isEmpty { BalancesPendingRowV(//symLog: symLog, stack: stack.push(), balance: balance, @@ -135,7 +135,7 @@ extension BalancesSectionView: View { reloadPending: loadPending) .padding(.leading, ICONLEADING) } - if scannedTransactions.count > 0 { + if !scannedTransactions.isEmpty { BalancesDialogRowV(stack: stack.push(), balance: balance, selectedBalance: $selectedBalance, @@ -157,7 +157,8 @@ extension BalancesSectionView: View { await loadScanned(stack.push(".task - load scanned")) } /// if there is only one currency, then show MAXRECENT recent transactions - if sectionCount == 1 && recentTransactions.count > 0 { + let recentCount = recentTransactions.count + if sectionCount == 1 && recentCount > 0 { Section { let _ = symLog.log("recent transactions") TransactionsArraySliceV(symLog: symLog, @@ -169,7 +170,7 @@ extension BalancesSectionView: View { .padding(.leading, ICONLEADING) } header: { if !minimalistic { - let recentHeader = recentTransactions.count > 1 + let recentHeader = recentCount > 1 ? String(localized: "Recent transactions", comment: "section header plural") : String(localized: "Recent transaction", comment: "section header singular") Text(recentHeader) diff --git a/TalerWallet1/Views/HelperViews/AgePicker.swift b/TalerWallet1/Views/HelperViews/AgePicker.swift @@ -14,7 +14,7 @@ struct AgePicker: View { func setAges(ages: [Int]?) { if let ages { var zero: [Int] = [] - if ages.count > 0 { // need at least 1 value from exchange which is not 0 + if !ages.isEmpty { // need at least 1 value from exchange which is not 0 if ages[0] != 0 { // ensure that the first age is "0" zero.insert(0, at: 0) // if not, insert "0" at position 0 } diff --git a/TalerWallet1/Views/HelperViews/BarGraph.swift b/TalerWallet1/Views/HelperViews/BarGraph.swift @@ -71,12 +71,11 @@ struct BarGraph: View { var body: some View { let slice = transactions.prefix(maxBars) - let count = slice.count let tenTransactions: [TalerTransaction] = Array(slice) let maxValue = maxValue(tenTransactions) HStack(alignment: .center, spacing: 1) { - if count > 0 { + if !slice.isEmpty { ForEach(tenTransactions, id: \.self) {transaction in let common = transaction.common let incoming = common.isIncoming diff --git a/TalerWallet1/Views/HelperViews/Buttons.swift b/TalerWallet1/Views/HelperViews/Buttons.swift @@ -408,7 +408,7 @@ struct TalerButtonStyle: ButtonStyle { let aligned2: Alignment = (aligned == .center) ? Alignment.center : (aligned == .leading) ? Alignment.leading : Alignment.trailing - let hasBadge = badge.count > 0 + let hasBadge = !badge.isEmpty let buttonLabel = configuration.label .multilineTextAlignment(aligned) .talerFont(.title3) // narrow ? .title3 : .title2 diff --git a/TalerWallet1/Views/HelperViews/SubjectInputV.swift b/TalerWallet1/Views/HelperViews/SubjectInputV.swift @@ -43,8 +43,8 @@ struct SubjectInputV<TargetView: View>: View { // let feeLabel = insufficient ? insufficientLabel // : feeLabel(feeStr) // let available = amountAvailable?.formatted(scope, isNegative: false) ?? nil -// let disabled = insufficient || summary.count == 0 - let disabled = summary.count == 0 +// let disabled = insufficient || summary.isEmpty + let disabled = summary.isEmpty ScrollView { VStack(alignment: .leading) { // if let available { // Text("Available:\t\(available)") diff --git a/TalerWallet1/Views/OIM/ArrowHistoryView.swift b/TalerWallet1/Views/OIM/ArrowHistoryView.swift @@ -63,7 +63,6 @@ struct ArrowHistoryView: View { } var body: some View { - let count = shownItems.count // let _ = logger.log("ArrowHistoryView \(width.pTwo)") ZStack(alignment: .top) { @@ -83,7 +82,7 @@ struct ArrowHistoryView: View { ScrollViewReader { scrollProxy in OptimalSize(.horizontal) { // keep it small if we have only a few tx ScrollView(.horizontal) { - if count > 0 { + if !shownItems.isEmpty { HStack(spacing: 0) { ForEach(-maxXValue...0, id: \.self) { xVal in ArrowTileView(historyItem: historyItem(for: xVal)) { diff --git a/TalerWallet1/Views/OIM/OIMlayout.swift b/TalerWallet1/Views/OIM/OIMlayout.swift @@ -308,7 +308,7 @@ struct OIMlayout: Layout { } func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize { - guard subviews.count > 0 else { return CGSize.zero } + guard !subviews.isEmpty else { return CGSize.zero } let (spacing, offset) = spacing(for: proposal) let sorted = sortByValue(subviews) let viewSizes = sorted.map { $0.sizeThatFits(proposal) } // <- THIS takes time... diff --git a/TalerWallet1/Views/OIM/OIMtransactions.swift b/TalerWallet1/Views/OIM/OIMtransactions.swift @@ -237,7 +237,7 @@ struct OIMtransactions: View { cash.update2(availableVal) // set cash to available cash.setTarget(.history) debugTick += 1 - if computedItems.count == 0 { + if computedItems.isEmpty { computeData(from: history, balance: balance.available.value) // set chartMaxY, computedData } showHistoryItems(oimChart ? Animation.talerDelay0 : 0.0) diff --git a/TalerWallet1/Views/OIM/RiverHistoryView.swift b/TalerWallet1/Views/OIM/RiverHistoryView.swift @@ -63,7 +63,6 @@ struct RiverHistoryView: View { } var body: some View { - let count = shownItems.count // let _ = logger.log("RiverHistoryView \(width.pTwo)") ZStack(alignment: .top) { @@ -83,7 +82,7 @@ struct RiverHistoryView: View { ScrollViewReader { scrollProxy in OptimalSize(.horizontal) { // keep it small if we have only a few tx ScrollView(.horizontal) { - if count > 0 { + if !shownItems.isEmpty { HStack(spacing: 0) { ForEach(-maxXValue...0, id: \.self) { xVal in RiverTileView(historyItem: historyItem(for: xVal)) { diff --git a/TalerWallet1/Views/Settings/Bank/BankEditView.swift b/TalerWallet1/Views/Settings/Bank/BankEditView.swift @@ -61,7 +61,7 @@ struct BankEditView: View { let payTo = PayTo(account.paytoUri) iban = payTo.iban ?? EMPTYSTRING xTaler = payTo.xTaler ?? EMPTYSTRING - if iban.count < 1 && xTaler.count > 1 { + if iban.isEmpty && xTaler.count > 1 { paytoType = .xTalerBank } accountLabel = account.label ?? EMPTYSTRING diff --git a/TalerWallet1/Views/Settings/Bank/BankSectionView.swift b/TalerWallet1/Views/Settings/Bank/BankSectionView.swift @@ -50,7 +50,7 @@ struct BankSectionView: View { cyclos = payTo.cyclos ?? EMPTYSTRING xTaler = payTo.xTaler ?? EMPTYSTRING - if iban.count < 1 { + if iban.isEmpty { if cyclos.count > 1 { paytoType = .cyclos } else if xTaler.count > 1 { diff --git a/TalerWallet1/Views/Settings/Exchange/ExchangeSectionView.swift b/TalerWallet1/Views/Settings/Exchange/ExchangeSectionView.swift @@ -36,8 +36,7 @@ struct ExchangeSectionView: View { @MainActor private func viewDidLoad() async { if let exc = try? await model.listExchanges(scope: balance.scopeInfo) { - if exc.count > 0 { - let exchange = exc[0] + if let exchange = exc.first { global = exchange.scopeInfo.type == .global } withAnimation { exchanges = exc } @@ -54,29 +53,27 @@ struct ExchangeSectionView: View { private func deleteExchange() { disabled = true // don't try this more than once Task { // runs on MainActor - if exchanges.count > 0 { - let exchange = exchanges[0] - let baseUrl = exchange.exchangeBaseUrl - if let _ = try? await model.deleteExchange(url: baseUrl, purge: purge, viewHandles: !purge) { - purge = false - symLog.log("deleted \(baseUrl.trimURL)") - didDelete = true // change button text - NotificationCenter.default.post(name: .ExchangeDeleted, object: nil, userInfo: nil) - NotificationCenter.default.post(name: .BalanceChange, object: nil, userInfo: nil) - demoHints = true - } else { - purge = true - showAlert = true - disabled = false + if let exchange = exchanges.first { + let baseUrl = exchange.exchangeBaseUrl + if let _ = try? await model.deleteExchange(url: baseUrl, purge: purge, viewHandles: !purge) { + purge = false + symLog.log("deleted \(baseUrl.trimURL)") + didDelete = true // change button text + NotificationCenter.default.post(name: .ExchangeDeleted, object: nil, userInfo: nil) + NotificationCenter.default.post(name: .BalanceChange, object: nil, userInfo: nil) + demoHints = true + } else { + purge = true + showAlert = true + disabled = false + } } - } } } @MainActor private func setGlobal() { - if exchanges.count > 0 { - let exchange = exchanges[0] + if let exchange = exchanges.first { let scope = exchange.scopeInfo Task { if scope.type != .global { diff --git a/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift b/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift @@ -99,9 +99,7 @@ struct PayTemplateV: View { amountIsEditable = contract.amount == nil summaryIsEditable = contract.summary == nil - let prepCurrency = contract.currency ?? defaults?.currency ?? - (supportedCurrencies.count > 0 ? supportedCurrencies[0] - : UNKNOWN) + let prepCurrency = contract.currency ?? defaults?.currency ?? supportedCurrencies.first ?? UNKNOWN let zeroAmount = Amount(currency: prepCurrency, cent: 0) let prepAmount = contract.amount ?? defaults?.amount // might be nil let prepSummary = contract.summary ?? defaults?.summary // might be nil diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift @@ -12,8 +12,7 @@ import SymLog typealias Announce = (_ this: String) -> () fileprivate func feeLabel(_ feeString: String) -> String { - feeString.count > 0 ? String(localized: "+ \(feeString) fee") - : EMPTYSTRING + feeString.isEmpty ? EMPTYSTRING : String(localized: "+ \(feeString) fee") } func templateFee(ppCheck: PreparePayResult?) -> Amount? { @@ -93,7 +92,7 @@ struct PaymentView: View, Sendable { @MainActor func checkCurrencyInfo(for result: PreparePayResult) async { if let scopes = result.scopes { - if scopes.count > 0 { + if !scopes.isEmpty { for scope in scopes { controller.checkInfo(for: scope, model: model) } diff --git a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift @@ -64,8 +64,7 @@ struct WithdrawURIView: View { private func buttonAction() { buttonSelected = true } private func feeLabel(_ feeString: String) -> String { - feeString.count > 0 ? String(localized: "\(feeString) fee") - : EMPTYSTRING + feeString.isEmpty ? EMPTYSTRING : String(localized: "\(feeString) fee") } @MainActor diff --git a/TalerWallet1/Views/Transactions/ManualDetailsWireV.swift b/TalerWallet1/Views/Transactions/ManualDetailsWireV.swift @@ -266,7 +266,7 @@ struct ManualDetailsWireV: View { } } ibanCode - } else if cyclos.count > 0 { + } else if !cyclos.isEmpty { step2x payeeCode } else { diff --git a/TalerWallet1/Views/Transactions/ThreeAmountsSection.swift b/TalerWallet1/Views/Transactions/ThreeAmountsSection.swift @@ -164,7 +164,7 @@ struct ThreeAmountsSection: View { } Section { if let summary { - if productImages.count == 0 { + if productImages.isEmpty { Text(summary) .talerFont(.title3) .lineLimit(4) diff --git a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift @@ -326,7 +326,7 @@ struct TransactionSummaryV: View { let amountValue = amount.valueStr let creditPaytoUris = info.creditPaytoUris let validDetails = validDetails(creditPaytoUris) - if validDetails.count > 0 { + if !validDetails.isEmpty { let countPaytos = creditPaytoUris.count let account = validDetails[accountID]