Fix tab selection

This commit is contained in:
Arkadiusz Fal 2021-06-27 01:50:32 +02:00
parent 7c4eee4a44
commit 8d89d7cc08
2 changed files with 12 additions and 7 deletions

View File

@ -12,11 +12,11 @@ struct VideosView: View {
@State private var showingViewOptions = false @State private var showingViewOptions = false
var body: some View { var body: some View {
Section { VStack {
if layout == .list { if layout == .cells {
VideosListView(videos: videos)
} else {
VideosCellsView(videos: videos, columns: self.profile.cellsColumns) VideosCellsView(videos: videos, columns: self.profile.cellsColumns)
} else {
VideosListView(videos: videos)
} }
} }
.fullScreenCover(isPresented: $showingViewOptions) { ViewOptionsView() } .fullScreenCover(isPresented: $showingViewOptions) { ViewOptionsView() }

View File

@ -5,11 +5,9 @@ struct ContentView: View {
@ObservedObject private var state = AppState() @ObservedObject private var state = AppState()
@ObservedObject private var profile = Profile() @ObservedObject private var profile = Profile()
@Default(.tabSelection) var tabSelection
var body: some View { var body: some View {
NavigationView { NavigationView {
TabView(selection: $tabSelection) { TabView(selection: tabSelection) {
SubscriptionsView() SubscriptionsView()
.tabItem { Text("Subscriptions") } .tabItem { Text("Subscriptions") }
.tag(TabSelection.subscriptions) .tag(TabSelection.subscriptions)
@ -40,6 +38,13 @@ struct ContentView: View {
.environmentObject(state) .environmentObject(state)
.environmentObject(profile) .environmentObject(profile)
} }
var tabSelection: Binding<TabSelection> {
Binding(
get: { Defaults[.tabSelection] },
set: { Defaults[.tabSelection] = $0 }
)
}
} }
struct ContentView_Previews: PreviewProvider { struct ContentView_Previews: PreviewProvider {