diff --git a/Model/NavigationModel.swift b/Model/NavigationModel.swift index cfea408c..11dff244 100644 --- a/Model/NavigationModel.swift +++ b/Model/NavigationModel.swift @@ -107,7 +107,7 @@ final class NavigationModel: ObservableObject { navigation.sidebarSectionChanged.toggle() navigation.tabSelection = .recentlyOpened(recent.tag) } else { - withAnimation { + withAnimation(.linear(duration: 0.3)) { navigation.presentingChannel = true } } @@ -137,7 +137,7 @@ final class NavigationModel: ObservableObject { navigation.sidebarSectionChanged.toggle() navigation.tabSelection = .recentlyOpened(recent.tag) } else { - withAnimation { + withAnimation(.linear(duration: 0.3)) { navigation.presentingPlaylist = true } } diff --git a/Shared/Navigation/AppTabNavigation.swift b/Shared/Navigation/AppTabNavigation.swift index 66a70cd4..63780aaf 100644 --- a/Shared/Navigation/AppTabNavigation.swift +++ b/Shared/Navigation/AppTabNavigation.swift @@ -156,9 +156,8 @@ struct AppTabNavigation: View { .environmentObject(player) .environmentObject(subscriptions) .environmentObject(thumbnailsModel) - .transition(.asymmetric(insertion: .flipFromBottom, removal: .move(edge: .bottom))) - } else { - EmptyView() + .id("channelVideos") + .transition(.move(edge: .bottom)) } } @@ -171,9 +170,8 @@ struct AppTabNavigation: View { .environmentObject(player) .environmentObject(subscriptions) .environmentObject(thumbnailsModel) - .transition(.asymmetric(insertion: .flipFromBottom, removal: .move(edge: .bottom))) - } else { - EmptyView() + .id("channelPlaylist") + .transition(.move(edge: .bottom)) } } } diff --git a/Shared/Views/ChannelPlaylistView.swift b/Shared/Views/ChannelPlaylistView.swift index 417f1b2f..2b0463ae 100644 --- a/Shared/Views/ChannelPlaylistView.swift +++ b/Shared/Views/ChannelPlaylistView.swift @@ -2,19 +2,11 @@ import Siesta import SwiftUI struct ChannelPlaylistView: View { - #if os(iOS) - static let hiddenOffset = max(UIScreen.main.bounds.height, UIScreen.main.bounds.width) + 100 - #endif - var playlist: ChannelPlaylist? @State private var presentingShareSheet = false @State private var shareURL: URL? - #if os(iOS) - @State private var viewVerticalOffset = Self.hiddenOffset - #endif - @StateObject private var store = Store() @Environment(\.colorScheme) private var colorScheme @@ -51,17 +43,6 @@ struct ChannelPlaylistView: View { content } } - #if os(iOS) - .onChange(of: navigation.presentingPlaylist) { newValue in - if newValue { - store.clear() - viewVerticalOffset = 0 - resource?.load() - } else { - viewVerticalOffset = Self.hiddenOffset - } - } - #endif } else { BrowserPlayerControls { content @@ -92,7 +73,13 @@ struct ChannelPlaylistView: View { .environment(\.inChannelPlaylistView, true) } .onAppear { - resource?.loadIfNeeded() + if navigationStyle == .tab { + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + resource?.loadIfNeeded() + } + } else { + resource?.loadIfNeeded() + } } #if os(tvOS) .background(Color.background(scheme: colorScheme)) diff --git a/Shared/Views/ChannelVideosView.swift b/Shared/Views/ChannelVideosView.swift index fc4062b4..b80a35e0 100644 --- a/Shared/Views/ChannelVideosView.swift +++ b/Shared/Views/ChannelVideosView.swift @@ -2,19 +2,12 @@ import Siesta import SwiftUI struct ChannelVideosView: View { - #if os(iOS) - static let hiddenOffset = max(UIScreen.main.bounds.height, UIScreen.main.bounds.width) + 100 - #endif var channel: Channel? @State private var presentingShareSheet = false @State private var shareURL: URL? @State private var subscriptionToggleButtonDisabled = false - #if os(iOS) - @State private var viewVerticalOffset = Self.hiddenOffset - #endif - @StateObject private var store = Store() @Environment(\.colorScheme) private var colorScheme @@ -47,17 +40,6 @@ struct ChannelVideosView: View { content } } - #if os(iOS) - .onChange(of: navigation.presentingChannel) { newValue in - if newValue { - store.clear() - viewVerticalOffset = 0 - resource?.load() - } else { - viewVerticalOffset = Self.hiddenOffset - } - } - #endif } else { BrowserPlayerControls { content @@ -132,7 +114,13 @@ struct ChannelVideosView: View { } #endif .onAppear { - resource?.loadIfNeeded() + if navigationStyle == .tab { + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + resource?.loadIfNeeded() + } + } else { + resource?.loadIfNeeded() + } } #if !os(tvOS) .navigationTitle(navigationTitle)