Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions BDKSwiftExampleWallet/Model/BalanceDisplayFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ enum BalanceDisplayFormat: String, CaseIterable, Codable {
case bitcoinSats = "bitcoinSats"
case bitcoin = "btc"
case sats = "sats"
case bip21q = "bip21q"
// case bip21q = "bip21q"
case fiat = "usd"
case bip177 = "bip177"

var displayText: String {
switch self {
case .sats, .bitcoinSats: return "sats"
case .bitcoin, .bip177: return ""
case .bip21q: return "₿"
// case .bip21q: return "₿"
case .fiat: return "USD"
}
}
Expand Down
1 change: 0 additions & 1 deletion BDKSwiftExampleWallet/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@
}
},
"%llu sats" : {
"extractionState" : "stale",
"localizations" : {
"fr" : {
"stringUnit" : {
Expand Down
38 changes: 32 additions & 6 deletions BDKSwiftExampleWallet/View/Home/BalanceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct BalanceView: View {
removal: .move(edge: .trailing).combined(with: .opacity)
)
)
.opacity(format == .sats || format == .bip21q ? 0 : 1)
.opacity(format == .sats ? 0 : 1)
.id("symbol-\(format)")
.animation(.spring(response: 0.3, dampingFraction: 0.7), value: format)
}
Expand All @@ -44,8 +44,6 @@ struct BalanceView: View {
return String(format: "%.8f", Double(balance) / 100_000_000)
case .bitcoinSats:
return balance.formattedSatoshis()
case .bip21q:
return balance.formatted(.number)
case .fiat:
return satsPrice.formatted(.number.precision(.fractionLength(2)))
case .bip177:
Expand Down Expand Up @@ -102,7 +100,7 @@ struct BalanceView: View {
private func buildBalance() -> some View {
VStack(spacing: 10) {
HStack(spacing: 15) {
if format != .sats && format != .bip21q {
if format != .sats {
currencySymbol
}
balanceText
Expand All @@ -120,9 +118,37 @@ struct BalanceView: View {
}

#if DEBUG
#Preview {
#Preview("bip177") {
BalanceView(
format: .bip177,
balance: 5000,
fiatPrice: 89000
)
}
#Preview("bitcoin") {
BalanceView(
format: .bitcoin,
balance: 5000,
fiatPrice: 89000
)
}
#Preview("sats") {
BalanceView(
format: .sats,
balance: 5000,
fiatPrice: 89000
)
}
#Preview("bitcoinSats") {
BalanceView(
format: .bitcoinSats,
balance: 5000,
fiatPrice: 89000
)
}
#Preview("fiat") {
BalanceView(
format: .bip21q,
format: .fiat,
balance: 5000,
fiatPrice: 89000
)
Expand Down