Skip to content
Transaction Rows preview
Rendered from the SwiftUI source on this page.

Transaction Rows

From syxUI — written for both platforms, not translated between them.

Finance transaction rows with amounts.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

TransactionRow.swift
// Transaction Rows · syxUI · https://syxui.dev/components/list-transaction
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let listGreen = Color(red: 0.20, green: 0.78, blue: 0.35)

extension View {
    func formaCard(_ pad: CGFloat = 18) -> some View {
        self.padding(pad)
            .background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: 20, style: .continuous))
            .overlay(RoundedRectangle(cornerRadius: 20, style: .continuous).stroke(Color.primary.opacity(0.06), lineWidth: 1))
            .shadow(color: .black.opacity(0.05), radius: 14, x: 0, y: 6)
    }
}

// Transaction row
struct TransactionRow: View {
    let rows: [(String, String, String, String, Color)] = [("cart.fill", "Whole Foods", "Groceries", "-$84.20", Color(red: 0.98, green: 0.55, blue: 0.10)), ("arrow.down.left", "Salary", "Deposit", "+$3,200", Color(red: 0.16, green: 0.66, blue: 0.40))]
    var body: some View {
        VStack(spacing: 0) {
            ForEach(Array(rows.enumerated()), id: \.offset) { i, r in
                HStack(spacing: 12) {
                    Image(systemName: r.0).font(.system(size: 15)).foregroundStyle(r.4).frame(width: 38, height: 38).background(r.4.opacity(0.12), in: Circle())
                    VStack(alignment: .leading, spacing: 2) { Text(r.1).font(.system(size: 15, weight: .medium)); Text(r.2).font(.system(size: 12)).foregroundStyle(.secondary) }
                    Spacer()
                    Text(r.3).font(.system(size: 15, weight: .semibold)).foregroundStyle(r.3.hasPrefix("+") ? listGreen : Color.primary)
                }.padding(.vertical, 9)
                if i < rows.count - 1 { Divider().padding(.leading, 50) }
            }
        }.formaCard(14).frame(width: 330)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17