mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Add channel description
This commit is contained in:
parent
adc32d5ae1
commit
485c4315ac
@ -25,6 +25,7 @@ extension Video {
|
|||||||
name: "The Channel",
|
name: "The Channel",
|
||||||
bannerURL: URL(string: bannerURL)!,
|
bannerURL: URL(string: bannerURL)!,
|
||||||
thumbnailURL: URL(string: thumbnailURL)!,
|
thumbnailURL: URL(string: thumbnailURL)!,
|
||||||
|
description: "The best channel that ever existed.\nThe best channel that ever existed. The best channel that ever existed. The best channel that ever existed. The best channel that ever existed. ",
|
||||||
subscriptionsCount: 2300,
|
subscriptionsCount: 2300,
|
||||||
totalViews: 3_260_378_817,
|
totalViews: 3_260_378_817,
|
||||||
videos: []
|
videos: []
|
||||||
|
@ -142,6 +142,7 @@ struct Channel: Identifiable, Hashable {
|
|||||||
"name": name,
|
"name": name,
|
||||||
"bannerURL": bannerURL?.absoluteString as Any,
|
"bannerURL": bannerURL?.absoluteString as Any,
|
||||||
"thumbnailURL": thumbnailURL?.absoluteString as Any,
|
"thumbnailURL": thumbnailURL?.absoluteString as Any,
|
||||||
|
"description": description,
|
||||||
"subscriptionsCount": subscriptionsCount as Any,
|
"subscriptionsCount": subscriptionsCount as Any,
|
||||||
"subscriptionsText": subscriptionsText as Any,
|
"subscriptionsText": subscriptionsText as Any,
|
||||||
"totalViews": totalViews as Any,
|
"totalViews": totalViews as Any,
|
||||||
@ -157,6 +158,7 @@ struct Channel: Identifiable, Hashable {
|
|||||||
name: json["name"].stringValue,
|
name: json["name"].stringValue,
|
||||||
bannerURL: json["bannerURL"].url,
|
bannerURL: json["bannerURL"].url,
|
||||||
thumbnailURL: json["thumbnailURL"].url,
|
thumbnailURL: json["thumbnailURL"].url,
|
||||||
|
description: json["description"].stringValue,
|
||||||
subscriptionsCount: json["subscriptionsCount"].int,
|
subscriptionsCount: json["subscriptionsCount"].int,
|
||||||
subscriptionsText: json["subscriptionsText"].string,
|
subscriptionsText: json["subscriptionsText"].string,
|
||||||
totalViews: json["totalViews"].int,
|
totalViews: json["totalViews"].int,
|
||||||
|
@ -14,6 +14,7 @@ struct ChannelVideosView: View {
|
|||||||
@State private var contentType = Channel.ContentType.videos
|
@State private var contentType = Channel.ContentType.videos
|
||||||
@StateObject private var contentTypeItems = Store<[ContentItem]>()
|
@StateObject private var contentTypeItems = Store<[ContentItem]>()
|
||||||
|
|
||||||
|
@State private var descriptionExpanded = false
|
||||||
@StateObject private var store = Store<Channel>()
|
@StateObject private var store = Store<Channel>()
|
||||||
|
|
||||||
@Environment(\.colorScheme) private var colorScheme
|
@Environment(\.colorScheme) private var colorScheme
|
||||||
@ -68,7 +69,33 @@ struct ChannelVideosView: View {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
VerticalCells(items: contentItems) {
|
VerticalCells(items: contentItems) {
|
||||||
|
if let description = presentedChannel?.description, !description.isEmpty {
|
||||||
|
Button {
|
||||||
|
withAnimation(.spring()) {
|
||||||
|
descriptionExpanded.toggle()
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
VStack(alignment: .leading) {
|
||||||
banner
|
banner
|
||||||
|
|
||||||
|
ZStack(alignment: .topTrailing) {
|
||||||
|
Text(description)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
.lineLimit(descriptionExpanded ? 50 : 1)
|
||||||
|
.multilineTextAlignment(.leading)
|
||||||
|
#if os(tvOS)
|
||||||
|
.foregroundColor(.primary)
|
||||||
|
#else
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding(.bottom, descriptionExpanded ? 10 : 0)
|
||||||
|
}
|
||||||
|
.buttonStyle(.plain)
|
||||||
|
} else {
|
||||||
|
banner
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.environment(\.inChannelView, true)
|
.environment(\.inChannelView, true)
|
||||||
.environment(\.listingStyle, channelPlaylistListingStyle)
|
.environment(\.listingStyle, channelPlaylistListingStyle)
|
||||||
@ -383,9 +410,13 @@ struct ChannelVideosView: View {
|
|||||||
|
|
||||||
struct ChannelVideosView_Previews: PreviewProvider {
|
struct ChannelVideosView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
NavigationView {
|
#if os(macOS)
|
||||||
ChannelVideosView(channel: Video.fixture.channel)
|
ChannelVideosView(channel: Video.fixture.channel)
|
||||||
.environment(\.navigationStyle, .sidebar)
|
.environment(\.navigationStyle, .sidebar)
|
||||||
}
|
#else
|
||||||
|
NavigationView {
|
||||||
|
ChannelVideosView(channel: Video.fixture.channel)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user