Files
attendi/Widgets/Attendi/Sources/Views/RecordingStateLabel.swift
T

60 lines
1.5 KiB
Swift

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: {
state.state.symbol
.foregroundStyle(state.state.tint)
}
.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
)
}