Fix toolbar tabs

This commit is contained in:
Arkadiusz Fal
2022-11-18 22:22:57 +01:00
parent c31a5ee2e0
commit 414b6210c0
5 changed files with 29 additions and 14 deletions

View File

@@ -8,6 +8,7 @@ struct VideoDetails: View {
case info, inspector, chapters, comments, related, queue
}
@Binding var page: DetailsPage
@Binding var sidebarQueue: Bool
@Binding var fullScreen: Bool
var bottomPadding = false
@@ -15,8 +16,6 @@ struct VideoDetails: View {
@State private var subscribed = false
@State private var subscriptionToggleButtonDisabled = false
@State private var page = DetailsPage.queue
@Environment(\.navigationStyle) private var navigationStyle
#if os(iOS)
@Environment(\.verticalSizeClass) private var verticalSizeClass
@@ -84,7 +83,11 @@ struct VideoDetails: View {
}
}
.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 {
subscribed = false
@@ -243,7 +246,7 @@ struct VideoDetails: View {
struct VideoDetails_Previews: PreviewProvider {
static var previews: some View {
VideoDetails(sidebarQueue: .constant(true), fullScreen: .constant(false))
VideoDetails(page: .constant(.info), sidebarQueue: .constant(true), fullScreen: .constant(false))
.injectFixtureEnvironmentObjects()
}
}