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

import SwiftUI
import SwiftData

struct TeleprompterView: View {
    let project: OCProject
    
    @State private var textSize = 45.0
    
    var body: some View {
        ScrollView {
            Text(project.script)
                .font(.system(size: textSize))
                .padding(.horizontal)
        }
        .toolbar {
            ToolbarItem(placement: .topBarTrailing) {
                Menu {
                    Menu {
                        Slider(value: $textSize, in: 12...150, step: 1)
                    } label: {
                        Image(systemName: "textformat.size")
                    }
                } label: {
                    Image(systemName: "ellipsis.circle")
                }

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

#Preview {
    let config = ModelConfiguration(isStoredInMemoryOnly: true)
    let container = try! ModelContainer(for: OCProject.self, configurations: config)
    
    container.mainContext.insert(PreviewData.project)
    
    return TeleprompterView(project: PreviewData.project)
        .modelContainer(container)
}
