vrtnu-app/vrtnu/vrtnu/ContentView.swift

131 lines
3.6 KiB
Swift

//
// ContentView.swift
// vrtnu
//
// Created by Jens Timmerman on 23/09/2020.
//
import SwiftUI
import AVKit
import AVFoundation
import Combine
struct ContentView: View {
var body: some View {
NavigationView(){
List(VRTNu().shows, id: \.self){ show in
NavigationLink(destination: ShowView(show: show)){
HStack{
AsyncImage(url: show.imageURL,placeholder: {
//Image(name: "loading")
Text("Loading...")
}, image:{Image(uiImage:$0).resizable()}).frame(width: 300, height:300)
Text(show.title)
}
}
}
}
}
}
struct ShowView: View {
var show: Show
var body: some View {
NavigationView(){
List(show.getSeasons(), id: \.self){ season in
NavigationLink(destination: SeasonView(season: season)){
Text(season.seasonName)
}
}
}
}
}
struct SeasonView: View {
var season: Season
var body: some View {
NavigationView(){
List(season.getEpisodes(), id:\.self){ episode in
NavigationLink(destination: VideoView(episode: episode)){
HStack{
AsyncImage(url: episode.imageURL,placeholder: {
//Image(name: "loading")
Text("Loading...")
},image:{Image(uiImage:$0).resizable()}).frame(width: 300, height: 300)
Text(episode.name)
}
}
}
}
}
}
struct VideoView: View {
var episode: Episode
var body: some View {
let url = episode.getVideo().hlsUrl
let player = AVPlayer(url: url);
VideoPlayer(player: player).fixedSize().onAppear(){
player.play()
}
};
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
SeasonView(season: VRTNu().shows[0].getSeasons()[0])
//ContentView()
}
}
/*struct OldContentView: View {
var body: some View {
NavigationView(){
VStack(alignment: .leading) {
ForEach(VRTNu().shows, id: \.self){ show in
VStack{
Text(show.title)
HStack{
ForEach(show.seasons, id:\.self){ season in
List(season.episodes, id:\.self){ episode in
NavigationLink(destination: VideoView(url: episode.video.hlsUrl)){
VStack{
Text(season.seasonName)
Text(episode.name)
AsyncImage(url: episode.imageurl,placeholder: {
//Image(name: "loading")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
},image:{Image(uiImage:$0).resizable()})
}}
}
}
}
}
}
}
}
}
}*/