Extracted the PreviewPreinstalling service in the Sample app target into its own file and declared it as development asset.
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
"sourceLanguage" : "en",
|
"sourceLanguage" : "en",
|
||||||
"strings" : {
|
"strings" : {
|
||||||
"view.recording.navigation.title" : {
|
"view.recording.navigation.title" : {
|
||||||
|
"comment" : "The title of the navigation bar in the recording view.",
|
||||||
|
"extractionState" : "manual",
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"en" : {
|
"en" : {
|
||||||
"stringUnit" : {
|
"stringUnit" : {
|
||||||
@@ -60,6 +62,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"view.recording.picker.locale.title" : {
|
"view.recording.picker.locale.title" : {
|
||||||
|
"comment" : "A label for the picker that selects the locale of the spoken language to transcribe.",
|
||||||
|
"extractionState" : "manual",
|
||||||
|
"isCommentAutoGenerated" : true,
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"en" : {
|
"en" : {
|
||||||
"stringUnit" : {
|
"stringUnit" : {
|
||||||
@@ -70,6 +75,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"view.transcription.navigation.title" : {
|
"view.transcription.navigation.title" : {
|
||||||
|
"comment" : "The title of the navigation bar in the transcription modal view.",
|
||||||
"extractionState" : "manual",
|
"extractionState" : "manual",
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"en" : {
|
"en" : {
|
||||||
@@ -81,6 +87,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"view.transcription.unavailable.description" : {
|
"view.transcription.unavailable.description" : {
|
||||||
|
"comment" : "The description of the content unavailable view shown in the transcription modal view for an empty transcription.",
|
||||||
|
"extractionState" : "manual",
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"en" : {
|
"en" : {
|
||||||
"stringUnit" : {
|
"stringUnit" : {
|
||||||
@@ -91,6 +99,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"view.transcription.unavailable.title" : {
|
"view.transcription.unavailable.title" : {
|
||||||
|
"comment" : "The title of the content unavailable view shown in the transcription modal view for an empty transcription.",
|
||||||
|
"extractionState" : "manual",
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"en" : {
|
"en" : {
|
||||||
"stringUnit" : {
|
"stringUnit" : {
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import Foundation
|
||||||
|
import Recording
|
||||||
|
|
||||||
|
/// The preinstalling service used by the previews, which resolves every locale as supported and downloads nothing.
|
||||||
|
struct PreviewPreinstalling: Preinstalling {
|
||||||
|
|
||||||
|
/// The stream of events the service emits, which finishes immediately.
|
||||||
|
let events: AsyncStream<PreinstallingEvent> = .init { continuation in
|
||||||
|
continuation.finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Simulates the preinstallation of the speech model assets of the given locale, downloading nothing.
|
||||||
|
///
|
||||||
|
/// - Parameter locale: The locale to preinstall the speech model assets for.
|
||||||
|
func preinstall(
|
||||||
|
for locale: Locale
|
||||||
|
) async {
|
||||||
|
// The previews preinstall no speech model assets.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the given locale as its own supported equivalent.
|
||||||
|
///
|
||||||
|
/// - Parameter locale: The locale to find a supported equivalent for.
|
||||||
|
/// - Returns: The given locale, unchanged.
|
||||||
|
func supportedLocale(
|
||||||
|
equivalentTo locale: Locale
|
||||||
|
) async -> Locale? {
|
||||||
|
locale
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a sample of supported locales for the locale picker.
|
||||||
|
///
|
||||||
|
/// - Returns: A pair of sample locales.
|
||||||
|
func supportedLocales() async -> [Locale] {
|
||||||
|
[
|
||||||
|
Locale(identifier: "en-US"),
|
||||||
|
Locale(identifier: "nl-NL"),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,6 +15,9 @@ extension ContentView {
|
|||||||
/// Every picked locale kicks off ``preinstall()``, a cancellable task that preinstalls the locale's speech model assets through the
|
/// Every picked locale kicks off ``preinstall()``, a cancellable task that preinstalls the locale's speech model assets through the
|
||||||
/// preinstalling service — cancelling any download still in flight for a previously picked locale. The service's started, cancelled, and
|
/// preinstalling service — cancelling any download still in flight for a previously picked locale. The service's started, cancelled, and
|
||||||
/// failed download events are mapped to the transient, self-dismissing notifications of the ``notifier``.
|
/// failed download events are mapped to the transient, self-dismissing notifications of the ``notifier``.
|
||||||
|
///
|
||||||
|
/// Every collaborator is injected at initialization behind its protocol, defaulting to the on-device services: the app runs the model
|
||||||
|
/// against the real backends, while its unit tests and previews attach mocks and dummies without touching this type.
|
||||||
@MainActor
|
@MainActor
|
||||||
@Observable
|
@Observable
|
||||||
final class Model {
|
final class Model {
|
||||||
@@ -84,9 +87,10 @@ extension ContentView {
|
|||||||
|
|
||||||
// MARK: Methods
|
// MARK: Methods
|
||||||
|
|
||||||
/// Loads the locales the transcriber supports into ``locales``, sorted by their localized names, and aligns ``locale`` with the
|
/// Loads the locales the transcriber supports — resolved through the preinstalling service — into ``locales``, sorted by their
|
||||||
/// supported equivalent of its current value — falling back to the supported equivalent of a default locale when none exists —
|
/// localized names, and aligns ``locale`` with the supported equivalent of its current value — falling back to the supported
|
||||||
/// so the locale picker starts with a valid selection.
|
/// equivalent of a default locale when none exists — so the locale picker starts with a valid selection. It then kicks off the
|
||||||
|
/// preinstallation of the aligned locale's speech model assets.
|
||||||
func load() async {
|
func load() async {
|
||||||
locales =
|
locales =
|
||||||
await preinstaller
|
await preinstaller
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import SwiftUI
|
|||||||
///
|
///
|
||||||
/// The services attached to the feature, the transcription shown in the sheet, and the notifier owning the notifications live in the view's
|
/// 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
|
/// ``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.
|
/// user-facing text is localized through the app's string catalog, resolved via its generated string symbols.
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
|
|
||||||
// MARK: Properties
|
// MARK: Properties
|
||||||
@@ -220,35 +220,6 @@ private enum Constant {
|
|||||||
|
|
||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
/// The preinstalling service used by the previews, which resolves every locale as supported and downloads nothing.
|
|
||||||
private struct PreviewPreinstalling: Preinstalling {
|
|
||||||
|
|
||||||
/// The stream of events the service emits, which finishes immediately.
|
|
||||||
let events: AsyncStream<PreinstallingEvent> = .init { continuation in
|
|
||||||
continuation.finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
func preinstall(
|
|
||||||
for locale: Locale
|
|
||||||
) async {
|
|
||||||
// The previews preinstall no speech model assets.
|
|
||||||
}
|
|
||||||
|
|
||||||
func supportedLocale(
|
|
||||||
equivalentTo locale: Locale
|
|
||||||
) async -> Locale? {
|
|
||||||
locale
|
|
||||||
}
|
|
||||||
|
|
||||||
func supportedLocales() async -> [Locale] {
|
|
||||||
[
|
|
||||||
Locale(identifier: "en-US"),
|
|
||||||
Locale(identifier: "nl-NL"),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#Preview(
|
#Preview(
|
||||||
"Content view"
|
"Content view"
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import Recording
|
|||||||
/// on demand.
|
/// on demand.
|
||||||
@MainActor
|
@MainActor
|
||||||
final class PreinstallingMock: Preinstalling {
|
final class PreinstallingMock: Preinstalling {
|
||||||
|
|
||||||
|
// MARK: Properties
|
||||||
|
|
||||||
/// The stream of events the service emits while preinstalling.
|
/// The stream of events the service emits while preinstalling.
|
||||||
let events: AsyncStream<PreinstallingEvent>
|
let events: AsyncStream<PreinstallingEvent>
|
||||||
@@ -20,10 +22,14 @@ final class PreinstallingMock: Preinstalling {
|
|||||||
|
|
||||||
/// The continuation that feeds ``events``.
|
/// The continuation that feeds ``events``.
|
||||||
private let continuation: AsyncStream<PreinstallingEvent>.Continuation
|
private let continuation: AsyncStream<PreinstallingEvent>.Continuation
|
||||||
|
|
||||||
|
// MARK: Initializers
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
(events, continuation) = AsyncStream.makeStream(of: PreinstallingEvent.self)
|
(events, continuation) = AsyncStream.makeStream(of: PreinstallingEvent.self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: Methods
|
||||||
|
|
||||||
/// Emits the given event through ``events``.
|
/// Emits the given event through ``events``.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
membershipExceptions = (
|
membershipExceptions = (
|
||||||
Attendi/Catalogs/Assets.xcassets,
|
Attendi/Catalogs/Assets.xcassets,
|
||||||
Attendi/Catalogs/Localizable.xcstrings,
|
Attendi/Catalogs/Localizable.xcstrings,
|
||||||
|
Attendi/Previews/Services/PreviewPreinstalling.swift,
|
||||||
Attendi/Sources/App/AttendiApp.swift,
|
Attendi/Sources/App/AttendiApp.swift,
|
||||||
"Attendi/Sources/View Models/ContentViewModel.swift",
|
"Attendi/Sources/View Models/ContentViewModel.swift",
|
||||||
Attendi/Sources/Views/ContentView.swift,
|
Attendi/Sources/Views/ContentView.swift,
|
||||||
@@ -285,6 +286,7 @@
|
|||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
DEVELOPMENT_ASSET_PATHS = Apps/Attendi/Previews/Services/PreviewPreinstalling.swift;
|
||||||
DEVELOPMENT_TEAM = 7FMNM89WKG;
|
DEVELOPMENT_TEAM = 7FMNM89WKG;
|
||||||
ENABLE_APP_SANDBOX = YES;
|
ENABLE_APP_SANDBOX = YES;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
@@ -401,6 +403,7 @@
|
|||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
DEVELOPMENT_ASSET_PATHS = Apps/Attendi/Previews/Services/PreviewPreinstalling.swift;
|
||||||
DEVELOPMENT_TEAM = 7FMNM89WKG;
|
DEVELOPMENT_TEAM = 7FMNM89WKG;
|
||||||
ENABLE_APP_SANDBOX = YES;
|
ENABLE_APP_SANDBOX = YES;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
|
|||||||
Reference in New Issue
Block a user