diff --git a/Sources/Conan/Views/MenuBarContentView.swift b/Sources/Conan/Views/MenuBarContentView.swift index d397495..89284f1 100644 --- a/Sources/Conan/Views/MenuBarContentView.swift +++ b/Sources/Conan/Views/MenuBarContentView.swift @@ -8,6 +8,7 @@ struct MenuBarContentView: View { @EnvironmentObject private var updater: UpdaterController @State private var launchAtLogin = false @AppStorage(SessionStore.remindWhenIdleDefaultsKey) private var remindWhenIdle = false + @AppStorage(SessionStore.hideMenuBarClockDefaultsKey) private var hideClock = false var body: some View { VStack(alignment: .leading, spacing: 12) { @@ -47,6 +48,7 @@ struct MenuBarContentView: View { .onChange(of: remindWhenIdle) { enabled in if enabled { Notifier.requestAuthorization() } } + Toggle("Hide timer in menu bar", isOn: $hideClock) Toggle("Automatically check for updates", isOn: updater.automaticChecksBinding) HStack(spacing: 10) { Text(AppInfo.version) diff --git a/Sources/Conan/Views/MenuBarLabel.swift b/Sources/Conan/Views/MenuBarLabel.swift index 3ff56d6..e97a7a6 100644 --- a/Sources/Conan/Views/MenuBarLabel.swift +++ b/Sources/Conan/Views/MenuBarLabel.swift @@ -1,16 +1,21 @@ import SwiftUI import ConanCore -/// The menu-bar item itself: a live elapsed timer when running, otherwise the -/// timer glyph. +/// The menu-bar item itself: a live elapsed timer when running (or a static +/// recording glyph when the clock is hidden), otherwise the timer glyph. struct MenuBarLabel: View { @EnvironmentObject private var store: SessionStore @EnvironmentObject private var ticker: Ticker + @AppStorage(SessionStore.hideMenuBarClockDefaultsKey) private var hideClock = false var body: some View { if store.isRunning { - Text(TimeFormat.clock(store.mainElapsed(asOf: ticker.now))) - .monospacedDigit() + if hideClock { + Image(systemName: "record.circle") + } else { + Text(TimeFormat.clock(store.mainElapsed(asOf: ticker.now))) + .monospacedDigit() + } } else { Image(systemName: "timer") } diff --git a/Sources/ConanCore/SessionStore.swift b/Sources/ConanCore/SessionStore.swift index 9f7b9a7..2793d3a 100644 --- a/Sources/ConanCore/SessionStore.swift +++ b/Sources/ConanCore/SessionStore.swift @@ -27,6 +27,10 @@ public final class SessionStore: ObservableObject { /// with the SwiftUI toggle via `@AppStorage`). public static let remindWhenIdleDefaultsKey = "conan.remindWhenIdle" + /// UserDefaults key for hiding the ticking clock in the menu bar (shared + /// with the SwiftUI toggle via `@AppStorage`). + public static let hideMenuBarClockDefaultsKey = "conan.hideMenuBarClock" + public init( watson: WatsonClient?, stateURL: URL = SessionStore.defaultStateURL(),