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.
51 lines
1.5 KiB
51 lines
1.5 KiB
//
|
|
// MatchFormatStorageView.swift
|
|
// PadelClub
|
|
//
|
|
// Created by Razmig Sarkissian on 18/04/2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
import LeStorage
|
|
|
|
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.user.saveMatchFormatsDefaultDuration(matchFormat, estimatedDuration: estimatedDuration)
|
|
self.dataStore.saveUser()
|
|
}
|
|
}
|
|
}
|
|
|
|
|