// The small cap a feed row wears for the database it came from.//// Only the three feeds that read across databases draw it — Today, search and// "Asked of you" — and only when there is something to tell apart: the row// names a database and this device holds more than one. The cap is that// database's own enamel (`DatabasesModel.colours`), the one its cap on the// Databases screen wears, and its accessibility label is the database's name.importCottonKitimportSwiftUI/// A feed row's database, as a tiny cap. Draws nothing for a row with no/// database, or while this device holds one database.publicstructDatabaseMark: View {privatelet database: FeedRowDatabase? @Environment(DatabasesModel.self) privatevar model: DatabasesModel?publicinit(_ database: FeedRowDatabase?) {self.database = database }publicvar body: someView {iflet model, let database, let colour = Self.colour(for: database, in: model) { ZStack {CottonMedia.image(colour.asset)? .resizable() .interpolation(.medium) .scaledToFit()// The enamel says nothing; the mark says the name. .accessibilityHidden(true) } .frame(width: 14, height: 14) .accessibilityElement(children: .ignore) .accessibilityLabel(Self.name(of: database, in: model)) .accessibilityIdentifier("database-mark-\(database.databaseId)") } }/// The enamel a row's mark wears: its database's cap, when the row names/// a database this device holds and it holds more than one. Nil draws/// nothing.staticfunc colour(for database: FeedRowDatabase?, in model: DatabasesModel) -> CapColour? {guardlet database, model.held.count > 1else { returnnil }return model.colours[database.databaseId] }/// The database's name: the held list's, else the one the row carried.staticfunc name(of database: FeedRowDatabase, in model: DatabasesModel) -> String { model.database(database.databaseId)?.name ?? database.databaseName }}