//
//  AgentDetailView.swift
//  TipsForLol
//
//  Created by Mehmet Ateş on 13.04.2022.
//

import SwiftUI
import AVKit

struct AgentDetailView: View {
    @ObservedObject private var pageViewModel = AgentDetailViewModel()
    var agent: Agent
    
    init(agent: Agent){
        self.agent = agent
        self.agent.abilities?.sort(by: { ability1, ability2 in
            ability1?.slot ?? "" < ability2?.slot ?? ""
        })
    }
    
    var body: some View {
        ScrollView{
            AgentPictureView(agent: agent)
            VStack{
                VStack{
                    Text(agent.description ?? "")
                        .foregroundColor(.secondary)
                        .font(.caption)
                    }.padding(.horizontal)
                    .padding(.bottom, 1)
                PageTitle(title: "LOCAL_SPELLS", tintColor: valoColor)
                AgentAbilitiesAndVideos(pageViewModel: pageViewModel, agent: agent)
                
            }.padding(.horizontal)
            
        }.navigationBarTitleDisplayMode(.inline)
            .navigationTitle(agent.displayName?.capitalized ?? "")
    }
}
