Skip to content

Commit

Permalink
feat: bip21q
Browse files Browse the repository at this point in the history
  • Loading branch information
reez authored Feb 4, 2025
1 parent 11d73d4 commit 7802e55
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions BDKSwiftExampleWallet/Model/BalanceDisplayFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ enum BalanceDisplayFormat: String, CaseIterable, Codable {
case bitcoinSats = "bitcoinSats"
case bitcoin = "btc"
case sats = "sats"
case bip21q = "bip21q"
case fiat = "usd"

var displayText: String {
switch self {
case .sats, .bitcoinSats: return "sats"
case .bitcoin: return ""
case .bip21q: return ""
case .fiat: return "USD"
}
}
Expand Down
8 changes: 5 additions & 3 deletions BDKSwiftExampleWallet/View/WalletView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,12 @@ extension WalletView {
switch balanceFormat {
case .sats:
return viewModel.balanceTotal.formatted(.number)
case .bitcoinSats:
return viewModel.balanceTotal.formattedSatoshis()
case .bitcoin:
return String(format: "%.8f", Double(viewModel.balanceTotal) / 100_000_000)
case .bitcoinSats:
return viewModel.balanceTotal.formattedSatoshis()
case .bip21q:
return viewModel.balanceTotal.formatted(.number)
case .fiat:
return viewModel.satsPrice.formatted(.number.precision(.fractionLength(2)))
}
Expand All @@ -316,7 +318,7 @@ extension WalletView {
removal: .move(edge: .trailing).combined(with: .opacity)
)
)
.opacity(balanceFormat == .sats ? 0 : 1)
.opacity(balanceFormat == .sats || balanceFormat == .bip21q ? 0 : 1)
.id("symbol-\(balanceFormat)")
.animation(.spring(response: 0.3, dampingFraction: 0.7), value: balanceFormat)
}
Expand Down

0 comments on commit 7802e55

Please sign in to comment.