Skip to content

Commit 322a14b

Browse files
committed
Improve time display readability and center window on launch
1 parent 5abd26a commit 322a14b

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

Sources/main.swift

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,22 @@ class FlowTimerState: ObservableObject {
8888
var isOvertime: Bool { elapsedSeconds > estimatedSeconds }
8989

9090
var elapsedString: String {
91-
let m = elapsedSeconds / 60
91+
let h = elapsedSeconds / 3600
92+
let m = (elapsedSeconds % 3600) / 60
9293
let s = elapsedSeconds % 60
94+
if h > 0 {
95+
return String(format: "%dh %02d:%02d", h, m, s)
96+
}
9397
return String(format: "%02d:%02d", m, s)
9498
}
9599

96100
var estimatedString: String {
97-
let m = estimatedSeconds / 60
98-
let s = estimatedSeconds % 60
99-
return String(format: "%02d:%02d", m, s)
101+
let h = estimatedSeconds / 3600
102+
let m = (estimatedSeconds % 3600) / 60
103+
if h > 0 {
104+
return m > 0 ? "\(h)h \(m)min" : "\(h)h"
105+
}
106+
return "\(m)min"
100107
}
101108

102109
var percentageString: String {
@@ -278,15 +285,14 @@ struct FlowTimerView: View {
278285

279286
HStack(spacing: 4) {
280287
Text(state.percentageString)
281-
.frame(width: 36, alignment: .trailing)
282288
Text("\u{00B7}")
283289
.foregroundColor(.white.opacity(0.25))
284290
Text(state.estimatedString)
285-
.frame(width: 40, alignment: .leading)
286291
}
287292
.font(.system(size: 12, weight: .medium))
288293
.foregroundColor(dimTextColor)
289294
.monospacedDigit()
295+
.fixedSize()
290296
}
291297

292298
// Full width progress bar
@@ -365,8 +371,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
365371

366372
if let screen = NSScreen.main {
367373
let screenFrame = screen.visibleFrame
368-
let x = screenFrame.maxX - window.frame.width - 20
369-
let y = screenFrame.maxY - window.frame.height - 20
374+
let x = screenFrame.midX - window.frame.width / 2
375+
let y = screenFrame.midY - window.frame.height / 2
370376
window.setFrameOrigin(NSPoint(x: x, y: y))
371377
}
372378

0 commit comments

Comments
 (0)