Show each address QR in a bottom drawer
This commit is contained in:
@@ -6,7 +6,7 @@ struct AccountsView: View {
|
||||
|
||||
@State private var error: String?
|
||||
@State private var busy = false
|
||||
@State private var expandedAddress: String?
|
||||
@State private var qrAddress: AddressQR?
|
||||
@State private var showAccountPrompt = false
|
||||
@State private var showSubaddressPrompt = false
|
||||
@State private var pendingLabel = ""
|
||||
@@ -37,6 +37,9 @@ struct AccountsView: View {
|
||||
}
|
||||
}
|
||||
.task(id: model.moneroReady) { await model.loadAccounts() }
|
||||
.sheet(item: $qrAddress) { item in
|
||||
AddressQRSheet(title: item.title, address: item.address) { qrAddress = nil }
|
||||
}
|
||||
.alert("Account name", isPresented: $showAccountPrompt) {
|
||||
TextField("e.g. Savings", text: $pendingLabel)
|
||||
Button("Create") { createAccount() }
|
||||
@@ -64,16 +67,14 @@ struct AccountsView: View {
|
||||
Spacer()
|
||||
}
|
||||
|
||||
addressRow(id: "\(account.index)/primary",
|
||||
title: "Primary address",
|
||||
addressRow(title: "Primary address",
|
||||
address: account.address,
|
||||
isUsed: true)
|
||||
|
||||
if !account.subaddresses.isEmpty {
|
||||
Divider().overlay(Theme.border)
|
||||
ForEach(account.subaddresses.filter { $0.index != 0 }) { subaddress in
|
||||
addressRow(id: subaddress.id,
|
||||
title: subaddress.label.isEmpty ? "Address \(subaddress.index)" : subaddress.label,
|
||||
addressRow(title: subaddress.label.isEmpty ? "Address \(subaddress.index)" : subaddress.label,
|
||||
address: subaddress.address,
|
||||
isUsed: subaddress.isUsed,
|
||||
balance: subaddress.balance)
|
||||
@@ -89,8 +90,10 @@ struct AccountsView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private func addressRow(id: String, title: String, address: String, isUsed: Bool, balance: String? = nil) -> some View {
|
||||
VStack(spacing: 10) {
|
||||
private func addressRow(title: String, address: String, isUsed: Bool, balance: String? = nil) -> some View {
|
||||
Button {
|
||||
qrAddress = AddressQR(title: title, address: address)
|
||||
} label: {
|
||||
HStack(spacing: 8) {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(title)
|
||||
@@ -108,31 +111,17 @@ struct AccountsView: View {
|
||||
}
|
||||
}
|
||||
Spacer(minLength: 6)
|
||||
Button {
|
||||
expandedAddress = expandedAddress == id ? nil : id
|
||||
} label: {
|
||||
Image(systemName: expandedAddress == id ? "xmark" : "qrcode")
|
||||
.font(.system(size: 14, weight: .semibold))
|
||||
.foregroundStyle(Theme.accent)
|
||||
.frame(width: 32, height: 32)
|
||||
.background(Theme.surfaceAlt)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous))
|
||||
}
|
||||
}
|
||||
|
||||
if expandedAddress == id {
|
||||
VStack(spacing: 10) {
|
||||
QRCodeView(text: address)
|
||||
.frame(maxWidth: 180)
|
||||
HStack(spacing: 8) {
|
||||
SecondaryButton(title: "Copy") {
|
||||
UIPasteboard.general.string = address
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
Image(systemName: "qrcode")
|
||||
.font(.system(size: 14, weight: .semibold))
|
||||
.foregroundStyle(Theme.accent)
|
||||
.frame(width: 32, height: 32)
|
||||
.background(Theme.surfaceAlt)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous))
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.disabled(address.isEmpty)
|
||||
}
|
||||
|
||||
private func createAccount() {
|
||||
|
||||
Reference in New Issue
Block a user