Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sources/Conan/Views/MenuBarContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 9 additions & 4 deletions Sources/Conan/Views/MenuBarLabel.swift
Original file line number Diff line number Diff line change
@@ -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")
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/ConanCore/SessionStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down