import SwiftUI struct BulletinsView: View { @Environment(ChurchDataService.self) private var dataService @Environment(\.horizontalSizeClass) private var horizontalSizeClass var body: some View { List { if dataService.isLoading { HStack { Spacer() VStack { ProgressView("Loading bulletins...") Text("Fetching church bulletins") .font(.caption) .foregroundColor(.secondary) .padding(.top, 8) } Spacer() } .listRowSeparator(.hidden) } else if dataService.bulletins.isEmpty { HStack { Spacer() VStack(spacing: 16) { Image(systemName: "newspaper.badge.exclamationmark") .font(.system(size: 50)) .foregroundColor(.secondary) Text("No Bulletins Available") .font(.headline) .foregroundColor(.secondary) Text("Check back later for weekly church bulletins and announcements.") .font(.subheadline) .foregroundColor(.secondary) .multilineTextAlignment(.center) .padding(.horizontal) } .padding() Spacer() } .listRowSeparator(.hidden) } else { ForEach(dataService.bulletins) { bulletin in NavigationLink { BulletinDetailView(bulletin: bulletin) } label: { BulletinRowView(bulletin: bulletin) } } } } .refreshable { await dataService.loadAllBulletins() } .navigationTitle("Bulletins") .navigationBarTitleDisplayMode(.large) .task { await dataService.loadAllBulletins() } } } struct BulletinRowView: View { let bulletin: ChurchBulletin @Environment(\.horizontalSizeClass) private var horizontalSizeClass var body: some View { if horizontalSizeClass == .regular { // iPad: Enhanced layout with more information HStack(spacing: 20) { // Bulletin icon Image(systemName: "newspaper.fill") .font(.title) .foregroundColor(Color(hex: "fb8b23")) .frame(width: 50, height: 50) .background(Color(hex: "fb8b23").opacity(0.1), in: RoundedRectangle(cornerRadius: 12)) VStack(alignment: .leading, spacing: 8) { HStack { Spacer() Text(bulletin.formattedDate) .font(.subheadline) .foregroundColor(.secondary) .fontWeight(.medium) if bulletin.pdfPath != nil { Image(systemName: "arrow.down.circle.fill") .font(.title3) .foregroundColor(.green) } } Text(bulletin.title) .font(.system(size: 20, weight: .semibold)) .lineLimit(2) .multilineTextAlignment(.leading) // Service details in grid layout for iPad HStack(spacing: 40) { VStack(alignment: .leading, spacing: 4) { Text("Sabbath School") .font(.caption2) .fontWeight(.medium) .foregroundColor(.secondary) .textCase(.uppercase) Text(bulletin.sabbathSchool) .font(.subheadline) .lineLimit(2) } .frame(maxWidth: .infinity, alignment: .leading) VStack(alignment: .leading, spacing: 4) { Text("Divine Worship") .font(.caption2) .fontWeight(.medium) .foregroundColor(.secondary) .textCase(.uppercase) Text(bulletin.divineWorship) .font(.subheadline) .lineLimit(2) } .frame(maxWidth: .infinity, alignment: .leading) VStack(alignment: .leading, spacing: 4) { Text("Scripture Reading") .font(.caption2) .fontWeight(.medium) .foregroundColor(.secondary) .textCase(.uppercase) Text(bulletin.scriptureReading) .font(.subheadline) .lineLimit(2) } .frame(maxWidth: .infinity, alignment: .leading) } } Image(systemName: "chevron.right") .font(.caption) .foregroundColor(.secondary) } .padding(.vertical, 16) } else { // iPhone: Compact layout (current design) HStack(spacing: 12) { // Bulletin icon Image(systemName: "newspaper.fill") .font(.title2) .foregroundColor(Color(hex: "fb8b23")) .frame(width: 40, height: 40) .background(Color(hex: "fb8b23").opacity(0.1), in: Circle()) VStack(alignment: .leading, spacing: 6) { HStack { Spacer() if bulletin.pdfPath != nil { Image(systemName: "arrow.down.circle.fill") .font(.title3) .foregroundColor(.green) } } Text(bulletin.title) .font(.system(size: 16, weight: .semibold)) .lineLimit(2) .multilineTextAlignment(.leading) Text(bulletin.formattedDate) .font(.system(size: 13)) .foregroundColor(.secondary) // Service preview HStack { VStack(alignment: .leading, spacing: 2) { Text("Sabbath School:") .font(.caption2) .foregroundColor(.secondary) Text(bulletin.sabbathSchool) .font(.caption) .lineLimit(1) } Spacer() VStack(alignment: .leading, spacing: 2) { Text("Divine Worship:") .font(.caption2) .foregroundColor(.secondary) Text(bulletin.divineWorship) .font(.caption) .lineLimit(1) } } .padding(.top, 4) } Spacer() } .padding(.vertical, 8) } } }