Add configurable iPhone widgets
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
import UIKit
|
||||
import WidgetKit
|
||||
|
||||
@MainActor
|
||||
final class AppContext {
|
||||
let core = GotchaCore()
|
||||
let core: GotchaCore
|
||||
private let window: UIWindow
|
||||
private(set) var tabs = UITabBarController()
|
||||
private(set) var navigationControllers: [UINavigationController] = []
|
||||
|
||||
init(window: UIWindow) {
|
||||
self.window = window
|
||||
let storageDirectory = FileManager.default.containerURL(
|
||||
forSecurityApplicationGroupIdentifier: "group.de.rfc1437.gotcha"
|
||||
)?.path
|
||||
core = GotchaCore(storageDirectory: storageDirectory)
|
||||
applyAppearance()
|
||||
}
|
||||
|
||||
@@ -61,6 +66,21 @@ final class AppContext {
|
||||
for (index, root) in replacements {
|
||||
navigationControllers[index].setViewControllers([root], animated: false)
|
||||
}
|
||||
WidgetCenter.shared.reloadAllTimelines()
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
func route(widgetURL: URL) -> Bool {
|
||||
guard widgetURL.scheme == "gotcha" else { return false }
|
||||
let index: Int
|
||||
switch widgetURL.host {
|
||||
case "home": index = 0
|
||||
case "pulls": index = 3
|
||||
default: return false
|
||||
}
|
||||
tabs.selectedIndex = index
|
||||
navigationControllers[index].popToRootViewController(animated: false)
|
||||
return true
|
||||
}
|
||||
|
||||
func didAddServer(index: UInt32) throws {
|
||||
|
||||
Reference in New Issue
Block a user