Skip to content

Commit cee8364

Browse files
committed
Rename
1 parent 75ff488 commit cee8364

File tree

2 files changed

+15
-26
lines changed

2 files changed

+15
-26
lines changed

Examples/Example-SwiftUI/ContentView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import SystemSettingsNavigator
1010

1111
struct ContentView: View {
1212

13-
@Environment(\.openSystemSetting)
14-
private var openSystemSetting
13+
@Environment(\.openSystemSettings)
14+
private var openSystemSettings
1515

1616
var body: some View {
1717
VStack {
1818
Button {
19-
openSystemSetting(.privacySecurity(.extensions(.fileSystem)))
19+
openSystemSettings(.privacySecurity(.extensions(.fileSystem)))
2020
} label: {
2121
Text("Open System Settings")
2222
}

Sources/SystemSettingsNavigator/SystemSettingsNavigator.swift

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ public final class SystemSettingsNavigator {
1010
public static let shared = SystemSettingsNavigator()
1111

1212
#if canImport(UIKit) && targetEnvironment(macCatalyst)
13-
@available(*, deprecated, renamed: "UIApplication.openSystemSetting(_:completion:)")
13+
@available(*, deprecated, renamed: "UIApplication.openSystemSettings(_:completion:)")
1414
public func navigate(to pane: SystemSettingsPane, completion: ((Bool) -> Void)? = nil) throws {
1515
UIApplication.shared.open(pane.url, completionHandler: completion)
1616
}
1717
#endif
1818

1919
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
2020
@discardableResult
21-
@available(*, deprecated, renamed: "NSWorkspace.openSystemSetting(_:)")
21+
@available(*, deprecated, renamed: "NSWorkspace.openSystemSettings(_:)")
2222
public func navigate(to pane: SystemSettingsPane) throws -> Bool {
2323
NSWorkspace.shared.open(pane.url)
2424
}
@@ -27,12 +27,7 @@ public final class SystemSettingsNavigator {
2727

2828
#if canImport(UIKit) && targetEnvironment(macCatalyst)
2929
extension UIApplication {
30-
@available(*, deprecated, renamed: "UIApplication.openSystemSetting(_:completion:)")
3130
public func openSystemSettings(_ pane: SystemSettingsPane, completion: ((Bool) -> Void)? = nil) {
32-
openSystemSetting(pane, completion: completion)
33-
}
34-
35-
public func openSystemSetting(_ pane: SystemSettingsPane, completion: ((Bool) -> Void)? = nil) {
3631
open(pane.url, completionHandler: completion)
3732
}
3833
}
@@ -41,13 +36,7 @@ extension UIApplication {
4136
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
4237
extension NSWorkspace {
4338
@discardableResult
44-
@available(*, deprecated, renamed: "NSWorkspace.openSystemSetting(_:)")
4539
public func openSystemSettings(_ pane: SystemSettingsPane) -> Bool {
46-
openSystemSetting(pane)
47-
}
48-
49-
@discardableResult
50-
public func openSystemSetting(_ pane: SystemSettingsPane) -> Bool {
5140
open(pane.url)
5241
}
5342
}
@@ -57,33 +46,33 @@ extension NSWorkspace {
5746

5847
import SwiftUI
5948

60-
@MainActor @preconcurrency public struct OpenSystemSettingAction: Sendable {
49+
@MainActor @preconcurrency public struct OpenSystemSettingsAction: Sendable {
6150
@MainActor @preconcurrency public func callAsFunction(_ pane: SystemSettingsPane) {
6251
#if canImport(UIKit) && targetEnvironment(macCatalyst)
63-
UIApplication.shared.openSystemSetting(pane)
52+
UIApplication.shared.openSystemSettings(pane)
6453
#elseif canImport(AppKit) && !targetEnvironment(macCatalyst)
65-
NSWorkspace.shared.openSystemSetting(pane)
54+
NSWorkspace.shared.openSystemSettings(pane)
6655
#endif
6756
}
6857

6958
@MainActor @preconcurrency public func callAsFunction(_ pane: SystemSettingsPane, completion: @escaping (_ accepted: Bool) -> Void) {
7059
#if canImport(UIKit) && targetEnvironment(macCatalyst)
71-
UIApplication.shared.openSystemSetting(pane) { completion($0) }
60+
UIApplication.shared.openSystemSettings(pane) { completion($0) }
7261
#elseif canImport(AppKit) && !targetEnvironment(macCatalyst)
73-
let accepted = NSWorkspace.shared.openSystemSetting(pane)
62+
let accepted = NSWorkspace.shared.openSystemSettings(pane)
7463
completion(accepted)
7564
#endif
7665
}
7766
}
7867

79-
@preconcurrency private enum OpenSystemSettingActionKey: EnvironmentKey {
80-
static let defaultValue: OpenSystemSettingAction = .init()
68+
@preconcurrency private enum OpenSystemSettingsActionKey: EnvironmentKey {
69+
static let defaultValue: OpenSystemSettingsAction = .init()
8170
}
8271

8372
extension EnvironmentValues {
84-
@MainActor @preconcurrency public var openSystemSetting: OpenSystemSettingAction {
85-
get { self[OpenSystemSettingActionKey.self] }
86-
set { self[OpenSystemSettingActionKey.self] = newValue }
73+
@MainActor @preconcurrency public var openSystemSettings: OpenSystemSettingsAction {
74+
get { self[OpenSystemSettingsActionKey.self] }
75+
set { self[OpenSystemSettingsActionKey.self] = newValue }
8776
}
8877
}
8978

0 commit comments

Comments
 (0)