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.
LeCountdown/LeCountdown/Views/Reusable/SoundFormView.swift

94 lines
2.5 KiB

//
// SoundImageFormView.swift
// LeCountdown
//
// Created by Laurent Morvillier on 01/02/2023.
//
import SwiftUI
struct SoundFormView : View {
var model: TimerModel
// var repeatCountBinding: Binding<Int16>? = nil
var optionalSound: Binding<Bool>? = nil
// @State var imageSelectionSheetShown: Bool = false
var body: some View {
Section("Properties") {
if self.optionalSound != nil {
Toggle("Play sound on end", isOn: optionalSound!)
if self.optionalSound?.wrappedValue == true {
NavigationLink {
PlaylistsView(model: self.model.soundModel, catalog: .ring)
} label: {
Text("Sound")
}
}
}
SoundLinkView(soundModel: self.model.soundModel,
catalog: .ring,
title: NSLocalizedString("Sound", comment: "") )
SoundLinkView(soundModel: self.model.confirmationSoundModel,
catalog: .confirmation,
title: NSLocalizedString("Start Sound", comment: ""))
}
// .sheet(isPresented: self.$imageSelectionSheetShown) {
// ImageSelectionView(showBinding: self.$imageSelectionSheetShown,
// imageBinding: self.imageBinding)
// }
}
}
struct SoundLinkView: View {
@StateObject var soundModel: SoundModel
var catalog: Catalog
var title: String
var body: some View {
NavigationLink {
NavigationStack {
PlaylistsView(model: self.soundModel,
catalog: self.catalog)
}
} label: {
LabeledContent(self.title, value: self.soundModel.soundSelection())
}
}
}
struct SoundLightLinkView: View {
@StateObject var soundModel: SoundModel
var catalog: Catalog
var title: String
var body: some View {
NavigationLink {
PlaylistsView(model: self.soundModel,
catalog: self.catalog)
} label: {
LabeledContent(self.title, value: self.soundModel.soundSelection())
}
}
}
struct SoundImageFormView_Previews: PreviewProvider {
static var previews: some View {
Form {
SoundFormView(model: TimerModel())
}
}
}