2021-07-12 02:22:49 +05:30
|
|
|
import Defaults
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct AppTabNavigation: View {
|
2021-09-25 13:48:22 +05:30
|
|
|
@EnvironmentObject<NavigationModel> private var navigation
|
|
|
|
@EnvironmentObject<SearchModel> private var search
|
2021-09-25 17:47:58 +05:30
|
|
|
@EnvironmentObject<RecentsModel> private var recents
|
2021-09-19 16:36:54 +05:30
|
|
|
|
2021-07-12 02:22:49 +05:30
|
|
|
var body: some View {
|
2021-09-29 04:31:49 +05:30
|
|
|
TabView(selection: navigation.tabSelectionBinding) {
|
2021-07-12 02:22:49 +05:30
|
|
|
NavigationView {
|
2021-09-25 13:48:22 +05:30
|
|
|
LazyView(WatchNowView())
|
|
|
|
.toolbar { toolbarContent }
|
2021-07-12 02:22:49 +05:30
|
|
|
}
|
|
|
|
.tabItem {
|
2021-09-19 02:06:42 +05:30
|
|
|
Label("Watch Now", systemImage: "play.circle")
|
2021-07-12 02:22:49 +05:30
|
|
|
.accessibility(label: Text("Subscriptions"))
|
|
|
|
}
|
2021-09-19 02:06:42 +05:30
|
|
|
.tag(TabSelection.watchNow)
|
2021-07-12 02:22:49 +05:30
|
|
|
|
|
|
|
NavigationView {
|
2021-09-25 13:48:22 +05:30
|
|
|
LazyView(SubscriptionsView())
|
|
|
|
.toolbar { toolbarContent }
|
2021-07-12 02:22:49 +05:30
|
|
|
}
|
|
|
|
.tabItem {
|
2021-09-19 02:06:42 +05:30
|
|
|
Label("Subscriptions", systemImage: "star.circle.fill")
|
|
|
|
.accessibility(label: Text("Subscriptions"))
|
2021-07-12 02:22:49 +05:30
|
|
|
}
|
2021-09-19 02:06:42 +05:30
|
|
|
.tag(TabSelection.subscriptions)
|
|
|
|
|
|
|
|
// TODO: reenable with settings
|
|
|
|
// ============================
|
|
|
|
// NavigationView {
|
2021-09-25 13:48:22 +05:30
|
|
|
// LazyView(PopularView())
|
|
|
|
// .toolbar { toolbarContent }
|
2021-09-19 02:06:42 +05:30
|
|
|
// }
|
|
|
|
// .tabItem {
|
|
|
|
// Label("Popular", systemImage: "chart.bar")
|
|
|
|
// .accessibility(label: Text("Popular"))
|
|
|
|
// }
|
|
|
|
// .tag(TabSelection.popular)
|
2021-07-12 02:22:49 +05:30
|
|
|
|
|
|
|
NavigationView {
|
2021-09-25 13:48:22 +05:30
|
|
|
LazyView(TrendingView())
|
|
|
|
.toolbar { toolbarContent }
|
2021-07-12 02:22:49 +05:30
|
|
|
}
|
|
|
|
.tabItem {
|
|
|
|
Label("Trending", systemImage: "chart.line.uptrend.xyaxis")
|
|
|
|
.accessibility(label: Text("Trending"))
|
|
|
|
}
|
|
|
|
.tag(TabSelection.trending)
|
|
|
|
|
|
|
|
NavigationView {
|
2021-09-25 13:48:22 +05:30
|
|
|
LazyView(PlaylistsView())
|
|
|
|
.toolbar { toolbarContent }
|
2021-07-12 02:22:49 +05:30
|
|
|
}
|
|
|
|
.tabItem {
|
|
|
|
Label("Playlists", systemImage: "list.and.film")
|
|
|
|
.accessibility(label: Text("Playlists"))
|
|
|
|
}
|
|
|
|
.tag(TabSelection.playlists)
|
|
|
|
|
|
|
|
NavigationView {
|
2021-09-25 13:48:22 +05:30
|
|
|
LazyView(
|
|
|
|
SearchView()
|
|
|
|
.toolbar { toolbarContent }
|
|
|
|
.searchable(text: $search.queryText, placement: .navigationBarDrawer(displayMode: .always)) {
|
|
|
|
ForEach(search.querySuggestions.collection, id: \.self) { suggestion in
|
|
|
|
Text(suggestion)
|
|
|
|
.searchCompletion(suggestion)
|
|
|
|
}
|
2021-09-14 02:11:16 +05:30
|
|
|
}
|
2021-09-25 13:48:22 +05:30
|
|
|
.onChange(of: search.queryText) { query in
|
|
|
|
search.loadSuggestions(query)
|
2021-09-14 02:11:16 +05:30
|
|
|
}
|
2021-09-25 13:48:22 +05:30
|
|
|
.onSubmit(of: .search) {
|
|
|
|
search.changeQuery { query in
|
|
|
|
query.query = search.queryText
|
|
|
|
}
|
2021-09-14 02:11:16 +05:30
|
|
|
|
2021-09-25 17:47:58 +05:30
|
|
|
recents.addQuery(search.queryText)
|
2021-09-25 13:48:22 +05:30
|
|
|
}
|
|
|
|
)
|
2021-07-12 02:22:49 +05:30
|
|
|
}
|
|
|
|
.tabItem {
|
|
|
|
Label("Search", systemImage: "magnifyingglass")
|
|
|
|
.accessibility(label: Text("Search"))
|
|
|
|
}
|
|
|
|
.tag(TabSelection.search)
|
|
|
|
}
|
2021-09-19 18:12:47 +05:30
|
|
|
.environment(\.navigationStyle, .tab)
|
2021-09-25 13:48:22 +05:30
|
|
|
.sheet(isPresented: $navigation.isChannelOpen, onDismiss: {
|
2021-09-19 16:36:54 +05:30
|
|
|
if let channel = recents.presentedChannel {
|
|
|
|
let recent = RecentItem(from: channel)
|
|
|
|
recents.close(recent)
|
|
|
|
}
|
2021-09-01 02:47:50 +05:30
|
|
|
}) {
|
2021-09-19 16:36:54 +05:30
|
|
|
if recents.presentedChannel != nil {
|
2021-09-01 02:47:50 +05:30
|
|
|
NavigationView {
|
2021-09-25 13:48:22 +05:30
|
|
|
ChannelVideosView(channel: recents.presentedChannel!)
|
2021-09-01 02:47:50 +05:30
|
|
|
.environment(\.inNavigationView, true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-25 13:48:22 +05:30
|
|
|
|
|
|
|
var toolbarContent: some ToolbarContent {
|
|
|
|
#if os(iOS)
|
|
|
|
Group {
|
|
|
|
ToolbarItemGroup(placement: .navigationBarLeading) {
|
|
|
|
Button(action: { navigation.presentingSettings = true }) {
|
|
|
|
Image(systemName: "gearshape.2")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ToolbarItemGroup(placement: .navigationBarTrailing) {
|
|
|
|
AccountsMenuView()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2021-07-12 02:22:49 +05:30
|
|
|
}
|