Files
workouts/Workouts/Utils/ListItem.swift
2025-07-25 17:42:25 -04:00

51 lines
1.4 KiB
Swift
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// ListItem.swift
// Workouts
//
// Created by rzen on 7/13/25 at 10:42AM.
//
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
//
import SwiftUI
struct ListItem: View {
var title: String
var subtitle: String?
var count: Int?
var badges: [Badge]? = []
var body: some View {
HStack {
VStack (alignment: .leading) {
Text("\(title)")
HStack {
if let subtitle = subtitle {
Text("\(subtitle)")
.font(.footnote)
}
if let badges = badges {
ForEach (badges, id: \.self) { badge in
Text("\(badge.text)")
.bold()
.padding([.leading,.trailing], 5)
.cornerRadius(4)
.background(badge.color)
.foregroundColor(.white)
}
}
}
}
if let count = count {
Spacer()
Text("\(count)")
.font(.caption)
.foregroundColor(.gray)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
}
}