Settings View: SwiftUI wrapper
This commit is contained in:
@@ -22,6 +22,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||
}
|
||||
|
||||
static func appMenuShortcuts() -> [UIKeyCommand] {
|
||||
[
|
||||
// Preferences
|
||||
UIKeyCommand(
|
||||
modifiers: .command,
|
||||
input: ",",
|
||||
title: "Preferences",
|
||||
action: #selector(ShortcutResponder.showPreferences)
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
static func fileMenuShortcuts() -> [UIKeyCommand] {
|
||||
[
|
||||
// Open Location...
|
||||
@@ -90,13 +102,31 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
}
|
||||
|
||||
override var keyCommands: [UIKeyCommand]? {
|
||||
get { return Self.fileMenuShortcuts() }
|
||||
get { return Self.fileMenuShortcuts() + Self.appMenuShortcuts() }
|
||||
}
|
||||
|
||||
override func buildMenu(with builder: UIMenuBuilder) {
|
||||
builder.replaceChildren(ofMenu: .file) { children in
|
||||
return Self.fileMenuShortcuts() + children
|
||||
}
|
||||
|
||||
builder.replaceChildren(ofMenu: .application, from: { children in
|
||||
let index = children.firstIndex(where: { elem in
|
||||
if let elem = elem as? UIMenu {
|
||||
return elem.identifier == .about
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
var newChildren = children
|
||||
if let index = index {
|
||||
newChildren.insert(contentsOf: Self.appMenuShortcuts(), at: index + 1)
|
||||
} else {
|
||||
newChildren.append(contentsOf: Self.appMenuShortcuts())
|
||||
}
|
||||
|
||||
return newChildren
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user