Subscribed channels list in tab navigation

This commit is contained in:
Arkadiusz Fal
2022-12-11 12:38:57 +01:00
parent 7ba743afbc
commit 5e0f13cace
28 changed files with 566 additions and 222 deletions

View File

@@ -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() }
}
}

View File

@@ -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)