multistore
Raz 1 year ago
parent 79cd364a89
commit 599c942c59
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 2
      PadelClub/Data/Tournament.swift
  3. 29
      PadelClub/Views/Components/FooterButtonView.swift
  4. 29
      PadelClub/Views/Navigation/Agenda/ActivityView.swift
  5. 2
      PadelClub/Views/Subscription/Guard.swift
  6. 4
      PadelClub/Views/Tournament/Screen/TournamentRankView.swift

@ -1859,7 +1859,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 43;
CURRENT_PROJECT_VERSION = 45;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6;
@ -1896,7 +1896,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 43;
CURRENT_PROJECT_VERSION = 45;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6;

@ -1075,7 +1075,7 @@ class Tournament : ModelObject, Storable {
}
let groupStages = groupStages()
let baseRank = teamCount - teamsPerGroupStage * groupStageCount + qualifiedPerGroupStage * groupStageCount + groupStageAdditionalQualified
let baseRank = teamCount - groupStageSpots() + qualifiedPerGroupStage * groupStageCount + groupStageAdditionalQualified
groupStages.forEach { groupStage in
let groupStageTeams = groupStage.teams(true)

@ -7,22 +7,43 @@
import SwiftUI
fileprivate let defaultConfirmationMessage = "Êtes-vous sûr de vouloir faire cela ?"
struct FooterButtonView: View {
var role: ButtonRole? = nil
let title: String
let confirmationMessage: String
let action: () -> ()
init(_ title: String, action: @escaping () -> Void) {
@State private var askConfirmation: Bool = false
init(_ title: String, role: ButtonRole? = nil, confirmationMessage: String? = nil, action: @escaping () -> Void) {
self.title = title
self.action = action
self.role = role
self.confirmationMessage = confirmationMessage ?? defaultConfirmationMessage
}
var body: some View {
Button {
action()
Button(role: role) {
if role == .destructive {
askConfirmation = true
} else {
action()
}
} label: {
Text(title)
.underline()
}
.buttonStyle(.borderless)
.confirmationDialog("Confirmation",
isPresented: $askConfirmation,
titleVisibility: .visible) {
Button("OK") {
action()
}
Button("Annuler", role: .cancel) {}
} message: {
Text(confirmationMessage)
}
}
}

@ -27,6 +27,11 @@ struct ActivityView: View {
.filter({ federalDataViewModel.isTournamentValidForFilters($0) })
}
func getRunningTournaments() -> [Tournament] {
dataStore.tournaments.filter({ $0.endDate == nil })
.filter({ federalDataViewModel.isTournamentValidForFilters($0) })
}
var endedTournaments: [Tournament] {
dataStore.tournaments.filter({ $0.endDate != nil })
.filter({ federalDataViewModel.isTournamentValidForFilters($0) })
@ -53,6 +58,29 @@ struct ActivityView: View {
}
}
@ViewBuilder
private func _pasteView() -> some View {
if UIPasteboard.general.hasStrings {
// Enable string-related control...
if let string = UIPasteboard.general.string {
// use the string here
Section {
Menu("Utiliser le contenu du presse-papier") {
Section {
ForEach(getRunningTournaments()) { tournament in
Button(tournament.tournamentTitle()) {
navigation.path.append(tournament)
tournament.navigationPath = [Screen.inscription]
}
}
} header: {
Text("coller dans")
}
}
}
}
}
}
var body: some View {
@Bindable var navigation = navigation
NavigationStack(path: $navigation.path) {
@ -62,6 +90,7 @@ struct ActivityView: View {
List {
switch navigation.agendaDestination! {
case .activity:
_pasteView()
EventListView(tournaments: runningTournaments, viewStyle: viewStyle, sortAscending: true)
case .history:
EventListView(tournaments: endedTournaments, viewStyle: viewStyle, sortAscending: false)

@ -141,7 +141,7 @@ import LeStorage
var currentPlan: StoreItem? {
// #if DEBUG
// return .monthlyUnlimited
return .monthlyUnlimited
// #else
if let currentBestPlan = self.currentBestPlan, let plan = StoreItem(rawValue: currentBestPlan.productID) {
return plan

@ -36,7 +36,7 @@ struct TournamentRankView: View {
Text("Classement publié")
}
RowButtonView("Publier le classement", role: .destructive) {
RowButtonView(rankingPublished ? "Re-publier le classement" : "Publier le classement", role: .destructive) {
rankings.keys.sorted().forEach { rank in
if let rankedTeams = rankings[rank] {
rankedTeams.forEach { team in
@ -48,7 +48,7 @@ struct TournamentRankView: View {
_save()
}
} footer: {
FooterButtonView("masquer le classement") {
FooterButtonView("masquer le classement", role: .destructive) {
tournament.unsortedTeams().forEach { team in
team.finalRanking = nil
team.pointsEarned = nil

Loading…
Cancel
Save