import SwiftUI import SFSafeSymbols struct CapRowView: View { private let imageSize: CGFloat = 70 private let sufficientImageCount = 10 let cap: Cap let match: Float? @EnvironmentObject var database: Database var imageUrl: URL { database.serverUrl.appendingPathComponent(cap.mainImagePath) } var body: some View { HStack(alignment: .center) { VStack(alignment: .leading, spacing: 0) { Text(cap.name) .font(.headline) .padding(.bottom, 3) HStack(spacing: 4) { Image(systemSymbol: .tag) Text("\(cap.id)") .padding(.trailing, 8) Image(systemSymbol: .photo) Text("\(cap.imageCount)") .padding(.trailing, 8) if cap.imageCount < sufficientImageCount { Image(systemSymbol: .eyeTrianglebadgeExclamationmark) .padding(.trailing, 8) } if !database.canClassify(cap: cap.id) { Image(systemSymbol: .eyeSlash) .padding(.trailing, 8) } if database.hasPendingUpdates(for: cap.id) { Image(systemSymbol: .arrowUpArrowDownCircle) .padding(.trailing, 8) } if let match = match { Image(systemSymbol: .target) Text("\(Int((match * 100).rounded())) %") .padding(.trailing, 8) } } .foregroundColor(.secondary) .padding(.top, 0) .font(.footnote) }//.padding(.vertical) Spacer() CachedCapImage(cap, cap.image, cache: database.images) { image in image.resizable() } placeholder: { ProgressView() } .frame(width: imageSize, height: imageSize) .cornerRadius(imageSize / 2) } } } struct CapRowView_Previews: PreviewProvider { static var previews: some View { CapRowView(cap: Cap(id: 123, name: "My new cap"), match: 0.13) .previewLayout(.fixed(width: 375, height: 80)) .environmentObject(Database.mock) } }