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.
 
 
PadelClub/PadelClub/Views/Navigation/Toolbox/MatchFormatStorageView.swift

50 lines
1.5 KiB

//
// MatchFormatStorageView.swift
// PadelClub
//
// Created by Razmig Sarkissian on 18/04/2024.
//
import SwiftUI
struct MatchFormatStorageView: View {
@State private var estimatedDuration: Int
@EnvironmentObject var dataStore: DataStore
let matchFormat: MatchFormat
init(matchFormat: MatchFormat) {
self.matchFormat = matchFormat
_estimatedDuration = State(wrappedValue: matchFormat.getEstimatedDuration())
}
var body: some View {
Section {
LabeledContent {
StepperView(title: "minutes", count: $estimatedDuration, step: 5)
} label: {
Text("Durée \(matchFormat.format)")
Text(matchFormat.computedShortLabelWithoutPrefix)
}
} footer: {
if estimatedDuration != matchFormat.defaultEstimatedDuration {
HStack {
Spacer()
Button {
self.estimatedDuration = matchFormat.defaultEstimatedDuration
} label: {
Text("remettre la durée par défault")
.underline()
}
.buttonStyle(.borderless)
}
}
}
.onChange(of: estimatedDuration) {
dataStore.appSettings.saveMatchFormatsDefaultDuration(matchFormat, estimatedDuration: estimatedDuration)
dataStore.updateSettings()
}
}
}