Implemented an unavailable view for empty transcriptions on the ContentView view in the Sample app target.

This commit is contained in:
2026-07-04 13:23:42 +02:00
parent 0d0705c95a
commit 3c542ee033
4 changed files with 43 additions and 13 deletions
@@ -31,6 +31,26 @@
}
}
}
},
"view.transcription.unavailable.description" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Nothing could be transcribed from the recording. Try recording again, or check that the picked locale matches the spoken language."
}
}
}
},
"view.transcription.unavailable.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "No Transcription"
}
}
}
}
},
"version" : "1.2"
+21 -11
View File
@@ -18,8 +18,8 @@ struct ContentView: View {
// MARK: Body
/// The content of the view: a navigation stack with the recording feature's view, attached to the model's services, 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,
/// closable through its toolbar button or a swipe.
/// 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.
var body: some View {
NavigationStack {
RecordingView(
@@ -64,16 +64,26 @@ struct ContentView: View {
}
.sheet(item: $model.transcription) { transcription in
NavigationStack {
ScrollView {
Text(transcription.text)
.font(.body)
.fontWeight(.regular)
.foregroundStyle(.primary)
.frame(
maxWidth: .infinity,
alignment: .leading
Group {
if transcription.isEmpty {
ContentUnavailableView(
"view.transcription.unavailable.title",
systemImage: "text.page.slash",
description: Text("view.transcription.unavailable.description")
)
.padding()
} else {
ScrollView {
Text(transcription.text)
.font(.body)
.fontWeight(.regular)
.foregroundStyle(.primary)
.frame(
maxWidth: .infinity,
alignment: .leading
)
.padding()
}
}
}
.navigationTitle("view.transcription.navigation.title")
#if !os(macOS)
@@ -24,7 +24,7 @@ public struct Transcription: Equatable, Identifiable, Sendable {
// MARK: Computed
/// A Boolean value that indicates whether the transcription has no text.
var isEmpty: Bool {
public var isEmpty: Bool {
text.isEmpty
}
@@ -137,7 +137,7 @@ private enum Constant {
/// The size constants.
enum Size {
/// The base width and height of a button's label, before dynamic type scaling.
static let button: CGFloat = 16
static let button: CGFloat = 32
}
}