import Foundation import Observation import Recording extension ContentView { /// The observable model that drives ``ContentView``. /// /// The model owns the recording and transcribing services attached to the recording feature, and holds the transcription currently /// presented in the view's modal sheet: ``received(_:)`` wraps the transcribed text of a processed recording for presentation, and /// ``dismissed()`` clears it when the sheet closes. @MainActor @Observable final class Model { // MARK: Properties /// The locale of the spoken language to transcribe. var locale: Locale = .current /// The transcription currently presented in the modal sheet, or `nil` when none is shown. var transcription: Transcription? /// The service that captures the audio from the device's microphone. @ObservationIgnored let recorder = AudioRecordingService() /// The service that transcribes the recorded audio into text on device. @ObservationIgnored let transcriber = AudioTranscribing() // MARK: Methods /// Handles the transcription of a processed recording, presenting it in the modal sheet. /// /// - Parameter transcription: The transcription of the processed recording. func received( _ transcription: Transcription ) { self.transcription = transcription } /// Handles the dismissal of the modal sheet. func dismissed() { transcription = nil } } }