mirror of
https://github.com/yattee/yattee.git
synced 2024-11-09 15:58:20 +00:00
don’t open video when dismissing context menu
fixes #510 fix tvOS build Signed-off-by: Toni Förster <toni.foerster@gmail.com>
This commit is contained in:
parent
2d7a101ce0
commit
b00b733fd5
@ -24,14 +24,42 @@ struct VideoContextMenuView: View {
|
|||||||
|
|
||||||
private var backgroundContext = PersistenceController.shared.container.newBackgroundContext()
|
private var backgroundContext = PersistenceController.shared.container.newBackgroundContext()
|
||||||
|
|
||||||
|
@State private var isOverlayVisible = false
|
||||||
|
|
||||||
init(video: Video) {
|
init(video: Video) {
|
||||||
self.video = video
|
self.video = video
|
||||||
_watchRequest = video.watchFetchRequest
|
_watchRequest = video.watchFetchRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
ZStack {
|
||||||
|
// Conditional overlay to block taps on underlying views
|
||||||
|
if isOverlayVisible {
|
||||||
|
Color.clear
|
||||||
|
.contentShape(Rectangle())
|
||||||
|
#if !os(tvOS)
|
||||||
|
// This is not available on tvOS < 16 so we leave out.
|
||||||
|
// TODO: remove #if when setting the minimum deployment target to >= 16
|
||||||
|
.onTapGesture {
|
||||||
|
// Dismiss overlay without triggering other interactions
|
||||||
|
isOverlayVisible = false
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
.ignoresSafeArea() // Ensure overlay covers the entire screen
|
||||||
|
.accessibilityLabel("Dismiss context menu")
|
||||||
|
.accessibilityHint("Tap to close the context")
|
||||||
|
.accessibilityAddTraits(.isButton)
|
||||||
|
}
|
||||||
|
|
||||||
if video.videoID != Video.fixtureID {
|
if video.videoID != Video.fixtureID {
|
||||||
contextMenu
|
contextMenu
|
||||||
|
.onAppear {
|
||||||
|
isOverlayVisible = true
|
||||||
|
}
|
||||||
|
.onDisappear {
|
||||||
|
isOverlayVisible = false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user