mirror of
https://github.com/yattee/yattee.git
synced 2024-12-23 05:53:41 +00:00
New playlist navigation
This commit is contained in:
parent
0ad350a6b5
commit
a2e23fe72c
@ -78,6 +78,7 @@ final class NavigationModel: ObservableObject {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
navigation.presentingPlaylist = false
|
||||||
navigation.presentingChannel = false
|
navigation.presentingChannel = false
|
||||||
|
|
||||||
let recent = RecentItem(from: channel)
|
let recent = RecentItem(from: channel)
|
||||||
@ -115,6 +116,9 @@ final class NavigationModel: ObservableObject {
|
|||||||
navigationStyle: NavigationStyle,
|
navigationStyle: NavigationStyle,
|
||||||
delay: Bool = false
|
delay: Bool = false
|
||||||
) {
|
) {
|
||||||
|
navigation.presentingChannel = false
|
||||||
|
navigation.presentingPlaylist = false
|
||||||
|
|
||||||
let recent = RecentItem(from: playlist)
|
let recent = RecentItem(from: playlist)
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
Windows.main.open()
|
Windows.main.open()
|
||||||
|
@ -43,24 +43,9 @@ struct AppTabNavigation: View {
|
|||||||
searchNavigationView
|
searchNavigationView
|
||||||
}
|
}
|
||||||
.id(accounts.current?.id ?? "")
|
.id(accounts.current?.id ?? "")
|
||||||
.environment(\.navigationStyle, .tab)
|
|
||||||
.overlay(channelView)
|
.overlay(channelView)
|
||||||
|
.overlay(playlistView)
|
||||||
.background(
|
.environment(\.navigationStyle, .tab)
|
||||||
EmptyView().sheet(isPresented: $navigation.presentingPlaylist) {
|
|
||||||
if let playlist = recents.presentedPlaylist {
|
|
||||||
NavigationView {
|
|
||||||
ChannelPlaylistView(playlist: playlist)
|
|
||||||
.environment(\.managedObjectContext, persistenceController.container.viewContext)
|
|
||||||
.environmentObject(accounts)
|
|
||||||
.environmentObject(navigation)
|
|
||||||
.environmentObject(player)
|
|
||||||
.environmentObject(subscriptions)
|
|
||||||
.environmentObject(thumbnailsModel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private var favoritesNavigationView: some View {
|
private var favoritesNavigationView: some View {
|
||||||
@ -186,4 +171,14 @@ struct AppTabNavigation: View {
|
|||||||
.environmentObject(subscriptions)
|
.environmentObject(subscriptions)
|
||||||
.environmentObject(thumbnailsModel)
|
.environmentObject(thumbnailsModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var playlistView: some View {
|
||||||
|
ChannelPlaylistView()
|
||||||
|
.environment(\.managedObjectContext, persistenceController.container.viewContext)
|
||||||
|
.environmentObject(accounts)
|
||||||
|
.environmentObject(navigation)
|
||||||
|
.environmentObject(player)
|
||||||
|
.environmentObject(subscriptions)
|
||||||
|
.environmentObject(thumbnailsModel)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,31 +2,73 @@ import Siesta
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct ChannelPlaylistView: View {
|
struct ChannelPlaylistView: View {
|
||||||
var playlist: ChannelPlaylist
|
#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 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
|
||||||
|
@Environment(\.navigationStyle) private var navigationStyle
|
||||||
|
|
||||||
@EnvironmentObject<AccountsModel> private var accounts
|
@EnvironmentObject<AccountsModel> private var accounts
|
||||||
|
@EnvironmentObject<NavigationModel> private var navigation
|
||||||
@EnvironmentObject<PlayerModel> private var player
|
@EnvironmentObject<PlayerModel> private var player
|
||||||
|
@EnvironmentObject<RecentsModel> private var recents
|
||||||
|
|
||||||
var items: [ContentItem] {
|
private var items: [ContentItem] {
|
||||||
ContentItem.array(of: store.item?.videos ?? [])
|
ContentItem.array(of: store.item?.videos ?? [])
|
||||||
}
|
}
|
||||||
|
|
||||||
var resource: Resource? {
|
private var presentedPlaylist: ChannelPlaylist? {
|
||||||
accounts.api.channelPlaylist(playlist.id)
|
recents.presentedPlaylist ?? playlist
|
||||||
|
}
|
||||||
|
|
||||||
|
private var resource: Resource? {
|
||||||
|
guard let playlist = presentedPlaylist else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
let resource = accounts.api.channelPlaylist(playlist.id)
|
||||||
|
resource?.addObserver(store)
|
||||||
|
|
||||||
|
return resource
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
if navigationStyle == .tab {
|
||||||
|
NavigationView {
|
||||||
BrowserPlayerControls {
|
BrowserPlayerControls {
|
||||||
content
|
content
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if os(iOS)
|
||||||
|
.onChange(of: navigation.presentingPlaylist) { newValue in
|
||||||
|
if newValue {
|
||||||
|
viewVerticalOffset = 0
|
||||||
|
resource?.load()
|
||||||
|
} else {
|
||||||
|
viewVerticalOffset = Self.hiddenOffset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.offset(y: viewVerticalOffset)
|
||||||
|
.animation(.easeIn(duration: 0.2), value: viewVerticalOffset)
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
BrowserPlayerControls {
|
||||||
|
content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var content: some View {
|
var content: some View {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
@ -58,7 +100,6 @@ struct ChannelPlaylistView: View {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
.onAppear {
|
.onAppear {
|
||||||
resource?.addObserver(store)
|
|
||||||
resource?.loadIfNeeded()
|
resource?.loadIfNeeded()
|
||||||
}
|
}
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
@ -66,23 +107,31 @@ struct ChannelPlaylistView: View {
|
|||||||
#else
|
#else
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .navigation) {
|
ToolbarItem(placement: .navigation) {
|
||||||
|
if navigationStyle == .tab {
|
||||||
|
Button("Done") {
|
||||||
|
navigation.presentingPlaylist = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolbarItem(placement: playlistButtonsPlacement) {
|
||||||
|
HStack {
|
||||||
ShareButton(
|
ShareButton(
|
||||||
contentItem: contentItem,
|
contentItem: contentItem,
|
||||||
presentingShareSheet: $presentingShareSheet,
|
presentingShareSheet: $presentingShareSheet,
|
||||||
shareURL: $shareURL
|
shareURL: $shareURL
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
ToolbarItem(placement: playlistButtonsPlacement) {
|
if let playlist = presentedPlaylist {
|
||||||
HStack {
|
|
||||||
FavoriteButton(item: FavoriteItem(section: .channelPlaylist(playlist.id, playlist.title)))
|
FavoriteButton(item: FavoriteItem(section: .channelPlaylist(playlist.id, playlist.title)))
|
||||||
|
}
|
||||||
|
|
||||||
playButton
|
playButton
|
||||||
shuffleButton
|
shuffleButton
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navigationTitle(playlist.title)
|
.navigationTitle(presentedPlaylist?.title ?? "")
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1407,6 +1407,7 @@
|
|||||||
37152EE926EFEB95004FB96D /* LazyView.swift */,
|
37152EE926EFEB95004FB96D /* LazyView.swift */,
|
||||||
37030FF627B0347C00ECDDAA /* MPVPlayerView.swift */,
|
37030FF627B0347C00ECDDAA /* MPVPlayerView.swift */,
|
||||||
37E70926271CDDAE00D34DDE /* OpenSettingsButton.swift */,
|
37E70926271CDDAE00D34DDE /* OpenSettingsButton.swift */,
|
||||||
|
37FEF11227EFD8580033912F /* PlaceholderCell.swift */,
|
||||||
3769C02D2779F18600DDB3EA /* PlaceholderProgressView.swift */,
|
3769C02D2779F18600DDB3EA /* PlaceholderProgressView.swift */,
|
||||||
37BA793A26DB8EE4002A0235 /* PlaylistVideosView.swift */,
|
37BA793A26DB8EE4002A0235 /* PlaylistVideosView.swift */,
|
||||||
37AAF27D26737323007FC770 /* PopularView.swift */,
|
37AAF27D26737323007FC770 /* PopularView.swift */,
|
||||||
@ -1415,7 +1416,6 @@
|
|||||||
37AAF29F26741C97007FC770 /* SubscriptionsView.swift */,
|
37AAF29F26741C97007FC770 /* SubscriptionsView.swift */,
|
||||||
37B17D9F268A1F25006AEE9B /* VideoContextMenuView.swift */,
|
37B17D9F268A1F25006AEE9B /* VideoContextMenuView.swift */,
|
||||||
37E70922271CD43000D34DDE /* WelcomeScreen.swift */,
|
37E70922271CD43000D34DDE /* WelcomeScreen.swift */,
|
||||||
37FEF11227EFD8580033912F /* PlaceholderCell.swift */,
|
|
||||||
);
|
);
|
||||||
path = Views;
|
path = Views;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
Loading…
Reference in New Issue
Block a user