Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Nov 15, 2023
1 parent 1b92b9b commit 731615a
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 28 deletions.
6 changes: 2 additions & 4 deletions Example/KeyboardShortcutsExample/MainScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ struct MainScreen: View {
}
}

struct MainScreen_Previews: PreviewProvider {
static var previews: some View {
MainScreen()
}
#Preview {
MainScreen()
}
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version:5.9
import PackageDescription

let package = Package(
Expand Down
4 changes: 2 additions & 2 deletions Sources/KeyboardShortcuts/KeyboardShortcuts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public enum KeyboardShortcuts {
You can safely call this even if the user has not yet set a keyboard shortcut. It will just be inactive until they do.
```swift
import Cocoa
import AppKit
import KeyboardShortcuts
@main
Expand All @@ -388,7 +388,7 @@ public enum KeyboardShortcuts {
You can safely call this even if the user has not yet set a keyboard shortcut. It will just be inactive until they do.
```swift
import Cocoa
import AppKit
import KeyboardShortcuts
@main
Expand Down
2 changes: 1 addition & 1 deletion Sources/KeyboardShortcuts/NSMenuItem++.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension NSMenuItem {
This method overrides `.keyEquivalent` and `.keyEquivalentModifierMask`.
```swift
import Cocoa
import AppKit
import KeyboardShortcuts
extension KeyboardShortcuts.Name {
Expand Down
25 changes: 14 additions & 11 deletions Sources/KeyboardShortcuts/Recorder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,18 @@ extension KeyboardShortcuts.Recorder {
}

@available(macOS 10.15, *)
struct SwiftUI_Previews: PreviewProvider {
static var previews: some View {
Group {
KeyboardShortcuts.Recorder(for: .init("xcodePreview"))
.environment(\.locale, .init(identifier: "en"))
KeyboardShortcuts.Recorder(for: .init("xcodePreview"))
.environment(\.locale, .init(identifier: "zh-Hans"))
KeyboardShortcuts.Recorder(for: .init("xcodePreview"))
.environment(\.locale, .init(identifier: "ru"))
}
}
#Preview {
KeyboardShortcuts.Recorder(for: .init("xcodePreview"))
.environment(\.locale, .init(identifier: "en"))
}

@available(macOS 10.15, *)
#Preview {
KeyboardShortcuts.Recorder(for: .init("xcodePreview"))
.environment(\.locale, .init(identifier: "zh-Hans"))
}
@available(macOS 10.15, *)
#Preview {
KeyboardShortcuts.Recorder(for: .init("xcodePreview"))
.environment(\.locale, .init(identifier: "ru"))
}
4 changes: 2 additions & 2 deletions Sources/KeyboardShortcuts/RecorderCocoa.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Cocoa
import AppKit
import Carbon.HIToolbox

extension KeyboardShortcuts {
Expand All @@ -12,7 +12,7 @@ extension KeyboardShortcuts {
It takes care of storing the keyboard shortcut in `UserDefaults` for you.
```swift
import Cocoa
import AppKit
import KeyboardShortcuts
final class SettingsViewController: NSViewController {
Expand Down
2 changes: 1 addition & 1 deletion Sources/KeyboardShortcuts/Shortcut.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Cocoa
import AppKit
import Carbon.HIToolbox

extension KeyboardShortcuts {
Expand Down
10 changes: 5 additions & 5 deletions Sources/KeyboardShortcuts/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,15 @@ enum AssociationPolicy {
var rawValue: objc_AssociationPolicy {
switch self {
case .assign:
return .OBJC_ASSOCIATION_ASSIGN
.OBJC_ASSOCIATION_ASSIGN
case .retainNonatomic:
return .OBJC_ASSOCIATION_RETAIN_NONATOMIC
.OBJC_ASSOCIATION_RETAIN_NONATOMIC
case .copyNonatomic:
return .OBJC_ASSOCIATION_COPY_NONATOMIC
.OBJC_ASSOCIATION_COPY_NONATOMIC
case .retain:
return .OBJC_ASSOCIATION_RETAIN
.OBJC_ASSOCIATION_RETAIN
case .copy:
return .OBJC_ASSOCIATION_COPY
.OBJC_ASSOCIATION_COPY
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ You can also find a [real-world example](https://github.com/sindresorhus/Plash/b
Using [`KeyboardShortcuts.RecorderCocoa`](Sources/KeyboardShortcuts/RecorderCocoa.swift) instead of `KeyboardShortcuts.Recorder`:

```swift
import Cocoa
import AppKit
import KeyboardShortcuts

final class SettingsViewController: NSViewController {
Expand Down

0 comments on commit 731615a

Please sign in to comment.