Integrated the Notifier and the AssetPreinstalling to the ContentView view model in the Sample app target.

This commit is contained in:
2026-07-05 13:43:49 +02:00
parent d22a8dda13
commit ee212cb6e3
3 changed files with 90 additions and 123 deletions
+17 -14
View File
@@ -1,3 +1,4 @@
import Notifying
import Recording
import SwiftUI
@@ -6,16 +7,18 @@ import SwiftUI
/// The view hosts the `RecordingView` feature from the `Recording` target of the `Features` package, which drives the whole recording flow,
/// inside a navigation stack, and presents the transcribed text of every processed recording in a modal sheet of its own navigation stack.
/// A toolbar menu picks the locale of the spoken language to transcribe, and every pick kicks off the preinstallation of the locale's speech
/// model assets, whose download events surface as transient in-app notifications overlaying the feature just below the navigation bar.
/// model assets, whose download events surface as transient in-app notifications banners wearing the `Notifying` target's label
/// style overlaying the feature just below the navigation bar.
///
/// The services attached to the feature, the transcription shown in the sheet, and the posted notifications live in the view's ``Model``;
/// the view itself only renders it and forwards the feature's output, the picker's changes, and the sheet's dismissal. All user-facing text
/// is localized through the app's string catalog.
/// The services attached to the feature, the transcription shown in the sheet, and the notifier owning the notifications live in the view's
/// ``Model``; the view itself only renders it and forwards the feature's output, the picker's changes, and the sheet's dismissal. All
/// user-facing text is localized through the app's string catalog.
struct ContentView: View {
// MARK: Properties
/// The model that owns the attached services, the transcription presented in the modal sheet, and the posted in-app notifications.
/// The model that owns the attached services, the transcription presented in the modal sheet, and the notifier of the in-app
/// notifications.
@State private var model = Model()
// MARK: Body
@@ -23,10 +26,10 @@ struct ContentView: View {
/// The content of the view: a navigation stack with the recording feature's view, attached to the model's services and expanded to fill
/// the available space, with a toolbar picker for the locale of the spoken language to transcribe, and a modal sheet presenting the
/// transcribed text of every processed recording or a content unavailable message when the transcription is empty closable
/// through its toolbar button or a swipe. The model's in-app notifications overlay the feature, stacking downward just below the
/// through its toolbar button or a swipe. The notifier's in-app notifications overlay the feature, stacking downward just below the
/// navigation bar; each one slides in from the leading edge when posted and out again when its scheduled dismissal arrives, without
/// displacing the recording controls underneath. Every posted notification is also announced to assistive technologies, since the
/// banners themselves are transient.
/// displacing the recording controls underneath. The notifier also announces every posted notification to assistive technologies,
/// since the banners themselves are transient.
var body: some View {
NavigationStack {
RecordingView(
@@ -104,7 +107,7 @@ private extension ContentView {
.accessibilityHint(Text("view.recording.picker.locale.hint"))
}
/// The stack of the model's in-app notifications, each one sliding in from the leading edge when posted and out again when
/// The stack of the notifier's in-app notifications, each one sliding in from the leading edge when posted and out again when
/// its scheduled dismissal arrives.
var stackNotifications: some View {
VStack(
@@ -112,16 +115,16 @@ private extension ContentView {
spacing: Constant.Spacing.stack
) {
ForEach(
model.notifications
model.notifier.notifications
) { notification in
Label {
Text(notification.textMessage)
Text(notification.message)
} icon: {
Image(systemName: notification.imageSymbol)
Image(systemName: notification.symbol)
.accessibilityHidden(true)
}
.labelStyle(.notification(
event: notification.event
kind: notification.kind
))
.accessibilityElement(
children: .combine
@@ -136,7 +139,7 @@ private extension ContentView {
.padding(.horizontal)
.animation(
.spring,
value: model.notifications
value: model.notifier.notifications
)
}