mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
UI improvements
This commit is contained in:
parent
a35d697ebe
commit
b351b31e05
@ -5,12 +5,6 @@ import SDWebImageSwiftUI
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct VideoBanner: View {
|
struct VideoBanner: View {
|
||||||
#if os(tvOS)
|
|
||||||
static let titleAppend = ""
|
|
||||||
#else
|
|
||||||
static let titleAppend = "\n"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
let video: Video?
|
let video: Video?
|
||||||
var playbackTime: CMTime?
|
var playbackTime: CMTime?
|
||||||
var videoDuration: TimeInterval?
|
var videoDuration: TimeInterval?
|
||||||
@ -22,7 +16,7 @@ struct VideoBanner: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(alignment: stackAlignment, spacing: 12) {
|
HStack(alignment: .top, spacing: 12) {
|
||||||
VStack(spacing: thumbnailStackSpacing) {
|
VStack(spacing: thumbnailStackSpacing) {
|
||||||
smallThumbnail
|
smallThumbnail
|
||||||
|
|
||||||
@ -34,7 +28,7 @@ struct VideoBanner: View {
|
|||||||
Group {
|
Group {
|
||||||
if let video {
|
if let video {
|
||||||
HStack(alignment: .top) {
|
HStack(alignment: .top) {
|
||||||
Text(video.displayTitle + Self.titleAppend)
|
Text(video.displayTitle)
|
||||||
if video.isLocal, let fileExtension = video.localStreamFileExtension {
|
if video.isLocal, let fileExtension = video.localStreamFileExtension {
|
||||||
Spacer()
|
Spacer()
|
||||||
Text(fileExtension)
|
Text(fileExtension)
|
||||||
@ -47,11 +41,10 @@ struct VideoBanner: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.truncationMode(.middle)
|
.truncationMode(.middle)
|
||||||
.lineLimit(2)
|
.lineLimit(5)
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.frame(alignment: .leading)
|
|
||||||
|
|
||||||
HStack {
|
HStack(alignment: .top) {
|
||||||
Group {
|
Group {
|
||||||
if let video {
|
if let video {
|
||||||
if !video.isLocal || video.localStreamIsRemoteURL {
|
if !video.isLocal || video.localStreamIsRemoteURL {
|
||||||
@ -92,6 +85,7 @@ struct VideoBanner: View {
|
|||||||
.fontWeight(.light)
|
.fontWeight(.light)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
}
|
}
|
||||||
.padding(.vertical, playbackTime.isNil ? 0 : 5)
|
.padding(.vertical, playbackTime.isNil ? 0 : 5)
|
||||||
@ -99,25 +93,16 @@ struct VideoBanner: View {
|
|||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
.buttonStyle(.card)
|
.buttonStyle(.card)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
#endif
|
#endif
|
||||||
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: 100, alignment: .center)
|
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: 150, alignment: .center)
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
.padding(.vertical, 20)
|
.padding(.vertical, 20)
|
||||||
.padding(.trailing, 10)
|
.padding(.trailing, 10)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private var stackAlignment: VerticalAlignment {
|
|
||||||
#if os(macOS)
|
|
||||||
playbackTime.isNil ? .center : .top
|
|
||||||
#else
|
|
||||||
.center
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
private var thumbnailStackSpacing: Double {
|
private var thumbnailStackSpacing: Double {
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
8
|
8
|
||||||
@ -165,8 +150,8 @@ struct VideoBanner: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var videoDurationLabel: String {
|
private var videoDurationLabel: String {
|
||||||
guard videoDuration != 0 else { return PlayerTimeModel.timePlaceholder }
|
guard videoDuration != 0 else { return "" }
|
||||||
return (videoDuration ?? video?.length ?? 0).formattedAsPlaybackTime() ?? PlayerTimeModel.timePlaceholder
|
return (videoDuration ?? video?.length ?? 0).formattedAsPlaybackTime() ?? ""
|
||||||
}
|
}
|
||||||
|
|
||||||
private var progressView: some View {
|
private var progressView: some View {
|
||||||
|
@ -16,6 +16,13 @@ struct ContentItemView: View {
|
|||||||
.contextMenu {
|
.contextMenu {
|
||||||
VideoContextMenuView(video: item.video)
|
VideoContextMenuView(video: item.video)
|
||||||
}
|
}
|
||||||
|
#if os(tvOS)
|
||||||
|
.padding(.horizontal, 30)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !os(tvOS)
|
||||||
|
Divider()
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
case .playlist:
|
case .playlist:
|
||||||
ChannelPlaylistCell(playlist: item.playlist)
|
ChannelPlaylistCell(playlist: item.playlist)
|
||||||
|
Loading…
Reference in New Issue
Block a user