mirror of
https://github.com/sindresorhus/touch-bar-simulator
synced 2024-11-10 06:34:23 +00:00
Minor tweaks
This commit is contained in:
parent
f4992d264d
commit
4d89b83c54
7 changed files with 37 additions and 39 deletions
|
@ -1,4 +1,4 @@
|
|||
whitelist_rules:
|
||||
only_rules:
|
||||
- anyobject_protocol
|
||||
- array_init
|
||||
- block_based_kvo
|
||||
|
@ -35,7 +35,7 @@ whitelist_rules:
|
|||
- empty_parentheses_with_trailing_closure
|
||||
- empty_string
|
||||
- empty_xctest_method
|
||||
- enum_case_associated_value_count
|
||||
- enum_case_associated_values_count
|
||||
- explicit_init
|
||||
- fallthrough
|
||||
- fatal_error_message
|
||||
|
@ -48,6 +48,7 @@ whitelist_rules:
|
|||
- identifier_name
|
||||
- implicit_getter
|
||||
- implicit_return
|
||||
- inclusive_language
|
||||
- inert_defer
|
||||
- is_disjoint
|
||||
- joined_default_parameter
|
||||
|
@ -86,7 +87,6 @@ whitelist_rules:
|
|||
- private_action
|
||||
- private_outlet
|
||||
- private_unit_test
|
||||
- prohibited_nan_comparison
|
||||
- prohibited_super_call
|
||||
- protocol_property_accessors_order
|
||||
- reduce_boolean
|
||||
|
@ -100,7 +100,6 @@ whitelist_rules:
|
|||
- redundant_type_annotation
|
||||
- redundant_void_return
|
||||
- required_enum_case
|
||||
- return_value_from_void_function
|
||||
- return_arrow_whitespace
|
||||
- shorthand_operator
|
||||
- sorted_first_last
|
||||
|
@ -111,19 +110,19 @@ whitelist_rules:
|
|||
- switch_case_alignment
|
||||
- switch_case_on_newline
|
||||
- syntactic_sugar
|
||||
- test_case_accessibility
|
||||
- toggle_bool
|
||||
- trailing_closure
|
||||
- trailing_comma
|
||||
- trailing_newline
|
||||
- trailing_semicolon
|
||||
- trailing_whitespace
|
||||
- tuple_pattern
|
||||
- unavailable_function
|
||||
- unneeded_break_in_switch
|
||||
- unneeded_notification_center_removal
|
||||
- unneeded_parentheses_in_closure_argument
|
||||
- unowned_variable_capture
|
||||
- untyped_error_in_catch
|
||||
- unused_capture_list
|
||||
- unused_closure_parameter
|
||||
- unused_control_flow_label
|
||||
- unused_enumerated
|
||||
|
@ -142,9 +141,6 @@ whitelist_rules:
|
|||
analyzer_rules:
|
||||
- unused_declaration
|
||||
- unused_import
|
||||
force_cast: warning
|
||||
force_try: warning
|
||||
force_unwrapping: warning
|
||||
number_separator:
|
||||
minimum_length: 5
|
||||
identifier_name:
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
E39A158A214D011F00F86D5D /* SkyLight.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E39A1589214D011F00F86D5D /* SkyLight.framework */; };
|
||||
E39A158B214D011F00F86D5D /* SkyLight.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E39A1589214D011F00F86D5D /* SkyLight.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
E39A158E214D0C4F00F86D5D /* TouchBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E39A158D214D0C4F00F86D5D /* TouchBarView.swift */; };
|
||||
E3FE2CC31E726CE800C6713A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3FE2CC21E726CE800C6713A /* AppDelegate.swift */; };
|
||||
E3FE2CC31E726CE800C6713A /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3FE2CC21E726CE800C6713A /* App.swift */; };
|
||||
E3FE2CC51E726CE800C6713A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E3FE2CC41E726CE800C6713A /* Assets.xcassets */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
|
@ -59,7 +59,7 @@
|
|||
E39A1589214D011F00F86D5D /* SkyLight.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SkyLight.framework; path = ../../../../../System/Library/PrivateFrameworks/SkyLight.framework; sourceTree = "<group>"; };
|
||||
E39A158D214D0C4F00F86D5D /* TouchBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = TouchBarView.swift; sourceTree = "<group>"; usesTabs = 1; };
|
||||
E3FE2CBF1E726CE800C6713A /* Touch Bar Simulator.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Touch Bar Simulator.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
E3FE2CC21E726CE800C6713A /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = AppDelegate.swift; sourceTree = "<group>"; usesTabs = 1; };
|
||||
E3FE2CC21E726CE800C6713A /* App.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = App.swift; sourceTree = "<group>"; usesTabs = 1; };
|
||||
E3FE2CC41E726CE800C6713A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
E3FE2CC91E726CE800C6713A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
E3FE2CD21E726EA100C6713A /* Touch Bar Simulator-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "Touch Bar Simulator-Bridging-Header.h"; sourceTree = "<group>"; usesTabs = 1; };
|
||||
|
@ -117,7 +117,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
E3930B0F216625BE00F66410 /* Constants.swift */,
|
||||
E3FE2CC21E726CE800C6713A /* AppDelegate.swift */,
|
||||
E3FE2CC21E726CE800C6713A /* App.swift */,
|
||||
E35579EA21595EDC001CB642 /* TouchBarWindow.swift */,
|
||||
E39A158D214D0C4F00F86D5D /* TouchBarView.swift */,
|
||||
AF6C7BC51E7FAF38004A27E0 /* ToolbarSlider.swift */,
|
||||
|
@ -275,7 +275,7 @@
|
|||
E356A16321028D81000148AD /* main.swift in Sources */,
|
||||
E35579EB21595EDC001CB642 /* TouchBarWindow.swift in Sources */,
|
||||
E3930B10216625BE00F66410 /* Constants.swift in Sources */,
|
||||
E3FE2CC31E726CE800C6713A /* AppDelegate.swift in Sources */,
|
||||
E3FE2CC31E726CE800C6713A /* App.swift in Sources */,
|
||||
E39A158E214D0C4F00F86D5D /* TouchBarView.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -504,7 +504,7 @@
|
|||
repositoryURL = "https://github.com/sindresorhus/KeyboardShortcuts";
|
||||
requirement = {
|
||||
kind = upToNextMinorVersion;
|
||||
minimumVersion = 0.5.0;
|
||||
minimumVersion = 0.6.0;
|
||||
};
|
||||
};
|
||||
E31957F723F140D500856B40 /* XCRemoteSwiftPackageReference "Defaults" */ = {
|
||||
|
|
|
@ -5,12 +5,12 @@ import LaunchAtLogin
|
|||
import KeyboardShortcuts
|
||||
|
||||
final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
lazy var window = with(TouchBarWindow()) {
|
||||
private(set) lazy var window = with(TouchBarWindow()) {
|
||||
$0.alphaValue = CGFloat(Defaults[.windowTransparency])
|
||||
$0.setUp()
|
||||
}
|
||||
|
||||
lazy var statusItem = with(NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)) {
|
||||
private(set) lazy var statusItem = with(NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)) {
|
||||
$0.menu = with(NSMenu()) {
|
||||
$0.delegate = self
|
||||
}
|
||||
|
@ -52,11 +52,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
alert.addButton(withTitle: "Quit")
|
||||
|
||||
guard alert.runModal() == .alertFirstButtonReturn else {
|
||||
App.quit()
|
||||
SSApp.quit()
|
||||
return
|
||||
}
|
||||
|
||||
App.relaunch()
|
||||
SSApp.relaunch()
|
||||
}
|
||||
|
||||
@objc
|
|
@ -6,7 +6,7 @@ private struct ShortcutRecorder: View {
|
|||
var shortcut: KeyboardShortcuts.Name
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
HStack(alignment: .firstTextBaseline) {
|
||||
Text("\(title):")
|
||||
KeyboardShortcuts.Recorder(for: shortcut)
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ final class ToolbarSlider: NSSlider {
|
|||
super.init(frame: frame)
|
||||
|
||||
let knobShadow = NSShadow()
|
||||
knobShadow.shadowColor = NSColor.black.withAlphaComponent(0.7)
|
||||
knobShadow.shadowColor = .black.withAlphaComponent(0.7)
|
||||
knobShadow.shadowOffset = CGSize(width: 0.8, height: -0.8)
|
||||
knobShadow.shadowBlurRadius = 5
|
||||
|
||||
|
@ -113,7 +113,7 @@ final class MenubarSlider: NSSlider {
|
|||
super.init(frame: frame)
|
||||
|
||||
let knobShadow = NSShadow()
|
||||
knobShadow.shadowColor = NSColor.black.withAlphaComponent(0.6)
|
||||
knobShadow.shadowColor = .black.withAlphaComponent(0.6)
|
||||
knobShadow.shadowOffset = CGSize(width: 0.8, height: -0.8)
|
||||
knobShadow.shadowBlurRadius = 4
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ final class TouchBarWindow: NSPanel {
|
|||
}
|
||||
}
|
||||
|
||||
var showOnAllDesktops: Bool = false {
|
||||
var showOnAllDesktops = false {
|
||||
didSet {
|
||||
if showOnAllDesktops {
|
||||
collectionBehavior = .canJoinAllSpaces
|
||||
|
@ -352,7 +352,7 @@ final class TouchBarWindow: NSPanel {
|
|||
)
|
||||
|
||||
self.level = .assistiveTechHigh
|
||||
self._setPreventsActivation(true)
|
||||
_setPreventsActivation(true)
|
||||
self.isRestorable = true
|
||||
self.hidesOnDeactivate = false
|
||||
self.worksWhenModal = true
|
||||
|
|
|
@ -52,11 +52,15 @@ extension NSWindow {
|
|||
|
||||
extension NSWindow {
|
||||
enum MoveXPositioning {
|
||||
case left, center, right
|
||||
case left
|
||||
case center
|
||||
case right
|
||||
}
|
||||
|
||||
enum MoveYPositioning {
|
||||
case top, center, bottom
|
||||
case top
|
||||
case center
|
||||
case bottom
|
||||
}
|
||||
|
||||
func moveTo(x xPositioning: MoveXPositioning, y yPositioning: MoveYPositioning) {
|
||||
|
@ -77,7 +81,7 @@ extension NSWindow {
|
|||
}
|
||||
switch yPositioning {
|
||||
case .top:
|
||||
// Defect fix: keep docked windows below menubar area.
|
||||
// Defect fix: Keep docked windows below menubar area.
|
||||
// Previously, the window would obstruct menubar clicks when the menubar was set to auto-hide.
|
||||
// Now, the window stays below that area.
|
||||
let menubarThickness = NSStatusBar.system.thickness
|
||||
|
@ -133,8 +137,8 @@ extension NSMenuItem {
|
|||
}
|
||||
|
||||
|
||||
final class AssociatedObject<T: Any> {
|
||||
subscript(index: Any) -> T? {
|
||||
final class ObjectAssociation<T: Any> {
|
||||
subscript(index: AnyObject) -> T? {
|
||||
get {
|
||||
objc_getAssociatedObject(index, Unmanaged.passUnretained(self).toOpaque()) as! T?
|
||||
} set {
|
||||
|
@ -169,8 +173,8 @@ private final class ActionTrampoline<Sender>: NSObject {
|
|||
}
|
||||
}
|
||||
|
||||
private struct TargetActionSenderAssociatedKeys {
|
||||
fileprivate static let trampoline = AssociatedObject<AnyObject>()
|
||||
private enum TargetActionSenderAssociatedKeys {
|
||||
fileprivate static let trampoline = ObjectAssociation<AnyObject>()
|
||||
}
|
||||
|
||||
extension TargetActionSender {
|
||||
|
@ -232,8 +236,8 @@ func pressKey(keyCode: CGKeyCode, flags: CGEventFlags = []) {
|
|||
|
||||
|
||||
extension NSWindow.Level {
|
||||
private static func level(for cgLevelKey: CGWindowLevelKey) -> NSWindow.Level {
|
||||
NSWindow.Level(rawValue: Int(CGWindowLevelForKey(cgLevelKey)))
|
||||
private static func level(for cgLevelKey: CGWindowLevelKey) -> Self {
|
||||
.init(rawValue: Int(CGWindowLevelForKey(cgLevelKey)))
|
||||
}
|
||||
|
||||
public static let desktop = level(for: .desktopWindow)
|
||||
|
@ -251,7 +255,7 @@ extension NSWindow.Level {
|
|||
}
|
||||
|
||||
|
||||
struct App {
|
||||
enum SSApp {
|
||||
static let url = Bundle.main.bundleURL
|
||||
|
||||
static func quit() {
|
||||
|
@ -283,7 +287,7 @@ extension NSScreen {
|
|||
Publishers.Merge(
|
||||
NotificationCenter.default.publisher(for: NSApplication.didChangeScreenParametersNotification),
|
||||
// We use a wake up notification as the screen setup might have changed during sleep. For example, a screen could have been unplugged.
|
||||
NotificationCenter.default.publisher(for: NSWorkspace.didWakeNotification)
|
||||
NSWorkspace.shared.notificationCenter.publisher(for: NSWorkspace.didWakeNotification)
|
||||
)
|
||||
.map { _ in }
|
||||
.eraseToAnyPublisher()
|
||||
|
@ -308,8 +312,8 @@ extension Defaults {
|
|||
}
|
||||
|
||||
|
||||
@_functionBuilder
|
||||
struct ArrayBuilder<T> {
|
||||
@resultBuilder
|
||||
enum ArrayBuilder<T> {
|
||||
static func buildBlock(_ elements: T...) -> [T] { elements }
|
||||
}
|
||||
|
||||
|
@ -325,9 +329,7 @@ extension NSStatusBarButton {
|
|||
Can be useful if clicking the status bar button triggers an action instead of opening a menu/popover.
|
||||
*/
|
||||
var preventsHighlight: Bool {
|
||||
get {
|
||||
buttonCell?.highlightsBy.isEmpty ?? false
|
||||
}
|
||||
get { buttonCell?.highlightsBy.isEmpty ?? false }
|
||||
set {
|
||||
buttonCell?.highlightsBy = newValue ? [] : [.changeBackgroundCellMask]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue