// The GROUP face (a group deck: Money's By person, albums by artist): one// card per record a view's people place names, as the core deals it// (`records::card::deal_groups`). The person's photograph across the top, or// their initial ringed in pencil, as the person face draws it; the name// in the book serif; what the group comes to typed heavy ("₹1,800 between// you"); a hairline; then its latest lines, each its title with its amount// at the right and its day in pencil under it, and "+4" when there are more.// Every word is the core's (`DeckCard`).importCottonPaperimportCottonValuesimportSwiftUIenumGroupFaceKnobs {/// The photograph's share of the card's height: less than a person's,/// so three lines fit under it.staticlet photoShare: CGFloat = 0.36staticlet photoInset = EdgeInsets(top: 7, leading: 8, bottom: 0, trailing: 8)staticlet textInset: CGFloat = 25staticlet nameSize: CGFloat = 27staticlet netSize: CGFloat = 21staticlet lineSize: CGFloat = 14staticlet daySize: CGFloat = 11staticlet lineGap: CGFloat = 12}/// One of a group's lines, as the core said it through the card's places.structGroupLine: Equatable, Identifiable {let id: Intlet title: String?let amount: String?let date: String?/// The card's `lines`, in the core's order; a line with nothing to say/// is left out.staticfunc of(_ card: DeckCard) -> [GroupLine] {guardcase .list(let lines)? = card.fields["lines"] else { return [] }return lines.enumerated().compactMap { index, line inguardcase .object(let said) = line else { returnnil }let words = { (slot: String) in said[slot]?.text.flatMap { $0.isEmpty ? nil : $0 } }let found = GroupLine(id: index, title: words("title"), amount: words("amount") ?? words("price"), date: words("date"))return found.title == nil && found.amount == nil && found.date == nil ? nil : found } }}publicstructGroupFace<Photo: View>: View {let card: DeckCard/// The group's person's photograph filling its frame; nil draws the/// initials.let photo: Photo?publicinit(card: DeckCard, photo: Photo?) {self.card = cardself.photo = photo }privatevar net: [String] {guardcase .list(let said)? = card.fields["net"] else { return [] }return said.compactMap(\.text) }publicvar body: someView {GeometryReader { sheet in VStack(alignment: .leading, spacing: 0) {Group {iflet photo {MountedPrint(photo: photo) } else {InitialsMount(name: card.text("title") ?? "") } } .frame(height: sheet.size.height * GroupFaceKnobs.photoShare) .frame(maxWidth: .infinity) .padding(GroupFaceKnobs.photoInset) .facePart(.picture) words .padding(.horizontal, GroupFaceKnobs.textInset) .padding(.top, 13)Spacer(minLength: 6) } } .onCardPaper(GroupFaceCatalogue.stock.laid(card.pace)) }privatevar words: someView { VStack(alignment: .leading, spacing: 0) {iflet name = card.text("title") {Text(name) .font(CottonFonts.serif(GroupFaceKnobs.nameSize)) .lineLimit(1) .minimumScaleFactor(0.7) .faceInk(.ink) .accessibilityAddTraits(.isHeader) .accessibilityIdentifier("face-name") .facePart(.title) }ForEach(net, id: \.self) { figure inHeavyType(words: figure, size: GroupFaceKnobs.netSize) .lineLimit(1) .minimumScaleFactor(0.6) .padding(.top, 6) .accessibilityIdentifier("group-net") }FaceHairline() .padding(.vertical, 12) VStack(alignment: .leading, spacing: GroupFaceKnobs.lineGap) {ForEach(GroupLine.of(card)) { line in lineView(line) } }iflet more = card.text("more") {Text(more) .font(CottonFonts.type(GroupFaceKnobs.daySize)) .faceInk(.pencil) .padding(.top, 10) .accessibilityIdentifier("group-more") } } }privatefunc lineView(_ line: GroupLine) -> someView { VStack(alignment: .leading, spacing: 2) { HStack(alignment: .firstTextBaseline, spacing: 10) {Text(line.title ?? "") .font(CottonFonts.type(GroupFaceKnobs.lineSize)) .lineLimit(1) .faceInk(.ink)Spacer(minLength: 4)iflet amount = line.amount {Text(amount) .font(CottonFonts.type(GroupFaceKnobs.lineSize)) .lineLimit(1) .faceInk(.ink) } }iflet date = line.date {Text(date) .font(CottonFonts.type(GroupFaceKnobs.daySize)) .lineLimit(1) .faceInk(.pencil) } } .accessibilityElement(children: .combine) .accessibilityIdentifier("group-line") }}/// The group face, by the kind's name, and the cards it is reviewed in.publicenumGroupFaceCatalogue {publicstaticlet stock: FaceStock = .creampublicstaticlet ground: FaceGround = .paperpublicstaticlet face = Face(id: "group", specimens: [Specimen("friend", friend)]) { card, picture, _ inGroupFace(card: card, photo: picture) }publicstaticlet friend = DeckCard(face: .group, fields: ["title": .text("Invented Friend"), "net": .list([.text("Owes you \u{20B9}1,200")]),"lines": .list([ .object(["title": .text("Dinner"), "amount": .text("\u{20B9}800"), "date": .text("Thu 22 Oct")]), .object(["title": .text("Cab"), "amount": .text("\u{20B9}400")]), ]), ])}