-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuView.swift
More file actions
73 lines (62 loc) · 2.22 KB
/
Copy pathMenuView.swift
File metadata and controls
73 lines (62 loc) · 2.22 KB
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
73
import SwiftUI
import AppKit
/// The compact panel that drops down from the menu-bar icon.
struct MenuView: View {
@ObservedObject var model: RecorderModel
@Environment(\.openWindow) private var openWindow
var body: some View {
VStack(alignment: .leading, spacing: 12) {
HStack(spacing: 6) {
Image(systemName: "waveform")
Text("System Audio Recorder").font(.headline)
}
SourcePicker(model: model)
RecordButton(model: model)
if let last = model.lastFileURL, !model.isRecording {
lastFileRow(last)
}
if model.permissionNeeded {
PermissionBanner(model: model)
} else if let msg = model.statusMessage {
Text(msg)
.font(.caption).foregroundStyle(.red)
.fixedSize(horizontal: false, vertical: true)
}
Divider()
HStack {
Button {
NSApp.activate(ignoringOtherApps: true)
openWindow(id: "main")
} label: {
Label("Open Window", systemImage: "macwindow")
}
Spacer()
Button {
model.openAppSettings()
} label: {
Label("Settings…", systemImage: "gearshape")
}
}
.controlSize(.small)
Divider()
HStack {
Text("\(model.quality.label) · \(model.quality.bitrate / 1000) kbps")
.font(.caption2).foregroundStyle(.secondary)
Spacer()
Button("Quit") { NSApp.terminate(nil) }
.controlSize(.small)
}
}
.padding(14)
.frame(width: 300)
}
private func lastFileRow(_ url: URL) -> some View {
HStack(spacing: 6) {
Image(systemName: "checkmark.circle.fill").foregroundStyle(.green)
Text(url.lastPathComponent)
.font(.caption).lineLimit(1).truncationMode(.middle)
Spacer()
Button("Show") { model.revealLastFile() }.controlSize(.small)
}
}
}