//
//  PodcastInfoDetail.swift
//  PodcastsApp
//
//  Created by BREUIL Yohann on 17/05/2023.
//

import SwiftUI

struct PodcastView: View {
    let columns = [GridItem(.flexible())]
    
    var podcast: Podcast
    
    var body: some View {
        NavigationStack {
            ScrollView {
                VStack {
                    PodcastCover(podcast: podcast)
                    
                    LazyVGrid(columns: columns, spacing: 10, pinnedViews: [.sectionHeaders]) {
                        Section {
                            HStack {
                              Text("Épisodes")
                            }
                        }
                        
                        ForEach (podcast.episodes) { episode in
                            PodcastEpisode(episode: episode)
                        }
                    }
                }
            }
            .toolbar {
                HStack {
                    Button(action: {}) {
                        Image(systemName: "checkmark")
                    }
                    .clipShape(Circle())
                    .buttonStyle(.bordered)
                    
                    Button(action: {}) {
                        Image(systemName: "ellipsis")
                    }
                    .clipShape(Circle())
                    .buttonStyle(.bordered)
                }
            }
            .listStyle(.grouped)
        }
    }
}

struct PodcastInfoDetail_Previews: PreviewProvider {
    static var previews: some View {
        Group {
            PodcastView(podcast: podcastList[0])
            PodcastView(podcast: podcastList[0]).preferredColorScheme(.dark)
        }
        
    }
}
