mirror of
https://github.com/lumaa-dev/BubbleApp.git
synced 2025-01-26 16:35:08 +01:00
OpenURL preference
This commit is contained in:
parent
de27761045
commit
a9b35603db
@ -5,6 +5,7 @@ import SwiftUI
|
||||
struct ContentView: View {
|
||||
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
|
||||
|
||||
@State private var preferences: UserPreferences = .defaultPreferences
|
||||
@State private var navigator = Navigator()
|
||||
@State private var sheet: SheetDestination?
|
||||
@State private var accountManager: AccountManager = AccountManager()
|
||||
@ -61,6 +62,12 @@ struct ContentView: View {
|
||||
.environment(navigator)
|
||||
.environment(appDelegate)
|
||||
.onAppear {
|
||||
do {
|
||||
preferences = try UserPreferences.loadAsCurrent() ?? .defaultPreferences
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
|
||||
if accountManager.getClient() == nil {
|
||||
Task {
|
||||
await recognizeAccount()
|
||||
@ -72,10 +79,12 @@ struct ContentView: View {
|
||||
}
|
||||
.environment(\.openURL, OpenURLAction { url in
|
||||
// Open internal URL.
|
||||
guard preferences.browserType == .inApp else { return .systemAction }
|
||||
navigator.presentedSheet = .safari(url: url)
|
||||
return OpenURLAction.Result.handled
|
||||
})
|
||||
.onOpenURL(perform: { url in
|
||||
guard preferences.browserType == .inApp else { return }
|
||||
navigator.presentedSheet = .safari(url: url)
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user