mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Show video properties
This commit is contained in:
parent
e58afcbf3f
commit
b6067a3f67
@ -12,39 +12,50 @@ struct VideoActions: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
HStack {
|
HStack {
|
||||||
if let video {
|
if let video {
|
||||||
ShareButton(contentItem: .init(video: video)) {
|
if !video.isLocal || video.localStreamIsRemoteURL {
|
||||||
actionButton("Share", systemImage: "square.and.arrow.up")
|
ShareButton(contentItem: .init(video: video)) {
|
||||||
}
|
actionButton("Share", systemImage: "square.and.arrow.up")
|
||||||
|
}
|
||||||
|
|
||||||
Spacer()
|
|
||||||
|
|
||||||
actionButton("Add", systemImage: "text.badge.plus") {
|
|
||||||
navigation.presentAddToPlaylist(video)
|
|
||||||
}
|
|
||||||
if accounts.app.supportsSubscriptions, accounts.signedIn {
|
|
||||||
Spacer()
|
Spacer()
|
||||||
if subscriptions.isSubscribing(video.channel.id) {
|
}
|
||||||
actionButton("Unsubscribe", systemImage: "xmark.circle") {
|
|
||||||
#if os(tvOS)
|
if !video.isLocal {
|
||||||
subscriptions.unsubscribe(video.channel.id)
|
if accounts.signedIn, accounts.app.supportsUserPlaylists {
|
||||||
#else
|
actionButton("Add", systemImage: "text.badge.plus") {
|
||||||
navigation.presentUnsubscribeAlert(video.channel, subscriptions: subscriptions)
|
navigation.presentAddToPlaylist(video)
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} else {
|
Spacer()
|
||||||
actionButton("Subscribe", systemImage: "star.circle") {
|
}
|
||||||
subscriptions.subscribe(video.channel.id) {
|
if accounts.signedIn, accounts.app.supportsSubscriptions {
|
||||||
navigation.sidebarSectionChanged.toggle()
|
if subscriptions.isSubscribing(video.channel.id) {
|
||||||
|
actionButton("Unsubscribe", systemImage: "xmark.circle") {
|
||||||
|
#if os(tvOS)
|
||||||
|
subscriptions.unsubscribe(video.channel.id)
|
||||||
|
#else
|
||||||
|
navigation.presentUnsubscribeAlert(video.channel, subscriptions: subscriptions)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
actionButton("Subscribe", systemImage: "star.circle") {
|
||||||
|
subscriptions.subscribe(video.channel.id) {
|
||||||
|
navigation.sidebarSectionChanged.toggle()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Spacer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Spacer()
|
|
||||||
|
if player.currentItem == nil {
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
|
||||||
actionButton("Hide", systemImage: "chevron.down") {
|
actionButton("Hide", systemImage: "chevron.down") {
|
||||||
player.hide(animate: true)
|
player.hide(animate: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if player.currentItem != nil {
|
if player.currentItem != nil {
|
||||||
Spacer()
|
Spacer()
|
||||||
actionButton("Close", systemImage: "xmark") {
|
actionButton("Close", systemImage: "xmark") {
|
||||||
@ -80,58 +91,6 @@ struct VideoActions: View {
|
|||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
.accessibilityLabel(Text(name))
|
.accessibilityLabel(Text(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder var videoProperties: some View {
|
|
||||||
HStack(spacing: 2) {
|
|
||||||
publishedDateSection
|
|
||||||
|
|
||||||
Spacer()
|
|
||||||
|
|
||||||
HStack(spacing: 4) {
|
|
||||||
Image(systemName: "eye")
|
|
||||||
|
|
||||||
if let views = video?.viewsCount, player.videoBeingOpened.isNil {
|
|
||||||
Text(views)
|
|
||||||
} else {
|
|
||||||
Text("1,234M").redacted(reason: .placeholder)
|
|
||||||
}
|
|
||||||
|
|
||||||
Image(systemName: "hand.thumbsup")
|
|
||||||
|
|
||||||
if let likes = video?.likesCount, player.videoBeingOpened.isNil {
|
|
||||||
Text(likes)
|
|
||||||
} else {
|
|
||||||
Text("1,234M").redacted(reason: .placeholder)
|
|
||||||
}
|
|
||||||
|
|
||||||
if Defaults[.enableReturnYouTubeDislike] {
|
|
||||||
Image(systemName: "hand.thumbsdown")
|
|
||||||
|
|
||||||
if let dislikes = video?.dislikesCount, player.videoBeingOpened.isNil {
|
|
||||||
Text(dislikes)
|
|
||||||
} else {
|
|
||||||
Text("1,234M").redacted(reason: .placeholder)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.font(.system(size: 12))
|
|
||||||
.foregroundColor(.secondary)
|
|
||||||
}
|
|
||||||
|
|
||||||
var publishedDateSection: some View {
|
|
||||||
Group {
|
|
||||||
if let video {
|
|
||||||
HStack(spacing: 4) {
|
|
||||||
if let published = video.publishedDate {
|
|
||||||
Text(published)
|
|
||||||
} else {
|
|
||||||
Text("1 century ago").redacted(reason: .placeholder)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct VideoActions_Previews: PreviewProvider {
|
struct VideoActions_Previews: PreviewProvider {
|
||||||
|
@ -144,6 +144,8 @@ struct VideoDetails: View {
|
|||||||
ScrollView(.vertical, showsIndicators: false) {
|
ScrollView(.vertical, showsIndicators: false) {
|
||||||
if let video {
|
if let video {
|
||||||
VStack(alignment: .leading, spacing: 10) {
|
VStack(alignment: .leading, spacing: 10) {
|
||||||
|
videoProperties
|
||||||
|
|
||||||
if !player.videoBeingOpened.isNil && (video.description.isNil || video.description!.isEmpty) {
|
if !player.videoBeingOpened.isNil && (video.description.isNil || video.description!.isEmpty) {
|
||||||
VStack(alignment: .leading, spacing: 0) {
|
VStack(alignment: .leading, spacing: 0) {
|
||||||
ForEach(1 ... Int.random(in: 2 ... 5), id: \.self) { _ in
|
ForEach(1 ... Int.random(in: 2 ... 5), id: \.self) { _ in
|
||||||
@ -167,6 +169,58 @@ struct VideoDetails: View {
|
|||||||
}
|
}
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ViewBuilder var videoProperties: some View {
|
||||||
|
HStack(spacing: 2) {
|
||||||
|
publishedDateSection
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
HStack(spacing: 4) {
|
||||||
|
Image(systemName: "eye")
|
||||||
|
|
||||||
|
if let views = video?.viewsCount, player.videoBeingOpened.isNil {
|
||||||
|
Text(views)
|
||||||
|
} else {
|
||||||
|
Text("1,234M").redacted(reason: .placeholder)
|
||||||
|
}
|
||||||
|
|
||||||
|
Image(systemName: "hand.thumbsup")
|
||||||
|
|
||||||
|
if let likes = video?.likesCount, player.videoBeingOpened.isNil {
|
||||||
|
Text(likes)
|
||||||
|
} else {
|
||||||
|
Text("1,234M").redacted(reason: .placeholder)
|
||||||
|
}
|
||||||
|
|
||||||
|
if Defaults[.enableReturnYouTubeDislike] {
|
||||||
|
Image(systemName: "hand.thumbsdown")
|
||||||
|
|
||||||
|
if let dislikes = video?.dislikesCount, player.videoBeingOpened.isNil {
|
||||||
|
Text(dislikes)
|
||||||
|
} else {
|
||||||
|
Text("1,234M").redacted(reason: .placeholder)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.font(.system(size: 12))
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
|
||||||
|
var publishedDateSection: some View {
|
||||||
|
Group {
|
||||||
|
if let video {
|
||||||
|
HStack(spacing: 4) {
|
||||||
|
if let published = video.publishedDate {
|
||||||
|
Text(published)
|
||||||
|
} else {
|
||||||
|
Text("1 century ago").redacted(reason: .placeholder)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct VideoDetails_Previews: PreviewProvider {
|
struct VideoDetails_Previews: PreviewProvider {
|
||||||
|
Loading…
Reference in New Issue
Block a user