mirror of
https://github.com/yattee/yattee.git
synced 2025-08-04 01:34:10 +00:00
Subscribed channels list in tab navigation
This commit is contained in:
@@ -201,6 +201,8 @@ extension Defaults.Keys {
|
||||
static let mpvCacheSecs = Key<String>("mpvCacheSecs", default: "120")
|
||||
static let mpvCachePauseWait = Key<String>("mpvCachePauseWait", default: "3")
|
||||
static let mpvEnableLogging = Key<Bool>("mpvEnableLogging", default: false)
|
||||
|
||||
static let subscriptionsViewPage = Key<SubscriptionsView.Page>("subscriptionsViewPage", default: .feed)
|
||||
}
|
||||
|
||||
enum ResolutionSetting: String, CaseIterable, Defaults.Serializable {
|
||||
|
@@ -4,6 +4,8 @@ import SwiftUI
|
||||
struct PlayerOverlayModifier: ViewModifier {
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
.overlay(ControlsBar(fullScreen: .constant(false)), alignment: .bottom)
|
||||
#if !os(tvOS)
|
||||
.overlay(ControlsBar(fullScreen: .constant(false)), alignment: .bottom)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ import SwiftUI
|
||||
|
||||
struct AppSidebarSubscriptions: View {
|
||||
@ObservedObject private var navigation = NavigationModel.shared
|
||||
@ObservedObject private var subscriptions = SubscriptionsModel.shared
|
||||
@ObservedObject private var subscriptions = SubsribedChannelsModel.shared
|
||||
|
||||
var body: some View {
|
||||
Section(header: Text("Subscriptions")) {
|
||||
@@ -23,3 +23,9 @@ struct AppSidebarSubscriptions: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct AppSidebarSubscriptions_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
AppSidebarSubscriptions()
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ struct AppTabNavigation: View {
|
||||
@ObservedObject private var accounts = AccountsModel.shared
|
||||
@ObservedObject private var navigation = NavigationModel.shared
|
||||
private var player = PlayerModel.shared
|
||||
@ObservedObject private var subscriptions = SubscriptionsModel.shared
|
||||
@ObservedObject private var subscriptions = SubsribedChannelsModel.shared
|
||||
|
||||
@Default(.showHome) private var showHome
|
||||
@Default(.showDocuments) private var showDocuments
|
||||
@@ -170,23 +170,27 @@ struct AppTabNavigation: View {
|
||||
|
||||
@ViewBuilder private var channelView: some View {
|
||||
if navigation.presentingChannel {
|
||||
ChannelVideosView()
|
||||
.environment(\.managedObjectContext, persistenceController.container.viewContext)
|
||||
.environment(\.inChannelView, true)
|
||||
.environment(\.navigationStyle, .tab)
|
||||
.id("channelVideos")
|
||||
.zIndex(player.presentingPlayer ? -1 : 2)
|
||||
.transition(.move(edge: .bottom))
|
||||
NavigationView {
|
||||
ChannelVideosView(showCloseButton: true)
|
||||
}
|
||||
.environment(\.managedObjectContext, persistenceController.container.viewContext)
|
||||
.environment(\.inChannelView, true)
|
||||
.environment(\.navigationStyle, .tab)
|
||||
.id("channelVideos")
|
||||
.zIndex(player.presentingPlayer ? -1 : 2)
|
||||
.transition(.move(edge: .bottom))
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder private var playlistView: some View {
|
||||
if navigation.presentingPlaylist {
|
||||
ChannelPlaylistView()
|
||||
.environment(\.managedObjectContext, persistenceController.container.viewContext)
|
||||
.id("channelPlaylist")
|
||||
.zIndex(player.presentingPlayer ? -1 : 1)
|
||||
.transition(.move(edge: .bottom))
|
||||
NavigationView {
|
||||
ChannelPlaylistView(showCloseButton: true)
|
||||
}
|
||||
.environment(\.managedObjectContext, persistenceController.container.viewContext)
|
||||
.id("channelPlaylist")
|
||||
.zIndex(player.presentingPlayer ? -1 : 1)
|
||||
.transition(.move(edge: .bottom))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ struct ContentView: View {
|
||||
@ObservedObject private var navigation = NavigationModel.shared
|
||||
@ObservedObject private var player = PlayerModel.shared
|
||||
private var playlists = PlaylistsModel.shared
|
||||
private var subscriptions = SubscriptionsModel.shared
|
||||
private var subscriptions = SubsribedChannelsModel.shared
|
||||
|
||||
#if os(iOS)
|
||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||
|
@@ -8,7 +8,7 @@ final class AppleAVPlayerViewController: UIViewController {
|
||||
var navigationModel: NavigationModel { .shared }
|
||||
var playerModel: PlayerModel { .shared }
|
||||
var playlistsModel: PlaylistsModel { .shared }
|
||||
var subscriptionsModel: SubscriptionsModel { .shared }
|
||||
var subscriptionsModel: SubsribedChannelsModel { .shared }
|
||||
var playerView = AVPlayerViewController()
|
||||
|
||||
let persistenceController = PersistenceController.shared
|
||||
|
@@ -15,7 +15,7 @@ struct CommentView: View {
|
||||
@Environment(\.navigationStyle) private var navigationStyle
|
||||
|
||||
@ObservedObject private var comments = CommentsModel.shared
|
||||
var subscriptions = SubscriptionsModel.shared
|
||||
var subscriptions = SubsribedChannelsModel.shared
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
|
@@ -4,7 +4,7 @@ import SwiftUI
|
||||
struct VideoActions: View {
|
||||
@ObservedObject private var accounts = AccountsModel.shared
|
||||
var navigation = NavigationModel.shared
|
||||
@ObservedObject private var subscriptions = SubscriptionsModel.shared
|
||||
@ObservedObject private var subscriptions = SubsribedChannelsModel.shared
|
||||
@ObservedObject private var player = PlayerModel.shared
|
||||
|
||||
var video: Video?
|
||||
|
109
Shared/Subscriptions/ChannelsView.swift
Normal file
109
Shared/Subscriptions/ChannelsView.swift
Normal file
@@ -0,0 +1,109 @@
|
||||
import SDWebImageSwiftUI
|
||||
import SwiftUI
|
||||
|
||||
struct ChannelsView: View {
|
||||
@ObservedObject private var subscriptions = SubsribedChannelsModel.shared
|
||||
@ObservedObject private var accounts = AccountsModel.shared
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
Section(header: header) {
|
||||
ForEach(subscriptions.all) { channel in
|
||||
NavigationLink(destination: ChannelVideosView(channel: channel).modifier(PlayerOverlayModifier())) {
|
||||
HStack {
|
||||
if let url = channel.thumbnailURL {
|
||||
ThumbnailView(url: url)
|
||||
.frame(width: 35, height: 35)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 35))
|
||||
Text(channel.name)
|
||||
} else {
|
||||
Label(channel.name, systemImage: RecentsModel.symbolSystemImage(channel.name))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#if os(tvOS)
|
||||
.padding(.horizontal, 50)
|
||||
#endif
|
||||
|
||||
Color.clear.padding(.bottom, 50)
|
||||
.listRowBackground(Color.clear)
|
||||
.backport
|
||||
.listRowSeparator(false)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
subscriptions.load()
|
||||
}
|
||||
.onChange(of: accounts.current) { _ in
|
||||
subscriptions.load(force: true)
|
||||
}
|
||||
#if os(iOS)
|
||||
.refreshControl { refreshControl in
|
||||
subscriptions.load(force: true) {
|
||||
refreshControl.endRefreshing()
|
||||
}
|
||||
}
|
||||
.backport
|
||||
.refreshable {
|
||||
await subscriptions.load(force: true)
|
||||
}
|
||||
#endif
|
||||
#if !os(tvOS)
|
||||
.background(
|
||||
Button("Refresh") {
|
||||
subscriptions.load(force: true)
|
||||
}
|
||||
.keyboardShortcut("r")
|
||||
.opacity(0)
|
||||
)
|
||||
#endif
|
||||
#if !os(macOS)
|
||||
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in
|
||||
subscriptions.load()
|
||||
}
|
||||
#endif
|
||||
#if os(tvOS)
|
||||
.padding(.horizontal, 30)
|
||||
#endif
|
||||
}
|
||||
|
||||
var header: some View {
|
||||
HStack {
|
||||
#if os(tvOS)
|
||||
SubscriptionsPageButton()
|
||||
#endif
|
||||
|
||||
Spacer()
|
||||
|
||||
CacheStatusHeader(
|
||||
refreshTime: subscriptions.formattedCacheTime,
|
||||
isLoading: subscriptions.isLoading
|
||||
)
|
||||
|
||||
#if os(tvOS)
|
||||
Button {
|
||||
subscriptions.load(force: true)
|
||||
} label: {
|
||||
Label("Refresh", systemImage: "arrow.clockwise")
|
||||
.labelStyle(.iconOnly)
|
||||
.imageScale(.small)
|
||||
.font(.caption2)
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
#if os(tvOS)
|
||||
.padding(.bottom, 15)
|
||||
.padding(.top, 15)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
struct ChannelsView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NavigationView {
|
||||
ChannelsView()
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,8 +1,8 @@
|
||||
import Foundation
|
||||
import Siesta
|
||||
|
||||
final class SubscriptionsViewModel: ObservableObject {
|
||||
static let shared = SubscriptionsViewModel()
|
||||
final class FeedModel: ObservableObject {
|
||||
static let shared = FeedModel()
|
||||
|
||||
@Published var isLoading = false
|
||||
@Published var videos = [Video]()
|
||||
@@ -114,7 +114,8 @@ final class SubscriptionsViewModel: ObservableObject {
|
||||
}
|
||||
|
||||
private func loadCachedFeed() {
|
||||
let cache = FeedCacheModel.shared.retrieveFeed(account: accounts.current)
|
||||
guard let account = accounts.current else { return }
|
||||
let cache = FeedCacheModel.shared.retrieveFeed(account: account)
|
||||
if !cache.isEmpty {
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
self?.videos = cache
|
82
Shared/Subscriptions/FeedView.swift
Normal file
82
Shared/Subscriptions/FeedView.swift
Normal file
@@ -0,0 +1,82 @@
|
||||
import Defaults
|
||||
import Siesta
|
||||
import SwiftUI
|
||||
|
||||
struct FeedView: View {
|
||||
@ObservedObject private var feed = FeedModel.shared
|
||||
@ObservedObject private var accounts = AccountsModel.shared
|
||||
|
||||
var videos: [ContentItem] {
|
||||
ContentItem.array(of: feed.videos)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VerticalCells(items: videos) {
|
||||
HStack {
|
||||
#if os(tvOS)
|
||||
SubscriptionsPageButton()
|
||||
#endif
|
||||
|
||||
Spacer()
|
||||
|
||||
CacheStatusHeader(refreshTime: feed.formattedFeedTime, isLoading: feed.isLoading)
|
||||
|
||||
#if os(tvOS)
|
||||
Button {
|
||||
feed.loadResources(force: true)
|
||||
} label: {
|
||||
Label("Refresh", systemImage: "arrow.clockwise")
|
||||
.labelStyle(.iconOnly)
|
||||
.imageScale(.small)
|
||||
.font(.caption2)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
.padding(.leading, 30)
|
||||
#if os(tvOS)
|
||||
.padding(.bottom, 15)
|
||||
#endif
|
||||
}
|
||||
.environment(\.loadMoreContentHandler) { feed.loadNextPage() }
|
||||
.onAppear {
|
||||
feed.loadResources()
|
||||
}
|
||||
.onChange(of: accounts.current) { _ in
|
||||
feed.reset()
|
||||
feed.loadResources(force: true)
|
||||
}
|
||||
#if os(iOS)
|
||||
.refreshControl { refreshControl in
|
||||
feed.loadResources(force: true) {
|
||||
refreshControl.endRefreshing()
|
||||
}
|
||||
}
|
||||
.backport
|
||||
.refreshable {
|
||||
await feed.loadResources(force: true)
|
||||
}
|
||||
#endif
|
||||
#if !os(tvOS)
|
||||
.background(
|
||||
Button("Refresh") {
|
||||
feed.loadResources(force: true)
|
||||
}
|
||||
.keyboardShortcut("r")
|
||||
.opacity(0)
|
||||
)
|
||||
#endif
|
||||
#if !os(macOS)
|
||||
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in
|
||||
feed.loadResources()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
struct SubscriptonsView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NavigationView {
|
||||
FeedView()
|
||||
}
|
||||
}
|
||||
}
|
22
Shared/Subscriptions/SubscriptionsPageButton.swift
Normal file
22
Shared/Subscriptions/SubscriptionsPageButton.swift
Normal file
@@ -0,0 +1,22 @@
|
||||
import Defaults
|
||||
import SwiftUI
|
||||
|
||||
struct SubscriptionsPageButton: View {
|
||||
@Default(.subscriptionsViewPage) private var subscriptionsViewPage
|
||||
|
||||
var body: some View {
|
||||
Button {
|
||||
subscriptionsViewPage = subscriptionsViewPage.next()
|
||||
} label: {
|
||||
Text(subscriptionsViewPage.rawValue.capitalized)
|
||||
.frame(maxWidth: .infinity)
|
||||
.font(.caption2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SubscriptionsPageButton_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SubscriptionsPageButton()
|
||||
}
|
||||
}
|
@@ -1,78 +1,68 @@
|
||||
import Siesta
|
||||
import Defaults
|
||||
import SwiftUI
|
||||
|
||||
struct SubscriptionsView: View {
|
||||
@ObservedObject private var model = SubscriptionsViewModel.shared
|
||||
@ObservedObject private var accounts = AccountsModel.shared
|
||||
|
||||
var videos: [ContentItem] {
|
||||
ContentItem.array(of: model.videos)
|
||||
enum Page: String, CaseIterable, Defaults.Serializable {
|
||||
case feed
|
||||
case channels
|
||||
}
|
||||
|
||||
@Default(.subscriptionsViewPage) private var subscriptionsViewPage
|
||||
|
||||
var body: some View {
|
||||
SignInRequiredView(title: "Subscriptions".localized()) {
|
||||
VerticalCells(items: videos) {
|
||||
HStack {
|
||||
Spacer()
|
||||
|
||||
CacheStatusHeader(refreshTime: model.formattedFeedTime, isLoading: model.isLoading)
|
||||
|
||||
#if os(tvOS)
|
||||
Button {
|
||||
model.loadResources(force: true)
|
||||
} label: {
|
||||
Label("Refresh", systemImage: "arrow.clockwise")
|
||||
.labelStyle(.iconOnly)
|
||||
.imageScale(.small)
|
||||
.font(.caption2)
|
||||
}
|
||||
.padding(.horizontal, 10)
|
||||
#endif
|
||||
}
|
||||
switch subscriptionsViewPage {
|
||||
case .feed:
|
||||
FeedView()
|
||||
case .channels:
|
||||
ChannelsView()
|
||||
#if os(tvOS)
|
||||
.ignoresSafeArea(.all, edges: .horizontal)
|
||||
#endif
|
||||
}
|
||||
.environment(\.loadMoreContentHandler) { model.loadNextPage() }
|
||||
.onAppear {
|
||||
model.loadResources()
|
||||
}
|
||||
.onChange(of: accounts.current) { _ in
|
||||
model.reset()
|
||||
model.loadResources(force: true)
|
||||
}
|
||||
#if os(iOS)
|
||||
.refreshControl { refreshControl in
|
||||
model.loadResources(force: true) {
|
||||
refreshControl.endRefreshing()
|
||||
}
|
||||
}
|
||||
.backport
|
||||
.refreshable {
|
||||
await model.loadResources(force: true)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !os(tvOS)
|
||||
.background(
|
||||
Button("Refresh") {
|
||||
model.loadResources(force: true)
|
||||
}
|
||||
.keyboardShortcut("r")
|
||||
.opacity(0)
|
||||
)
|
||||
#endif
|
||||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(RefreshControl.navigationBarTitleDisplayMode)
|
||||
#endif
|
||||
#if !os(macOS)
|
||||
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in
|
||||
model.loadResources()
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .principal) {
|
||||
subscriptionsMenu
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
var subscriptionsMenu: some View {
|
||||
Menu {
|
||||
Picker("Page", selection: $subscriptionsViewPage) {
|
||||
Label("Feed", systemImage: "film").tag(Page.feed)
|
||||
Label("Channels", systemImage: "person.3.fill").tag(Page.channels)
|
||||
}
|
||||
} label: {
|
||||
HStack(spacing: 12) {
|
||||
Text(menuLabel)
|
||||
.font(.headline)
|
||||
.foregroundColor(.primary)
|
||||
|
||||
Image(systemName: "chevron.down.circle.fill")
|
||||
.foregroundColor(.accentColor)
|
||||
.imageScale(.small)
|
||||
}
|
||||
.transaction { t in t.animation = nil }
|
||||
}
|
||||
}
|
||||
|
||||
var menuLabel: String {
|
||||
subscriptionsViewPage == .channels ? "Channels" : "Feed"
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
struct SubscriptonsView_Previews: PreviewProvider {
|
||||
struct SubscriptionsView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SubscriptionsView()
|
||||
NavigationView {
|
||||
SubscriptionsView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -14,24 +14,27 @@ struct ThumbnailView: View {
|
||||
var body: some View {
|
||||
Group {
|
||||
if imageManager.image != nil {
|
||||
#if os(macOS)
|
||||
Image(nsImage: imageManager.image!)
|
||||
.resizable()
|
||||
#else
|
||||
Image(uiImage: imageManager.image!)
|
||||
.resizable()
|
||||
#endif
|
||||
Group {
|
||||
#if os(macOS)
|
||||
Image(nsImage: imageManager.image!)
|
||||
.resizable()
|
||||
#else
|
||||
Image(uiImage: imageManager.image!)
|
||||
.resizable()
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
Rectangle().fill(Color("PlaceholderColor"))
|
||||
.onAppear {
|
||||
self.imageManager.setOnFailure { _ in
|
||||
guard let url else { return }
|
||||
self.thumbnails.insertUnloadable(url)
|
||||
}
|
||||
self.imageManager.load(url: url)
|
||||
}
|
||||
.onDisappear { self.imageManager.cancel() }
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
guard let url else { return }
|
||||
|
||||
self.imageManager.setOnFailure { _ in
|
||||
self.thumbnails.insertUnloadable(url)
|
||||
}
|
||||
self.imageManager.load(url: url)
|
||||
}
|
||||
.onDisappear { self.imageManager.cancel() }
|
||||
}
|
||||
}
|
||||
|
@@ -164,7 +164,7 @@ struct VideoCell: View {
|
||||
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
if !channelOnThumbnail, !inChannelView {
|
||||
channelButton(badge: false)
|
||||
channelControl(badge: false)
|
||||
}
|
||||
|
||||
if additionalDetailsAvailable {
|
||||
@@ -251,7 +251,7 @@ struct VideoCell: View {
|
||||
.frame(minHeight: 40, alignment: .top)
|
||||
#endif
|
||||
if !channelOnThumbnail, !inChannelView {
|
||||
channelButton(badge: false)
|
||||
channelControl(badge: false)
|
||||
.padding(.top, 4)
|
||||
.padding(.bottom, 6)
|
||||
}
|
||||
@@ -305,33 +305,55 @@ struct VideoCell: View {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder private func channelButton(badge: Bool = true) -> some View {
|
||||
@ViewBuilder private func channelControl(badge: Bool = true) -> some View {
|
||||
if !video.channel.name.isEmpty {
|
||||
Button {
|
||||
guard !inChannelView else {
|
||||
return
|
||||
}
|
||||
|
||||
NavigationModel.shared.openChannel(
|
||||
video.channel,
|
||||
navigationStyle: navigationStyle
|
||||
)
|
||||
} label: {
|
||||
if badge {
|
||||
DetailBadge(text: video.author, style: .prominent)
|
||||
.foregroundColor(.primary)
|
||||
} else {
|
||||
Text(video.channel.name)
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
#if os(tvOS)
|
||||
.buttonStyle(.card)
|
||||
channelButton(badge: badge)
|
||||
#else
|
||||
.buttonStyle(.plain)
|
||||
if navigationStyle == .tab {
|
||||
channelNavigationLink(badge: badge)
|
||||
} else {
|
||||
channelButton(badge: badge)
|
||||
}
|
||||
#endif
|
||||
.help("\(video.channel.name) Channel")
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder private func channelNavigationLink(badge: Bool = true) -> some View {
|
||||
NavigationLink(destination: ChannelVideosView(channel: video.channel)) {
|
||||
channelLabel(badge: badge)
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder private func channelButton(badge: Bool = true) -> some View {
|
||||
Button {
|
||||
guard !inChannelView else {
|
||||
return
|
||||
}
|
||||
|
||||
NavigationModel.shared.openChannel(
|
||||
video.channel,
|
||||
navigationStyle: navigationStyle
|
||||
)
|
||||
} label: {
|
||||
channelLabel(badge: badge)
|
||||
}
|
||||
#if os(tvOS)
|
||||
.buttonStyle(.card)
|
||||
#else
|
||||
.buttonStyle(.plain)
|
||||
#endif
|
||||
.help("\(video.channel.name) Channel")
|
||||
}
|
||||
|
||||
@ViewBuilder private func channelLabel(badge: Bool = true) -> some View {
|
||||
if badge {
|
||||
DetailBadge(text: video.author, style: .prominent)
|
||||
.foregroundColor(.primary)
|
||||
} else {
|
||||
Text(video.channel.name)
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,7 +393,7 @@ struct VideoCell: View {
|
||||
Spacer()
|
||||
|
||||
if channelOnThumbnail, !inChannelView {
|
||||
channelButton()
|
||||
channelControl()
|
||||
}
|
||||
}
|
||||
#if os(tvOS)
|
||||
|
@@ -12,7 +12,7 @@ struct CacheStatusHeader: View {
|
||||
.opacity(isLoading ? 1 : 0)
|
||||
Text(refreshTime)
|
||||
}
|
||||
.font(.caption)
|
||||
.font(.caption.monospacedDigit())
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
|
@@ -8,20 +8,42 @@ struct ChannelCell: View {
|
||||
@Environment(\.navigationStyle) private var navigationStyle
|
||||
|
||||
var body: some View {
|
||||
#if os(tvOS)
|
||||
button
|
||||
#else
|
||||
if navigationStyle == .tab {
|
||||
navigationLink
|
||||
} else {
|
||||
button
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
var navigationLink: some View {
|
||||
NavigationLink(destination: ChannelVideosView(channel: channel).modifier(PlayerOverlayModifier())) {
|
||||
labelContent
|
||||
}
|
||||
}
|
||||
|
||||
var button: some View {
|
||||
Button {
|
||||
NavigationModel.shared.openChannel(
|
||||
channel,
|
||||
navigationStyle: navigationStyle
|
||||
)
|
||||
} label: {
|
||||
content
|
||||
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
|
||||
.contentShape(RoundedRectangle(cornerRadius: 12))
|
||||
labelContent
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
|
||||
var content: some View {
|
||||
var label: some View {
|
||||
labelContent
|
||||
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
|
||||
.contentShape(RoundedRectangle(cornerRadius: 12))
|
||||
}
|
||||
|
||||
var labelContent: some View {
|
||||
VStack {
|
||||
HStack(alignment: .top, spacing: 3) {
|
||||
Image(systemName: "person.crop.rectangle")
|
||||
|
@@ -9,14 +9,22 @@ struct ChannelPlaylistCell: View {
|
||||
var navigation = NavigationModel.shared
|
||||
|
||||
var body: some View {
|
||||
Button {
|
||||
NavigationModel.shared.openChannelPlaylist(playlist, navigationStyle: navigationStyle)
|
||||
} label: {
|
||||
content
|
||||
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
|
||||
.contentShape(RoundedRectangle(cornerRadius: 12))
|
||||
if navigationStyle == .tab {
|
||||
NavigationLink(destination: ChannelPlaylistView(playlist: playlist)) { cell }
|
||||
} else {
|
||||
Button {
|
||||
NavigationModel.shared.openChannelPlaylist(playlist, navigationStyle: navigationStyle)
|
||||
} label: {
|
||||
cell
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
|
||||
var cell: some View {
|
||||
content
|
||||
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
|
||||
.contentShape(RoundedRectangle(cornerRadius: 12))
|
||||
}
|
||||
|
||||
var content: some View {
|
||||
|
@@ -3,6 +3,7 @@ import SwiftUI
|
||||
|
||||
struct ChannelPlaylistView: View {
|
||||
var playlist: ChannelPlaylist?
|
||||
var showCloseButton = false
|
||||
|
||||
@State private var presentingShareSheet = false
|
||||
@State private var shareURL: URL?
|
||||
@@ -36,16 +37,6 @@ struct ChannelPlaylistView: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
if navigationStyle == .tab {
|
||||
NavigationView {
|
||||
content
|
||||
}
|
||||
} else {
|
||||
content
|
||||
}
|
||||
}
|
||||
|
||||
var content: some View {
|
||||
VStack(alignment: .leading) {
|
||||
#if os(tvOS)
|
||||
HStack {
|
||||
@@ -81,7 +72,7 @@ struct ChannelPlaylistView: View {
|
||||
#else
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
if navigationStyle == .tab {
|
||||
if showCloseButton {
|
||||
Button {
|
||||
NavigationModel.shared.presentingPlaylist = false
|
||||
} label: {
|
||||
|
@@ -4,6 +4,7 @@ import SwiftUI
|
||||
|
||||
struct ChannelVideosView: View {
|
||||
var channel: Channel?
|
||||
var showCloseButton = false
|
||||
|
||||
@State private var presentingShareSheet = false
|
||||
@State private var shareURL: URL?
|
||||
@@ -15,7 +16,6 @@ struct ChannelVideosView: View {
|
||||
@StateObject private var store = Store<Channel>()
|
||||
|
||||
@Environment(\.colorScheme) private var colorScheme
|
||||
@Environment(\.navigationStyle) private var navigationStyle
|
||||
|
||||
#if os(iOS)
|
||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||
@@ -24,7 +24,7 @@ struct ChannelVideosView: View {
|
||||
@ObservedObject private var accounts = AccountsModel.shared
|
||||
@ObservedObject private var navigation = NavigationModel.shared
|
||||
@ObservedObject private var recents = RecentsModel.shared
|
||||
@ObservedObject private var subscriptions = SubscriptionsModel.shared
|
||||
@ObservedObject private var subscriptions = SubsribedChannelsModel.shared
|
||||
@Namespace private var focusNamespace
|
||||
|
||||
var presentedChannel: Channel? {
|
||||
@@ -40,16 +40,6 @@ struct ChannelVideosView: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
if navigationStyle == .tab {
|
||||
NavigationView {
|
||||
content
|
||||
}
|
||||
} else {
|
||||
content
|
||||
}
|
||||
}
|
||||
|
||||
var content: some View {
|
||||
let content = VStack {
|
||||
#if os(tvOS)
|
||||
VStack {
|
||||
@@ -95,7 +85,7 @@ struct ChannelVideosView: View {
|
||||
}
|
||||
#endif
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
if navigationStyle == .tab {
|
||||
if showCloseButton {
|
||||
Button {
|
||||
withAnimation(Constants.overlayAnimation) {
|
||||
navigation.presentingChannel = false
|
||||
@@ -141,13 +131,7 @@ struct ChannelVideosView: View {
|
||||
}
|
||||
#endif
|
||||
.onAppear {
|
||||
if navigationStyle == .tab {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
resource?.loadIfNeeded()
|
||||
}
|
||||
} else {
|
||||
resource?.loadIfNeeded()
|
||||
}
|
||||
resource?.loadIfNeeded()
|
||||
}
|
||||
.onChange(of: contentType) { _ in
|
||||
resource?.load()
|
||||
|
@@ -14,7 +14,7 @@ struct ControlsBar: View {
|
||||
var navigation = NavigationModel.shared
|
||||
@ObservedObject private var model = PlayerModel.shared
|
||||
@ObservedObject private var playlists = PlaylistsModel.shared
|
||||
@ObservedObject private var subscriptions = SubscriptionsModel.shared
|
||||
@ObservedObject private var subscriptions = SubsribedChannelsModel.shared
|
||||
|
||||
@ObservedObject private var controls = PlayerControlsModel.shared
|
||||
|
||||
|
@@ -15,7 +15,7 @@ struct VideoContextMenuView: View {
|
||||
@ObservedObject private var navigation = NavigationModel.shared
|
||||
@ObservedObject private var player = PlayerModel.shared
|
||||
@ObservedObject private var playlists = PlaylistsModel.shared
|
||||
@ObservedObject private var subscriptions = SubscriptionsModel.shared
|
||||
@ObservedObject private var subscriptions = SubsribedChannelsModel.shared
|
||||
|
||||
@FetchRequest private var watchRequest: FetchedResults<Watch>
|
||||
|
||||
|
@@ -40,7 +40,7 @@ struct YatteeApp: App {
|
||||
@StateObject private var playlists = PlaylistsModel.shared
|
||||
@StateObject private var recents = RecentsModel.shared
|
||||
@StateObject private var settings = SettingsModel.shared
|
||||
@StateObject private var subscriptions = SubscriptionsModel.shared
|
||||
@StateObject private var subscriptions = SubsribedChannelsModel.shared
|
||||
@StateObject private var thumbnails = ThumbnailsModel.shared
|
||||
|
||||
let persistenceController = PersistenceController.shared
|
||||
|
Reference in New Issue
Block a user