You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
//
|
|
// EditingTeamView.swift
|
|
// PadelClub
|
|
//
|
|
// Created by Razmig Sarkissian on 17/04/2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct EditingTeamView: View {
|
|
@EnvironmentObject var dataStore: DataStore
|
|
var team: TeamRegistration
|
|
@State private var registrationDate : Date
|
|
|
|
init(team: TeamRegistration) {
|
|
self.team = team
|
|
_registrationDate = State(wrappedValue: team.registrationDate ?? Date())
|
|
}
|
|
|
|
var body: some View {
|
|
List {
|
|
Section {
|
|
DatePicker(registrationDate.formatted(.dateTime.weekday()), selection: $registrationDate)
|
|
} header: {
|
|
Text("Date d'inscription")
|
|
}
|
|
}
|
|
.onChange(of: registrationDate) {
|
|
team.registrationDate = registrationDate
|
|
_save()
|
|
}
|
|
.headerProminence(.increased)
|
|
.navigationTitle("Édition")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbarBackground(.visible, for: .navigationBar)
|
|
}
|
|
|
|
private func _save() {
|
|
try? dataStore.teamRegistrations.addOrUpdate(instance: team)
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
EditingTeamView(team: TeamRegistration.mock())
|
|
}
|
|
|