1
0
mirror of https://github.com/yattee/yattee.git synced 2025-04-29 16:30:32 +05:30

Video details layout fixes

This commit is contained in:
Arkadiusz Fal 2022-11-13 22:50:42 +01:00
parent b6067a3f67
commit 7cc3cd950b
4 changed files with 88 additions and 67 deletions

View File

@ -64,7 +64,7 @@ struct VideoActions: View {
} }
} }
.padding(.horizontal) .padding(.horizontal)
.borderBottom(height: 0.4, color: Color("ControlsBorderColor")) .borderBottom(height: 0.5, color: Color("ControlsBorderColor"))
.multilineTextAlignment(.center) .multilineTextAlignment(.center)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.frame(height: 50) .frame(height: 50)

View File

@ -31,7 +31,6 @@ struct VideoDetails: View {
@EnvironmentObject<RecentsModel> private var recents @EnvironmentObject<RecentsModel> private var recents
@EnvironmentObject<SubscriptionsModel> private var subscriptions @EnvironmentObject<SubscriptionsModel> private var subscriptions
@Default(.playerDetailsPageButtonLabelStyle) private var playerDetailsPageButtonLabelStyle
@Default(.playerSidebar) private var playerSidebar @Default(.playerSidebar) private var playerSidebar
var video: Video? { var video: Video? {
@ -53,6 +52,7 @@ struct VideoDetails: View {
ZStack(alignment: .bottom) { ZStack(alignment: .bottom) {
currentPage currentPage
.frame(maxWidth: detailsSize.width)
.transition(.fade) .transition(.fade)
HStack(alignment: .center) { HStack(alignment: .center) {
@ -181,29 +181,41 @@ struct VideoDetails: View {
if let views = video?.viewsCount, player.videoBeingOpened.isNil { if let views = video?.viewsCount, player.videoBeingOpened.isNil {
Text(views) Text(views)
} else {
if player.videoBeingOpened == nil {
Text("?")
} else { } else {
Text("1,234M").redacted(reason: .placeholder) Text("1,234M").redacted(reason: .placeholder)
} }
}
Image(systemName: "hand.thumbsup") Image(systemName: "hand.thumbsup")
if let likes = video?.likesCount, player.videoBeingOpened.isNil { if let likes = video?.likesCount, player.videoBeingOpened.isNil {
Text(likes) Text(likes)
} else {
if player.videoBeingOpened == nil {
Text("?")
} else { } else {
Text("1,234M").redacted(reason: .placeholder) Text("1,234M").redacted(reason: .placeholder)
} }
}
if Defaults[.enableReturnYouTubeDislike] { if Defaults[.enableReturnYouTubeDislike] {
Image(systemName: "hand.thumbsdown") Image(systemName: "hand.thumbsdown")
if let dislikes = video?.dislikesCount, player.videoBeingOpened.isNil { if let dislikes = video?.dislikesCount, player.videoBeingOpened.isNil {
Text(dislikes) Text(dislikes)
} else {
if player.videoBeingOpened == nil {
Text("?")
} else { } else {
Text("1,234M").redacted(reason: .placeholder) Text("1,234M").redacted(reason: .placeholder)
} }
} }
} }
} }
}
.font(.system(size: 12)) .font(.system(size: 12))
.foregroundColor(.secondary) .foregroundColor(.secondary)
} }

View File

@ -18,7 +18,7 @@ struct VideoDetailsTool: Identifiable {
case .info: case .info:
return video != nil && !video!.isLocal return video != nil && !video!.isLocal
case .inspector: case .inspector:
return true return false
case .chapters: case .chapters:
return video != nil && !video!.chapters.isEmpty return video != nil && !video!.chapters.isEmpty
case .comments: case .comments:

View File

@ -1,6 +1,8 @@
import Defaults
import SwiftUI import SwiftUI
struct VideoDetailsToolbar: View { struct VideoDetailsToolbar: View {
static let lowOpacity = 0.33
var video: Video? var video: Video?
@Binding var page: VideoDetails.DetailsPage @Binding var page: VideoDetails.DetailsPage
var sidebarQueue: Bool var sidebarQueue: Bool
@ -18,8 +20,10 @@ struct VideoDetailsToolbar: View {
@State private var startedToolPosition: CGRect = .zero @State private var startedToolPosition: CGRect = .zero
@State private var opacity = 1.0 @State private var opacity = 1.0
@EnvironmentObject<PlayerModel> private var player
@Default(.playerDetailsPageButtonLabelStyle) private var playerDetailsPageButtonLabelStyle
var body: some View { var body: some View {
Group {
VStack { VStack {
HStack(spacing: 12) { HStack(spacing: 12) {
ForEach($tools) { $tool in ForEach($tools) { $tool in
@ -63,32 +67,35 @@ struct VideoDetailsToolbar: View {
startedToolPosition = .zero startedToolPosition = .zero
} }
Delay.by(2) { Delay.by(2) {
withAnimation(.easeOut(duration: 1)) { lowerOpacity()
opacity = 0.1
}
} }
} }
) )
} }
.onAppear { .onAppear {
Delay.by(2) { Delay.by(2) { lowerOpacity() }
withAnimation(.linear(duration: 1)) {
opacity = 0.1
}
}
} }
.opacity(opacity) .opacity(opacity)
}
.background( .background(
Rectangle() Rectangle()
.contentShape(Rectangle()) .contentShape(Rectangle())
.foregroundColor(.clear) .foregroundColor(.clear)
) )
.onHover { hovering in .onHover { hovering in
withAnimation(.linear(duration: 0.1)) { hovering ? resetOpacity(0.2) : lowerOpacity(0.2)
opacity = hovering ? 1 : 0.1
} }
} }
func lowerOpacity(_ duration: Double = 1.0) {
withAnimation(.linear(duration: duration)) {
opacity = Self.lowOpacity
}
}
func resetOpacity(_ duration: Double = 1.0) {
withAnimation(.linear(duration: duration)) {
opacity = 1
}
} }
@ViewBuilder func ToolView(tool: Binding<VideoDetailsTool>) -> some View { @ViewBuilder func ToolView(tool: Binding<VideoDetailsTool>) -> some View {
@ -110,13 +117,15 @@ struct VideoDetailsToolbar: View {
} }
) )
if activeToolID == tool.wrappedValue.id, false { if activeToolID == tool.wrappedValue.id,
playerDetailsPageButtonLabelStyle.text,
player.playerSize.width > 450
{
Text(tool.wrappedValue.name) Text(tool.wrappedValue.name)
.font(.system(size: 14).bold()) .font(.system(size: 14).bold())
.foregroundColor(.white) .foregroundColor(.white)
.allowsTightening(true) .allowsTightening(true)
.lineLimit(1) .lineLimit(1)
.layoutPriority(2)
} }
} }
.padding(.horizontal, 10) .padding(.horizontal, 10)