Refined the recording Live Activity presentation in the Widget target.

This commit is contained in:
2026-07-07 00:11:39 +02:00
parent 9e431c8e7a
commit dfd4829980
13 changed files with 281 additions and 163 deletions
@@ -8,66 +8,89 @@ import WidgetKit
/// button while recording; discard, resume, and send buttons while paused; and only a discard button while the recorded input
/// is being processed.
struct RecordingControls: View {
// MARK: Properties
/// The dynamic content of the Live Activity to render.
let state: RecordingActivityAttributes.ContentState
// MARK: Body
var body: some View {
HStack(
spacing: Constant.Spacing.stack
) {
switch state.state {
case .recording:
Button(intent: ToggleRecordingIntent()) {
Image.Symbol.pause
.resizable()
}
.buttonStyle(.action(
type: .default
))
pauseButton
case .paused:
Button(intent: DiscardRecordingIntent()) {
Image.Symbol.discard
.resizable()
}
.buttonStyle(.action(
type: .destructive
))
Button(intent: ToggleRecordingIntent()) {
Image.Symbol.microphone
.resizable()
}
.buttonStyle(.action(
type: .default
))
Button(intent: ProcessRecordingIntent()) {
Image.Symbol.send
.resizable()
}
.buttonStyle(.action(
type: .confirmative
))
discardButton
recordButton
processButton
case .processing:
Button(intent: DiscardRecordingIntent()) {
Image.Symbol.discard
.resizable()
}
.buttonStyle(.action(
type: .destructive
))
discardButton
}
}
.buttonStyle(.borderedProminent)
}
}
// MARK: - Subviews
private extension RecordingControls {
// MARK: Computed
/// The discard button, shown while the recording is paused or being processed, that throws the recording away.
var discardButton: some View {
Button(intent: DiscardRecordingIntent()) {
Image.Symbol.discard
.resizable()
}
.buttonStyle(.action(
type: .destructive
))
.accessibilityLabel(Text("view.recording-controls.button.discard"))
}
/// The pause button, shown while recording, that pauses the ongoing recording.
var pauseButton: some View {
Button(intent: ToggleRecordingIntent()) {
Image.Symbol.pause
.resizable()
}
.buttonStyle(.action(
type: .default
))
.accessibilityLabel(Text("view.recording-controls.button.pause"))
}
/// The send button, shown while the recording is paused, that sends it for processing.
var processButton: some View {
Button(intent: ProcessRecordingIntent()) {
Image.Symbol.send
.resizable()
}
.buttonStyle(.action(
type: .confirmative
))
.accessibilityLabel(Text("view.recording-controls.button.send"))
}
/// The resume button, shown while the recording is paused, that resumes it.
var recordButton: some View {
Button(intent: ToggleRecordingIntent()) {
Image.Symbol.microphone
.resizable()
}
.buttonStyle(.action(
type: .default
))
.accessibilityLabel(Text("view.recording-controls.button.resume"))
}
}
// MARK: - Constants