Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Dec 1, 2022
1 parent 2410aba commit cf553c1
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 241 deletions.
17 changes: 11 additions & 6 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
only_rules:
- anyobject_protocol
- accessibility_trait_for_button
- array_init
- block_based_kvo
- class_delegate_protocol
Expand All @@ -10,6 +10,7 @@ only_rules:
- collection_alignment
- colon
- comma
- comma_inheritance
- compiler_protocol_init
- computed_accessors_order
- conditional_returns_on_newline
Expand Down Expand Up @@ -77,12 +78,11 @@ only_rules:
- no_fallthrough_only
- no_space_in_method_call
- notification_center_detachment
- ns_number_init_as_function_reference
- nsobject_prefer_isequal
- number_separator
- opening_brace
- operator_usage_whitespace
- operator_whitespace
- orphaned_doc_comment
- overridden_super_call
- prefer_self_in_static_references
- prefer_self_type_over_type_of_self
Expand All @@ -106,8 +106,10 @@ only_rules:
- required_enum_case
- return_arrow_whitespace
- return_value_from_void_function
- self_binding
- self_in_property_initialization
- shorthand_operator
- shorthand_optional_binding
- sorted_first_last
- statement_position
- static_operator
Expand Down Expand Up @@ -137,9 +139,9 @@ only_rules:
- unused_setter_value
- valid_ibinspectable
- vertical_parameter_alignment
- vertical_parameter_alignment_on_call
- vertical_whitespace_closing_braces
- vertical_whitespace_opening_braces
- void_function_in_ternary
- void_return
- xct_specific_matcher
- xctfail_message
Expand All @@ -149,8 +151,8 @@ analyzer_rules:
- unused_declaration
- unused_import
- typesafe_array_init
number_separator:
minimum_length: 5
for_where:
allow_for_as_filter: true
identifier_name:
max_length:
warning: 100
Expand Down Expand Up @@ -203,3 +205,6 @@ custom_rules:
final_class:
regex: '^class [a-zA-Z\d]+[^{]+\{'
message: 'Classes should be marked as final whenever possible. If you actually need it to be subclassable, just add `// swiftlint:disable:next final_class`.'
no_alignment_center:
regex: '\b\(alignment: .center\b'
message: 'This alignment is the default.'
40 changes: 24 additions & 16 deletions Color Picker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 55;
objectVersion = 56;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -24,7 +24,7 @@
E3DFA8C92662514800D2623E /* Events.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3DFA8C82662514800D2623E /* Events.swift */; };
E3E7D79B27218903009D71F4 /* Intents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E3E7D79A27218903009D71F4 /* Intents.framework */; platformFilter = maccatalyst; };
E3E7D79E27218903009D71F4 /* IntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3E7D79D27218903009D71F4 /* IntentHandler.swift */; };
E3E7D7A227218903009D71F4 /* IntentsExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = E3E7D79927218903009D71F4 /* IntentsExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
E3E7D7A227218903009D71F4 /* IntentsExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = E3E7D79927218903009D71F4 /* IntentsExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
E3E7D7A927218959009D71F4 /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = E3E7D7A827218959009D71F4 /* Intents.intentdefinition */; };
E3E7D7AA27218959009D71F4 /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = E3E7D7A827218959009D71F4 /* Intents.intentdefinition */; };
E3E7D7AC27218C03009D71F4 /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = E38D4332263AB24E00701B82 /* Utilities.swift */; };
Expand All @@ -44,15 +44,15 @@
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
E3E7D7A327218903009D71F4 /* Embed App Extensions */ = {
E3E7D7A327218903009D71F4 /* Embed Foundation Extensions */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 13;
files = (
E3E7D7A227218903009D71F4 /* IntentsExtension.appex in Embed App Extensions */,
E3E7D7A227218903009D71F4 /* IntentsExtension.appex in Embed Foundation Extensions */,
);
name = "Embed App Extensions";
name = "Embed Foundation Extensions";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -186,7 +186,7 @@
E3A3B11625904E7B001B4D0C /* Frameworks */,
E3A3B11725904E7B001B4D0C /* Resources */,
E394DAAF263E95E200F5B042 /* Copy “Launch at Login Helper” */,
E3E7D7A327218903009D71F4 /* Embed App Extensions */,
E3E7D7A327218903009D71F4 /* Embed Foundation Extensions */,
);
buildRules = (
);
Expand Down Expand Up @@ -233,7 +233,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1310;
LastUpgradeCheck = 1250;
LastUpgradeCheck = 1400;
TargetAttributes = {
E3A3B11825904E7B001B4D0C = {
CreatedOnToolsVersion = 12.3;
Expand All @@ -244,7 +244,7 @@
};
};
buildConfigurationList = E3A3B11425904E7B001B4D0C /* Build configuration list for PBXProject "Color Picker" */;
compatibilityVersion = "Xcode 13.0";
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
Expand Down Expand Up @@ -291,6 +291,7 @@
/* Begin PBXShellScriptBuildPhase section */
E394DAAF263E95E200F5B042 /* Copy “Launch at Login Helper” */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand All @@ -310,6 +311,7 @@
};
E3E9F9AE2642B8F800AE6450 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -403,6 +405,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand All @@ -420,7 +423,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MACOSX_DEPLOYMENT_TARGET = 12.4;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -466,6 +469,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -477,7 +481,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MACOSX_DEPLOYMENT_TARGET = 12.4;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
Expand All @@ -497,11 +501,13 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = YG56YK5RN5;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = "Color Picker/Info.plist";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
Expand All @@ -522,11 +528,13 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = YG56YK5RN5;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = "Color Picker/Info.plist";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
Expand All @@ -544,6 +552,7 @@
CODE_SIGN_ENTITLEMENTS = IntentsExtension/IntentsExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = YG56YK5RN5;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -555,7 +564,6 @@
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.sindresorhus.Color-Picker.IntentsExtension";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -571,6 +579,7 @@
CODE_SIGN_ENTITLEMENTS = IntentsExtension/IntentsExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = YG56YK5RN5;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -582,7 +591,6 @@
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.sindresorhus.Color-Picker.IntentsExtension";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -637,31 +645,31 @@
repositoryURL = "https://github.com/sindresorhus/LaunchAtLogin";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 4.2.0;
minimumVersion = 5.0.0;
};
};
E394DAB0263E965500F5B042 /* XCRemoteSwiftPackageReference "KeyboardShortcuts" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sindresorhus/KeyboardShortcuts";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.6.0;
minimumVersion = 1.9.0;
};
};
E3E14060259A0D97004FC89F /* XCRemoteSwiftPackageReference "Defaults" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sindresorhus/Defaults";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 6.2.1;
minimumVersion = 6.3.0;
};
};
E3F4BC852788A5780075DC52 /* XCRemoteSwiftPackageReference "sentry-cocoa" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/getsentry/sentry-cocoa";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 7.17.0;
minimumVersion = 7.31.3;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
19 changes: 17 additions & 2 deletions Color Picker/App.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import SwiftUI
import Defaults
import LaunchAtLogin

/**
NOTES:
- The "com.apple.security.files.user-selected.read-only" entitlement is required by the "Open" menu in the "Color Palettes" pane.
TODO when targeting macOS 13:
- Upload non-App Store version.
TODO shortcut action ideas;
- Convert color
- Toggle color panel
- Toggle color sampler in app
*/

@main
Expand Down Expand Up @@ -56,8 +65,8 @@ struct AppMain: App {
CommandGroup(replacing: .help) {
Link("What is LCH color?", destination: "https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/")
Link("FAQ", destination: "https://github.com/sindresorhus/System-Color-Picker#faq")
Divider()
Link("Website", destination: "https://sindresorhus.com/system-color-picker")
Divider()
Link("Rate on the App Store", destination: "macappstore://apps.apple.com/app/id1545870783?action=write-review")
Link("More Apps by Me", destination: "macappstore://apps.apple.com/developer/id328077650")
Divider()
Expand All @@ -72,6 +81,8 @@ struct AppMain: App {
}

private func migrate() {
LaunchAtLogin.migrateIfNeeded()

// TODO: Remove in 2023.
SSApp.runOnce(identifier: "migrateShownColorFormats") {
guard !SSApp.isFirstLaunch else {
Expand Down Expand Up @@ -119,7 +130,11 @@ struct AppMain: App {

@MainActor
private final class AppDelegate: NSObject, NSApplicationDelegate {
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { true }
func applicationDidFinishLaunching(_ notification: Notification) {
if #available(macOS 13, *) {
SSApp.swiftUIMainWindow?.close()
}
}

// Does not work on macOS 12.0.1 because of `WindowGroup`: https://github.com/feedback-assistant/reports/issues/246
// This is only run when the app is started when it's already running.
Expand Down
23 changes: 16 additions & 7 deletions Color Picker/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ final class AppState: ObservableObject {
let colorPanel = ColorPanel()
colorPanel.titleVisibility = .hidden
colorPanel.hidesOnDeactivate = false
colorPanel.becomesKeyOnlyIfNeeded = false
colorPanel.isFloatingPanel = false
colorPanel.isRestorable = false
colorPanel.styleMask.remove(.utilityWindow)
colorPanel.standardWindowButton(.miniaturizeButton)?.isHidden = true
colorPanel.standardWindowButton(.zoomButton)?.isHidden = true
colorPanel.tabbingMode = .disallowed
colorPanel.collectionBehavior = [
.moveToActiveSpace,
.canJoinAllSpaces,
.fullScreenAuxiliary
// We cannot enable tiling as then it doesn't show up in fullscreen spaces. (macOS 12.5)
// .fullScreenAllowsTiling
]
colorPanel.makeMain()

Expand Down Expand Up @@ -145,6 +148,8 @@ final class AppState: ObservableObject {

if Defaults[.showInMenuBar] {
colorPanel.close()
} else {
colorPanel.makeKeyAndOrderFront(nil)
}

#if DEBUG
Expand All @@ -162,12 +167,16 @@ final class AppState: ObservableObject {
}

private func fixStuff() {
// Make the invisible native SwitUI window not block access to the desktop. (macOS 12.0)
// https://github.com/feedback-assistant/reports/issues/253
SSApp.swiftUIMainWindow?.ignoresMouseEvents = true

// Make the invisible native SwiftUI window not show up in mission control when in menu bar mode. (macOS 11.6)
SSApp.swiftUIMainWindow?.collectionBehavior = .stationary
if #available(macOS 13, *) {
SSApp.swiftUIMainWindow?.close()
} else {
// Make the invisible native SwitUI window not block access to the desktop. (macOS 12.0)
// https://github.com/feedback-assistant/reports/issues/253
SSApp.swiftUIMainWindow?.ignoresMouseEvents = true

// Make the invisible native SwiftUI window not show up in mission control when in menu bar mode. (macOS 11.6)
SSApp.swiftUIMainWindow?.collectionBehavior = .stationary
}
}

private func requestReview() {
Expand Down
Loading

0 comments on commit cf553c1

Please sign in to comment.