Compare commits
2 Commits
main
...
format-rec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46b3082284 | ||
|
|
794732fed5 |
@ -1,4 +1,5 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
// MARK: - Denomination
|
||||
|
||||
@ -57,6 +58,29 @@ extension String {
|
||||
guard count > leading + trailing + 3 else { return self }
|
||||
return "\(prefix(leading))...\(suffix(trailing))"
|
||||
}
|
||||
|
||||
/// Build a styled Text view with space-separated 4-character chunks,
|
||||
/// alternating between primary and secondary text colors.
|
||||
func chunkedAddressText(font: Font = .hbMono(13)) -> Text {
|
||||
var chunks: [String] = []
|
||||
var current = ""
|
||||
for (i, char) in enumerated() {
|
||||
if i > 0, i % 4 == 0 {
|
||||
chunks.append(current)
|
||||
current = ""
|
||||
}
|
||||
current.append(char)
|
||||
}
|
||||
if !current.isEmpty { chunks.append(current) }
|
||||
|
||||
var result = Text("")
|
||||
for (i, chunk) in chunks.enumerated() {
|
||||
if i > 0 { result = result + Text(" ") }
|
||||
let color: Color = i % 2 == 0 ? .hbTextPrimary : .hbTextSecondary
|
||||
result = result + Text(chunk).font(font).foregroundColor(color)
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
extension Date {
|
||||
|
||||
@ -26,9 +26,7 @@ struct AddressDetailView: View {
|
||||
.font(.hbLabel())
|
||||
.foregroundStyle(Color.hbTextSecondary)
|
||||
|
||||
Text(address)
|
||||
.font(.hbMono(13))
|
||||
.foregroundStyle(Color.hbTextPrimary)
|
||||
address.chunkedAddressText()
|
||||
.multilineTextAlignment(.center)
|
||||
.padding(.horizontal, 32)
|
||||
.textSelection(.enabled)
|
||||
|
||||
@ -37,9 +37,7 @@ struct ReceiveView: View {
|
||||
.font(.hbLabel())
|
||||
.foregroundStyle(Color.hbTextSecondary)
|
||||
|
||||
Text(viewModel.currentAddress)
|
||||
.font(.hbMono(13))
|
||||
.foregroundStyle(Color.hbTextPrimary)
|
||||
viewModel.currentAddress.chunkedAddressText()
|
||||
.multilineTextAlignment(.center)
|
||||
.padding(.horizontal, 32)
|
||||
.textSelection(.enabled)
|
||||
|
||||
@ -338,17 +338,11 @@ private struct PSBTReviewCard: View {
|
||||
ForEach(Array(viewModel.recipients.enumerated()), id: \.element.id) { index, recipient in
|
||||
if viewModel.recipients.count > 1 {
|
||||
ReviewItem(label: "Recipient \(index + 1)") {
|
||||
Text(recipient.address)
|
||||
.font(.hbMono(12))
|
||||
.foregroundStyle(Color.hbTextPrimary)
|
||||
.lineLimit(2)
|
||||
recipient.address.chunkedAddressText(font: .hbMono(12))
|
||||
}
|
||||
} else {
|
||||
ReviewItem(label: "To") {
|
||||
Text(recipient.address)
|
||||
.font(.hbMono(12))
|
||||
.foregroundStyle(Color.hbTextPrimary)
|
||||
.lineLimit(2)
|
||||
recipient.address.chunkedAddressText(font: .hbMono(12))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -24,17 +24,11 @@ struct SendReviewView: View {
|
||||
ForEach(Array(viewModel.recipients.enumerated()), id: \.element.id) { index, recipient in
|
||||
if viewModel.recipients.count > 1 {
|
||||
ReviewItem(label: "Recipient \(index + 1)") {
|
||||
Text(recipient.address)
|
||||
.font(.hbMono(12))
|
||||
.foregroundStyle(Color.hbTextPrimary)
|
||||
.lineLimit(2)
|
||||
recipient.address.chunkedAddressText(font: .hbMono(12))
|
||||
}
|
||||
} else {
|
||||
ReviewItem(label: "To") {
|
||||
Text(recipient.address)
|
||||
.font(.hbMono(12))
|
||||
.foregroundStyle(Color.hbTextPrimary)
|
||||
.lineLimit(2)
|
||||
recipient.address.chunkedAddressText(font: .hbMono(12))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -110,9 +110,7 @@ struct UTXODetailView: View {
|
||||
.font(.hbMono(12))
|
||||
.foregroundStyle(Color.hbTextPrimary)
|
||||
} else {
|
||||
Text(address)
|
||||
.font(.hbMono(12))
|
||||
.foregroundStyle(Color.hbTextPrimary)
|
||||
address.chunkedAddressText(font: .hbMono(12))
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,9 +162,7 @@ struct WalletVerifyView: View {
|
||||
.clipShape(RoundedRectangle(cornerRadius: 8))
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
Text(viewModel.firstReceiveAddress)
|
||||
.font(.hbMono(12))
|
||||
.foregroundStyle(Color.hbTextPrimary)
|
||||
viewModel.firstReceiveAddress.chunkedAddressText(font: .hbMono(12))
|
||||
.multilineTextAlignment(.center)
|
||||
.frame(maxWidth: .infinity)
|
||||
.textSelection(.enabled)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user