Show Monero accounts as a stack of cards you can swipe through

This commit is contained in:
2026-10-07 21:27:57 +08:00
parent 4fa1584dfc
commit 7e739e1b77
2 changed files with 120 additions and 55 deletions
+5 -55
View File
@@ -94,7 +94,6 @@ struct HomeView: View {
@State private var showDeleteConfirm = false
@State private var selectedTransaction: TransactionRecord?
@State private var showSettings = false
@State private var activeAccount = 0
@State private var qrAddress: AddressQR?
var body: some View {
@@ -196,15 +195,11 @@ struct HomeView: View {
}
if model.chain == .xmr, !model.moneroAccounts.isEmpty {
// Cake Wallet style: one card per account, swiped horizontally.
TabView(selection: $activeAccount) {
ForEach(model.moneroAccounts) { account in
moneroAccountCard(account)
.tag(account.index)
}
}
.tabViewStyle(.page(indexDisplayMode: .always))
.frame(height: 208)
// Cake Wallet style: a deck of account cards, drag the front card
// away to bring the next one up.
AccountStack(accounts: model.moneroAccounts,
fiat: { model.fiatValue(of: $0, chain: .xmr) },
onQR: { qrAddress = AddressQR(title: $0.title, address: $0.address) })
} else {
VStack(alignment: .leading, spacing: 4) {
Text("Balance")
@@ -302,51 +297,6 @@ struct HomeView: View {
}
}
private func moneroAccountCard(_ account: MoneroAccount) -> some View {
VStack(alignment: .leading, spacing: 10) {
HStack {
Text(account.title)
.font(.system(size: 13, weight: .semibold))
.foregroundStyle(Theme.muted)
Spacer()
Text("Account \(account.index + 1) of \(model.moneroAccounts.count)")
.font(.system(size: 11))
.foregroundStyle(Theme.muted)
}
VStack(alignment: .leading, spacing: 3) {
Text("\(account.balance) XMR")
.font(.system(size: 26, weight: .bold, design: .rounded))
.foregroundStyle(Theme.text)
if let fiat = model.fiatValue(of: account.balance, chain: .xmr) {
Text(fiat)
.font(.system(size: 12, weight: .medium))
.foregroundStyle(Theme.muted)
}
if account.unlocked != account.balance {
Text("\(account.unlocked) XMR unlocked")
.font(.system(size: 11))
.foregroundStyle(Theme.muted)
}
}
HStack(spacing: 8) {
AddressRow(address: account.address)
Button {
qrAddress = AddressQR(title: account.title, address: account.address)
} label: {
Image(systemName: "qrcode")
.font(.system(size: 13, weight: .semibold))
.foregroundStyle(Theme.accent)
.frame(width: 36, height: 36)
.background(Theme.surfaceAlt)
.clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous))
}
}
}
.padding(.bottom, 18)
}
private var moneroUnavailableCard: some View {
VStack(spacing: 14) {
ChainPicker(selection: Binding(get: { model.chain },