//
//  ClockToolbar.swift
//  TheNoiseClock
//
//  Created by Matt Bruce on 9/8/25.
//

import SwiftUI

/// Component that handles the clock view toolbar and navigation
struct ClockToolbar: View {
    
    // MARK: - Properties
    let isDisplayMode: Bool
    let onSettingsTap: () -> Void
    
    // MARK: - Body
    var body: some View {
        EmptyView()
            .navigationTitle(isDisplayMode ? "" : "Clock")
            .toolbar {
                if !isDisplayMode {
                    ToolbarItem(placement: .navigationBarTrailing) {
                        Button {
                            onSettingsTap()
                        } label: {
                            Image(systemName: "gear")
                                .font(.title2)
                                .transition(.opacity)
                        }
                    }
                }
            }
            .navigationBarBackButtonHidden(isDisplayMode)
            .toolbar(isDisplayMode ? .hidden : .automatic)
    }
}

// MARK: - Preview
#Preview {
    NavigationStack {
        ClockToolbar(
            isDisplayMode: false,
            onSettingsTap: {}
        )
    }
}
