parent
9e4a13246c
commit
797caf55a2
@ -1,59 +0,0 @@ |
|||||||
// |
|
||||||
// TenupEventListView.swift |
|
||||||
// PadelClub |
|
||||||
// |
|
||||||
// Created by Razmig Sarkissian on 28/03/2024. |
|
||||||
// |
|
||||||
|
|
||||||
import SwiftUI |
|
||||||
|
|
||||||
struct TenupEventListView: View { |
|
||||||
@EnvironmentObject var dataStore: DataStore |
|
||||||
|
|
||||||
let tournaments: [FederalTournament] |
|
||||||
let viewStyle: AgendaDestination.ViewStyle |
|
||||||
|
|
||||||
var body: some View { |
|
||||||
let groupedTournamentsByDate = Dictionary(grouping: tournaments) { $0.startDate.startOfMonth } |
|
||||||
|
|
||||||
ForEach(groupedTournamentsByDate.keys.sorted(by: <), id: \.self) { section in |
|
||||||
if let _tournaments = groupedTournamentsByDate[section]?.sorted(by: \.startDate) { |
|
||||||
Section { |
|
||||||
switch viewStyle { |
|
||||||
case .list: |
|
||||||
_listView(_tournaments) |
|
||||||
case .calendar: |
|
||||||
CalendarView(date: section, tournaments: _tournaments) |
|
||||||
} |
|
||||||
} header: { |
|
||||||
HStack { |
|
||||||
Text(section.monthYearFormatted) |
|
||||||
Spacer() |
|
||||||
Text(_tournaments.map { $0.tournaments.count }.reduce(0,+).formatted()) |
|
||||||
} |
|
||||||
} |
|
||||||
.headerProminence(.increased) |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private func _listView(_ tournaments: [FederalTournament]) -> some View { |
|
||||||
ForEach(tournaments, id: \.holderId) { tournament in |
|
||||||
TournamentCellView(tournament: tournament) |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/* |
|
||||||
Button("importer") { |
|
||||||
let event = dataStore.events.first(where: { $0.tenupId == tournament.id.string }) ?? Event(tenupId: tournament.id.string) |
|
||||||
let tournament = Tournament(event: event.id, ) |
|
||||||
} |
|
||||||
.buttonStyle(.bordered) |
|
||||||
.buttonBorderShape(.capsule) |
|
||||||
|
|
||||||
*/ |
|
||||||
} |
|
||||||
|
|
||||||
#Preview { |
|
||||||
TenupEventListView(tournaments: [], viewStyle: .calendar) |
|
||||||
} |
|
||||||
Loading…
Reference in new issue