Video details toolbar and inspector settings

This commit is contained in:
Arkadiusz Fal
2022-11-13 23:36:46 +01:00
parent 7cc3cd950b
commit 041a28e7a0
8 changed files with 97 additions and 9 deletions

View File

@@ -75,7 +75,7 @@ struct InspectorView: View {
Text(detail)
.foregroundColor(.secondary)
Spacer()
let value = Text(value)
let value = Text(value).lineLimit(1)
if #available(iOS 15.0, macOS 12.0, *) {
value
#if !os(tvOS)

View File

@@ -83,8 +83,9 @@ struct VideoActions: View {
Text(name)
.foregroundColor(.secondary)
.font(.caption2)
.allowsTightening(true)
}
.padding(.horizontal, 10)
.padding(.horizontal, 6)
.padding(.vertical, 5)
.contentShape(Rectangle())
}

View File

@@ -31,6 +31,7 @@ struct VideoDetails: View {
@EnvironmentObject<RecentsModel> private var recents
@EnvironmentObject<SubscriptionsModel> private var subscriptions
@Default(.detailsToolbarPosition) private var detailsToolbarPosition
@Default(.playerSidebar) private var playerSidebar
var video: Video? {
@@ -56,12 +57,17 @@ struct VideoDetails: View {
.transition(.fade)
HStack(alignment: .center) {
Spacer()
if detailsToolbarPosition.needsLeftSpacer { Spacer() }
VideoDetailsToolbar(video: video, page: $page, sidebarQueue: sidebarQueue)
Spacer()
if detailsToolbarPosition.needsRightSpacer { Spacer() }
}
.padding(.leading, detailsToolbarPosition == .left ? 10 : 0)
.padding(.trailing, detailsToolbarPosition == .right ? 10 : 0)
#if os(iOS)
.offset(y: bottomPadding ? -SafeArea.insets.bottom : 0)
.offset(y: bottomPadding ? -SafeArea.insets.bottom : 0)
#endif
}
.onChange(of: player.currentItem) { newItem in

View File

@@ -1,3 +1,4 @@
import Defaults
import Foundation
struct VideoDetailsTool: Identifiable {
@@ -18,7 +19,7 @@ struct VideoDetailsTool: Identifiable {
case .info:
return video != nil && !video!.isLocal
case .inspector:
return false
return video == nil || Defaults[.showInspector] == .always || video!.isLocal
case .chapters:
return video != nil && !video!.chapters.isEmpty
case .comments:

View File

@@ -2,7 +2,7 @@ import Defaults
import SwiftUI
struct VideoDetailsToolbar: View {
static let lowOpacity = 0.33
static let lowOpacity = 0.5
var video: Video?
@Binding var page: VideoDetails.DetailsPage
var sidebarQueue: Bool
@@ -123,6 +123,7 @@ struct VideoDetailsToolbar: View {
{
Text(tool.wrappedValue.name)
.font(.system(size: 14).bold())
.padding(.trailing, 4)
.foregroundColor(.white)
.allowsTightening(true)
.lineLimit(1)
@@ -136,7 +137,18 @@ struct VideoDetailsToolbar: View {
)
}
var visibleToolsCount: Int {
tools.filter { $0.isAvailable(for: video, sidebarQueue: sidebarQueue) }.count
}
var activeToolID: VideoDetailsTool.ID {
activeTool?.id ?? "queue"
}
}
struct VideoDetailsToolbar_Previews: PreviewProvider {
static var previews: some View {
VideoDetailsToolbar(page: .constant(.queue), sidebarQueue: false)
.injectFixtureEnvironmentObjects()
}
}