Implemented the (first version of the) Recording Live Activity in the Attendi widget target.
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import Commanding
|
||||
import SwiftUI
|
||||
import WidgetKit
|
||||
|
||||
/// The label naming the current state of the recording flow, next to an icon matching that state: a microphone while recording,
|
||||
/// a pause symbol while paused, and a send symbol while the recorded input is being processed.
|
||||
struct RecordingStateLabel: View {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// The dynamic content of the Live Activity to render.
|
||||
let state: RecordingActivityAttributes.ContentState
|
||||
|
||||
// MARK: Body
|
||||
|
||||
var body: some View {
|
||||
Label {
|
||||
switch state.state {
|
||||
case .recording:
|
||||
Text(.viewRecordingStateLabelStateRecording)
|
||||
case .paused:
|
||||
Text(.viewRecordingStateLabelStatePaused)
|
||||
case .processing:
|
||||
Text(.viewRecordingStateLabelStateProcessing)
|
||||
}
|
||||
} icon: {
|
||||
switch state.state {
|
||||
case .recording:
|
||||
Image.Symbol.microphone
|
||||
.foregroundStyle(.yellow)
|
||||
case .paused:
|
||||
Image.Symbol.pause
|
||||
.foregroundStyle(.yellow)
|
||||
case .processing:
|
||||
Image.Symbol.send
|
||||
.foregroundStyle(.green)
|
||||
}
|
||||
}
|
||||
.font(.body)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
#Preview(
|
||||
"Recording State label",
|
||||
as: .dynamicIsland(.expanded),
|
||||
using: RecordingActivityAttributes()
|
||||
) {
|
||||
RecordingLiveActivity()
|
||||
} contentStates: {
|
||||
RecordingActivityAttributes.ContentState(
|
||||
state: .recording,
|
||||
anchor: .now,
|
||||
elapsed: 0
|
||||
)
|
||||
RecordingActivityAttributes.ContentState(
|
||||
state: .paused,
|
||||
anchor: nil,
|
||||
elapsed: 325
|
||||
)
|
||||
RecordingActivityAttributes.ContentState(
|
||||
state: .processing,
|
||||
anchor: nil,
|
||||
elapsed: 325
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user