// // UserActivities.swift // Gemini-iOS // // Created by Shadowfacts on 9/28/21. // import Foundation import BrowserCore private let type = "space.vaccor.Gemini.activity.browse" extension NSUserActivity { convenience init(geminiURL url: URL) { self.init(activityType: type) self.userInfo = [ "url": url, ] } convenience init(navigationManager manager: NavigationManager) { self.init(activityType: type) self.userInfo = [ "url": manager.currentURL, "back": manager.backStack, "forward": manager.forwardStack, ] } var navigationManager: NavigationManager? { guard activityType == type, let url = userInfo?["url"] as? URL else { return nil } let back = userInfo?["back"] as? [URL] ?? [] let forward = userInfo?["forward"] as? [URL] ?? [] let manager = NavigationManager(url: url) manager.backStack = back manager.forwardStack = forward return manager } var geminiURL: URL? { guard activityType == type, let url = userInfo?["url"] as? URL else { return nil } return url } }