//
//  ProjectSlideshowView.swift
//  OnCue
//
//  Created by Pradyun Setti on 22/06/2024.
//

import SwiftUI

struct ProjectSlideshowView: View {
    let project: OCProject
    @State private var textSize = 25.0
    
    var body: some View {
        TabView() {
            ForEach(project.sortedCards) { card in
                VStack(alignment: .leading) {
                    Text(card.content)
                        .foregroundColor(.primary)
                        .font(.system(size: textSize))
                        .padding()
                        .frame(height: 550)
                    Spacer()
                }
                    .navigationTitle("\(card.index+1)")
                    .navigationBarTitleDisplayMode(.inline)
            }
        }
        .tabViewStyle(PageTabViewStyle(indexDisplayMode: .always))
        .persistentSystemOverlays(.hidden)
        .toolbar {
            ToolbarItem(placement: .topBarTrailing) {
                Menu {
                    Menu {
                        Slider(value: $textSize, in: 12...80, step: 1)
                    } label: {
                        Image(systemName: "textformat.size")
                    }
                } label: {
                    Image(systemName: "ellipsis.circle")
                }

            }
            ToolbarItem(placement: .topBarTrailing) {
                NavigationLink(destination: { CardsView(project: project) }) {
                    Image(systemName: "stop.fill")
                }
            }
        }
    }
}

#Preview {
    ProjectSlideshowView(project: PreviewData.project)
}
