feat(macos): add voice wake mic picker
parent
081460e59d
commit
cd30a99fae
|
|
@ -185,13 +185,7 @@ private struct MenuContent: View {
|
||||||
|
|
||||||
private var voiceWakeMicMenu: some View {
|
private var voiceWakeMicMenu: some View {
|
||||||
Menu {
|
Menu {
|
||||||
Picker("Microphone", selection: self.$state.voiceWakeMicID) {
|
self.microphoneMenuItems
|
||||||
Text(self.defaultMicLabel).tag("")
|
|
||||||
ForEach(self.availableMics) { mic in
|
|
||||||
Text(mic.name).tag(mic.uid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.labelsHidden()
|
|
||||||
|
|
||||||
if self.loadingMics {
|
if self.loadingMics {
|
||||||
Divider()
|
Divider()
|
||||||
|
|
@ -206,9 +200,6 @@ private struct MenuContent: View {
|
||||||
Spacer()
|
Spacer()
|
||||||
Text(self.selectedMicLabel)
|
Text(self.selectedMicLabel)
|
||||||
.foregroundStyle(.secondary)
|
.foregroundStyle(.secondary)
|
||||||
Image(systemName: "chevron.right")
|
|
||||||
.font(.caption.weight(.semibold))
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.task { await self.loadMicrophones() }
|
.task { await self.loadMicrophones() }
|
||||||
|
|
@ -222,6 +213,28 @@ private struct MenuContent: View {
|
||||||
return "Unavailable"
|
return "Unavailable"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var microphoneMenuItems: some View {
|
||||||
|
Group {
|
||||||
|
Button {
|
||||||
|
self.state.voiceWakeMicID = ""
|
||||||
|
} label: {
|
||||||
|
Label(self.defaultMicLabel, systemImage: self.state.voiceWakeMicID.isEmpty ? "checkmark" : "")
|
||||||
|
.labelStyle(.titleAndIcon)
|
||||||
|
}
|
||||||
|
.buttonStyle(.plain)
|
||||||
|
|
||||||
|
ForEach(self.availableMics) { mic in
|
||||||
|
Button {
|
||||||
|
self.state.voiceWakeMicID = mic.uid
|
||||||
|
} label: {
|
||||||
|
Label(mic.name, systemImage: self.state.voiceWakeMicID == mic.uid ? "checkmark" : "")
|
||||||
|
.labelStyle(.titleAndIcon)
|
||||||
|
}
|
||||||
|
.buttonStyle(.plain)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var defaultMicLabel: String {
|
private var defaultMicLabel: String {
|
||||||
if let host = Host.current().localizedName, !host.isEmpty {
|
if let host = Host.current().localizedName, !host.isEmpty {
|
||||||
return "Auto-detect (\(host))"
|
return "Auto-detect (\(host))"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue