Skip to content

Commit b529c55

Browse files
committed
Cleanup
1 parent 628057e commit b529c55

File tree

3 files changed

+42
-21
lines changed

3 files changed

+42
-21
lines changed

Sources/MenuBarExtraAccess/MenuBarExtraAccess.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ struct MenuBarExtraAccess<Content: Scene>: Scene {
130130
return 0
131131
}
132132

133+
// MARK: Observers
134+
133135
private var observerContainer = ObserverContainer()
134136

135137
private class ObserverContainer {

Sources/MenuBarExtraAccess/MenuBarExtraUtils.swift renamed to Sources/MenuBarExtraAccess/MenuBarExtraUtils/MenuBarExtraUtils.swift

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ enum MenuBarExtraUtils {
3232
guard let item = statusItem(for: ident) else { return }
3333
item.setPresented(state: state)
3434
}
35-
36-
// MARK: - Objects and Metadata
37-
35+
}
36+
37+
// MARK: - Objects and Metadata
38+
39+
extension MenuBarExtraUtils {
3840
/// Returns the underlying status item(s) created by `MenuBarExtra` instances.
3941
///
4042
/// Each `MenuBarExtra` creates one status item.
@@ -115,9 +117,11 @@ enum MenuBarExtraUtils {
115117
}
116118
}
117119
}
118-
119-
// MARK: - Observer
120-
120+
}
121+
122+
// MARK: - Observers
123+
124+
extension MenuBarExtraUtils {
121125
/// Call from MenuBarExtraAccess init to set up observer.
122126
static func newStatusItemButtonStateObserver(
123127
index: Int,
@@ -211,21 +215,7 @@ enum MenuBarExtraUtils {
211215
}
212216
}
213217

214-
enum StatusItemIdentity {
215-
case index(Int)
216-
case id(String)
217-
}
218-
219-
extension StatusItemIdentity: CustomStringConvertible {
220-
var description: String {
221-
switch self {
222-
case .index(let int):
223-
return "index \(int)"
224-
case .id(let string):
225-
return "ID \"\(string)\""
226-
}
227-
}
228-
}
218+
// MARK: - NSStatusItem Introspection
229219

230220
extension NSStatusItem {
231221
var menuBarExtraIndex: Int {
@@ -295,6 +285,8 @@ extension NSStatusItem {
295285
}
296286
}
297287

288+
// MARK: - NSWindow Introspection
289+
298290
extension NSWindow {
299291
fileprivate var menuBarExtraID: String? {
300292
// Note: this is not ideal, but it's currently the ONLY way to achieve this
@@ -358,6 +350,8 @@ extension Mirror {
358350
}
359351
}
360352

353+
// MARK: - Misc.
354+
361355
extension MenuBarExtraUtils {
362356
static func hash(anyView: any View) -> String {
363357
// can't hash `any View`
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// MenuBarExtraUtils.swift
3+
// MenuBarExtraAccess • https://github.com/orchetect/MenuBarExtraAccess
4+
// © 2023 Steffan Andrews • Licensed under MIT License
5+
//
6+
7+
#if os(macOS)
8+
9+
enum StatusItemIdentity: Equatable, Hashable {
10+
case index(Int)
11+
case id(String)
12+
}
13+
14+
extension StatusItemIdentity: CustomStringConvertible {
15+
var description: String {
16+
switch self {
17+
case .index(let int):
18+
return "index \(int)"
19+
case .id(let string):
20+
return "ID \"\(string)\""
21+
}
22+
}
23+
}
24+
25+
#endif

0 commit comments

Comments
 (0)