From 8af12768242f59510e6c110f1c9a64d96c863d81 Mon Sep 17 00:00:00 2001 From: Pedro Cuenca Date: Wed, 18 Jan 2023 13:59:30 +0100 Subject: [PATCH] Make Share work. --- Diffusion-macOS/ContentView.swift | 9 +++++++-- Diffusion/State.swift | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Diffusion-macOS/ContentView.swift b/Diffusion-macOS/ContentView.swift index 663f92d..aa83f08 100644 --- a/Diffusion-macOS/ContentView.swift +++ b/Diffusion-macOS/ContentView.swift @@ -20,8 +20,13 @@ struct ContentView: View { .frame(width: 512, height: 512) .cornerRadius(15) .toolbar { - Button(action: {}) { - Label("share", systemImage: "square.and.arrow.up") + if case .complete(let prompt, let cgImage, _) = generation.state, let cgImage = cgImage { + let image = Image(cgImage, scale: 1, label: Text(prompt)) + ShareLink(prompt, item: image, preview: SharePreview(prompt, image: image)) + } else { + let prompt = DEFAULT_PROMPT + let image = Image("placeholder") + ShareLink(prompt, item: image, preview: SharePreview(prompt, image: image)) } } diff --git a/Diffusion/State.swift b/Diffusion/State.swift index 3833be2..594f6d7 100644 --- a/Diffusion/State.swift +++ b/Diffusion/State.swift @@ -10,6 +10,7 @@ import SwiftUI import StableDiffusion let DEFAULT_MODEL = ModelInfo.v2Base +let DEFAULT_PROMPT = "Labrador in the style of Vermeer" enum GenerationState { case startup @@ -35,7 +36,7 @@ class GenerationContext: ObservableObject { } @Published var state: GenerationState = .startup - @Published var positivePrompt = "Labrador in the style of Vermeer" + @Published var positivePrompt = DEFAULT_PROMPT @Published var negativePrompt = "" // FIXME: Double to support the slider component