Skip to content

Commit 674655e

Browse files
committed
feat(#8): add option to use IceBar only on notched displays
Signed-off-by: Toni Förster <toni.foerster@icloud.com>
1 parent 2abd97d commit 674655e

5 files changed

Lines changed: 39 additions & 1 deletion

File tree

Thaw/MenuBar/MenuBarSection.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,14 @@ final class MenuBarSection {
6666

6767
/// A Boolean value that indicates whether the Ice Bar should be used.
6868
private var useIceBar: Bool {
69-
appState?.settings.general.useIceBar ?? false
69+
guard let settings = appState?.settings.general, settings.useIceBar else {
70+
return false
71+
}
72+
if settings.useIceBarOnlyOnNotchedDisplay {
73+
let screen = screenForIceBar
74+
return screen?.hasNotch ?? false
75+
}
76+
return true
7077
}
7178

7279
/// A weak reference to the menu bar manager.

Thaw/Resources/Localizable.xcstrings

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6863,6 +6863,9 @@
68636863
}
68646864
}
68656865
},
6866+
"Only on displays with notch" : {
6867+
"comment" : "A toggle that lets the user choose whether to show the Thaw Bar only on displays with a notch."
6868+
},
68666869
"Open %@ Settings" : {
68676870
"comment" : "A button that opens the settings app to grant screen recording permissions for the \\(Constants.displayName) Bar.",
68686871
"isCommentAutoGenerated" : true,
@@ -10521,6 +10524,9 @@
1052110524
}
1052210525
}
1052310526
},
10527+
"Use %@ Bar only on displays with a notch. On other displays, show icons in the menu bar." : {
10528+
"comment" : "A toggle that allows the user to choose whether to only show the Thaw Bar on displays with a notch."
10529+
},
1052410530
"Use dynamic appearance" : {
1052510531
"comment" : "A toggle that lets the user choose whether to use different appearance settings based on the current system appearance.",
1052610532
"isCommentAutoGenerated" : true,

Thaw/Settings/Models/GeneralSettings.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ final class GeneralSettings: ObservableObject {
3434
/// in a separate bar below the menu bar.
3535
@Published var useIceBar = false
3636

37+
/// A Boolean value that indicates whether to use the Ice Bar
38+
/// only on displays with a notch.
39+
@Published var useIceBarOnlyOnNotchedDisplay = false
40+
3741
/// The location where the Ice Bar appears.
3842
@Published var iceBarLocation: IceBarLocation = .dynamic
3943

@@ -90,6 +94,7 @@ final class GeneralSettings: ObservableObject {
9094
Defaults.ifPresent(key: .showIceIcon, assign: &showIceIcon)
9195
Defaults.ifPresent(key: .customIceIconIsTemplate, assign: &customIceIconIsTemplate)
9296
Defaults.ifPresent(key: .useIceBar, assign: &useIceBar)
97+
Defaults.ifPresent(key: .useIceBarOnlyOnNotchedDisplay, assign: &useIceBarOnlyOnNotchedDisplay)
9398
Defaults.ifPresent(key: .showOnClick, assign: &showOnClick)
9499
Defaults.ifPresent(key: .showOnHover, assign: &showOnHover)
95100
Defaults.ifPresent(key: .showOnScroll, assign: &showOnScroll)
@@ -163,6 +168,13 @@ final class GeneralSettings: ObservableObject {
163168
}
164169
.store(in: &c)
165170

171+
$useIceBarOnlyOnNotchedDisplay
172+
.receive(on: DispatchQueue.main)
173+
.sink { useIceBarOnlyOnNotchedDisplay in
174+
Defaults.set(useIceBarOnlyOnNotchedDisplay, forKey: .useIceBarOnlyOnNotchedDisplay)
175+
}
176+
.store(in: &c)
177+
166178
$iceBarLocation
167179
.receive(on: DispatchQueue.main)
168180
.sink { location in

Thaw/Settings/SettingsPanes/GeneralSettingsPane.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,27 @@ struct GeneralSettingsPane: View {
178178
private var iceBarOptions: some View {
179179
useIceBar
180180
if settings.useIceBar {
181+
if hasNotchedDisplay {
182+
useIceBarOnlyOnNotchedDisplay
183+
}
181184
iceBarLocationPicker
182185
}
183186
}
184187

188+
private var hasNotchedDisplay: Bool {
189+
NSScreen.screens.contains { $0.hasNotch }
190+
}
191+
185192
private var useIceBar: some View {
186193
Toggle("Use \(Constants.displayName) Bar", isOn: $settings.useIceBar)
187194
.annotation("Show hidden menu bar items in a separate bar below the menu bar.")
188195
}
189196

197+
private var useIceBarOnlyOnNotchedDisplay: some View {
198+
Toggle("Only on displays with notch", isOn: $settings.useIceBarOnlyOnNotchedDisplay)
199+
.annotation("Use \(Constants.displayName) Bar only on displays with a notch. On other displays, show icons in the menu bar.")
200+
}
201+
190202
private var iceBarLocationPicker: some View {
191203
IcePicker("Location", selection: $settings.iceBarLocation) {
192204
ForEach(IceBarLocation.allCases) { location in

Thaw/Utilities/Defaults.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ extension Defaults {
146146
case iceIcon = "IceIcon"
147147
case customIceIconIsTemplate = "CustomIceIconIsTemplate"
148148
case useIceBar = "UseIceBar"
149+
case useIceBarOnlyOnNotchedDisplay = "UseIceBarOnlyOnNotchedDisplay"
149150
case iceBarLocation = "IceBarLocation"
150151
case showOnClick = "ShowOnClick"
151152
case showOnHover = "ShowOnHover"

0 commit comments

Comments
 (0)