From 8d89d7cc08ee7bf4e7accff7e51813e9701de863 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sun, 27 Jun 2021 01:50:32 +0200 Subject: [PATCH] Fix tab selection --- Apple TV/VideosView.swift | 8 ++++---- Shared/ContentView.swift | 11 ++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Apple TV/VideosView.swift b/Apple TV/VideosView.swift index 134cc578..a81310cc 100644 --- a/Apple TV/VideosView.swift +++ b/Apple TV/VideosView.swift @@ -12,11 +12,11 @@ struct VideosView: View { @State private var showingViewOptions = false var body: some View { - Section { - if layout == .list { - VideosListView(videos: videos) - } else { + VStack { + if layout == .cells { VideosCellsView(videos: videos, columns: self.profile.cellsColumns) + } else { + VideosListView(videos: videos) } } .fullScreenCover(isPresented: $showingViewOptions) { ViewOptionsView() } diff --git a/Shared/ContentView.swift b/Shared/ContentView.swift index 59fd231f..9cab4b75 100644 --- a/Shared/ContentView.swift +++ b/Shared/ContentView.swift @@ -5,11 +5,9 @@ struct ContentView: View { @ObservedObject private var state = AppState() @ObservedObject private var profile = Profile() - @Default(.tabSelection) var tabSelection - var body: some View { NavigationView { - TabView(selection: $tabSelection) { + TabView(selection: tabSelection) { SubscriptionsView() .tabItem { Text("Subscriptions") } .tag(TabSelection.subscriptions) @@ -40,6 +38,13 @@ struct ContentView: View { .environmentObject(state) .environmentObject(profile) } + + var tabSelection: Binding { + Binding( + get: { Defaults[.tabSelection] }, + set: { Defaults[.tabSelection] = $0 } + ) + } } struct ContentView_Previews: PreviewProvider {