//
//  PodcastsListView.swift
//  PodcastsApp
//
//  Created by BREUIL Yohann on 14/05/2023.
//

import SwiftUI

struct LibraryView: View {
    let columns = [GridItem(.flexible()), GridItem(.flexible())]
    
    var body: some View {
        NavigationStack {
            List {
                NavigationLink(destination: PodcastListView()) {
                    LibraryMenuItem(imageName: "square.stack", text: "Podcasts")
                }
                NavigationLink(destination: PodcastListView()) {
                    LibraryMenuItem(imageName: "checklist.unchecked", text: "Chaînes")
                }
                NavigationLink(destination: PodcastListView()) {
                    LibraryMenuItem(imageName: "bookmark", text: "Enregistrés")
                }
                NavigationLink(destination: PodcastListView()) {
                    LibraryMenuItem(imageName: "arrow.down.circle", text: "Téléchargés")
                }
                NavigationLink(destination: PodcastListView()) {
                    LibraryMenuItem(imageName: "clock", text: "Derniers épisodes")
                }
                
                VStack {
                    Text("Mis à jour récemment")
                        .font(.title2)
                        .bold()
                    
                    LazyVGrid(columns: columns, spacing: 20) {
                        NavigationLink(destination: PodcastView()) {
                            PodcastListItem()
                        }
                        NavigationLink(destination: PodcastView()) {
                            PodcastListItem()
                        }
                        NavigationLink(destination: PodcastView()) {
                            PodcastListItem()
                        }
                        NavigationLink(destination: PodcastView()) {
                            PodcastListItem()
                        }
                        NavigationLink(destination: PodcastView()) {
                            PodcastListItem()
                        }
                        NavigationLink(destination: PodcastView()) {
                            PodcastListItem()
                        }
                        NavigationLink(destination: PodcastView()) {
                            PodcastListItem()
                        }
                        NavigationLink(destination: PodcastView()) {
                            PodcastListItem()
                        }
                    }
                }
                .padding(.top)
            }
            .navigationTitle("Bibliothèque")
        }
    }
}

struct PodcastsListView_Previews: PreviewProvider {
    static var previews: some View {
        Group {
            LibraryView()
            LibraryView().preferredColorScheme(.dark)
        }
        
    }
}
