2021-09-25 13:48:22 +05:30
|
|
|
import Defaults
|
2021-06-10 02:21:23 +05:30
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
@main
|
2021-11-07 19:02:01 +05:30
|
|
|
struct YatteeApp: App {
|
2021-10-24 14:46:04 +05:30
|
|
|
#if os(macOS)
|
|
|
|
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
2021-12-08 04:39:49 +05:30
|
|
|
@StateObject private var updater = UpdaterModel()
|
2021-10-24 14:46:04 +05:30
|
|
|
#endif
|
|
|
|
|
2021-12-19 22:47:04 +05:30
|
|
|
@StateObject private var accounts = AccountsModel()
|
|
|
|
@StateObject private var comments = CommentsModel()
|
|
|
|
@StateObject private var instances = InstancesModel()
|
2021-11-09 04:44:28 +05:30
|
|
|
@StateObject private var menu = MenuModel()
|
2021-12-19 22:47:04 +05:30
|
|
|
@StateObject private var navigation = NavigationModel()
|
|
|
|
@StateObject private var player = PlayerModel()
|
|
|
|
@StateObject private var playlists = PlaylistsModel()
|
|
|
|
@StateObject private var recents = RecentsModel()
|
|
|
|
@StateObject private var search = SearchModel()
|
|
|
|
@StateObject private var subscriptions = SubscriptionsModel()
|
|
|
|
@StateObject private var thumbnails = ThumbnailsModel()
|
2021-11-09 04:44:28 +05:30
|
|
|
|
2021-06-10 02:21:23 +05:30
|
|
|
var body: some Scene {
|
|
|
|
WindowGroup {
|
|
|
|
ContentView()
|
2021-12-19 22:47:04 +05:30
|
|
|
.environmentObject(accounts)
|
|
|
|
.environmentObject(comments)
|
|
|
|
.environmentObject(instances)
|
|
|
|
.environmentObject(navigation)
|
|
|
|
.environmentObject(player)
|
|
|
|
.environmentObject(playlists)
|
|
|
|
.environmentObject(recents)
|
|
|
|
.environmentObject(subscriptions)
|
|
|
|
.environmentObject(thumbnails)
|
2021-11-09 04:44:28 +05:30
|
|
|
.environmentObject(menu)
|
2021-12-19 22:47:04 +05:30
|
|
|
.environmentObject(search)
|
|
|
|
#if !os(macOS)
|
|
|
|
.onReceive(
|
|
|
|
NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)
|
|
|
|
) { _ in
|
|
|
|
player.handleEnterForeground()
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if !os(tvOS)
|
|
|
|
.handlesExternalEvents(preferring: Set(["watch"]), allowing: Set(["watch"]))
|
|
|
|
#endif
|
2021-06-10 02:21:23 +05:30
|
|
|
}
|
2021-07-28 04:10:04 +05:30
|
|
|
#if !os(tvOS)
|
2021-12-19 22:47:04 +05:30
|
|
|
.handlesExternalEvents(matching: Set(arrayLiteral: "watch"))
|
2021-11-08 21:59:35 +05:30
|
|
|
.commands {
|
|
|
|
SidebarCommands()
|
2021-12-08 04:39:49 +05:30
|
|
|
|
2021-11-08 21:59:35 +05:30
|
|
|
CommandGroup(replacing: .newItem, addition: {})
|
2021-12-08 04:39:49 +05:30
|
|
|
|
|
|
|
#if os(macOS)
|
|
|
|
CommandGroup(after: .appInfo) {
|
|
|
|
CheckForUpdatesView()
|
|
|
|
.environmentObject(updater)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-11-09 04:44:28 +05:30
|
|
|
MenuCommands(model: Binding<MenuModel>(get: { menu }, set: { _ in }))
|
2021-11-08 21:59:35 +05:30
|
|
|
}
|
2021-07-28 04:10:04 +05:30
|
|
|
#endif
|
2021-09-25 13:48:22 +05:30
|
|
|
|
|
|
|
#if os(macOS)
|
2021-12-19 22:47:04 +05:30
|
|
|
WindowGroup(player.windowTitle) {
|
|
|
|
VideoPlayerView()
|
|
|
|
.onAppear { player.presentingPlayer = true }
|
|
|
|
.onDisappear { player.presentingPlayer = false }
|
|
|
|
.environment(\.navigationStyle, .sidebar)
|
|
|
|
.environmentObject(accounts)
|
|
|
|
.environmentObject(comments)
|
|
|
|
.environmentObject(instances)
|
|
|
|
.environmentObject(navigation)
|
|
|
|
.environmentObject(player)
|
|
|
|
.environmentObject(playlists)
|
|
|
|
.environmentObject(recents)
|
|
|
|
.environmentObject(subscriptions)
|
|
|
|
.environmentObject(thumbnails)
|
|
|
|
.handlesExternalEvents(preferring: Set(["player"]), allowing: Set(["player"]))
|
|
|
|
}
|
|
|
|
.handlesExternalEvents(matching: Set(["player"]))
|
|
|
|
|
2021-09-25 13:48:22 +05:30
|
|
|
Settings {
|
|
|
|
SettingsView()
|
2021-11-13 02:16:15 +05:30
|
|
|
.environmentObject(AccountsModel())
|
2021-10-06 01:50:09 +05:30
|
|
|
.environmentObject(InstancesModel())
|
2021-12-08 04:39:49 +05:30
|
|
|
.environmentObject(updater)
|
2021-09-25 13:48:22 +05:30
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2021-06-10 02:21:23 +05:30
|
|
|
}
|