1
0
mirror of https://github.com/yattee/yattee.git synced 2025-01-07 18:10:33 +05:30

Channel/playlist view transition improvements

This commit is contained in:
Arkadiusz Fal 2022-08-08 19:30:40 +02:00
parent 4d84defb03
commit c7a2b2632b
4 changed files with 20 additions and 47 deletions

View File

@ -107,7 +107,7 @@ final class NavigationModel: ObservableObject {
navigation.sidebarSectionChanged.toggle() navigation.sidebarSectionChanged.toggle()
navigation.tabSelection = .recentlyOpened(recent.tag) navigation.tabSelection = .recentlyOpened(recent.tag)
} else { } else {
withAnimation { withAnimation(.linear(duration: 0.3)) {
navigation.presentingChannel = true navigation.presentingChannel = true
} }
} }
@ -137,7 +137,7 @@ final class NavigationModel: ObservableObject {
navigation.sidebarSectionChanged.toggle() navigation.sidebarSectionChanged.toggle()
navigation.tabSelection = .recentlyOpened(recent.tag) navigation.tabSelection = .recentlyOpened(recent.tag)
} else { } else {
withAnimation { withAnimation(.linear(duration: 0.3)) {
navigation.presentingPlaylist = true navigation.presentingPlaylist = true
} }
} }

View File

@ -156,9 +156,8 @@ struct AppTabNavigation: View {
.environmentObject(player) .environmentObject(player)
.environmentObject(subscriptions) .environmentObject(subscriptions)
.environmentObject(thumbnailsModel) .environmentObject(thumbnailsModel)
.transition(.asymmetric(insertion: .flipFromBottom, removal: .move(edge: .bottom))) .id("channelVideos")
} else { .transition(.move(edge: .bottom))
EmptyView()
} }
} }
@ -171,9 +170,8 @@ struct AppTabNavigation: View {
.environmentObject(player) .environmentObject(player)
.environmentObject(subscriptions) .environmentObject(subscriptions)
.environmentObject(thumbnailsModel) .environmentObject(thumbnailsModel)
.transition(.asymmetric(insertion: .flipFromBottom, removal: .move(edge: .bottom))) .id("channelPlaylist")
} else { .transition(.move(edge: .bottom))
EmptyView()
} }
} }
} }

View File

@ -2,19 +2,11 @@ import Siesta
import SwiftUI import SwiftUI
struct ChannelPlaylistView: View { struct ChannelPlaylistView: View {
#if os(iOS)
static let hiddenOffset = max(UIScreen.main.bounds.height, UIScreen.main.bounds.width) + 100
#endif
var playlist: ChannelPlaylist? var playlist: ChannelPlaylist?
@State private var presentingShareSheet = false @State private var presentingShareSheet = false
@State private var shareURL: URL? @State private var shareURL: URL?
#if os(iOS)
@State private var viewVerticalOffset = Self.hiddenOffset
#endif
@StateObject private var store = Store<ChannelPlaylist>() @StateObject private var store = Store<ChannelPlaylist>()
@Environment(\.colorScheme) private var colorScheme @Environment(\.colorScheme) private var colorScheme
@ -51,17 +43,6 @@ struct ChannelPlaylistView: View {
content content
} }
} }
#if os(iOS)
.onChange(of: navigation.presentingPlaylist) { newValue in
if newValue {
store.clear()
viewVerticalOffset = 0
resource?.load()
} else {
viewVerticalOffset = Self.hiddenOffset
}
}
#endif
} else { } else {
BrowserPlayerControls { BrowserPlayerControls {
content content
@ -92,8 +73,14 @@ struct ChannelPlaylistView: View {
.environment(\.inChannelPlaylistView, true) .environment(\.inChannelPlaylistView, true)
} }
.onAppear { .onAppear {
if navigationStyle == .tab {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
resource?.loadIfNeeded() resource?.loadIfNeeded()
} }
} else {
resource?.loadIfNeeded()
}
}
#if os(tvOS) #if os(tvOS)
.background(Color.background(scheme: colorScheme)) .background(Color.background(scheme: colorScheme))
#else #else

View File

@ -2,19 +2,12 @@ import Siesta
import SwiftUI import SwiftUI
struct ChannelVideosView: View { struct ChannelVideosView: View {
#if os(iOS)
static let hiddenOffset = max(UIScreen.main.bounds.height, UIScreen.main.bounds.width) + 100
#endif
var channel: Channel? var channel: Channel?
@State private var presentingShareSheet = false @State private var presentingShareSheet = false
@State private var shareURL: URL? @State private var shareURL: URL?
@State private var subscriptionToggleButtonDisabled = false @State private var subscriptionToggleButtonDisabled = false
#if os(iOS)
@State private var viewVerticalOffset = Self.hiddenOffset
#endif
@StateObject private var store = Store<Channel>() @StateObject private var store = Store<Channel>()
@Environment(\.colorScheme) private var colorScheme @Environment(\.colorScheme) private var colorScheme
@ -47,17 +40,6 @@ struct ChannelVideosView: View {
content content
} }
} }
#if os(iOS)
.onChange(of: navigation.presentingChannel) { newValue in
if newValue {
store.clear()
viewVerticalOffset = 0
resource?.load()
} else {
viewVerticalOffset = Self.hiddenOffset
}
}
#endif
} else { } else {
BrowserPlayerControls { BrowserPlayerControls {
content content
@ -132,8 +114,14 @@ struct ChannelVideosView: View {
} }
#endif #endif
.onAppear { .onAppear {
if navigationStyle == .tab {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
resource?.loadIfNeeded() resource?.loadIfNeeded()
} }
} else {
resource?.loadIfNeeded()
}
}
#if !os(tvOS) #if !os(tvOS)
.navigationTitle(navigationTitle) .navigationTitle(navigationTitle)
#endif #endif