|
|
@ -18,10 +18,39 @@ struct StatusView: View {
|
|
|
|
if case .running = generation.state { return }
|
|
|
|
if case .running = generation.state { return }
|
|
|
|
Task {
|
|
|
|
Task {
|
|
|
|
generation.state = .running(nil)
|
|
|
|
generation.state = .running(nil)
|
|
|
|
let interval: TimeInterval?
|
|
|
|
do {
|
|
|
|
let image: CGImage?
|
|
|
|
let result = try await generation.generate()
|
|
|
|
(image, interval) = await generation.generate() ?? (nil, nil)
|
|
|
|
generation.state = .complete(generation.positivePrompt, result.image, result.lastSeed, result.interval)
|
|
|
|
generation.state = .complete(generation.positivePrompt, image, interval)
|
|
|
|
} catch {
|
|
|
|
|
|
|
|
generation.state = .failed(error)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func errorWithDetails(_ message: String, error: Error) -> any View {
|
|
|
|
|
|
|
|
HStack {
|
|
|
|
|
|
|
|
Text(message)
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -42,7 +71,7 @@ struct StatusView: View {
|
|
|
|
Text("Generating \(Int(round(100*fraction)))%")
|
|
|
|
Text("Generating \(Int(round(100*fraction)))%")
|
|
|
|
Spacer()
|
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case .complete(_, let image, let interval):
|
|
|
|
case .complete(_, let image, let lastSeed, let interval):
|
|
|
|
guard let _ = image else {
|
|
|
|
guard let _ = image else {
|
|
|
|
return HStack {
|
|
|
|
return HStack {
|
|
|
|
Text("Safety checker triggered, please try a different prompt or seed")
|
|
|
|
Text("Safety checker triggered, please try a different prompt or seed")
|
|
|
@ -55,6 +84,8 @@ struct StatusView: View {
|
|
|
|
Text(intervalString)
|
|
|
|
Text(intervalString)
|
|
|
|
Spacer()
|
|
|
|
Spacer()
|
|
|
|
}.frame(maxHeight: 25)
|
|
|
|
}.frame(maxHeight: 25)
|
|
|
|
|
|
|
|
case .failed(let error):
|
|
|
|
|
|
|
|
return errorWithDetails("Generation error", error: error)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -80,30 +111,7 @@ struct StatusView: View {
|
|
|
|
AnyView(generationStatusView())
|
|
|
|
AnyView(generationStatusView())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case .failed(let error):
|
|
|
|
case .failed(let error):
|
|
|
|
HStack {
|
|
|
|
AnyView(errorWithDetails("Pipeline loading error", error: error))
|
|
|
|
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()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|