UniNav includes client

This commit is contained in:
Lumaa 2024-02-17 02:06:06 +01:00
parent e590606caf
commit 2c76e8cdc8

View File

@ -36,6 +36,7 @@ struct ContentView: View {
} }
} }
}) })
.withAppRouter(uniNavigator)
} }
.overlay(alignment: .bottom) { .overlay(alignment: .bottom) {
TabsView(selectedTab: $uniNavigator.selectedTab, postButton: { TabsView(selectedTab: $uniNavigator.selectedTab, postButton: {
@ -50,6 +51,7 @@ struct ContentView: View {
.environment(accountManager) .environment(accountManager)
.environment(appDelegate) .environment(appDelegate)
.environmentObject(preferences) .environmentObject(preferences)
.navigationBarTitleDisplayMode(.inline)
.onAppear { .onAppear {
do { do {
preferences = try UserPreferences.loadAsCurrent() ?? .defaultPreferences preferences = try UserPreferences.loadAsCurrent() ?? .defaultPreferences
@ -66,12 +68,13 @@ struct ContentView: View {
.environment(\.openURL, OpenURLAction { url in .environment(\.openURL, OpenURLAction { url in
// Open internal URL. // Open internal URL.
guard preferences.browserType == .inApp else { return .systemAction } guard preferences.browserType == .inApp else { return .systemAction }
uniNavigator.presentedSheet = .safari(url: url) // let handled = uniNavigator.handle(url: url)
return OpenURLAction.Result.handled return OpenURLAction.Result.handled
}) })
.onOpenURL(perform: { url in .onOpenURL(perform: { url in
guard preferences.browserType == .inApp else { return } guard preferences.browserType == .inApp else { return }
uniNavigator.presentedSheet = .safari(url: url) uniNavigator.presentedSheet = .safari(url: url)
// let handled = uniNavigator.handle(url: url)
}) })
} }
@ -80,7 +83,9 @@ struct ContentView: View {
if appAccount == nil { if appAccount == nil {
uniNavigator.presentedCover = .welcome uniNavigator.presentedCover = .welcome
} else { } else {
accountManager.setClient(.init(server: appAccount!.server, oauthToken: appAccount!.oauthToken)) let cli = Client(server: appAccount!.server, oauthToken: appAccount!.oauthToken)
accountManager.setClient(cli)
uniNavigator.client = cli
// Check if token is still working // Check if token is still working
let fetched: Account? = await accountManager.fetchAccount() let fetched: Account? = await accountManager.fetchAccount()