// An ACCOUNT as its BANK CARD, the balance first (owner, 30 Oct 2026: "the // bank statement should mainly have the balance; maybe this month in and // out"; the ledger-card picture `objects-2/money/5-ledger-card`): a buff // account card of stiff stock with a red signal clip on its top edge and a // punched hole at its foot, lying bare on the money's pink terrazzo // (`FaceGround.terrazzo`). The card, its green ruling (a balance panel, a band of // two cells for the month's in and out, the column heads Date, Particulars, // Dr, Cr, Balance and six rows), the clip and their shadows are PAINTED // (`Media.xcassets`, cut and imported by `scripts/import-money-materials.py`); // the face writes live only what the card decides: // // the bank (`subtitle`) in the card's green print at its head; // the account's name (`title`) and masked number (`mask`) typed at the // top of the panel, two lines at most; // the BALANCE (`amount`) typed large in the panel, "Rs" and two places: // the one thing the card is about. // // The core carries this month's recent postings in `rows`, including the // Worker's stored balance after each posting. The face draws those words. // A tap on the screen's sides cuts to the next card (`FaceStep.cut`). Every // word but the card's print (BALANCE, and the painted heads) is the core's. import CottonPaper import CottonValues import SwiftUI enum StatementFaceKnobs { // THE CARD, as painted (`statement-card`, 929 by 1486 pixels): its width // over its height, its shadow's reach as a share of its width, and its // ruling as shares of its height — the head band's double rule, the // balance panel's foot — measured off the painting by the cut (`cut.py` // beside the layers), so a repainted card owes new knobs. static let aspect: CGFloat = 929.0 / 1486.0 static let shadowReach: CGFloat = 0.0753 static let headRule: CGFloat = 0.1104 static let panelTop: CGFloat = 0.1165 static let panelFoot: CGFloat = 0.3666 /// The clip (`statement-tab`): its width over its height as painted, /// its shadow's reach, its width and its left edge as shares of the /// card's width, and how much of its height stands over the card's top. static let tabAspect: CGFloat = 300.0 / 140.0 static let tabShadow: CGFloat = 0.0533 static let tabWidth: CGFloat = 0.17 static let tabLeft: CGFloat = 0.7 static let tabOver: CGFloat = 0.42 /// The card in the card's room: the most of its height (the clip over /// it included) and width it takes. static let fillHeight: CGFloat = 0.97 static let fillWidth: CGFloat = 0.96 /// The writing's side margin, and the type, as shares of the card's width. static let side: CGFloat = 0.07 static let bankSize: CGFloat = 0.05 static let nameSize: CGFloat = 0.062 static let labelSize: CGFloat = 0.042 static let balanceSize: CGFloat = 0.125 } public struct AccountStatementFace: View { let card: DeckCard public init(card: DeckCard) { self.card = card } public var body: some View { let knobs = StatementFaceKnobs.self GeometryReader { box in let over = knobs.tabOver * knobs.tabWidth * knobs.aspect / knobs.tabAspect let height = min(box.size.height * knobs.fillHeight / (1 + over), box.size.width * knobs.fillWidth / knobs.aspect) let size = CGSize(width: height * knobs.aspect, height: height) StatementCard(card: card, size: size) .frame(width: size.width, height: size.height) .padding(.top, over * height) .frame(width: box.size.width, height: box.size.height) } } } private struct StatementCard: View { let card: DeckCard let size: CGSize var body: some View { let knobs = StatementFaceKnobs.self let w = size.width let h = size.height let tab = CGSize(width: knobs.tabWidth * w, height: knobs.tabWidth * w / knobs.tabAspect) ZStack(alignment: .topLeading) { MoneyPaper(name: "statement-card", size: size, reach: knobs.shadowReach, standIn: MoneyMaterial.card.colour, corner: 0.03) Group { head .frame(width: w - 2 * knobs.side * w, height: knobs.headRule * h, alignment: .leading) .placed(x: knobs.side * w) balance .frame(width: w - 2 * knobs.side * w, height: (knobs.panelFoot - knobs.panelTop) * h) .placed(x: knobs.side * w, y: knobs.panelTop * h) rows } .blendMode(.multiply) MoneyPaper(name: "statement-tab", size: tab, reach: knobs.tabShadow, standIn: MoneyMaterial.tab.colour, corner: 0.1) .offset(x: knobs.tabLeft * w, y: -knobs.tabOver * tab.height) } .frame(width: w, height: h, alignment: .topLeading) .accessibilityElement(children: .contain) .accessibilityIdentifier("statement") } private var rows: some View { // Column edges and row baselines follow the painted ruling. let edges: [CGFloat] = [0.046, 0.196, 0.492, 0.644, 0.785, 0.973] let slots = ["date", "narration", "debit", "credit", "balance"] return ZStack(alignment: .topLeading) { ForEach(Array(card.entries("rows").prefix(6).enumerated()), id: \.offset) { row, entry in ForEach(0.. 1 ? .trailing : .leading) .placed(x: size.width * (edges[column] + 0.006), y: size.height * (0.512 + CGFloat(row) * 0.0587)) } } } } .accessibilityIdentifier("statement-rows") } /// The bank in the card's green print, clear of the clip over the /// card's top edge: two lines at most. private var head: some View { let knobs = StatementFaceKnobs.self let w = size.width return ZStack(alignment: .leading) { if let bank = card.text("subtitle") { Text(bank.uppercased()) .font(CottonFonts.caslon(knobs.bankSize * w)) .tracking(0.2 * knobs.bankSize * w) .foregroundStyle(MoneyMaterial.ledgerPrint.colour) .lineLimit(2) .minimumScaleFactor(0.7) .frame(width: (knobs.tabLeft - knobs.side - 0.03) * w, alignment: .leading) .facePart(.subtitle) } } .padding(.top, 0.012 * size.height) } /// The account typed, its name and masked number, then the balance /// large under its printed head. private var balance: some View { let knobs = StatementFaceKnobs.self let w = size.width let typed = MoneyMaterial.posting.colour let account = [card.text("title"), card.text("mask")].compactMap { $0 }.joined(separator: " ") return VStack(alignment: .leading, spacing: 0) { if !account.isEmpty { Text(account) .font(CottonFonts.type(knobs.nameSize * w)) .foregroundStyle(typed) .lineLimit(2) .minimumScaleFactor(0.7) .frame(maxWidth: .infinity, alignment: .leading) .padding(.top, 0.022 * size.height) .accessibilityIdentifier("deck-title") .facePart(.title) } Text(StatementPrint.balance) .font(CottonFonts.caslon(knobs.labelSize * w)) .tracking(0.2 * knobs.labelSize * w) .foregroundStyle(MoneyMaterial.ledgerPrint.colour) .padding(.top, 0.03 * size.height) Spacer(minLength: 0) if let said = card.text("amount") { FittedLine(words: SaidAmount(said).map(MoneyReading.typed) ?? said, font: CottonFonts.type(knobs.balanceSize * w), ink: typed, alignment: .center, shrink: 0.45) .facePart(.amount) } Spacer(minLength: 0) } } } /// The account card's own print beside its painted heads. enum StatementPrint { static let balance = "BALANCE" } /// An account as its bank card, by its id beside the account's own face, /// and the accounts it is reviewed in: invented names only. public enum AccountStatementFaceCatalogue { public static let stock: FaceStock = .own public static let ground: FaceGround = .terrazzo public static let face = Face(id: "account.statement", specimens: [ Specimen("savings", savings), Specimen("new", new), Specimen("long-name", longName), ], steps: .cut) { card, _, _ in AccountStatementFace(card: card) } static func account(_ fields: [String: RecordValue]) -> DeckCard { DeckCard(face: "account.statement", corner: nil, pressing: false, pace: nil, plate: nil, fields: fields) } /// The reference's account. public static let savings = account([ "title": .text("Savings"), "subtitle": .text("Northern Bank"), "mask": .text("\u{00B7}\u{00B7}\u{00B7}1173"), "amount": .text("\u{20B9}1,24,500"), "rows": .list([ .object(["date": .text("4 Oct"), "narration": .text("Sample groceries"), "debit": .text("₹1,908"), "balance": .text("₹1,24,400")]), .object(["date": .text("5 Oct"), "narration": .text("Sample refund"), "credit": .text("₹100"), "balance": .text("₹1,24,500")]), ]), ]) /// An account just opened: nothing in it yet. public static let new = account([ "title": .text("Salary account"), "subtitle": .text("Northern Bank"), "mask": .text("\u{00B7}\u{00B7}\u{00B7}0482"), "amount": .text("\u{20B9}0"), ]) /// A long name and a crore figure with paise. public static let longName = account([ "title": .text("Household joint savings for the new house"), "subtitle": .text("Riverside Co-operative Bank"), "mask": .text("\u{00B7}\u{00B7}\u{00B7}5530"), "amount": .text("\u{20B9}1,16,01,625.50"), ]) }