From dea5b19621f3dcfa55ce441099935091cf73eb30 Mon Sep 17 00:00:00 2001 From: Lukas Korba Date: Wed, 8 Mar 2023 19:50:09 +0100 Subject: [PATCH] [#628] TAZ vs ZEC builds (#637) - all instances of hardcoded ZEC are now dynamic depending on a target - debug menu fixed --- .../BalanceBreakdownView.swift | 24 +++++-- secant/Features/Home/HomeView.swift | 12 ++-- .../Views/CreateTransactionView.swift | 2 +- .../Views/TransactionSendingView.swift | 2 +- .../Views/TransactionDetailView.swift | 8 +-- .../Views/TransactionRowView.swift | 2 +- secant/Resources/Generated/L10n.swift | 72 ++++++++++--------- secant/Resources/Localizable.strings | 24 +++---- secant/SecantApp.swift | 10 +++ .../TransactionAmountTextField.swift | 2 +- 10 files changed, 93 insertions(+), 65 deletions(-) diff --git a/secant/Features/BalanceBreakdown/BalanceBreakdownView.swift b/secant/Features/BalanceBreakdown/BalanceBreakdownView.swift index 9b8d41b..76a0183 100644 --- a/secant/Features/BalanceBreakdown/BalanceBreakdownView.swift +++ b/secant/Features/BalanceBreakdown/BalanceBreakdownView.swift @@ -24,7 +24,7 @@ struct BalanceBreakdownView: View { .padding(.horizontal, 50) VStack(alignment: .leading, spacing: 10) { balanceView( - title: L10n.BalanceBreakdown.shieldedZec, + title: L10n.BalanceBreakdown.shieldedZec(TargetConstants.tokenName), viewStore.shieldedBalance.data.total, titleColor: Asset.Colors.Mfp.fontDark.color ) @@ -37,8 +37,13 @@ struct BalanceBreakdownView: View { HStack { Spacer() - Text(L10n.BalanceBreakdown.autoShieldingThreshold(viewStore.autoShieldingThreshold.decimalString())) - .foregroundColor(Asset.Colors.Mfp.fontLight.color) + Text( + L10n.BalanceBreakdown.autoShieldingThreshold( + viewStore.autoShieldingThreshold.decimalString(), + TargetConstants.tokenName + ) + ) + .foregroundColor(Asset.Colors.Mfp.fontLight.color) } .padding(.horizontal, 50) } @@ -58,10 +63,15 @@ extension BalanceBreakdownView { VStack(alignment: .leading) { Text("\(title)") .foregroundColor(titleColor) - Text(L10n.balance(balance.decimalString(formatter: NumberFormatter.zcashNumberFormatter8FractionDigits))) - .font(.system(size: 32)) - .fontWeight(.bold) - .foregroundColor(Asset.Colors.Mfp.fontDark.color) + Text( + L10n.balance( + balance.decimalString(formatter: NumberFormatter.zcashNumberFormatter8FractionDigits), + TargetConstants.tokenName + ) + ) + .font(.system(size: 32)) + .fontWeight(.bold) + .foregroundColor(Asset.Colors.Mfp.fontDark.color) } } } diff --git a/secant/Features/Home/HomeView.swift b/secant/Features/Home/HomeView.swift index 86d2834..d5f5a86 100644 --- a/secant/Features/Home/HomeView.swift +++ b/secant/Features/Home/HomeView.swift @@ -78,7 +78,7 @@ extension HomeView { Button(action: { viewStore.send(.updateDestination(.send)) }, label: { - Text(L10n.Home.sendZec) + Text(L10n.Home.sendZec(TargetConstants.tokenName)) }) .activeButtonStyle .padding(.bottom, 30) @@ -90,7 +90,7 @@ extension HomeView { Button(action: { viewStore.send(.updateDestination(.profile)) }, label: { - Text(L10n.Home.receiveZec) + Text(L10n.Home.receiveZec(TargetConstants.tokenName)) }) .activeButtonStyle .padding(.bottom, 30) @@ -101,12 +101,9 @@ extension HomeView { Button { viewStore.send(.updateDestination(.balanceBreakdown)) } label: { - Text(L10n.balance(viewStore.shieldedBalance.data.total.decimalString())) + Text(L10n.balance(viewStore.shieldedBalance.data.total.decimalString(), TargetConstants.tokenName)) .font(.system(size: 32)) .fontWeight(.bold) - .accessDebugMenuWithHiddenGesture { - viewStore.send(.debugMenuStartup) - } } if viewStore.walletConfig.isEnabled(.showFiatConversion) { @@ -115,6 +112,9 @@ extension HomeView { } Text(viewStore.synchronizerStatusSnapshot.message) + .accessDebugMenuWithHiddenGesture { + viewStore.send(.debugMenuStartup) + } } .foregroundColor(Asset.Colors.Mfp.primary.color) } diff --git a/secant/Features/SendFlow/Views/CreateTransactionView.swift b/secant/Features/SendFlow/Views/CreateTransactionView.swift index 7ea4017..58e5331 100644 --- a/secant/Features/SendFlow/Views/CreateTransactionView.swift +++ b/secant/Features/SendFlow/Views/CreateTransactionView.swift @@ -10,7 +10,7 @@ struct CreateTransaction: View { return WithViewStore(store) { viewStore in VStack { VStack(spacing: 0) { - Text(L10n.Balance.available(viewStore.shieldedBalance.data.total.decimalString())) + Text(L10n.Balance.available(viewStore.shieldedBalance.data.total.decimalString(), TargetConstants.tokenName)) .font(.system(size: 32)) .fontWeight(.bold) Text(L10n.Send.fundsInfo) diff --git a/secant/Features/SendFlow/Views/TransactionSendingView.swift b/secant/Features/SendFlow/Views/TransactionSendingView.swift index 55af0ef..0a389d4 100644 --- a/secant/Features/SendFlow/Views/TransactionSendingView.swift +++ b/secant/Features/SendFlow/Views/TransactionSendingView.swift @@ -16,7 +16,7 @@ struct TransactionSendingView: View { ZStack { VStack(alignment: .center, spacing: 40) { Spacer() - Text(L10n.Send.sendingTo(viewStore.amount.decimalString())) + Text(L10n.Send.sendingTo(viewStore.amount.decimalString(), TargetConstants.tokenName)) .foregroundColor(Asset.Colors.Mfp.fontDark.color) Text(viewStore.address) diff --git a/secant/Features/WalletEventsFlow/Views/TransactionDetailView.swift b/secant/Features/WalletEventsFlow/Views/TransactionDetailView.swift index c48bbba..64d389f 100644 --- a/secant/Features/WalletEventsFlow/Views/TransactionDetailView.swift +++ b/secant/Features/WalletEventsFlow/Views/TransactionDetailView.swift @@ -23,23 +23,23 @@ struct TransactionDetailView: View { VStack(alignment: .leading) { switch transaction.status { case .paid: - Text(L10n.Transaction.youSent(transaction.zecAmount.decimalString())) + Text(L10n.Transaction.youSent(transaction.zecAmount.decimalString(), TargetConstants.tokenName)) .padding() address(mark: .inactive, viewStore: viewStore) memo(transaction, viewStore, mark: .highlight) case .pending: - Text(L10n.Transaction.youAreSending(transaction.zecAmount.decimalString())) + Text(L10n.Transaction.youAreSending(transaction.zecAmount.decimalString(), TargetConstants.tokenName)) .padding() address(mark: .inactive, viewStore: viewStore) memo(transaction, viewStore, mark: .highlight) case .received: - Text(L10n.Transaction.youReceived(transaction.zecAmount.decimalString())) + Text(L10n.Transaction.youReceived(transaction.zecAmount.decimalString(), TargetConstants.tokenName)) .padding() address(mark: .inactive, viewStore: viewStore) memo(transaction, viewStore, mark: .highlight) case .failed: - Text(L10n.Transaction.youDidNotSent(transaction.zecAmount.decimalString())) + Text(L10n.Transaction.youDidNotSent(transaction.zecAmount.decimalString(), TargetConstants.tokenName)) .padding() address(mark: .inactive, viewStore: viewStore) memo(transaction, viewStore, mark: .highlight) diff --git a/secant/Features/WalletEventsFlow/Views/TransactionRowView.swift b/secant/Features/WalletEventsFlow/Views/TransactionRowView.swift index e18d46e..2dd3834 100644 --- a/secant/Features/WalletEventsFlow/Views/TransactionRowView.swift +++ b/secant/Features/WalletEventsFlow/Views/TransactionRowView.swift @@ -33,7 +33,7 @@ struct TransactionRowView: View { Text(transaction.unarySymbol) .font(.system(size: 16)) .foregroundColor(Asset.Colors.Mfp.fontDark.color) - + Text(L10n.balance(transaction.zecAmount.decimalString())) + + Text(L10n.balance(transaction.zecAmount.decimalString(), TargetConstants.tokenName)) .font(.system(size: 16)) .foregroundColor(Asset.Colors.Mfp.fontDark.color) } diff --git a/secant/Resources/Generated/L10n.swift b/secant/Resources/Generated/L10n.swift index b3f93a1..01f53da 100644 --- a/secant/Resources/Generated/L10n.swift +++ b/secant/Resources/Generated/L10n.swift @@ -10,9 +10,9 @@ import Foundation // swiftlint:disable explicit_type_interface function_parameter_count identifier_name line_length // swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces internal enum L10n { - /// %@ ZEC - internal static func balance(_ p1: Any) -> String { - return L10n.tr("Localizable", "balance", String(describing: p1), fallback: "%@ ZEC") + /// %@ %@ + internal static func balance(_ p1: Any, _ p2: Any) -> String { + return L10n.tr("Localizable", "balance", String(describing: p1), String(describing: p2), fallback: "%@ %@") } /// QR Code for %@ internal static func qrCodeFor(_ p1: Any) -> String { @@ -35,22 +35,24 @@ internal enum L10n { } } internal enum Balance { - /// %@ ZEC Available - internal static func available(_ p1: Any) -> String { - return L10n.tr("Localizable", "balance.available", String(describing: p1), fallback: "%@ ZEC Available") + /// %@ %@ Available + internal static func available(_ p1: Any, _ p2: Any) -> String { + return L10n.tr("Localizable", "balance.available", String(describing: p1), String(describing: p2), fallback: "%@ %@ Available") } } internal enum BalanceBreakdown { - /// Auto Shielding Threshold: %@ ZEC - internal static func autoShieldingThreshold(_ p1: Any) -> String { - return L10n.tr("Localizable", "balanceBreakdown.autoShieldingThreshold", String(describing: p1), fallback: "Auto Shielding Threshold: %@ ZEC") + /// Auto Shielding Threshold: %@ %@ + internal static func autoShieldingThreshold(_ p1: Any, _ p2: Any) -> String { + return L10n.tr("Localizable", "balanceBreakdown.autoShieldingThreshold", String(describing: p1), String(describing: p2), fallback: "Auto Shielding Threshold: %@ %@") } /// Block: %@ internal static func blockId(_ p1: Any) -> String { return L10n.tr("Localizable", "balanceBreakdown.blockId", String(describing: p1), fallback: "Block: %@") } - /// SHIELDED ZEC (SPENDABLE) - internal static let shieldedZec = L10n.tr("Localizable", "balanceBreakdown.shieldedZec", fallback: "SHIELDED ZEC (SPENDABLE)") + /// SHIELDED %@ (SPENDABLE) + internal static func shieldedZec(_ p1: Any) -> String { + return L10n.tr("Localizable", "balanceBreakdown.shieldedZec", String(describing: p1), fallback: "SHIELDED %@ (SPENDABLE)") + } /// TOTAL BALANCE internal static let totalBalance = L10n.tr("Localizable", "balanceBreakdown.totalBalance", fallback: "TOTAL BALANCE") /// TRANSPARENT BALANCE @@ -86,8 +88,10 @@ internal enum L10n { internal enum TransactionAmount { /// Amount: internal static let amount = L10n.tr("Localizable", "field.transactionAmount.amount", fallback: "Amount:") - /// ZEC Amount - internal static let zecAmount = L10n.tr("Localizable", "field.transactionAmount.zecAmount", fallback: "ZEC Amount") + /// %@ Amount + internal static func zecAmount(_ p1: Any) -> String { + return L10n.tr("Localizable", "field.transactionAmount.zecAmount", String(describing: p1), fallback: "%@ Amount") + } } } internal enum General { @@ -121,10 +125,14 @@ internal enum L10n { internal static let yes = L10n.tr("Localizable", "general.yes", fallback: "Yes") } internal enum Home { - /// Receive ZEC - internal static let receiveZec = L10n.tr("Localizable", "home.receiveZec", fallback: "Receive ZEC") - /// Send ZEC - internal static let sendZec = L10n.tr("Localizable", "home.sendZec", fallback: "Send ZEC") + /// Receive %@ + internal static func receiveZec(_ p1: Any) -> String { + return L10n.tr("Localizable", "home.receiveZec", String(describing: p1), fallback: "Receive %@") + } + /// Send %@ + internal static func sendZec(_ p1: Any) -> String { + return L10n.tr("Localizable", "home.sendZec", String(describing: p1), fallback: "Send %@") + } /// Secant Wallet internal static let title = L10n.tr("Localizable", "home.title", fallback: "Secant Wallet") /// See transaction history @@ -426,9 +434,9 @@ internal enum L10n { } /// Write a private message here internal static let memoPlaceholder = L10n.tr("Localizable", "send.memoPlaceholder", fallback: "Write a private message here") - /// Sending %@ ZEC to - internal static func sendingTo(_ p1: Any) -> String { - return L10n.tr("Localizable", "send.sendingTo", String(describing: p1), fallback: "Sending %@ ZEC to") + /// Sending %@ %@ to + internal static func sendingTo(_ p1: Any, _ p2: Any) -> String { + return L10n.tr("Localizable", "send.sendingTo", String(describing: p1), String(describing: p2), fallback: "Sending %@ %@ to") } /// Sending transaction succeeded internal static let succeeded = L10n.tr("Localizable", "send.succeeded", fallback: "Sending transaction succeeded") @@ -560,21 +568,21 @@ internal enum L10n { internal static let unconfirmed = L10n.tr("Localizable", "transaction.unconfirmed", fallback: "unconfirmed") /// With memo: internal static let withMemo = L10n.tr("Localizable", "transaction.withMemo", fallback: "With memo:") - /// You are sending %@ ZEC - internal static func youAreSending(_ p1: Any) -> String { - return L10n.tr("Localizable", "transaction.youAreSending", String(describing: p1), fallback: "You are sending %@ ZEC") + /// You are sending %@ %@ + internal static func youAreSending(_ p1: Any, _ p2: Any) -> String { + return L10n.tr("Localizable", "transaction.youAreSending", String(describing: p1), String(describing: p2), fallback: "You are sending %@ %@") } - /// You DID NOT send %@ ZEC - internal static func youDidNotSent(_ p1: Any) -> String { - return L10n.tr("Localizable", "transaction.youDidNotSent", String(describing: p1), fallback: "You DID NOT send %@ ZEC") + /// You DID NOT send %@ %@ + internal static func youDidNotSent(_ p1: Any, _ p2: Any) -> String { + return L10n.tr("Localizable", "transaction.youDidNotSent", String(describing: p1), String(describing: p2), fallback: "You DID NOT send %@ %@") } - /// You received %@ ZEC - internal static func youReceived(_ p1: Any) -> String { - return L10n.tr("Localizable", "transaction.youReceived", String(describing: p1), fallback: "You received %@ ZEC") + /// You received %@ %@ + internal static func youReceived(_ p1: Any, _ p2: Any) -> String { + return L10n.tr("Localizable", "transaction.youReceived", String(describing: p1), String(describing: p2), fallback: "You received %@ %@") } - /// You sent %@ ZEC - internal static func youSent(_ p1: Any) -> String { - return L10n.tr("Localizable", "transaction.youSent", String(describing: p1), fallback: "You sent %@ ZEC") + /// You sent %@ %@ + internal static func youSent(_ p1: Any, _ p2: Any) -> String { + return L10n.tr("Localizable", "transaction.youSent", String(describing: p1), String(describing: p2), fallback: "You sent %@ %@") } } internal enum TransactionDetail { diff --git a/secant/Resources/Localizable.strings b/secant/Resources/Localizable.strings index d6cfacc..7a5768a 100644 --- a/secant/Resources/Localizable.strings +++ b/secant/Resources/Localizable.strings @@ -62,8 +62,8 @@ "importWallet.alert.failed.message" = "Error: %@"; // MARK: - Home Screen -"home.sendZec" = "Send ZEC"; -"home.receiveZec" = "Receive ZEC"; +"home.sendZec" = "Send %@"; +"home.receiveZec" = "Receive %@"; "home.transactionHistory" = "See transaction history"; "home.title" = "Secant Wallet"; @@ -81,10 +81,10 @@ // MARK: - Balance Breakdown "balanceBreakdown.blockId" = "Block: %@"; -"balanceBreakdown.shieldedZec" = "SHIELDED ZEC (SPENDABLE)"; +"balanceBreakdown.shieldedZec" = "SHIELDED %@ (SPENDABLE)"; "balanceBreakdown.transparentBalance" = "TRANSPARENT BALANCE"; "balanceBreakdown.totalBalance" = "TOTAL BALANCE"; -"balanceBreakdown.autoShieldingThreshold" = "Auto Shielding Threshold: %@ ZEC"; +"balanceBreakdown.autoShieldingThreshold" = "Auto Shielding Threshold: %@ %@"; // MARK: - Scan "scan.info" = "We will validate any Zcash URI and take you to the appropriate action."; @@ -98,7 +98,7 @@ "send.memoPlaceholder" = "Write a private message here"; "send.failed" = "Sending transaction failed"; "send.succeeded" = "Sending transaction succeeded"; -"send.sendingTo" = "Sending %@ ZEC to"; +"send.sendingTo" = "Sending %@ %@ to"; "send.amount" = "amount: %@"; "send.address" = " address: %@"; "send.memo" = " memo: %@"; @@ -131,10 +131,10 @@ "transaction.sending" = "Sending"; "transaction.received" = "Received"; "transaction.failed" = "Failed"; -"transaction.youSent" = "You sent %@ ZEC"; -"transaction.youAreSending" = "You are sending %@ ZEC"; -"transaction.youReceived" = "You received %@ ZEC"; -"transaction.youDidNotSent" = "You DID NOT send %@ ZEC"; +"transaction.youSent" = "You sent %@ %@"; +"transaction.youAreSending" = "You are sending %@ %@"; +"transaction.youReceived" = "You received %@ %@"; +"transaction.youDidNotSent" = "You DID NOT send %@ %@"; "transaction.pending" = "PENDING"; "transaction.confirmed" = "Confirmed"; "transaction.confirmedTimes" = "%@ times"; @@ -165,8 +165,8 @@ "general.cancel" = "Cancel"; "general.success" = "Success"; "general.unknown" = "Unknown"; -"balance" = "%@ ZEC"; -"balance.available" = "%@ ZEC Available"; +"balance" = "%@ %@"; +"balance.available" = "%@ %@ Available"; "qrCodeFor" = "QR Code for %@"; "general.dateNotAvailable" = "date not available"; @@ -244,5 +244,5 @@ "field.transactionAddress.validZcashAddress" = "Valid Zcash Address"; "field.transactionAddress.to" = "To:"; -"field.transactionAmount.zecAmount" = "ZEC Amount"; +"field.transactionAmount.zecAmount" = "%@ Amount"; "field.transactionAmount.amount" = "Amount:"; diff --git a/secant/SecantApp.swift b/secant/SecantApp.swift index d3a0a9a..e36c289 100644 --- a/secant/SecantApp.swift +++ b/secant/SecantApp.swift @@ -60,6 +60,16 @@ enum TargetConstants { return ZcashNetworkBuilder.network(for: .testnet) #else fatalError("SECANT_MAINNET or SECANT_TESTNET flags not defined on Swift Compiler custom flags of your build target.") +#endif + } + + static var tokenName: String { +#if SECANT_MAINNET + return "ZEC" +#elseif SECANT_TESTNET + return "TAZ" +#else + fatalError("SECANT_MAINNET or SECANT_TESTNET flags not defined on Swift Compiler custom flags of your build target.") #endif } } diff --git a/secant/UI Components/TextFields/TransactionAmount/TransactionAmountTextField.swift b/secant/UI Components/TextFields/TransactionAmount/TransactionAmountTextField.swift index b150500..f13406c 100644 --- a/secant/UI Components/TextFields/TransactionAmount/TransactionAmountTextField.swift +++ b/secant/UI Components/TextFields/TransactionAmount/TransactionAmountTextField.swift @@ -14,7 +14,7 @@ struct TransactionAmountTextField: View { var body: some View { VStack { SingleLineTextField( - placeholderText: L10n.Field.TransactionAmount.zecAmount, + placeholderText: L10n.Field.TransactionAmount.zecAmount(TargetConstants.tokenName), title: L10n.Field.TransactionAmount.amount, store: store.scope( state: \.textFieldState,