Created the Commanding package target in the Features package for controlling the recording flow from Live Activities.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
#if os(iOS)
|
||||
import ActivityKit
|
||||
import Foundation
|
||||
|
||||
/// The attributes of the Live Activity that surfaces the recording flow on the Lock Screen and in the Dynamic Island.
|
||||
///
|
||||
/// The attributes carry no static content: everything the activity shows lives in its ``ContentState``, which the app's reporting
|
||||
/// service updates on every transition of the recording flow. The type is shared between the app — which starts, updates, and
|
||||
/// ends the activity — and the widget extension — which renders it.
|
||||
public struct RecordingActivityAttributes: ActivityAttributes {
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
/// Creates the attributes of the Live Activity of a recording flow.
|
||||
public init() {}
|
||||
|
||||
// MARK: Content state
|
||||
|
||||
/// The dynamic content of the Live Activity, updated on every transition of the recording flow.
|
||||
public struct ContentState: Codable, Hashable, Sendable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// The current state of the recording flow.
|
||||
public var state: RecordingActivityState
|
||||
|
||||
/// The instant the elapsed recording time counts from — moved back by the time already spent recording, so a timer
|
||||
/// counting up from it shows the elapsed recording time — or `nil` while the recording is not running.
|
||||
public var anchor: Date?
|
||||
|
||||
/// The number of seconds spent recording up to the last transition, excluding any time spent paused, shown as a frozen
|
||||
/// elapsed time while the recording is not running.
|
||||
public var elapsed: TimeInterval
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
/// Creates the dynamic content of the Live Activity of a recording flow.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - state: The current state of the recording flow.
|
||||
/// - anchor: The instant the elapsed recording time counts from, or `nil` while the recording is not running.
|
||||
/// - elapsed: The number of seconds spent recording up to the last transition, excluding any time spent paused.
|
||||
public init(
|
||||
state: RecordingActivityState,
|
||||
anchor: Date?,
|
||||
elapsed: TimeInterval
|
||||
) {
|
||||
self.state = state
|
||||
self.anchor = anchor
|
||||
self.elapsed = elapsed
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user