mirror of
				https://github.com/yattee/yattee.git
				synced 2025-11-03 22:22:02 +00:00 
			
		
		
		
	Show video properties
This commit is contained in:
		@@ -12,17 +12,22 @@ struct VideoActions: View {
 | 
			
		||||
    var body: some View {
 | 
			
		||||
        HStack {
 | 
			
		||||
            if let video {
 | 
			
		||||
                if !video.isLocal || video.localStreamIsRemoteURL {
 | 
			
		||||
                    ShareButton(contentItem: .init(video: video)) {
 | 
			
		||||
                        actionButton("Share", systemImage: "square.and.arrow.up")
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    Spacer()
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if !video.isLocal {
 | 
			
		||||
                    if accounts.signedIn, accounts.app.supportsUserPlaylists {
 | 
			
		||||
                        actionButton("Add", systemImage: "text.badge.plus") {
 | 
			
		||||
                            navigation.presentAddToPlaylist(video)
 | 
			
		||||
                        }
 | 
			
		||||
                if accounts.app.supportsSubscriptions, accounts.signedIn {
 | 
			
		||||
                        Spacer()
 | 
			
		||||
                    }
 | 
			
		||||
                    if accounts.signedIn, accounts.app.supportsSubscriptions {
 | 
			
		||||
                        if subscriptions.isSubscribing(video.channel.id) {
 | 
			
		||||
                            actionButton("Unsubscribe", systemImage: "xmark.circle") {
 | 
			
		||||
                                #if os(tvOS)
 | 
			
		||||
@@ -38,13 +43,19 @@ struct VideoActions: View {
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
                        Spacer()
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if player.currentItem == nil {
 | 
			
		||||
                Spacer()
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            actionButton("Hide", systemImage: "chevron.down") {
 | 
			
		||||
                player.hide(animate: true)
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if player.currentItem != nil {
 | 
			
		||||
                Spacer()
 | 
			
		||||
                actionButton("Close", systemImage: "xmark") {
 | 
			
		||||
@@ -80,58 +91,6 @@ struct VideoActions: View {
 | 
			
		||||
        .buttonStyle(.plain)
 | 
			
		||||
        .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 {
 | 
			
		||||
 
 | 
			
		||||
@@ -144,6 +144,8 @@ struct VideoDetails: View {
 | 
			
		||||
        ScrollView(.vertical, showsIndicators: false) {
 | 
			
		||||
            if let video {
 | 
			
		||||
                VStack(alignment: .leading, spacing: 10) {
 | 
			
		||||
                    videoProperties
 | 
			
		||||
 | 
			
		||||
                    if !player.videoBeingOpened.isNil && (video.description.isNil || video.description!.isEmpty) {
 | 
			
		||||
                        VStack(alignment: .leading, spacing: 0) {
 | 
			
		||||
                            ForEach(1 ... Int.random(in: 2 ... 5), id: \.self) { _ in
 | 
			
		||||
@@ -167,6 +169,58 @@ struct VideoDetails: View {
 | 
			
		||||
        }
 | 
			
		||||
        .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 {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user