feat(macos): add native menu bar app with notch overlay
Introduces a SwiftUI companion app for the Fail Well PWA: menu bar status item, popover with task list / record / history views, command palette, and a Dynamic Island-style notch overlay that shows the active step and timer beside the hardware notch and expands on hover to reveal pause/next controls.
This commit is contained in:
28
macos/Sources/FailWell/Services/TimeFormat.swift
Normal file
28
macos/Sources/FailWell/Services/TimeFormat.swift
Normal file
@@ -0,0 +1,28 @@
|
||||
import Foundation
|
||||
|
||||
enum TimeFormat {
|
||||
/// "MM:SS" or "H:MM:SS" depending on magnitude.
|
||||
static func clock(_ seconds: TimeInterval) -> String {
|
||||
let total = max(0, Int(seconds))
|
||||
let h = total / 3600
|
||||
let m = (total % 3600) / 60
|
||||
let s = total % 60
|
||||
if h > 0 { return String(format: "%d:%02d:%02d", h, m, s) }
|
||||
return String(format: "%d:%02d", m, s)
|
||||
}
|
||||
|
||||
/// Rounded to minutes. Returns "0m" for sub-minute durations.
|
||||
static func minutes(_ seconds: TimeInterval) -> String {
|
||||
"\(Int((seconds / 60).rounded()))m"
|
||||
}
|
||||
|
||||
/// Compact relative-date string, e.g. "today", "yesterday", "Mar 14".
|
||||
static func date(_ date: Date, relativeTo reference: Date = Date()) -> String {
|
||||
let cal = Calendar.current
|
||||
if cal.isDateInToday(date) { return "today" }
|
||||
if cal.isDateInYesterday(date) { return "yesterday" }
|
||||
let f = DateFormatter()
|
||||
f.dateFormat = cal.component(.year, from: date) == cal.component(.year, from: reference) ? "MMM d" : "MMM d yyyy"
|
||||
return f.string(from: date)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user