mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Fix toolbar tabs
This commit is contained in:
parent
c31a5ee2e0
commit
414b6210c0
@ -4,8 +4,10 @@ import SwiftUI
|
|||||||
struct VideoDetailsOverlay: View {
|
struct VideoDetailsOverlay: View {
|
||||||
@EnvironmentObject<PlayerControlsModel> private var controls
|
@EnvironmentObject<PlayerControlsModel> private var controls
|
||||||
|
|
||||||
|
@State private var detailsPage = VideoDetails.DetailsPage.queue
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VideoDetails(sidebarQueue: .constant(false), fullScreen: fullScreenBinding)
|
VideoDetails(page: $detailsPage, sidebarQueue: .constant(false), fullScreen: fullScreenBinding)
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 4))
|
.clipShape(RoundedRectangle(cornerRadius: 4))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ struct VideoDetails: View {
|
|||||||
case info, inspector, chapters, comments, related, queue
|
case info, inspector, chapters, comments, related, queue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Binding var page: DetailsPage
|
||||||
@Binding var sidebarQueue: Bool
|
@Binding var sidebarQueue: Bool
|
||||||
@Binding var fullScreen: Bool
|
@Binding var fullScreen: Bool
|
||||||
var bottomPadding = false
|
var bottomPadding = false
|
||||||
@ -15,8 +16,6 @@ struct VideoDetails: View {
|
|||||||
@State private var subscribed = false
|
@State private var subscribed = false
|
||||||
@State private var subscriptionToggleButtonDisabled = false
|
@State private var subscriptionToggleButtonDisabled = false
|
||||||
|
|
||||||
@State private var page = DetailsPage.queue
|
|
||||||
|
|
||||||
@Environment(\.navigationStyle) private var navigationStyle
|
@Environment(\.navigationStyle) private var navigationStyle
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
@Environment(\.verticalSizeClass) private var verticalSizeClass
|
@Environment(\.verticalSizeClass) private var verticalSizeClass
|
||||||
@ -84,7 +83,11 @@ struct VideoDetails: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
page = sidebarQueue ? .inspector : .queue
|
if video.isNil ||
|
||||||
|
!VideoDetailsTool.find(for: page)!.isAvailable(for: video!, sidebarQueue: sidebarQueue)
|
||||||
|
{
|
||||||
|
page = .info
|
||||||
|
}
|
||||||
|
|
||||||
guard video != nil, accounts.app.supportsSubscriptions else {
|
guard video != nil, accounts.app.supportsSubscriptions else {
|
||||||
subscribed = false
|
subscribed = false
|
||||||
@ -243,7 +246,7 @@ struct VideoDetails: View {
|
|||||||
|
|
||||||
struct VideoDetails_Previews: PreviewProvider {
|
struct VideoDetails_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
VideoDetails(sidebarQueue: .constant(true), fullScreen: .constant(false))
|
VideoDetails(page: .constant(.info), sidebarQueue: .constant(true), fullScreen: .constant(false))
|
||||||
.injectFixtureEnvironmentObjects()
|
.injectFixtureEnvironmentObjects()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,19 @@ import Defaults
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
struct VideoDetailsTool: Identifiable {
|
struct VideoDetailsTool: Identifiable {
|
||||||
|
static let all = [
|
||||||
|
Self(icon: "info.circle", name: "Info", page: .info),
|
||||||
|
Self(icon: "wand.and.stars", name: "Inspector", page: .inspector),
|
||||||
|
Self(icon: "bookmark", name: "Chapters", page: .chapters),
|
||||||
|
Self(icon: "text.bubble", name: "Comments", page: .comments),
|
||||||
|
Self(icon: "rectangle.stack.fill", name: "Related", page: .related),
|
||||||
|
Self(icon: "list.number", name: "Queue", page: .queue)
|
||||||
|
]
|
||||||
|
|
||||||
|
static func find(for page: VideoDetails.DetailsPage) -> Self? {
|
||||||
|
all.first { $0.page == page }
|
||||||
|
}
|
||||||
|
|
||||||
var id: String {
|
var id: String {
|
||||||
page.rawValue
|
page.rawValue
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,7 @@ struct VideoDetailsToolbar: View {
|
|||||||
@Binding var page: VideoDetails.DetailsPage
|
@Binding var page: VideoDetails.DetailsPage
|
||||||
var sidebarQueue: Bool
|
var sidebarQueue: Bool
|
||||||
|
|
||||||
@State private var tools: [VideoDetailsTool] = [
|
@State private var tools = VideoDetailsTool.all
|
||||||
.init(icon: "info.circle", name: "Info", page: .info),
|
|
||||||
.init(icon: "wand.and.stars", name: "Inspector", page: .inspector),
|
|
||||||
.init(icon: "bookmark", name: "Chapters", page: .chapters),
|
|
||||||
.init(icon: "text.bubble", name: "Comments", page: .comments),
|
|
||||||
.init(icon: "rectangle.stack.fill", name: "Related", page: .related),
|
|
||||||
.init(icon: "list.number", name: "Queue", page: .queue)
|
|
||||||
]
|
|
||||||
|
|
||||||
@State private var activeTool: VideoDetailsTool?
|
@State private var activeTool: VideoDetailsTool?
|
||||||
@State private var startedToolPosition: CGRect = .zero
|
@State private var startedToolPosition: CGRect = .zero
|
||||||
@ -34,6 +27,9 @@ struct VideoDetailsToolbar: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.id(video?.id)
|
.id(video?.id)
|
||||||
|
.onAppear {
|
||||||
|
activeTool = .find(for: page)
|
||||||
|
}
|
||||||
.onChange(of: page) { newValue in
|
.onChange(of: page) { newValue in
|
||||||
activeTool = tools.first { $0.id == newValue.rawValue }
|
activeTool = tools.first { $0.id == newValue.rawValue }
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ struct VideoPlayerView: View {
|
|||||||
|
|
||||||
@State private var playerSize: CGSize = .zero { didSet { updateSidebarQueue() } }
|
@State private var playerSize: CGSize = .zero { didSet { updateSidebarQueue() } }
|
||||||
@State private var hoveringPlayer = false
|
@State private var hoveringPlayer = false
|
||||||
|
@State private var detailsPage = VideoDetails.DetailsPage.queue
|
||||||
@State private var fullScreenDetails = false
|
@State private var fullScreenDetails = false
|
||||||
@State private var sidebarQueue = defaultSidebarQueueValue
|
@State private var sidebarQueue = defaultSidebarQueueValue
|
||||||
|
|
||||||
@ -339,7 +340,7 @@ struct VideoPlayerView: View {
|
|||||||
|
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
if !fullScreenPlayer {
|
if !fullScreenPlayer {
|
||||||
VideoDetails(sidebarQueue: $sidebarQueue, fullScreen: $fullScreenDetails, bottomPadding: detailsNeedBottomPadding)
|
VideoDetails(page: $detailsPage, sidebarQueue: $sidebarQueue, fullScreen: $fullScreenDetails, bottomPadding: detailsNeedBottomPadding)
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
.ignoresSafeArea(.all, edges: .bottom)
|
.ignoresSafeArea(.all, edges: .bottom)
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user