mirror of
https://github.com/yattee/yattee.git
synced 2024-11-10 08:18:19 +00:00
48 lines
1.3 KiB
Swift
48 lines
1.3 KiB
Swift
import Defaults
|
|
import SwiftUI
|
|
|
|
@main
|
|
struct PearvidiousApp: App {
|
|
@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()
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
ContentView()
|
|
.onAppear(perform: configureAPI)
|
|
.environmentObject(api)
|
|
.environmentObject(instances)
|
|
.environmentObject(playlists)
|
|
.environmentObject(search)
|
|
.environmentObject(subscriptions)
|
|
}
|
|
#if !os(tvOS)
|
|
.commands {
|
|
SidebarCommands()
|
|
}
|
|
#endif
|
|
|
|
#if os(macOS)
|
|
Settings {
|
|
SettingsView()
|
|
.onAppear(perform: configureAPI)
|
|
.environmentObject(api)
|
|
.environmentObject(instances)
|
|
}
|
|
#endif
|
|
}
|
|
|
|
fileprivate func configureAPI() {
|
|
playlists.api = api
|
|
search.api = api
|
|
subscriptions.api = api
|
|
|
|
if let account = instances.defaultAccount, api.account.isEmpty {
|
|
api.setAccount(account)
|
|
}
|
|
}
|
|
}
|