46 lines
1.2 KiB
Swift
46 lines
1.2 KiB
Swift
import SwiftUI
|
|
|
|
struct AddressQR: Identifiable {
|
|
let id = UUID()
|
|
let title: String
|
|
let address: String
|
|
}
|
|
|
|
/// One address as a scannable QR, shown inside the shared bottom drawer.
|
|
struct AddressQRSheet: View {
|
|
var title: String
|
|
var address: String
|
|
var onDone: () -> Void
|
|
|
|
@State private var copied = false
|
|
|
|
var body: some View {
|
|
VStack(spacing: 16) {
|
|
Text(title)
|
|
.font(.system(size: 16, weight: .semibold))
|
|
.foregroundStyle(Theme.text)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
|
|
QRCodeView(text: address)
|
|
.frame(maxWidth: 220)
|
|
|
|
Text(address)
|
|
.font(.system(size: 12, design: .monospaced))
|
|
.foregroundStyle(Theme.muted)
|
|
.multilineTextAlignment(.center)
|
|
.lineLimit(4)
|
|
.truncationMode(.middle)
|
|
.textSelection(.enabled)
|
|
|
|
SecondaryButton(title: copied ? "Copied" : "Copy address") {
|
|
UIPasteboard.general.string = address
|
|
copied = true
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { copied = false }
|
|
}
|
|
|
|
PrimaryButton(title: "Done", action: onDone)
|
|
}
|
|
.padding(.horizontal, 22)
|
|
.preferredColorScheme(.dark)
|
|
}
|
|
} |