Implemented an unavailable view for empty transcriptions on the ContentView view in the Sample app target.
This commit is contained in:
@@ -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"
|
||||||
|
|||||||
@@ -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,6 +64,14 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
.sheet(item: $model.transcription) { transcription in
|
.sheet(item: $model.transcription) { transcription in
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
|
Group {
|
||||||
|
if transcription.isEmpty {
|
||||||
|
ContentUnavailableView(
|
||||||
|
"view.transcription.unavailable.title",
|
||||||
|
systemImage: "text.page.slash",
|
||||||
|
description: Text("view.transcription.unavailable.description")
|
||||||
|
)
|
||||||
|
} else {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
Text(transcription.text)
|
Text(transcription.text)
|
||||||
.font(.body)
|
.font(.body)
|
||||||
@@ -75,6 +83,8 @@ struct ContentView: View {
|
|||||||
)
|
)
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
.navigationTitle("view.transcription.navigation.title")
|
.navigationTitle("view.transcription.navigation.title")
|
||||||
#if !os(macOS)
|
#if !os(macOS)
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user