Show full transaction details for Monero and XRP

This commit is contained in:
2026-09-20 00:43:09 +08:00
parent caca4321cc
commit 021672b47c
7 changed files with 228 additions and 13 deletions
+12 -1
View File
@@ -7,6 +7,7 @@ struct DashboardView: View {
@State private var showSeed = false
@State private var revealedSeed: String?
@State private var seedError: String?
@State private var selectedTransaction: TransactionRecord?
var body: some View {
VStack(alignment: .leading, spacing: 18) {
@@ -64,7 +65,12 @@ struct DashboardView: View {
.font(.system(size: 13, weight: .semibold))
.foregroundStyle(Theme.muted)
ForEach(model.transactions) { record in
TransactionRow(record: record, symbol: model.symbol)
Button {
selectedTransaction = record
} label: {
TransactionRow(record: record, symbol: model.symbol)
}
.buttonStyle(.plain)
if record.id != model.transactions.last?.id {
Divider().overlay(Theme.border)
}
@@ -96,6 +102,11 @@ struct DashboardView: View {
MessageBanner(message: seedError, isError: true)
}
}
.sheet(item: $selectedTransaction) { record in
TransactionDetailView(record: record,
symbol: model.symbol,
chain: model.chain) { selectedTransaction = nil }
}
.sheet(isPresented: $showSeed) {
if let revealedSeed {
SeedRevealView(seed: revealedSeed, symbol: model.symbol) { showSeed = false }
+12 -1
View File
@@ -71,6 +71,7 @@ struct HomeView: View {
@EnvironmentObject private var model: AppModel
@Binding var route: Route
@State private var showDeleteConfirm = false
@State private var selectedTransaction: TransactionRecord?
var body: some View {
VStack(spacing: 18) {
@@ -91,6 +92,11 @@ struct HomeView: View {
MessageBanner(message: message, isError: false)
}
}
.sheet(item: $selectedTransaction) { record in
TransactionDetailView(record: record,
symbol: model.symbol,
chain: model.chain) { selectedTransaction = nil }
}
.confirmationDialog("Delete this wallet?",
isPresented: $showDeleteConfirm,
titleVisibility: .visible) {
@@ -203,7 +209,12 @@ struct HomeView: View {
.font(.system(size: 13, weight: .semibold))
.foregroundStyle(Theme.muted)
ForEach(model.transactions) { record in
TransactionRow(record: record, symbol: model.symbol)
Button {
selectedTransaction = record
} label: {
TransactionRow(record: record, symbol: model.symbol)
}
.buttonStyle(.plain)
if record.id != model.transactions.last?.id {
Divider().overlay(Theme.border)
}
@@ -0,0 +1,147 @@
import SwiftUI
/// Full detail for one transaction. Monero and XRP fill different fields, so
/// rows are included only when the wallet knows the value.
struct TransactionDetailView: View {
var record: TransactionRecord
var symbol: String
var chain: Chain
var onDone: () -> Void
private var dateFormatter: DateFormatter {
let formatter = DateFormatter()
formatter.dateStyle = .medium
formatter.timeStyle = .medium
return formatter
}
/// A Monero incoming transfer only reveals the wallet's own receiving
/// address (the sender is hidden), so it is not labelled "From".
private var counterpartyLabel: String {
if chain == .xmr, record.direction == .incoming { return "Received at" }
return record.direction == .incoming ? "From" : "To"
}
private var statusText: String {
if record.direction == .incoming {
if let confirmations = record.confirmations, confirmations > 0 {
return "Confirmed · \(confirmations) confirmation\(confirmations == 1 ? "" : "s")"
}
return record.confirmed ? "Confirmed" : "Waiting for confirmation"
}
if let confirmations = record.confirmations, confirmations > 0 {
return "Confirmed · \(confirmations) confirmation\(confirmations == 1 ? "" : "s")"
}
return record.confirmed ? "Confirmed" : "Pending"
}
var body: some View {
ZStack {
Theme.background.ignoresSafeArea()
ScrollView {
VStack(alignment: .leading, spacing: 18) {
VStack(alignment: .leading, spacing: 8) {
HStack(spacing: 8) {
Image(systemName: record.direction == .incoming ? "arrow.down.left" : "arrow.up.right")
.font(.system(size: 14, weight: .bold))
.foregroundStyle(record.direction == .incoming ? Theme.success : Theme.accent)
Text(record.direction == .incoming ? "Received" : "Sent")
.font(.system(size: 14, weight: .semibold))
.foregroundStyle(Theme.text)
}
Text("\(record.direction == .incoming ? "+" : "-")\(record.amount) \(symbol)")
.font(.system(size: 30, weight: .bold, design: .rounded))
.foregroundStyle(Theme.text)
Text(statusText)
.font(.system(size: 12))
.foregroundStyle(Theme.muted)
}
Card {
VStack(alignment: .leading, spacing: 12) {
if let timestamp = record.timestamp {
DetailRow(label: "Date", value: dateFormatter.string(from: timestamp))
}
if let fee = record.fee, !fee.isEmpty, record.direction == .outgoing {
DetailRow(label: "Network fee", value: "\(fee) \(symbol)")
}
if let counterparty = record.counterparty, !counterparty.isEmpty {
DetailRow(label: counterpartyLabel, value: counterparty, monospaced: true, copyable: true)
}
if let tag = record.tag {
DetailRow(label: "Destination tag", value: String(tag))
}
if let height = record.height ?? record.ledgerIndex {
DetailRow(label: chain == .xmr ? "Block height" : "Ledger index", value: String(height))
}
if let confirmations = record.confirmations {
DetailRow(label: "Confirmations", value: String(confirmations))
}
if let accountIndex = record.accountIndex {
DetailRow(label: "Account", value: accountIndex == 0 ? "Primary (0)" : "Account \(accountIndex + 1) (\(accountIndex))")
}
if let subaddressIndex = record.subaddressIndex {
DetailRow(label: "Address index", value: "\(subaddressIndex)")
}
if let sequence = record.sequence {
DetailRow(label: "Sequence", value: String(sequence))
}
if let paymentId = record.paymentId {
DetailRow(label: "Payment ID", value: paymentId, monospaced: true, copyable: true)
}
if let weight = record.weight {
DetailRow(label: "Weight", value: "\(weight) bytes")
}
if let note = record.note {
DetailRow(label: "Note", value: note)
}
DetailRow(label: chain == .xmr ? "Transaction ID" : "Ledger hash",
value: record.id,
monospaced: true,
copyable: true)
}
}
PrimaryButton(title: "Done", action: onDone)
}
.padding(20)
}
}
.preferredColorScheme(.dark)
}
}
struct DetailRow: View {
var label: String
var value: String
var monospaced = false
var copyable = false
@State private var copied = false
var body: some View {
HStack(alignment: .top, spacing: 12) {
Text(label)
.font(.system(size: 12))
.foregroundStyle(Theme.muted)
.frame(width: 108, alignment: .leading)
Text(value)
.font(.system(size: 12, design: monospaced ? .monospaced : .default))
.foregroundStyle(Theme.text)
.textSelection(.enabled)
.frame(maxWidth: .infinity, alignment: .leading)
.fixedSize(horizontal: false, vertical: true)
if copyable {
Button {
UIPasteboard.general.string = value
copied = true
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { copied = false }
} label: {
Image(systemName: copied ? "checkmark" : "doc.on.doc")
.font(.system(size: 12, weight: .semibold))
.foregroundStyle(Theme.accent)
}
}
}
}
}