|
|
@ -23,7 +23,7 @@ func generate(pipeline: Pipeline?, prompt: String) async -> CGImage? {
|
|
|
|
enum GenerationState {
|
|
|
|
enum GenerationState {
|
|
|
|
case startup
|
|
|
|
case startup
|
|
|
|
case running(StableDiffusionProgress?)
|
|
|
|
case running(StableDiffusionProgress?)
|
|
|
|
case idle
|
|
|
|
case idle(String)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct ImageWithPlaceholder: View {
|
|
|
|
struct ImageWithPlaceholder: View {
|
|
|
@ -42,7 +42,7 @@ struct ImageWithPlaceholder: View {
|
|
|
|
let fraction = Double(step) / Double(progress.stepCount)
|
|
|
|
let fraction = Double(step) / Double(progress.stepCount)
|
|
|
|
let label = "Step \(step) of \(progress.stepCount)"
|
|
|
|
let label = "Step \(step) of \(progress.stepCount)"
|
|
|
|
return AnyView(ProgressView(label, value: fraction, total: 1).padding())
|
|
|
|
return AnyView(ProgressView(label, value: fraction, total: 1).padding())
|
|
|
|
default:
|
|
|
|
case .idle(let lastPrompt):
|
|
|
|
guard let theImage = image.wrappedValue else {
|
|
|
|
guard let theImage = image.wrappedValue else {
|
|
|
|
return AnyView(Image(systemName: "exclamationmark.triangle").resizable())
|
|
|
|
return AnyView(Image(systemName: "exclamationmark.triangle").resizable())
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -51,7 +51,7 @@ struct ImageWithPlaceholder: View {
|
|
|
|
return AnyView(
|
|
|
|
return AnyView(
|
|
|
|
VStack {
|
|
|
|
VStack {
|
|
|
|
imageView.resizable().clipShape(RoundedRectangle(cornerRadius: 20))
|
|
|
|
imageView.resizable().clipShape(RoundedRectangle(cornerRadius: 20))
|
|
|
|
ShareLink(item: imageView, preview: SharePreview("Generated image", image: imageView))
|
|
|
|
ShareLink(item: imageView, preview: SharePreview(lastPrompt, image: imageView))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -71,7 +71,7 @@ struct TextToImage: View {
|
|
|
|
Task {
|
|
|
|
Task {
|
|
|
|
state = .running(nil)
|
|
|
|
state = .running(nil)
|
|
|
|
image = await generate(pipeline: context.pipeline, prompt: prompt)
|
|
|
|
image = await generate(pipeline: context.pipeline, prompt: prompt)
|
|
|
|
state = .idle
|
|
|
|
state = .idle(prompt)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|