53 lines
1.4 KiB
Swift
53 lines
1.4 KiB
Swift
import SwiftUI
|
|
|
|
struct AddressQR: Identifiable {
|
|
let id = UUID()
|
|
let title: String
|
|
let address: String
|
|
}
|
|
|
|
/// Drawer that shows one address as a scannable QR, presented from the bottom
|
|
/// like the transaction detail sheet.
|
|
struct AddressQRSheet: View {
|
|
var title: String
|
|
var address: String
|
|
var onDone: () -> Void
|
|
|
|
@State private var copied = false
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
Theme.background.ignoresSafeArea()
|
|
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(22)
|
|
.frame(maxHeight: .infinity, alignment: .top)
|
|
}
|
|
.preferredColorScheme(.dark)
|
|
.presentationDetents([.medium, .large])
|
|
.presentationDragIndicator(.visible)
|
|
}
|
|
} |