From b30e1812b1a6b34c3c08f18931561840d807ce8c Mon Sep 17 00:00:00 2001 From: Marc Stibane Date: Wed, 1 Nov 2023 22:34:27 +0100 Subject: avoid unneccessary localizations --- TalerWallet1/Helper/LocalizedAlertError.swift | 3 +- TalerWallet1/Views/Balances/BalanceRowView.swift | 9 +- TalerWallet1/Views/HelperViews/AmountRowV.swift | 8 +- TalerWallet1/Views/HelperViews/Buttons.swift | 168 +-------------------- TalerWallet1/Views/Settings/SettingsItem.swift | 2 +- .../Views/Transactions/TransactionDetailView.swift | 3 +- 6 files changed, 19 insertions(+), 174 deletions(-) diff --git a/TalerWallet1/Helper/LocalizedAlertError.swift b/TalerWallet1/Helper/LocalizedAlertError.swift index 00070e5..ff6dfc1 100644 --- a/TalerWallet1/Helper/LocalizedAlertError.swift +++ b/TalerWallet1/Helper/LocalizedAlertError.swift @@ -48,7 +48,8 @@ extension View { error.wrappedValue = nil } } message: { error in - Text(error.failureReason ?? error.recoverySuggestion ?? "") + let emptyStr = "" + Text(error.failureReason ?? error.recoverySuggestion ?? emptyStr) } } } diff --git a/TalerWallet1/Views/Balances/BalanceRowView.swift b/TalerWallet1/Views/Balances/BalanceRowView.swift index 4af0a15..5b3179b 100644 --- a/TalerWallet1/Views/Balances/BalanceRowView.swift +++ b/TalerWallet1/Views/Balances/BalanceRowView.swift @@ -13,18 +13,19 @@ struct BalanceButton: View { @AppStorage("iconOnly") var iconOnly: Bool = false var body: some View { - let balanceTitle = String(localized: "Balance:", comment: "Main view") + let balanceTitleStr = String(localized: "Balance:", comment: "Main view") Button(action: rowAction) { SingleAxisGeometryReader { width in // e.g. 301 instead of 313 => padding = 6 Group { - let titles = [(balanceTitle, TalerFont.uiFont(.title2)), + let title = iconOnly ? "" : balanceTitleStr + let titles = [(balanceTitleStr, TalerFont.uiFont(.title2)), (amountStr, TalerFont.uiFont(.title))] let fitsSideBySide = iconOnly || Self.fitsSideBySide(titles, availableWidth: width, sizeCategory: sizeCategory, padding: 20, sameSize: false) AmountRowV(amountStr: amountStr, amountColor: .primary, largeAmountFont: true, fitsHorizontal: fitsSideBySide, vertAlignment: .lastTextBaseline) { - Text(iconOnly ? "" : balanceTitle) + Text(title) .accessibilityFont(.title2) .foregroundColor(.secondary) } @@ -33,7 +34,7 @@ struct BalanceButton: View { } .disabled(false) .buttonStyle(TalerButtonStyle(type: iconOnly ? .plain : .balance, aligned: .trailing)) .accessibilityElement(children: /*@START_MENU_TOKEN@*/.ignore/*@END_MENU_TOKEN@*/) - .accessibilityLabel("\(balanceTitle) \(amountStr)") // TODO: CurrencyFormatter! + .accessibilityLabel(balanceTitleStr + " " + amountStr) // TODO: CurrencyFormatter! } } diff --git a/TalerWallet1/Views/HelperViews/AmountRowV.swift b/TalerWallet1/Views/HelperViews/AmountRowV.swift index b3140e7..59b7c10 100644 --- a/TalerWallet1/Views/HelperViews/AmountRowV.swift +++ b/TalerWallet1/Views/HelperViews/AmountRowV.swift @@ -60,24 +60,24 @@ struct SectionWithAmountRow: View { Section { AmountRowV(amountStr: demoStr, amountColor: .primary, largeAmountFont: true, fitsHorizontal: true, vertAlignment: .lastTextBaseline) { - Text("Balance") + Text(verbatim: "Balance") .accessibilityFont(.title2) } AmountRowV(amountStr: demoStr, amountColor: .primary, largeAmountFont: true, fitsHorizontal: false, vertAlignment: .lastTextBaseline) { - Text("Balance") + Text(verbatim: "Balance") .accessibilityFont(.title2) } } Section { AmountRowV(amountStr: testStr, amountColor: .secondary, largeAmountFont: false, fitsHorizontal: true, vertAlignment: .lastTextBaseline) { - Text("Balance") + Text(verbatim: "Balance") .accessibilityFont(.title2) } AmountRowV(amountStr: testStr, amountColor: .secondary, largeAmountFont: false, fitsHorizontal: false, vertAlignment: .lastTextBaseline) { - Text("Balance") + Text(verbatim: "Balance") .accessibilityFont(.title2) } } diff --git a/TalerWallet1/Views/HelperViews/Buttons.swift b/TalerWallet1/Views/HelperViews/Buttons.swift index 945c86e..c40b542 100644 --- a/TalerWallet1/Views/HelperViews/Buttons.swift +++ b/TalerWallet1/Views/HelperViews/Buttons.swift @@ -189,170 +189,12 @@ struct TalerButtonStyle: ButtonStyle { } } - -struct Buttons_Previews: PreviewProvider { +#if DEBUG +fileprivate struct ContentView_Previews: PreviewProvider { static var previews: some View { - VStack { - HStack { - Button("1000") { - Controller.shared.playSound(1000) - }.padding() - Button("1013") { - Controller.shared.playSound(1013) - }.padding() - Button("1008") { - Controller.shared.playSound(1008) - }.padding() - Button("1001") { - Controller.shared.playSound(1001) - }.padding() - Button("1018") { - Controller.shared.playSound(1018) - }.padding() - } // Single - HStack { - Button("1003") { - Controller.shared.playSound(1003) - }.padding() - Button("1004") { - Controller.shared.playSound(1004) - }.padding() - Button("1016") { - Controller.shared.playSound(1016) - }.padding() - Button("1022") { - Controller.shared.playSound(1022) - }.padding() - Button("1034") { - Controller.shared.playSound(1034) - }.padding() - } // Double - HStack { - Button("1023") { - Controller.shared.playSound(1023) - }.padding() - Button("1029") { - Controller.shared.playSound(1029) - }.padding() - Button("1014") { - Controller.shared.playSound(1014) - }.padding() - Button("1021") { - Controller.shared.playSound(1021) - }.padding() - Button("1031") { - Controller.shared.playSound(1031) - }.padding() - } // long single - HStack { - Button("1002") { - Controller.shared.playSound(1002) // == 7,12,15 - }.padding() - Button("1006") { - Controller.shared.playSound(1006) - }.padding() - Button("1025") { - Controller.shared.playSound(1025) - }.padding() - Button("1026") { - Controller.shared.playSound(1026) - }.padding() - Button("1033") { - Controller.shared.playSound(1033) - }.padding() - } // Triple - HStack { - Button("1005") { - Controller.shared.playSound(1005) // 17 - }.padding() - Button("1009") { - Controller.shared.playSound(1009) - }.padding() - Button("1010") { - Controller.shared.playSound(1010) - }.padding() - } // Double 2 - HStack { - Button("1030") { - Controller.shared.playSound(1030) - }.padding() - Button("1035") { - Controller.shared.playSound(1035) - }.padding() - Button("1036") { - Controller.shared.playSound(1036) - }.padding() - Button("1027") { - Controller.shared.playSound(1027) - }.padding() - } - HStack { - Button("1020") { - Controller.shared.playSound(1020) - }.padding() - Button("1024") { - Controller.shared.playSound(1024) - }.padding() - Button("1032") { - Controller.shared.playSound(1032) - }.padding() - Button("1028") { - Controller.shared.playSound(1028) - }.padding() - } - HStack { - PlusButton() { - }.padding() - HamburgerButton() { - }.padding() - QRButton() { - }.padding() - ReloadButton(disabled: false) { - }.padding() - ReloadButton(disabled: true) { - }.padding() - } - Button(String(localized: "Accept"), action: { - Controller.shared.playSound(1028) - }) - .buttonStyle(TalerButtonStyle(type: .prominent)) - .padding(.horizontal) - } + let testButtonTitle = String("Placeholder") + Button(testButtonTitle) {} + .buttonStyle(TalerButtonStyle(type: .balance, aligned: .trailing)) } } - -#if DEBUG -//fileprivate struct ContentView: View { -// @State var isOn = false -// //The better route is to have a separate variable to control the animations -// // This prevents unpleasant side-effects. -// @State private var animate = false -// -// var body: some View { -// VStack { -// Text(verbatim: "I don't change.") -// .padding() -// Button("Press me, I do change") { -// isOn.toggle() -// animate = false -// // Because .opacity is animated, we need to switch it -// // back so the button shows. -// DispatchQueue.main.asyncAfter(deadline: .now() + 2) { -// animate = true -// } -// } -// // In this case I chose to animate .opacity -// .opacity(animate ? 1 : 0) -// .animation(.easeIn, value: animate) -// .frame(width: 300, height: 400) -// // If you want the button to animate when the view appears, you need to change the value -// .onAppear { animate = true } -// } -// } -//} -//fileprivate struct ContentView_Previews: PreviewProvider { -// static var previews: some View { -// ContentView() -// } -//} #endif diff --git a/TalerWallet1/Views/Settings/SettingsItem.swift b/TalerWallet1/Views/Settings/SettingsItem.swift index 76220e0..3524038 100644 --- a/TalerWallet1/Views/Settings/SettingsItem.swift +++ b/TalerWallet1/Views/Settings/SettingsItem.swift @@ -131,7 +131,7 @@ struct SettingsSpeaker: View { HStack { Text(name) .accessibilityFont(.title2) - Text(" ") + Text(verbatim: " ") .accessibilityFont(.largeTitle) Spacer() Image(systemName: image.0) diff --git a/TalerWallet1/Views/Transactions/TransactionDetailView.swift b/TalerWallet1/Views/Transactions/TransactionDetailView.swift index 2da1d91..440818c 100644 --- a/TalerWallet1/Views/Transactions/TransactionDetailView.swift +++ b/TalerWallet1/Views/Transactions/TransactionDetailView.swift @@ -196,7 +196,8 @@ struct TransactionDetailView: View { Group { switch transaction { case .dummy(_): - Text("") + let title = "" + Text(title) .accessibilityFont(.body) case .withdrawal(let withdrawalTransaction): let details = withdrawalTransaction.details -- cgit v1.2.3