From 1fc9328e7854cb704ea06b2c20dff368936cf9b8 Mon Sep 17 00:00:00 2001 From: Pedro Cuenca Date: Tue, 7 Feb 2023 16:07:01 +0100 Subject: [PATCH] Popover with error details. And display download errors too. --- Diffusion-macOS/ControlsView.swift | 2 ++ Diffusion-macOS/StatusView.swift | 29 +++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Diffusion-macOS/ControlsView.swift b/Diffusion-macOS/ControlsView.swift index f56b1fc..9481fda 100644 --- a/Diffusion-macOS/ControlsView.swift +++ b/Diffusion-macOS/ControlsView.swift @@ -89,6 +89,8 @@ struct ControlsView: View { pipelineState = .uncompressing case .readyOnDisk: pipelineState = .loading + case .failed(let error): + pipelineState = .failed(error) default: break } diff --git a/Diffusion-macOS/StatusView.swift b/Diffusion-macOS/StatusView.swift index 7262345..122874f 100644 --- a/Diffusion-macOS/StatusView.swift +++ b/Diffusion-macOS/StatusView.swift @@ -12,6 +12,8 @@ struct StatusView: View { @EnvironmentObject var generation: GenerationContext var pipelineState: Binding + @State private var showErrorPopover = false + func submit() { if case .running = generation.state { return } Task { @@ -77,8 +79,31 @@ struct StatusView: View { AnyView(generationStatusView()) } - case .failed: - Text("Pipeline loading error") + case .failed(let error): + HStack { + Text("Pipeline loading error") + Spacer() + Button { + showErrorPopover.toggle() + } label: { + Image(systemName: "info.circle") + }.buttonStyle(.plain) + .popover(isPresented: $showErrorPopover) { + VStack { + Text(verbatim: "\(error)") + .lineLimit(nil) + .padding(.all, 5) + Button { + showErrorPopover.toggle() + } label: { + Text("Dismiss").frame(maxWidth: 200) + } + .padding(.bottom) + } + .frame(minWidth: 400, idealWidth: 400, maxWidth: 400) + .fixedSize() + } + } } } }