2021-09-25 08:18:22 +00:00
|
|
|
import Defaults
|
2021-06-09 20:51:23 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
@main
|
|
|
|
struct PearvidiousApp: App {
|
2021-09-25 08:18:22 +00:00
|
|
|
@StateObject private var api = InvidiousAPI()
|
|
|
|
@StateObject private var instances = InstancesModel()
|
|
|
|
@StateObject private var playlists = PlaylistsModel()
|
|
|
|
@StateObject private var search = SearchModel()
|
|
|
|
@StateObject private var subscriptions = SubscriptionsModel()
|
|
|
|
|
2021-06-09 20:51:23 +00:00
|
|
|
var body: some Scene {
|
|
|
|
WindowGroup {
|
|
|
|
ContentView()
|
2021-09-25 08:18:22 +00:00
|
|
|
.onAppear(perform: configureAPI)
|
|
|
|
.environmentObject(api)
|
|
|
|
.environmentObject(instances)
|
|
|
|
.environmentObject(playlists)
|
|
|
|
.environmentObject(search)
|
|
|
|
.environmentObject(subscriptions)
|
2021-06-09 20:51:23 +00:00
|
|
|
}
|
2021-07-27 22:40:04 +00:00
|
|
|
#if !os(tvOS)
|
|
|
|
.commands {
|
|
|
|
SidebarCommands()
|
|
|
|
}
|
|
|
|
#endif
|
2021-09-25 08:18:22 +00:00
|
|
|
|
|
|
|
#if os(macOS)
|
|
|
|
Settings {
|
|
|
|
SettingsView()
|
|
|
|
.onAppear(perform: configureAPI)
|
|
|
|
.environmentObject(api)
|
|
|
|
.environmentObject(instances)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
fileprivate func configureAPI() {
|
|
|
|
playlists.api = api
|
2021-09-25 12:17:58 +00:00
|
|
|
search.api = api
|
|
|
|
subscriptions.api = api
|
2021-09-25 08:18:22 +00:00
|
|
|
|
2021-09-26 22:03:33 +00:00
|
|
|
if let account = instances.defaultAccount {
|
|
|
|
api.setAccount(account)
|
2021-09-25 08:18:22 +00:00
|
|
|
}
|
2021-06-09 20:51:23 +00:00
|
|
|
}
|
|
|
|
}
|