From 532e58db80e882926c59588a80f24d975f6a1263 Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 29 Apr 2024 15:53:20 +0200 Subject: [PATCH] graphical changes --- PadelClub.xcodeproj/project.pbxproj | 8 +- PadelClub/Data/Tournament.swift | 8 ++ .../Views/GroupStage/GroupStageView.swift | 6 +- PadelClub/Views/Match/MatchSummaryView.swift | 2 + .../Views/Planning/PlanningSettingsView.swift | 2 +- PadelClub/Views/Planning/PlanningView.swift | 2 +- PadelClub/Views/Planning/SchedulerView.swift | 6 +- .../Views/Shared/MatchFormatPickerView.swift | 2 +- .../Views/Subscription/OffersHeaderView.swift | 58 ------------- .../Subscription/SubscriptionInfoView.swift | 82 +++++++++++++++++++ .../Views/Tournament/Shared/DateBoxView.swift | 12 +-- .../Shared/TournamentCellView.swift | 25 +++--- .../Views/Tournament/TournamentView.swift | 2 +- 13 files changed, 127 insertions(+), 88 deletions(-) delete mode 100644 PadelClub/Views/Subscription/OffersHeaderView.swift create mode 100644 PadelClub/Views/Subscription/SubscriptionInfoView.swift diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 0cf439a..883ab2d 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -18,7 +18,7 @@ C45BAE442BCA753E002EEC8A /* Purchase.swift in Sources */ = {isa = PBXBuildFile; fileRef = C45BAE432BCA753E002EEC8A /* Purchase.swift */; }; C49EF0192BD694290077B5AA /* PurchaseListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C49EF0182BD694290077B5AA /* PurchaseListView.swift */; }; C49EF01B2BD6A1E80077B5AA /* URLs.swift in Sources */ = {isa = PBXBuildFile; fileRef = C49EF01A2BD6A1E80077B5AA /* URLs.swift */; }; - C49EF0262BD80AE80077B5AA /* OffersHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C49EF0252BD80AE80077B5AA /* OffersHeaderView.swift */; }; + C49EF0262BD80AE80077B5AA /* SubscriptionInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C49EF0252BD80AE80077B5AA /* SubscriptionInfoView.swift */; }; C4A47D5A2B6D383C00ADC637 /* Tournament.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A47D592B6D383C00ADC637 /* Tournament.swift */; }; C4A47D5E2B6D38EC00ADC637 /* DataStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A47D5D2B6D38EC00ADC637 /* DataStore.swift */; }; C4A47D632B6D3D6500ADC637 /* Club.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A47D622B6D3D6500ADC637 /* Club.swift */; }; @@ -320,7 +320,7 @@ C45BAE432BCA753E002EEC8A /* Purchase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Purchase.swift; sourceTree = ""; }; C49EF0182BD694290077B5AA /* PurchaseListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PurchaseListView.swift; sourceTree = ""; }; C49EF01A2BD6A1E80077B5AA /* URLs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLs.swift; sourceTree = ""; }; - C49EF0252BD80AE80077B5AA /* OffersHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OffersHeaderView.swift; sourceTree = ""; }; + C49EF0252BD80AE80077B5AA /* SubscriptionInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionInfoView.swift; sourceTree = ""; }; C4A47D592B6D383C00ADC637 /* Tournament.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tournament.swift; sourceTree = ""; }; C4A47D5D2B6D38EC00ADC637 /* DataStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataStore.swift; sourceTree = ""; }; C4A47D622B6D3D6500ADC637 /* Club.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Club.swift; sourceTree = ""; }; @@ -752,7 +752,7 @@ C4A47D8D2B7BBBEC00ADC637 /* StoreManager.swift */, C4A47D8F2B7BBBEC00ADC637 /* StoreItem.swift */, C49EF0182BD694290077B5AA /* PurchaseListView.swift */, - C49EF0252BD80AE80077B5AA /* OffersHeaderView.swift */, + C49EF0252BD80AE80077B5AA /* SubscriptionInfoView.swift */, ); path = Subscription; sourceTree = ""; @@ -1482,7 +1482,7 @@ FFCFC00E2BBC3D4600B82851 /* PointSelectionView.swift in Sources */, FF089EB62BB00A3800F0AEC7 /* TeamRowView.swift in Sources */, FF92680B2BCEE3E10080F940 /* ContactManager.swift in Sources */, - C49EF0262BD80AE80077B5AA /* OffersHeaderView.swift in Sources */, + C49EF0262BD80AE80077B5AA /* SubscriptionInfoView.swift in Sources */, FFCFC00C2BBC3D1E00B82851 /* EditScoreView.swift in Sources */, FF7091622B90F04300AB08DA /* TournamentOrganizerView.swift in Sources */, FF92680D2BCEE5EA0080F940 /* NetworkMonitor.swift in Sources */, diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index 3ea6e3b..61ace70 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -1160,3 +1160,11 @@ extension Tournament: TournamentBuildHolder { federalTournamentAge } } + +extension Tournament { + + static func fake() -> Tournament { + return Tournament(event: "Roland Garros", creator: "", name: "Magic P100", startDate: Date(), endDate: Date(), creationDate: Date(), isPrivate: false, groupStageFormat: .nineGames, roundFormat: nil, loserRoundFormat: nil, groupStageSortMode: .snake, groupStageCount: 4, rankSourceDate: nil, dayDuration: 2, teamCount: 24, teamSorting: .rank, federalCategory: .men, federalLevelCategory: .p100, federalAgeCategory: .a45, groupStageCourtCount: nil, seedCount: 8, closedRegistrationDate: nil, groupStageAdditionalQualified: 0, courtCount: 4, prioritizeClubMembers: false, qualifiedPerGroupStage: 2, teamsPerGroupStage: 4, entryFee: nil) + } + +} diff --git a/PadelClub/Views/GroupStage/GroupStageView.swift b/PadelClub/Views/GroupStage/GroupStageView.swift index 7833a3c..751ba58 100644 --- a/PadelClub/Views/GroupStage/GroupStageView.swift +++ b/PadelClub/Views/GroupStage/GroupStageView.swift @@ -91,12 +91,12 @@ struct GroupStageView: View { GroupStageTeamView(groupStage: groupStage, team: team) } label: { HStack(alignment: .center) { - VStack(alignment: .leading, spacing: 0) { - HStack { + VStack(alignment: .leading, spacing: 4.0) { + HStack(spacing: 6.0) { Text("#\(groupStagePosition + 1)") Text("Poids \(team.weight)") } - .font(.caption) + .font(.footnote) HStack { if let teamName = team.name { Text(teamName) diff --git a/PadelClub/Views/Match/MatchSummaryView.swift b/PadelClub/Views/Match/MatchSummaryView.swift index 9b62708..c769645 100644 --- a/PadelClub/Views/Match/MatchSummaryView.swift +++ b/PadelClub/Views/Match/MatchSummaryView.swift @@ -20,10 +20,12 @@ struct MatchSummaryView: View { } var color: Color { + return Color(white: 0.9) matchViewStyle == .plainStyle ? Color(uiColor: .tertiaryLabel) : Color(uiColor: .secondaryLabel) } var width: CGFloat { +// return 2.0 matchViewStyle == .plainStyle ? 1 : 2 } diff --git a/PadelClub/Views/Planning/PlanningSettingsView.swift b/PadelClub/Views/Planning/PlanningSettingsView.swift index 0252129..5d0a2fb 100644 --- a/PadelClub/Views/Planning/PlanningSettingsView.swift +++ b/PadelClub/Views/Planning/PlanningSettingsView.swift @@ -39,7 +39,7 @@ struct PlanningSettingsView: View { var body: some View { @Bindable var tournament = tournament - OffersHeaderView() + SubscriptionInfoView() List { Section { diff --git a/PadelClub/Views/Planning/PlanningView.swift b/PadelClub/Views/Planning/PlanningView.swift index dabc0e9..3633936 100644 --- a/PadelClub/Views/Planning/PlanningView.swift +++ b/PadelClub/Views/Planning/PlanningView.swift @@ -93,7 +93,7 @@ struct PlanningView: View { LabeledContent { Text(matches.count.formatted() + " match" + matches.count.pluralSuffix) } label: { - Text(key.formatted(date: .omitted, time: .shortened)).font(.largeTitle) + Text(key.formatted(date: .omitted, time: .shortened)).font(.title).fontWeight(.semibold) Text(Set(matches.compactMap { $0.roundTitle() }).joined(separator: ", ")) } } diff --git a/PadelClub/Views/Planning/SchedulerView.swift b/PadelClub/Views/Planning/SchedulerView.swift index c39bb5b..85bb94f 100644 --- a/PadelClub/Views/Planning/SchedulerView.swift +++ b/PadelClub/Views/Planning/SchedulerView.swift @@ -68,14 +68,14 @@ struct SchedulerView: View { .environment(tournament) } label: { LabeledContent { - Text(round.matchFormat.format).font(.largeTitle) + Text(round.matchFormat.format).font(.title2) } label: { if let startDate = round.getStartDate() { HStack { - Text(startDate.formattedAsHourMinute()).font(.largeTitle) + Text(startDate.formattedAsHourMinute()).font(.title2).fontWeight(.semibold) if let estimatedEndDate = round.estimatedEndDate(tournament.additionalEstimationDuration) { Image(systemName: "arrowshape.forward.fill") - Text(estimatedEndDate.formattedAsHourMinute()).font(.largeTitle) + Text(estimatedEndDate.formattedAsHourMinute()).font(.title2).fontWeight(.semibold) } } Text(startDate.formattedAsDate()) diff --git a/PadelClub/Views/Shared/MatchFormatPickerView.swift b/PadelClub/Views/Shared/MatchFormatPickerView.swift index 1de7981..d7e1fad 100644 --- a/PadelClub/Views/Shared/MatchFormatPickerView.swift +++ b/PadelClub/Views/Shared/MatchFormatPickerView.swift @@ -38,7 +38,7 @@ struct MatchFormatPickerView: View { Text("Durée").font(.caption) } HStack { - Text(matchFormat.format).font(.largeTitle) + Text(matchFormat.format).font(.title).fontWeight(.semibold) Spacer() VStack(alignment: .trailing) { Text("~" + matchFormat.formattedEstimatedDuration(tournament.additionalEstimationDuration)) diff --git a/PadelClub/Views/Subscription/OffersHeaderView.swift b/PadelClub/Views/Subscription/OffersHeaderView.swift deleted file mode 100644 index 1e0be93..0000000 --- a/PadelClub/Views/Subscription/OffersHeaderView.swift +++ /dev/null @@ -1,58 +0,0 @@ -// -// OffersHeaderView.swift -// PadelClub -// -// Created by Laurent Morvillier on 23/04/2024. -// - -import SwiftUI - -struct OffersHeaderView: View { - - let payment: Tournament.TournamentPayment? = .free - - var body: some View { - VStack { - if let text = self.text { - Text(text) - .multilineTextAlignment(.center) - .font(.callout) - .padding() - .foregroundColor(self.foregroundColor) - .frame(maxWidth: .infinity) - .background(self.backgroundColor) - } - - } - } - - var foregroundColor: Color { - switch self.payment { - case .free: return .blue - default: return .red - } - } - - var backgroundColor: Color { - switch self.payment { - case .free: return Color(red: 0.9, green: 0.9, blue: 1.0) - default: return Color(red: 1.0, green: 0.9, blue: 0.9) - } - } - - var text: String? { - switch self.payment { - case .free: - return "Nous vous offrons votre premier tournoi ! Convoquez les équipes, créez les poules, le tableau comme vous le souhaitez. \nEnregistrez les résultats de chaque équipes et diffusez les scores en temps réel sur les écrans de votre club !" - case nil: - return "Vous ne disposez pas d'une offre vous permettant de convoquer les joueurs ou de rentrer les résultats des matchs. Vous pouvez consulter les offres dans l'onglet JA." - default: - return nil - } - } - -} - -#Preview { - OffersHeaderView() -} diff --git a/PadelClub/Views/Subscription/SubscriptionInfoView.swift b/PadelClub/Views/Subscription/SubscriptionInfoView.swift new file mode 100644 index 0000000..1faec4c --- /dev/null +++ b/PadelClub/Views/Subscription/SubscriptionInfoView.swift @@ -0,0 +1,82 @@ +// +// OffersHeaderView.swift +// PadelClub +// +// Created by Laurent Morvillier on 23/04/2024. +// + +import SwiftUI +import TipKit + +struct SubscriptionInfoView: View { + + let payment: Tournament.TournamentPayment? = .free + + var body: some View { + + switch self.payment { + case .free: + TipView(FreeTournamentTip()) + case nil: + TipView(NoPaymentTip()) + default: + EmptyView() + } + + +// VStack { +// if let text = self.text { +// Text(text) +// .multilineTextAlignment(.center) +// .font(.callout) +// .padding() +// .foregroundColor(self.foregroundColor) +// .frame(maxWidth: .infinity) +// .background(self.backgroundColor) +// } +// +// } + } + + var foregroundColor: Color { + switch self.payment { + case .free: return .blue + default: return .red + } + } + + var backgroundColor: Color { + switch self.payment { + case .free: return Color(red: 0.9, green: 0.9, blue: 1.0) + default: return Color(red: 1.0, green: 0.9, blue: 0.9) + } + } + + var text: String? { + switch self.payment { + case .free: + return "Nous vous offrons votre premier tournoi ! Convoquez les équipes, créez les poules, le tableau comme vous le souhaitez. \nEnregistrez les résultats de chaque équipes et diffusez les scores en temps réel sur les écrans de votre club !" + case nil: + return "Vous ne disposez pas d'une offre vous permettant de convoquer les joueurs ou de rentrer les résultats des matchs. Vous pouvez consulter les offres dans l'onglet JA." + default: + return nil + } + } + +} + +struct FreeTournamentTip: Tip { + var title: Text { + return Text("Nous vous offrons votre premier tournoi ! Convoquez les équipes, créez les poules, le tableau comme vous le souhaitez. \nEnregistrez les résultats de chaque équipes et diffusez les scores en temps réel sur les écrans de votre club !") + } +} + +struct NoPaymentTip: Tip { + var title: Text { + return Text("Vous ne disposez pas d'une offre vous permettant de convoquer les joueurs ou de rentrer les résultats des matchs. Vous pouvez consulter les offres dans l'onglet JA.") + } +} + +#Preview { + SubscriptionInfoView() +} diff --git a/PadelClub/Views/Tournament/Shared/DateBoxView.swift b/PadelClub/Views/Tournament/Shared/DateBoxView.swift index 1f03840..470570b 100644 --- a/PadelClub/Views/Tournament/Shared/DateBoxView.swift +++ b/PadelClub/Views/Tournament/Shared/DateBoxView.swift @@ -12,21 +12,21 @@ struct DateBoxView: View { var displayStyle: DisplayStyle = .wide var body: some View { - VStack(alignment: .center, spacing: -2) { - Text(date.formatted(.dateTime.weekday(.abbreviated))) - .font(.caption2) + VStack(alignment: .center, spacing: 0.0) { + Text(date.formatted(.dateTime.weekday(.abbreviated)).uppercased()) HStack(alignment: .bottom) { Text(date.formatted(.dateTime.day(.twoDigits))) .font(displayStyle == .wide ? .title : .title3) .monospacedDigit() + .padding(-2) } if displayStyle == .wide { - Text(date.formatted(.dateTime.month(.abbreviated))) - .font(.caption2) + Text(date.formatted(.dateTime.month(.abbreviated)).uppercased()) Text(date.formatted(.dateTime.year())) - .font(.caption2) } } + .font(.footnote) + .fontWeight(.semibold) } } diff --git a/PadelClub/Views/Tournament/Shared/TournamentCellView.swift b/PadelClub/Views/Tournament/Shared/TournamentCellView.swift index b7fae0a..4b78e49 100644 --- a/PadelClub/Views/Tournament/Shared/TournamentCellView.swift +++ b/PadelClub/Views/Tournament/Shared/TournamentCellView.swift @@ -12,7 +12,7 @@ struct TournamentCellView: View { @Environment(NavigationViewModel.self) private var navigation let tournament: FederalTournamentHolder - let color: Color = .black +// let color: Color = .black var displayStyle: DisplayStyle = .wide var event: Event? { @@ -27,27 +27,28 @@ struct TournamentCellView: View { } private func _buildView(_ build: any TournamentBuildHolder, existingTournament: Tournament?) -> some View { - HStack { + HStack(spacing: 16.0) { DateBoxView(date: tournament.startDate, displayStyle: displayStyle == .wide ? .short : .wide) - Rectangle() - .fill(color) - .frame(width: 2) - VStack(alignment: .leading, spacing: -2) { +// Rectangle() +// .fill(Color(white: 0.8)) +// .frame(width: 2) + VStack(alignment: .leading, spacing: 0.0) { if let tournament = tournament as? Tournament { Text(tournament.locationLabel(displayStyle)) - .font(.caption2) + .font(.caption) } else { Text(tournament.clubLabel()) - .font(.caption2) + .font(.caption) } HStack(alignment: .bottom) { Text(build.level.localizedLabel()) + .fontWeight(.semibold) if displayStyle == .wide { VStack(alignment: .leading, spacing: 0) { Text(build.category.localizedLabel()) Text(build.age.localizedLabel()) } - .font(.caption2) + .font(.caption) } Spacer() if let tournament = tournament as? Tournament, displayStyle == .wide { @@ -98,6 +99,10 @@ struct TournamentCellView: View { } } } - .font(.caption2) + .font(.caption) } } + +#Preview { + TournamentCellView(tournament: Tournament.fake()) +} diff --git a/PadelClub/Views/Tournament/TournamentView.swift b/PadelClub/Views/Tournament/TournamentView.swift index 07432a8..f39d9a5 100644 --- a/PadelClub/Views/Tournament/TournamentView.swift +++ b/PadelClub/Views/Tournament/TournamentView.swift @@ -23,7 +23,7 @@ struct TournamentView: View { var body: some View { VStack(spacing: 0.0) { - OffersHeaderView() + SubscriptionInfoView() List { Section { NavigationLink(value: Screen.inscription) {