1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 14:50:32 +05:30
yattee/Shared/Navigation/ContentView.swift

67 lines
2.1 KiB
Swift
Raw Normal View History

2021-09-25 13:48:22 +05:30
import Defaults
2021-06-10 02:21:23 +05:30
import SwiftUI
struct ContentView: View {
2021-09-25 13:48:22 +05:30
@StateObject private var navigation = NavigationModel()
@StateObject private var playback = PlaybackModel()
2021-09-25 17:47:58 +05:30
@StateObject private var recents = RecentsModel()
2021-09-25 13:48:22 +05:30
@EnvironmentObject<InvidiousAPI> private var api
@EnvironmentObject<InstancesModel> private var instances
@EnvironmentObject<PlaylistsModel> private var playlists
2021-07-08 04:09:18 +05:30
2021-07-12 02:22:49 +05:30
#if os(iOS)
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
#endif
2021-06-12 02:41:59 +05:30
2021-06-10 02:21:23 +05:30
var body: some View {
2021-07-12 02:22:49 +05:30
Section {
#if os(iOS)
if horizontalSizeClass == .compact {
AppTabNavigation()
} else {
AppSidebarNavigation()
2021-06-12 02:41:59 +05:30
}
2021-07-12 02:22:49 +05:30
#elseif os(macOS)
AppSidebarNavigation()
#elseif os(tvOS)
TVNavigationView()
#endif
2021-07-30 04:04:13 +05:30
}
2021-09-25 13:48:22 +05:30
.environmentObject(navigation)
.environmentObject(playback)
.environmentObject(recents)
2021-08-02 04:31:24 +05:30
#if !os(tvOS)
2021-09-25 13:48:22 +05:30
.sheet(isPresented: $navigation.showingVideo) {
if let video = navigation.video {
2021-08-02 04:31:24 +05:30
VideoPlayerView(video)
2021-09-25 17:47:58 +05:30
.environmentObject(playback)
2021-08-23 00:43:33 +05:30
2021-08-02 04:31:24 +05:30
#if !os(iOS)
2021-08-23 00:43:33 +05:30
.frame(minWidth: 550, minHeight: 720)
2021-08-02 04:31:24 +05:30
.onExitCommand {
2021-09-25 13:48:22 +05:30
navigation.showingVideo = false
2021-08-02 04:31:24 +05:30
}
#endif
}
}
.sheet(isPresented: $navigation.presentingAddToPlaylist) {
AddToPlaylistView(video: navigation.videoToAddToPlaylist)
}
2021-09-25 13:48:22 +05:30
.sheet(isPresented: $navigation.presentingPlaylistForm) {
PlaylistFormView(playlist: $navigation.editedPlaylist)
}
.sheet(isPresented: $navigation.presentingSettings) {
SettingsView()
2021-08-30 03:06:18 +05:30
}
2021-08-02 04:31:24 +05:30
#endif
2021-07-08 04:09:18 +05:30
}
2021-06-10 02:21:23 +05:30
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
2021-09-29 17:15:00 +05:30
.injectFixtureEnvironmentObjects()
2021-06-10 02:21:23 +05:30
}
}