parent
bcd71ffa06
commit
16c750f950
@ -0,0 +1,74 @@ |
|||||||
|
// |
||||||
|
// SendToAllView.swift |
||||||
|
// PadelClub |
||||||
|
// |
||||||
|
// Created by Razmig Sarkissian on 28/04/2024. |
||||||
|
// |
||||||
|
|
||||||
|
import SwiftUI |
||||||
|
import LeStorage |
||||||
|
|
||||||
|
struct SendToAllView: View { |
||||||
|
@Environment(Tournament.self) var tournament: Tournament |
||||||
|
@State private var contactMethod: Int = 1 |
||||||
|
@State private var contactRecipients: Set<String> = Set() |
||||||
|
|
||||||
|
|
||||||
|
var body: some View { |
||||||
|
NavigationStack { |
||||||
|
List(selection: $contactRecipients) { |
||||||
|
Section { |
||||||
|
Picker(selection: $contactMethod) { |
||||||
|
Text("par sms").tag(0) |
||||||
|
Text("par mail").tag(1) |
||||||
|
} label: { |
||||||
|
Text("méthode") |
||||||
|
} |
||||||
|
.labelsHidden() |
||||||
|
.pickerStyle(.inline) |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
Section { |
||||||
|
ForEach(tournament.rounds()) { round in |
||||||
|
LabeledContent { |
||||||
|
let seeds = round.seeds() |
||||||
|
Text(round.seeds().count + " tête" + seeds.count.pluralSuffix + " de série") |
||||||
|
} label: { |
||||||
|
Text(round.roundTitle()) |
||||||
|
} |
||||||
|
.tag(round.id) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
Section { |
||||||
|
RowButtonView("Contacter \(totalString)") { |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
.environment(\.editMode, Binding.constant(EditMode.active)) |
||||||
|
.headerProminence(.increased) |
||||||
|
.navigationTitle("Réglages") |
||||||
|
.navigationBarTitleDisplayMode(.inline) |
||||||
|
.toolbarBackground(.visible, for: .navigationBar) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
func _teams() -> [TeamRegistration] { |
||||||
|
let rounds : [Round] = contactRecipients.map { Store.main.findById($0) } |
||||||
|
return rounds.flatMap({ $0.teams() }) |
||||||
|
} |
||||||
|
|
||||||
|
func _totalString() -> String { |
||||||
|
if contactRecipients.isEmpty { |
||||||
|
return "toutes les équipes" |
||||||
|
} else { |
||||||
|
return |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#Preview { |
||||||
|
SendToAllView() |
||||||
|
} |
||||||
Loading…
Reference in new issue