Implemented the ActivityReporting service in the Sample app target to surface the recording flow in Live Activities.

This commit is contained in:
2026-07-05 22:06:45 +02:00
parent cfe6b1b408
commit 380ffc39b3
5 changed files with 171 additions and 1 deletions
@@ -7,7 +7,7 @@ extension ContentView {
/// The observable model that drives ``ContentView``.
///
/// The model owns the recording and transcribing services attached to the recording feature, along with the ``locale`` the feature
/// The model owns the recording, transcribing, and reporting services attached to the recording feature, along with the ``locale`` the feature
/// transcribes in, picked in the view's toolbar from the supported ``locales`` that ``load(identifier:)`` fetches restoring the
/// locale the view persisted across launches, when one exists. It also holds the transcription
/// currently presented in the view's modal sheet: ``received(_:)`` presents the transcription of a processed recording, and
@@ -50,6 +50,10 @@ extension ContentView {
@ObservationIgnored
private let preinstaller: any Preinstalling
/// The service that reports the lifecycle of the recording flow outside the app's UI.
@ObservationIgnored
let reporter: any Reporting
/// The task that listens to the events emitted by the preinstalling service, or `nil` until the first preinstallation starts.
@ObservationIgnored
private var taskEvents: Task<Void, Never>?
@@ -70,11 +74,14 @@ extension ContentView {
/// - Parameters:
/// - capturer: The service that captures the audio from a microphone. Defaults to the on-device ``AudioCapturing``.
/// - preinstaller: The service that preinstalls the speech model assets of a picked locale. Defaults to ``AssetPreinstalling``.
/// - reporter: The service that reports the lifecycle of the recording flow outside the app's UI. Defaults to
/// ``ActivityReporting``, which surfaces the flow in a Live Activity on the platforms that support it.
/// - transcriber: The service that transcribes the recorded audio into text. Defaults to the on-device ``AudioTranscribing``.
/// - notifier: The notifier that owns the transient in-app notifications. Defaults to a notifier with its standard dismissal delay.
init(
capturer: any Capturing = AudioCapturing(),
preinstaller: any Preinstalling = AssetPreinstalling(),
reporter: any Reporting = ActivityReporting(),
transcriber: any Transcribing = AudioTranscribing(),
notifier: Notifier = .init(),
) {
@@ -83,6 +90,7 @@ extension ContentView {
self.capturer = capturer
self.notifier = notifier
self.preinstaller = preinstaller
self.reporter = reporter
self.transcriber = transcriber
}