forked from ivoronin/TomatoBar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TomatoBarView.swift
72 lines (70 loc) 路 2.95 KB
/
TomatoBarView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import SwiftUI
public struct TomatoBarView: View {
@ObservedObject var timer = TomatoBarTimer()
public var body: some View {
VStack(alignment: .leading, spacing: 8) {
Button {
timer.startStopAction()
AppDelegate.shared.closePopover(nil)
} label: {
Text(timer.startStopString)
.frame(maxWidth: .infinity)
}
.controlSize(.large)
.keyboardShortcut(.defaultAction)
.padding(.top, 4)
Divider()
Toggle(isOn: $timer.stopAfterBreak) {
Text("Stop after break").frame(maxWidth: .infinity, alignment: .leading)
}.toggleStyle(.switch)
Toggle(isOn: $timer.displayInMenuBar) {
Text("Display timer in menu bar").frame(maxWidth: .infinity, alignment: .leading)
}.toggleStyle(.switch)
.onChange(of: timer.displayInMenuBar) { _ in
timer.toggleMenuBar()
}
Group {
Stepper(value: $timer.workIntervalLength, in: 1...60) {
Text("Work interval:").frame(maxWidth: .infinity, alignment: .leading)
Text("\(timer.workIntervalLength) min")
}
Stepper(value: $timer.shortRestInterval, in: 1...60) {
Text("Short rest interval:").frame(maxWidth: .infinity, alignment: .leading)
Text("\(timer.shortRestInterval) min")
}
Stepper(value: $timer.longRestInterval, in: 1...60) {
Text("Long rest interval:").frame(maxWidth: .infinity, alignment: .leading)
Text("\(timer.longRestInterval) min")
}
Stepper(value: $timer.shortToLongBreakCounter, in: 1...3) {
Text("Short rest count:").frame(maxWidth: .infinity, alignment: .leading)
Text("\(timer.shortToLongBreakCounter) times").onChange(of: timer.shortToLongBreakCounter) { _ in
timer.updateBreakCounter()
}
}
// Text("Remaining short breaks: \(timer.shortToLongBreakCounterLocal)")
}
Divider()
Text("Sounds:")
HStack {
Toggle("Windup", isOn: $timer.isWindupEnabled)
Spacer()
Toggle("Ding", isOn: $timer.isDingEnabled)
Spacer()
Toggle("Ticking", isOn: $timer.isTickingEnabled)
.onChange(of: timer.isTickingEnabled) { _ in
timer.toggleTickingAction()
}
}
Button {
NSApplication.shared.terminate(self)
} label: {
Text("Quit")
.frame(maxWidth: .infinity)
}
.controlSize(.large)
.padding(.bottom, 4)
}
.padding(12)
}
}