Remove `Name` typealias in `KeyboardShortcuts.Name`
I realized you can just use `Self` instead 👌
This commit is contained in:
parent
c7094b0b7a
commit
a345f5f241
|
@ -2,8 +2,8 @@ import SwiftUI
|
|||
import KeyboardShortcuts
|
||||
|
||||
extension KeyboardShortcuts.Name {
|
||||
static let testShortcut1 = Name("testShortcut1")
|
||||
static let testShortcut2 = Name("testShortcut2")
|
||||
static let testShortcut1 = Self("testShortcut1")
|
||||
static let testShortcut2 = Self("testShortcut2")
|
||||
}
|
||||
|
||||
struct ContentView: View {
|
||||
|
|
|
@ -20,7 +20,7 @@ extension NSMenuItem {
|
|||
import KeyboardShortcuts
|
||||
|
||||
extension KeyboardShortcuts.Name {
|
||||
static let toggleUnicornMode = Name("toggleUnicornMode")
|
||||
static let toggleUnicornMode = Self("toggleUnicornMode")
|
||||
}
|
||||
|
||||
// … `Recorder` logic for recording the keyboard shortcut …
|
||||
|
@ -65,6 +65,7 @@ extension NSMenuItem {
|
|||
set()
|
||||
}
|
||||
|
||||
// TODO: Use Combine when targeting macOS 10.15.
|
||||
AssociatedKeys.observer[self] = NotificationCenter.default.addObserver(forName: .shortcutByNameDidChange, object: nil, queue: nil) { notification in
|
||||
guard
|
||||
let nameInNotification = notification.userInfo?["name"] as? KeyboardShortcuts.Name,
|
||||
|
|
|
@ -8,15 +8,12 @@ extension KeyboardShortcuts {
|
|||
import KeyboardShortcuts
|
||||
|
||||
extension KeyboardShortcuts.Name {
|
||||
static let toggleUnicornMode = Name("toggleUnicornMode")
|
||||
static let toggleUnicornMode = Self("toggleUnicornMode")
|
||||
}
|
||||
```
|
||||
*/
|
||||
public struct Name: Hashable {
|
||||
// These make it possible to use the types without the namespace.
|
||||
// `extension KeyboardShortcuts.Name { static let x = Name("x") }`.
|
||||
/// :nodoc:
|
||||
public typealias Name = KeyboardShortcuts.Name
|
||||
// This makes it possible to use `Shortcut` without the namespace.
|
||||
/// :nodoc:
|
||||
public typealias Shortcut = KeyboardShortcuts.Shortcut
|
||||
|
||||
|
|
|
@ -55,6 +55,6 @@ extension KeyboardShortcuts {
|
|||
@available(macOS 10.15, *)
|
||||
struct SwiftUI_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
KeyboardShortcuts.Recorder(for: .Name("xcodePreview"))
|
||||
KeyboardShortcuts.Recorder(for: .init("xcodePreview"))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue