mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Fix URL handling on macOS
This commit is contained in:
parent
58ba6f5fe7
commit
fe31e4ffd1
@ -131,10 +131,6 @@ struct ContentView: View {
|
|||||||
|
|
||||||
NavigationModel.shared.presentingOpenVideos = false
|
NavigationModel.shared.presentingOpenVideos = false
|
||||||
}
|
}
|
||||||
.onOpenURL { url in
|
|
||||||
URLBookmarkModel.shared.saveBookmark(url)
|
|
||||||
OpenURLHandler(navigationStyle: navigationStyle).handle(url)
|
|
||||||
}
|
|
||||||
.background(
|
.background(
|
||||||
EmptyView().sheet(isPresented: $navigation.presentingAddToPlaylist) {
|
EmptyView().sheet(isPresented: $navigation.presentingAddToPlaylist) {
|
||||||
AddToPlaylistView(video: navigation.videoToAddToPlaylist)
|
AddToPlaylistView(video: navigation.videoToAddToPlaylist)
|
||||||
@ -173,16 +169,6 @@ struct ContentView: View {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationStyle: NavigationStyle {
|
|
||||||
#if os(iOS)
|
|
||||||
return horizontalSizeClass == .compact ? .tab : .sidebar
|
|
||||||
#elseif os(tvOS)
|
|
||||||
return .tab
|
|
||||||
#else
|
|
||||||
return .sidebar
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@ViewBuilder var videoPlayer: some View {
|
@ViewBuilder var videoPlayer: some View {
|
||||||
if player.presentingPlayer {
|
if player.presentingPlayer {
|
||||||
playerView
|
playerView
|
||||||
@ -199,7 +185,6 @@ struct ContentView: View {
|
|||||||
|
|
||||||
var playerView: some View {
|
var playerView: some View {
|
||||||
VideoPlayerView()
|
VideoPlayerView()
|
||||||
.environment(\.navigationStyle, navigationStyle)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ struct YatteeApp: App {
|
|||||||
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
||||||
#elseif os(iOS)
|
#elseif os(iOS)
|
||||||
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
||||||
|
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@State private var configured = false
|
@State private var configured = false
|
||||||
@ -55,6 +56,7 @@ struct YatteeApp: App {
|
|||||||
ContentView()
|
ContentView()
|
||||||
.onAppear(perform: configure)
|
.onAppear(perform: configure)
|
||||||
.environment(\.managedObjectContext, persistenceController.container.viewContext)
|
.environment(\.managedObjectContext, persistenceController.container.viewContext)
|
||||||
|
.environment(\.navigationStyle, navigationStyle)
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
.background(
|
.background(
|
||||||
HostingWindowFinder { window in
|
HostingWindowFinder { window in
|
||||||
@ -76,6 +78,12 @@ struct YatteeApp: App {
|
|||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
.handlesExternalEvents(preferring: Set(["*"]), allowing: Set(["*"]))
|
.handlesExternalEvents(preferring: Set(["*"]), allowing: Set(["*"]))
|
||||||
#endif
|
#endif
|
||||||
|
#if !os(tvOS)
|
||||||
|
.onOpenURL { url in
|
||||||
|
URLBookmarkModel.shared.saveBookmark(url)
|
||||||
|
OpenURLHandler(navigationStyle: navigationStyle).handle(url)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
.handlesExternalEvents(matching: Set(["*"]))
|
.handlesExternalEvents(matching: Set(["*"]))
|
||||||
@ -114,6 +122,10 @@ struct YatteeApp: App {
|
|||||||
.environment(\.managedObjectContext, persistenceController.container.viewContext)
|
.environment(\.managedObjectContext, persistenceController.container.viewContext)
|
||||||
.environment(\.navigationStyle, .sidebar)
|
.environment(\.navigationStyle, .sidebar)
|
||||||
.handlesExternalEvents(preferring: Set(["player", "*"]), allowing: Set(["player", "*"]))
|
.handlesExternalEvents(preferring: Set(["player", "*"]), allowing: Set(["player", "*"]))
|
||||||
|
.onOpenURL { url in
|
||||||
|
URLBookmarkModel.shared.saveBookmark(url)
|
||||||
|
OpenURLHandler(navigationStyle: navigationStyle).handle(url)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.handlesExternalEvents(matching: Set(["player", "*"]))
|
.handlesExternalEvents(matching: Set(["player", "*"]))
|
||||||
|
|
||||||
@ -200,4 +212,14 @@ struct YatteeApp: App {
|
|||||||
|
|
||||||
Defaults[.homeHistoryItems] = -1
|
Defaults[.homeHistoryItems] = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var navigationStyle: NavigationStyle {
|
||||||
|
#if os(iOS)
|
||||||
|
return horizontalSizeClass == .compact ? .tab : .sidebar
|
||||||
|
#elseif os(tvOS)
|
||||||
|
return .tab
|
||||||
|
#else
|
||||||
|
return .sidebar
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user