mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +00:00
Subscribed channels list in tab navigation
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user