2021-06-27 04:59:55 +05:30
|
|
|
import Defaults
|
2021-06-10 02:21:23 +05:30
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct ContentView: View {
|
2021-06-28 20:32:13 +05:30
|
|
|
@Default(.openChannel) var channel
|
2021-07-08 04:09:18 +05:30
|
|
|
@Default(.showingVideoDetails) var showDetails
|
|
|
|
|
|
|
|
@State private var showingOptions = false
|
2021-06-12 02:41:59 +05:30
|
|
|
|
2021-06-10 02:21:23 +05:30
|
|
|
var body: some View {
|
2021-06-11 04:20:10 +05:30
|
|
|
NavigationView {
|
2021-06-27 05:20:32 +05:30
|
|
|
TabView(selection: tabSelection) {
|
2021-06-27 04:59:55 +05:30
|
|
|
SubscriptionsView()
|
2021-06-12 04:19:42 +05:30
|
|
|
.tabItem { Text("Subscriptions") }
|
|
|
|
.tag(TabSelection.subscriptions)
|
|
|
|
|
2021-06-27 04:59:55 +05:30
|
|
|
PopularVideosView()
|
2021-06-11 18:06:26 +05:30
|
|
|
.tabItem { Text("Popular") }
|
2021-06-12 02:41:59 +05:30
|
|
|
.tag(TabSelection.popular)
|
|
|
|
|
2021-06-28 20:32:13 +05:30
|
|
|
if channel != nil {
|
|
|
|
ChannelView(id: channel!.id)
|
|
|
|
.tabItem { Text("\(channel!.name) Channel") }
|
2021-06-12 02:41:59 +05:30
|
|
|
.tag(TabSelection.channel)
|
|
|
|
}
|
|
|
|
|
2021-06-27 04:59:55 +05:30
|
|
|
TrendingView()
|
2021-06-17 15:32:39 +05:30
|
|
|
.tabItem { Text("Trending") }
|
|
|
|
.tag(TabSelection.trending)
|
|
|
|
|
2021-06-27 04:59:55 +05:30
|
|
|
PlaylistsView()
|
2021-06-26 15:09:35 +05:30
|
|
|
.tabItem { Text("Playlists") }
|
|
|
|
.tag(TabSelection.playlists)
|
|
|
|
|
2021-06-27 04:59:55 +05:30
|
|
|
SearchView()
|
2021-06-11 18:06:26 +05:30
|
|
|
.tabItem { Image(systemName: "magnifyingglass") }
|
2021-06-12 02:41:59 +05:30
|
|
|
.tag(TabSelection.search)
|
2021-06-11 04:20:10 +05:30
|
|
|
}
|
2021-07-08 04:09:18 +05:30
|
|
|
.fullScreenCover(isPresented: $showingOptions) { OptionsView() }
|
|
|
|
.onPlayPauseCommand { showingOptions.toggle() }
|
|
|
|
.background(videoDetailsViewNavigationLink)
|
2021-06-11 04:20:10 +05:30
|
|
|
}
|
2021-06-10 02:21:23 +05:30
|
|
|
}
|
2021-06-27 05:20:32 +05:30
|
|
|
|
|
|
|
var tabSelection: Binding<TabSelection> {
|
|
|
|
Binding(
|
|
|
|
get: { Defaults[.tabSelection] },
|
|
|
|
set: { Defaults[.tabSelection] = $0 }
|
|
|
|
)
|
|
|
|
}
|
2021-07-08 04:09:18 +05:30
|
|
|
|
|
|
|
var videoDetailsViewNavigationLink: some View {
|
|
|
|
NavigationLink("", destination: VideoDetailsView(), isActive: $showDetails).hidden()
|
|
|
|
}
|
2021-06-10 02:21:23 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
struct ContentView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
ContentView()
|
|
|
|
}
|
|
|
|
}
|