IceCubes/IceCubesApp/App/IceCubesApp.swift

52 lines
1.4 KiB
Swift
Raw Normal View History

2022-12-01 09:05:26 +01:00
import SwiftUI
import Timeline
import Network
import KeychainSwift
2022-12-22 10:53:36 +01:00
import Env
2022-12-01 09:05:26 +01:00
@main
struct IceCubesApp: App {
2022-12-17 13:37:46 +01:00
public static let defaultServer = "mastodon.social"
2022-12-01 09:05:26 +01:00
@StateObject private var appAccountsManager = AppAccountsManager()
2022-12-22 11:19:56 +01:00
@StateObject private var currentAccount = CurrentAccount()
2022-12-22 10:53:36 +01:00
@StateObject private var quickLook = QuickLook()
2022-12-22 11:19:56 +01:00
2022-12-01 09:05:26 +01:00
var body: some Scene {
WindowGroup {
TabView {
TimelineTab()
.tabItem {
Label("Home", systemImage: "globe")
}
2022-12-20 15:37:51 +01:00
if appAccountsManager.currentClient.isAuth {
NotificationsTab()
.tabItem {
Label("Notifications", systemImage: "bell")
}
2022-12-20 16:08:09 +01:00
AccountTab()
.tabItem {
Label("Profile", systemImage: "person.circle")
}
2022-12-20 15:37:51 +01:00
}
2022-12-01 09:05:26 +01:00
SettingsTabs()
.tabItem {
Label("Settings", systemImage: "gear")
}
}
2022-12-20 16:08:09 +01:00
.tint(.brand)
2022-12-22 11:19:56 +01:00
.onChange(of: appAccountsManager.currentClient) { newClient in
currentAccount.setClient(client: newClient)
}
.onAppear {
currentAccount.setClient(client: appAccountsManager.currentClient)
}
2022-12-01 09:05:26 +01:00
.environmentObject(appAccountsManager)
.environmentObject(appAccountsManager.currentClient)
2022-12-22 10:53:36 +01:00
.environmentObject(quickLook)
2022-12-22 11:19:56 +01:00
.environmentObject(currentAccount)
.quickLookPreview($quickLook.url, in: quickLook.urls)
2022-12-01 09:05:26 +01:00
}
}
}