add error alert
This commit is contained in:
@@ -30,7 +30,7 @@ struct AuthTokenView: View {
|
||||
}
|
||||
}
|
||||
|
||||
struct APIKeyView_Previews: PreviewProvider {
|
||||
struct AuthTokenView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
return AuthTokenView(
|
||||
storedToken: Binding.constant(nil),
|
||||
|
||||
@@ -7,6 +7,9 @@ struct CoachView: View {
|
||||
@State var answer: String
|
||||
@State var answerSelection = NSRange()
|
||||
|
||||
@State var showError = false
|
||||
@State var errorDescription = ""
|
||||
|
||||
init(viewModel: AppViewModel) {
|
||||
self.viewModel = viewModel
|
||||
self.answer = viewModel.answer ?? ""
|
||||
@@ -55,6 +58,17 @@ struct CoachView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.onReceive(viewModel.$errorDescription) {
|
||||
if let error = $0 {
|
||||
self.showError = true
|
||||
self.errorDescription = error
|
||||
}
|
||||
}
|
||||
.alert(errorDescription, isPresented: $showError) {
|
||||
Button("OK", role: .cancel) {
|
||||
self.showError = false
|
||||
}
|
||||
}
|
||||
HStack {
|
||||
VStack(alignment: .leading, spacing: 20) {
|
||||
if let transcript = viewModel.transcript {
|
||||
|
||||
@@ -6,7 +6,7 @@ struct ContentView: View {
|
||||
|
||||
@ViewBuilder
|
||||
var body: some View {
|
||||
if viewModel.authToken != nil {
|
||||
if viewModel.authToken?.isEmpty == false {
|
||||
VStack(spacing: 16) {
|
||||
switch viewModel.downloadState {
|
||||
case .pending:
|
||||
|
||||
Reference in New Issue
Block a user