This commit is contained in:
2025-07-15 16:33:55 -04:00
parent 39fd45e03f
commit 48bbbbf692
8 changed files with 242 additions and 85 deletions

View File

@ -10,7 +10,8 @@
import SwiftUI
struct ListItem: View {
var title: String
var title: String?
var text: String?
var subtitle: String?
var count: Int?
var badges: [Badge]? = []
@ -18,17 +19,18 @@ struct ListItem: View {
var body: some View {
HStack {
VStack (alignment: .leading) {
Text("\(title)")
.font(.headline)
if let title = title {
Text("\(title)")
.font(.headline)
} else if let text = text {
Text("\(text)")
} else {
Text("Untitled")
}
HStack (alignment: .bottom) {
if let badges = badges {
ForEach (badges, id: \.self) { badge in
Text("\(badge.text)")
.bold()
.padding([.leading,.trailing], 5)
.background(badge.color)
.foregroundColor(.white)
.cornerRadius(4)
BadgeView(badge: badge)
}
}
if let subtitle = subtitle {
@ -44,6 +46,7 @@ struct ListItem: View {
.foregroundColor(.gray)
}
}
.frame(height: 40)
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
}