//
//  ContentView.swift
//  TheNoiseClock
//
//  Created by Matt Bruce on 9/7/25.
//

import SwiftUI
import Bedrock

/// Main tab navigation coordinator
struct ContentView: View {
    
    // MARK: - Body
    private enum Tab: Hashable {
        case clock
        case alarms
        case noise
        case settings
    }

    @State private var selectedTab: Tab = .clock
    @State private var clockViewModel = ClockViewModel()

    var body: some View {
        TabView(selection: $selectedTab) {
            NavigationStack {
                ClockView(viewModel: clockViewModel)
            }
            .tabItem {
                Label("Clock", systemImage: "clock")
            }
            .tag(Tab.clock)
            
            NavigationStack {
                AlarmView()
            }
            .tabItem {
                Label("Alarms", systemImage: "alarm")
            }
            .tag(Tab.alarms)
            
            NavigationStack {
                NoiseView()
            }
            .tabItem {
                Label("Noise", systemImage: "waveform")
            }
            .tag(Tab.noise)

            NavigationStack {
                ClockSettingsView(style: clockViewModel.style) { newStyle in
                    clockViewModel.updateStyle(newStyle)
                }
                .navigationTitle("Settings")
                .navigationBarTitleDisplayMode(.inline)
            }
            .tabItem {
                Label("Settings", systemImage: "gearshape")
            }
            .tag(Tab.settings)
        }
        .accentColor(AppAccent.primary)
        .background(Color.Branding.primary.ignoresSafeArea())
    }
}

// MARK: - Preview
#Preview {
    ContentView()
}
