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" "version" : "1.2"
+21 -11
View File
@@ -18,8 +18,8 @@ struct ContentView: View {
// MARK: Body // 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 /// 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, /// 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. /// or a content unavailable message when the transcription is empty closable through its toolbar button or a swipe.
var body: some View { var body: some View {
NavigationStack { NavigationStack {
RecordingView( RecordingView(
@@ -64,16 +64,26 @@ struct ContentView: View {
} }
.sheet(item: $model.transcription) { transcription in .sheet(item: $model.transcription) { transcription in
NavigationStack { NavigationStack {
ScrollView { Group {
Text(transcription.text) if transcription.isEmpty {
.font(.body) ContentUnavailableView(
.fontWeight(.regular) "view.transcription.unavailable.title",
.foregroundStyle(.primary) systemImage: "text.page.slash",
.frame( description: Text("view.transcription.unavailable.description")
maxWidth: .infinity,
alignment: .leading
) )
.padding() } else {
ScrollView {
Text(transcription.text)
.font(.body)
.fontWeight(.regular)
.foregroundStyle(.primary)
.frame(
maxWidth: .infinity,
alignment: .leading
)
.padding()
}
}
} }
.navigationTitle("view.transcription.navigation.title") .navigationTitle("view.transcription.navigation.title")
#if !os(macOS) #if !os(macOS)
@@ -24,7 +24,7 @@ public struct Transcription: Equatable, Identifiable, Sendable {
// MARK: Computed // MARK: Computed
/// A Boolean value that indicates whether the transcription has no text. /// A Boolean value that indicates whether the transcription has no text.
var isEmpty: Bool { public var isEmpty: Bool {
text.isEmpty text.isEmpty
} }
@@ -137,7 +137,7 @@ private enum Constant {
/// The size constants. /// The size constants.
enum Size { enum Size {
/// The base width and height of a button's label, before dynamic type scaling. /// The base width and height of a button's label, before dynamic type scaling.
static let button: CGFloat = 16 static let button: CGFloat = 32
} }
} }