From f99893b0d5c0b7bc3cf99ec2d7a6cd63b65164a0 Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 30 Apr 2024 13:27:06 +0200 Subject: [PATCH] Subscription tips improvements --- .../beige.colorset/Contents.json | 38 ++++++++++++ .../Contents.json | 0 .../logoOrange.colorset/Contents.json | 38 ++++++++++++ .../logoRed.colorset/Contents.json | 38 ++++++++++++ .../logoYellow.colorset/Contents.json | 38 ++++++++++++ PadelClub/Extensions/Color+Extensions.swift | 2 + PadelClub/Manager/Tips.swift | 13 +++- .../Views/Navigation/Agenda/WelcomeView.swift | 2 +- .../Views/Planning/PlanningSettingsView.swift | 4 +- .../Subscription/SubscriptionInfoView.swift | 59 ++++++------------- .../Screen/InscriptionManagerView.swift | 2 +- 11 files changed, 185 insertions(+), 49 deletions(-) create mode 100644 PadelClub/Assets.xcassets/beige.colorset/Contents.json rename PadelClub/Assets.xcassets/{LaunchScreenBackground.colorset => logoBackground.colorset}/Contents.json (100%) create mode 100644 PadelClub/Assets.xcassets/logoOrange.colorset/Contents.json create mode 100644 PadelClub/Assets.xcassets/logoRed.colorset/Contents.json create mode 100644 PadelClub/Assets.xcassets/logoYellow.colorset/Contents.json diff --git a/PadelClub/Assets.xcassets/beige.colorset/Contents.json b/PadelClub/Assets.xcassets/beige.colorset/Contents.json new file mode 100644 index 0000000..5178bc5 --- /dev/null +++ b/PadelClub/Assets.xcassets/beige.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.808", + "green" : "0.906", + "red" : "0.980" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/PadelClub/Assets.xcassets/LaunchScreenBackground.colorset/Contents.json b/PadelClub/Assets.xcassets/logoBackground.colorset/Contents.json similarity index 100% rename from PadelClub/Assets.xcassets/LaunchScreenBackground.colorset/Contents.json rename to PadelClub/Assets.xcassets/logoBackground.colorset/Contents.json diff --git a/PadelClub/Assets.xcassets/logoOrange.colorset/Contents.json b/PadelClub/Assets.xcassets/logoOrange.colorset/Contents.json new file mode 100644 index 0000000..9251f6b --- /dev/null +++ b/PadelClub/Assets.xcassets/logoOrange.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.000", + "green" : "0.573", + "red" : "0.953" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/PadelClub/Assets.xcassets/logoRed.colorset/Contents.json b/PadelClub/Assets.xcassets/logoRed.colorset/Contents.json new file mode 100644 index 0000000..265a4eb --- /dev/null +++ b/PadelClub/Assets.xcassets/logoRed.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.220", + "green" : "0.251", + "red" : "0.910" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/PadelClub/Assets.xcassets/logoYellow.colorset/Contents.json b/PadelClub/Assets.xcassets/logoYellow.colorset/Contents.json new file mode 100644 index 0000000..b3f233e --- /dev/null +++ b/PadelClub/Assets.xcassets/logoYellow.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.000", + "green" : "0.827", + "red" : "1.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/PadelClub/Extensions/Color+Extensions.swift b/PadelClub/Extensions/Color+Extensions.swift index eaa8d41..60fb159 100644 --- a/PadelClub/Extensions/Color+Extensions.swift +++ b/PadelClub/Extensions/Color+Extensions.swift @@ -8,6 +8,7 @@ import SwiftUI extension Color { + func variation(withHueOffset hueOffset: Double = 0, saturationFactor: Double = 0.4, brightnessFactor: Double = 0.8, opacity: Double = 0.5) -> Color { var hue: CGFloat = 0 var saturation: CGFloat = 0 @@ -30,4 +31,5 @@ extension Color { return Color(hue: Double(hue), saturation: Double(saturation), brightness: Double(brightness), opacity: Double(alpha)) } + } diff --git a/PadelClub/Manager/Tips.swift b/PadelClub/Manager/Tips.swift index c5d9a1a..34cd474 100644 --- a/PadelClub/Manager/Tips.swift +++ b/PadelClub/Manager/Tips.swift @@ -337,9 +337,16 @@ struct NotFoundAreWalkOutTip: Tip { struct TipStyleModifier: ViewModifier { @Environment(\.colorScheme) var colorScheme var tint: Color? + var background: Color? func body(content: Content) -> some View { - if let tint { + + if let background { + content + .tint(.white) + .listRowInsets(EdgeInsets()) + .tipBackground(background) + } else if let tint { if colorScheme == .light { content .tint(tint) @@ -364,7 +371,7 @@ struct TipStyleModifier: ViewModifier { } extension View { - func tipStyle(tint: Color?) -> some View { - modifier(TipStyleModifier(tint: tint)) + func tipStyle(tint: Color?, background: Color? = nil) -> some View { + modifier(TipStyleModifier(tint: tint, background: background)) } } diff --git a/PadelClub/Views/Navigation/Agenda/WelcomeView.swift b/PadelClub/Views/Navigation/Agenda/WelcomeView.swift index b0eeab4..f7763b7 100644 --- a/PadelClub/Views/Navigation/Agenda/WelcomeView.swift +++ b/PadelClub/Views/Navigation/Agenda/WelcomeView.swift @@ -13,7 +13,7 @@ struct WelcomeView: View { .resizable() .scaledToFit() .buttonStyle(.borderedProminent) - .tint(.launchScreenBackground) + .tint(.logoBackground) .listRowBackground(Color.clear) .listRowInsets(EdgeInsets(.zero)) } diff --git a/PadelClub/Views/Planning/PlanningSettingsView.swift b/PadelClub/Views/Planning/PlanningSettingsView.swift index 5d0a2fb..8819483 100644 --- a/PadelClub/Views/Planning/PlanningSettingsView.swift +++ b/PadelClub/Views/Planning/PlanningSettingsView.swift @@ -39,9 +39,9 @@ struct PlanningSettingsView: View { var body: some View { @Bindable var tournament = tournament - SubscriptionInfoView() List { - + SubscriptionInfoView() + Section { DatePicker(tournament.startDate.formatted(.dateTime.weekday()), selection: $tournament.startDate) LabeledContent { diff --git a/PadelClub/Views/Subscription/SubscriptionInfoView.swift b/PadelClub/Views/Subscription/SubscriptionInfoView.swift index 1faec4c..d02e53e 100644 --- a/PadelClub/Views/Subscription/SubscriptionInfoView.swift +++ b/PadelClub/Views/Subscription/SubscriptionInfoView.swift @@ -10,57 +10,23 @@ import TipKit struct SubscriptionInfoView: View { - let payment: Tournament.TournamentPayment? = .free + var payment: Tournament.TournamentPayment? = .free + + init() { + self.payment = Guard.main.paymentForNewTournament() + } var body: some View { switch self.payment { case .free: - TipView(FreeTournamentTip()) + TipView(FreeTournamentTip()).tipStyle(tint: nil, background: .blue.opacity(0.2)) case nil: - TipView(NoPaymentTip()) + TipView(NoPaymentTip()).tipStyle(tint: nil, background: .logoRed) 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 - } } } @@ -69,11 +35,20 @@ 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 !") } + + var image: Image? { + Image(systemName: "gift.fill") + } + } 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.") + return Text("Vous ne disposez plus d'une offre vous permettant de convoquer les joueurs et de rentrer les résultats des matchs. Nous vous invitons à consulter les offres dans l'onglet JA.").foregroundStyle(.white) + } + + var image: Image? { + Image(systemName: "exclamationmark.bubble.fill") } } diff --git a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift index d805bbc..f011995 100644 --- a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift +++ b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift @@ -300,7 +300,7 @@ struct InscriptionManagerView: View { } } .buttonStyle(.borderedProminent) - .tint(.launchScreenBackground) + .tint(.logoBackground) .fixedSize(horizontal: false, vertical: true) .padding(16) }