Hide unavailable tools in local video details

This commit is contained in:
Arkadiusz Fal 2022-12-22 19:35:36 +01:00
parent 3c971f582f
commit 3661d06080
2 changed files with 28 additions and 12 deletions

View File

@ -37,7 +37,7 @@ struct Constants {
#endif #endif
} }
static var descriptionVisibility: Bool { static var detailsVisibility: Bool {
#if os(iOS) #if os(iOS)
false false
#else #else

View File

@ -31,7 +31,7 @@ struct VideoDetails: View {
var bottomPadding = false var bottomPadding = false
@State private var detailsSize = CGSize.zero @State private var detailsSize = CGSize.zero
@State private var descriptionVisibility = Constants.descriptionVisibility @State private var detailsVisibility = Constants.detailsVisibility
@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.info @State private var page = DetailsPage.info
@ -67,6 +67,9 @@ struct VideoDetails: View {
.animation(nil, value: player.currentItem) .animation(nil, value: player.currentItem)
pageView pageView
#if os(iOS)
.opacity(detailsVisibility ? 1 : 0)
#endif
} }
.overlay(GeometryReader { proxy in .overlay(GeometryReader { proxy in
Color.clear Color.clear
@ -118,21 +121,31 @@ struct VideoDetails: View {
.frame(width: 200, alignment: .leading) .frame(width: 200, alignment: .leading)
.transaction { t in t.animation = nil } .transaction { t in t.animation = nil }
} }
.animation(nil, value: descriptionVisibility) .animation(nil, value: detailsVisibility)
.modifier(SettingsPickerModifier()) .modifier(SettingsPickerModifier())
.offset(x: 15, y: 5) .offset(x: 15, y: 5)
.opacity(descriptionVisibility ? 1 : 0)
#endif #endif
} }
var pagePicker: some View { var pagePicker: some View {
Picker("Page", selection: $page) { Picker("Page", selection: $page) {
ForEach(DetailsPage.allCases, id: \.rawValue) { page in ForEach(DetailsPage.allCases.filter { pageAvailable($0) }, id: \.rawValue) { page in
Label(page.title, systemImage: page.systemImageName).tag(page) Label(page.title, systemImage: page.systemImageName).tag(page)
} }
} }
} }
func pageAvailable(_ page: DetailsPage) -> Bool {
guard let video else { return false }
switch page {
case .inspector:
return true
default:
return !video.isLocal
}
}
var pageView: some View { var pageView: some View {
ZStack(alignment: .topLeading) { ZStack(alignment: .topLeading) {
switch page { switch page {
@ -143,9 +156,6 @@ struct VideoDetails: View {
HStack { HStack {
videoProperties videoProperties
.frame(maxWidth: .infinity, alignment: .trailing) .frame(maxWidth: .infinity, alignment: .trailing)
#if os(iOS)
.opacity(descriptionVisibility ? 1 : 0)
#endif
} }
.padding(.bottom, 12) .padding(.bottom, 12)
@ -155,11 +165,9 @@ struct VideoDetails: View {
.progressViewStyle(.circular) .progressViewStyle(.circular)
} }
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.opacity(descriptionVisibility ? 1 : 0)
} else if video.description != nil, !video.description!.isEmpty { } else if video.description != nil, !video.description!.isEmpty {
VideoDescription(video: video, detailsSize: detailsSize) VideoDescription(video: video, detailsSize: detailsSize)
#if os(iOS) #if os(iOS)
.opacity(descriptionVisibility ? 1 : 0)
.padding(.bottom, player.playingFullScreen ? 10 : SafeArea.insets.bottom) .padding(.bottom, player.playingFullScreen ? 10 : SafeArea.insets.bottom)
#endif #endif
} else if !video.isLocal { } else if !video.isLocal {
@ -172,13 +180,21 @@ struct VideoDetails: View {
.padding(.bottom, 60) .padding(.bottom, 60)
} }
} }
.onAppear {
if video != nil, !pageAvailable(page) {
page = .inspector
}
}
#if os(iOS) #if os(iOS)
.onAppear { .onAppear {
if fullScreen { if fullScreen {
descriptionVisibility = true if let video, video.isLocal {
page = .inspector
}
detailsVisibility = true
return return
} }
Delay.by(0.4) { withAnimation(.easeIn(duration: 0.25)) { self.descriptionVisibility = true } } Delay.by(0.4) { withAnimation(.easeIn(duration: 0.25)) { self.detailsVisibility = true } }
} }
#endif #endif
.transition(.opacity) .transition(.opacity)