yattee/Shared/ContentView.swift

45 lines
1.4 KiB
Swift
Raw Normal View History

2021-06-09 20:51:23 +00:00
import SwiftUI
struct ContentView: View {
2021-06-17 10:02:39 +00:00
@ObservedObject private var state = AppState()
@StateObject private var trendingState = TrendingState()
2021-06-11 21:11:59 +00:00
2021-06-17 10:02:39 +00:00
@State private var tabSelection = TabSelection.popular
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-11 21:11:59 +00:00
TabView(selection: $tabSelection) {
2021-06-17 10:02:39 +00:00
SubscriptionsView(tabSelection: $tabSelection)
2021-06-11 22:49:42 +00:00
.tabItem { Text("Subscriptions") }
.tag(TabSelection.subscriptions)
2021-06-17 10:02:39 +00:00
PopularVideosView(tabSelection: $tabSelection)
2021-06-11 12:36:26 +00:00
.tabItem { Text("Popular") }
2021-06-11 21:11:59 +00:00
.tag(TabSelection.popular)
if state.showingChannel {
2021-06-17 10:02:39 +00:00
ChannelView(tabSelection: $tabSelection)
2021-06-11 22:49:42 +00:00
.tabItem { Text("\(state.channel) Channel") }
2021-06-11 21:11:59 +00:00
.tag(TabSelection.channel)
}
2021-06-17 10:02:39 +00:00
TrendingView(tabSelection: $tabSelection)
.tabItem { Text("Trending") }
.tag(TabSelection.trending)
SearchView(tabSelection: $tabSelection)
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-06-17 10:02:39 +00:00
.environmentObject(state)
.environmentObject(trendingState)
2021-06-09 20:51:23 +00:00
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}