2021-06-26 23:29:55 +00:00
|
|
|
import Defaults
|
2021-06-11 21:40:35 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct VideosView: View {
|
2021-07-18 22:32:46 +00:00
|
|
|
@EnvironmentObject<NavigationState> private var navigationState
|
|
|
|
|
2021-06-28 15:27:53 +00:00
|
|
|
@State private var profile = Profile()
|
2021-07-07 23:01:54 +00:00
|
|
|
|
2021-07-18 22:32:46 +00:00
|
|
|
#if os(tvOS)
|
|
|
|
@Default(.layout) var layout
|
|
|
|
#endif
|
2021-06-26 23:29:55 +00:00
|
|
|
|
2021-07-09 14:53:53 +00:00
|
|
|
@Default(.showingAddToPlaylist) var showingAddToPlaylist
|
|
|
|
|
2021-07-11 20:52:49 +00:00
|
|
|
#if os(iOS)
|
|
|
|
@Environment(\.verticalSizeClass) private var horizontalSizeClass
|
|
|
|
#endif
|
|
|
|
|
2021-07-07 22:39:18 +00:00
|
|
|
var videos: [Video]
|
2021-07-07 23:01:54 +00:00
|
|
|
|
2021-06-11 21:40:35 +00:00
|
|
|
var body: some View {
|
2021-07-09 14:53:53 +00:00
|
|
|
VStack {
|
2021-07-11 20:52:49 +00:00
|
|
|
#if os(tvOS)
|
|
|
|
if layout == .cells {
|
|
|
|
VideosCellsView(videos: videos, columns: self.profile.cellsColumns)
|
|
|
|
} else {
|
|
|
|
VideosListView(videos: videos)
|
|
|
|
}
|
|
|
|
#else
|
2021-06-26 23:50:32 +00:00
|
|
|
VideosListView(videos: videos)
|
2021-07-11 20:52:49 +00:00
|
|
|
#if os(macOS)
|
2021-07-11 23:23:04 +00:00
|
|
|
.frame(minWidth: 400)
|
2021-07-11 20:52:49 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2021-07-09 14:53:53 +00:00
|
|
|
}
|
2021-07-11 20:52:49 +00:00
|
|
|
|
|
|
|
#if os(tvOS)
|
2021-07-18 22:32:46 +00:00
|
|
|
.fullScreenCover(isPresented: $navigationState.showingVideo) {
|
|
|
|
if let video = navigationState.video {
|
|
|
|
VideoPlayerView(video)
|
|
|
|
}
|
|
|
|
}
|
2021-07-11 20:52:49 +00:00
|
|
|
.fullScreenCover(isPresented: $showingAddToPlaylist) {
|
|
|
|
AddToPlaylistView()
|
|
|
|
}
|
2021-07-18 22:32:46 +00:00
|
|
|
|
2021-07-11 20:52:49 +00:00
|
|
|
#endif
|
2021-06-11 21:40:35 +00:00
|
|
|
}
|
|
|
|
}
|