- Add isEmpty parameter to show "No items yet, tap + to add" text - Change date format to single line: "Day 1 - Friday, January 17" - Update preview to test both empty and non-empty states Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
63 lines
1.6 KiB
Swift
63 lines
1.6 KiB
Swift
//
|
|
// DayHeaderRow.swift
|
|
// SportsTime
|
|
//
|
|
// Header row for a day in the itinerary with day number, date, and add button.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct DayHeaderRow: View {
|
|
let dayNumber: Int
|
|
let date: Date
|
|
let isEmpty: Bool
|
|
let onAddTapped: () -> Void
|
|
|
|
@Environment(\.colorScheme) private var colorScheme
|
|
|
|
private var formattedDate: String {
|
|
date.formatted(.dateTime.weekday(.wide).month().day())
|
|
}
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
HStack {
|
|
Text("Day \(dayNumber) - \(formattedDate)")
|
|
.font(.title3)
|
|
.fontWeight(.semibold)
|
|
.foregroundStyle(Theme.textPrimary(colorScheme))
|
|
|
|
Spacer()
|
|
|
|
Button(action: onAddTapped) {
|
|
Image(systemName: "plus.circle.fill")
|
|
.font(.title2)
|
|
.foregroundStyle(Theme.warmOrange)
|
|
}
|
|
}
|
|
|
|
if isEmpty {
|
|
Text("No items yet, tap + to add")
|
|
.font(.subheadline)
|
|
.foregroundStyle(Theme.textSecondary(colorScheme))
|
|
}
|
|
}
|
|
.padding(.vertical, Theme.Spacing.sm)
|
|
.padding(.horizontal, Theme.Spacing.md)
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
VStack(spacing: 16) {
|
|
// Day with items (not empty)
|
|
DayHeaderRow(dayNumber: 1, date: Date(), isEmpty: false, onAddTapped: {})
|
|
|
|
Divider()
|
|
|
|
// Empty day
|
|
DayHeaderRow(dayNumber: 2, date: Date().addingTimeInterval(86400), isEmpty: true, onAddTapped: {})
|
|
}
|
|
.padding()
|
|
.background(Color.gray.opacity(0.1))
|
|
}
|