yattee/Shared/ContentView.swift

62 lines
1.8 KiB
Swift
Raw Normal View History

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