From e6d725df672ccb92348b64ab1b8b03d3a3ddaa32 Mon Sep 17 00:00:00 2001 From: Pedro Cuenca Date: Wed, 18 Jan 2023 12:39:24 +0100 Subject: [PATCH] Rename context -> generation --- Diffusion-macOS/ContentView.swift | 4 ++-- Diffusion-macOS/PromptView.swift | 4 ++-- Diffusion/Views/Loading.swift | 6 +++--- Diffusion/Views/TextToImage.swift | 12 ++++++------ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Diffusion-macOS/ContentView.swift b/Diffusion-macOS/ContentView.swift index f84bb7a..1f069f0 100644 --- a/Diffusion-macOS/ContentView.swift +++ b/Diffusion-macOS/ContentView.swift @@ -8,7 +8,7 @@ import SwiftUI struct ContentView: View { - @StateObject var context = GenerationContext() + @StateObject var generation = GenerationContext() var body: some View { NavigationSplitView { @@ -26,7 +26,7 @@ struct ContentView: View { } } - .environmentObject(context) + .environmentObject(generation) } } diff --git a/Diffusion-macOS/PromptView.swift b/Diffusion-macOS/PromptView.swift index ab2d7ae..21df81d 100644 --- a/Diffusion-macOS/PromptView.swift +++ b/Diffusion-macOS/PromptView.swift @@ -18,7 +18,7 @@ enum PipelineState { } struct PromptView: View { - @EnvironmentObject var context: GenerationContext + @EnvironmentObject var generation: GenerationContext static let models = ModelInfo.MODELS static let modelNames = models.map { $0.modelVersion } @@ -57,7 +57,7 @@ struct PromptView: View { } } do { - context.pipeline = try await loader.prepare() + generation.pipeline = try await loader.prepare() pipelineState = .ready } catch { print("Could not load model, error: \(error)") diff --git a/Diffusion/Views/Loading.swift b/Diffusion/Views/Loading.swift index ae9f727..a298f56 100644 --- a/Diffusion/Views/Loading.swift +++ b/Diffusion/Views/Loading.swift @@ -12,7 +12,7 @@ import Combine let model = ModelInfo.v2Base struct LoadingView: View { - @StateObject var context = GenerationContext() + @StateObject var generation = GenerationContext() @State private var preparationPhase = "Downloading…" @State private var downloadProgress: Double = 0 @@ -37,7 +37,7 @@ struct LoadingView: View { } } .animation(.easeIn, value: currentView) - .environmentObject(context) + .environmentObject(generation) .onAppear { Task.init { let loader = PipelineLoader(model: model) @@ -59,7 +59,7 @@ struct LoadingView: View { } } do { - context.pipeline = try await loader.prepare() + generation.pipeline = try await loader.prepare() self.currentView = .textToImage } catch { self.currentView = .error("Could not load model, error: \(error)") diff --git a/Diffusion/Views/TextToImage.swift b/Diffusion/Views/TextToImage.swift index 8861959..d0962d8 100644 --- a/Diffusion/Views/TextToImage.swift +++ b/Diffusion/Views/TextToImage.swift @@ -94,18 +94,18 @@ struct ImageWithPlaceholder: View { } struct TextToImage: View { - @EnvironmentObject var context: GenerationContext + @EnvironmentObject var generation: GenerationContext @State private var prompt = "Labrador in the style of Vermeer" func submit() { - if case .running = context.state { return } + if case .running = generation.state { return } Task { - context.state = .running(nil) + generation.state = .running(nil) let interval: TimeInterval? let image: CGImage? - (image, interval) = await context.generate(prompt: prompt, steps: steps, seed: seed) ?? (nil, nil) - context.state = .complete(prompt, image, interval) + (image, interval) = await generation.generate(prompt: prompt, steps: steps, seed: seed) ?? (nil, nil) + generation.state = .complete(prompt, image, interval) } } @@ -123,7 +123,7 @@ struct TextToImage: View { .padding() .buttonStyle(.borderedProminent) } - ImageWithPlaceholder(state: $context.state) + ImageWithPlaceholder(state: $generation.state) .scaledToFit() Spacer() }