//
//  StopwatchFormView.swift
//  LeCountdown
//
//  Created by Laurent Morvillier on 01/02/2023.
//

import SwiftUI

struct StopwatchFormView: View {
     
    var nameBinding: Binding<String>
    var imageBinding: Binding<CoolPic>
    var soundBinding: Binding<Sound>
    var playSoundBinding: Binding<Bool>

    var textFieldIsFocused: FocusState<Bool>.Binding

    var body: some View {
        
        Form {
            Section(header: Text("Name for tracking the activity")) {
                TextField("name", text: nameBinding)
                    .focused(textFieldIsFocused)
            }

            SoundImageFormView(imageBinding: imageBinding,
                               soundBinding: soundBinding,
                               optionalSound: playSoundBinding)
                               
        }
    }
}

struct StopwatchFormView_Previews: PreviewProvider {

    @FocusState static var textFieldIsFocused: Bool

    static var previews: some View {
        StopwatchFormView(nameBinding: .constant(""),
                          imageBinding: .constant(.pic1),
                          soundBinding: .constant(.trainhorn), playSoundBinding: .constant(true), textFieldIsFocused: $textFieldIsFocused)
    }
}
