From 825c423efbea5a4865e2d0a12645d64606a42ab8 Mon Sep 17 00:00:00 2001 From: Kevin Hermawan <84965338+kevinhermawan@users.noreply.github.com> Date: Sat, 13 Jul 2024 23:51:29 +0700 Subject: [PATCH] chore: updates dependencies (#13) --- Canvas.xcodeproj/project.pbxproj | 32 +++---- .../xcshareddata/swiftpm/Package.resolved | 16 ++-- Canvas/Extensions/Defaults+Keys.swift | 7 +- CoreModels/Package.swift | 2 +- .../Sources/CoreModels/DalleModel.swift | 83 ++++++++++++++++--- CoreViewModels/Package.swift | 4 +- CoreViews/Package.swift | 2 +- .../ImageEditModule/ImageEditView.swift | 14 ++-- .../ImageGenerationView.swift | 11 +-- .../ImagePreferencesView.swift | 28 ++----- .../Subviews/Pickers/SizePicker.swift | 23 ++--- .../ImageVariationView.swift | 10 +-- SettingsModule/Package.swift | 2 +- 13 files changed, 130 insertions(+), 104 deletions(-) diff --git a/Canvas.xcodeproj/project.pbxproj b/Canvas.xcodeproj/project.pbxproj index 8f957fc..4d9e5b4 100644 --- a/Canvas.xcodeproj/project.pbxproj +++ b/Canvas.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 0A03693D2B4D6FBB00D7DAD4 /* SettingsModule in Frameworks */ = {isa = PBXBuildFile; productRef = 0A03693C2B4D6FBB00D7DAD4 /* SettingsModule */; }; 0A20744D2B3CD3E5008516D1 /* ModelPricingModule in Frameworks */ = {isa = PBXBuildFile; productRef = 0A20744C2B3CD3E5008516D1 /* ModelPricingModule */; }; + 0A211A2A2C42D1C900B9029F /* AppInfo in Frameworks */ = {isa = PBXBuildFile; productRef = 0A211A292C42D1C900B9029F /* AppInfo */; }; 0A809A402B39752200C9A015 /* CanvasApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A809A3F2B39752200C9A015 /* CanvasApp.swift */; }; 0A809A462B39752300C9A015 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A809A452B39752300C9A015 /* Assets.xcassets */; }; 0A809A492B39752300C9A015 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A809A482B39752300C9A015 /* Preview Assets.xcassets */; }; @@ -26,7 +27,6 @@ 0A809A7C2B39988000C9A015 /* Defaults+Keys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A809A7B2B39988000C9A015 /* Defaults+Keys.swift */; }; 0A809A7F2B39DDB100C9A015 /* CoreExtensions in Frameworks */ = {isa = PBXBuildFile; productRef = 0A809A7E2B39DDB100C9A015 /* CoreExtensions */; }; 0A809A812B39DDBA00C9A015 /* CoreModels in Frameworks */ = {isa = PBXBuildFile; productRef = 0A809A802B39DDBA00C9A015 /* CoreModels */; }; - 0A809A842B39EB0100C9A015 /* AppInfo in Frameworks */ = {isa = PBXBuildFile; productRef = 0A809A832B39EB0100C9A015 /* AppInfo */; }; 0AE400612B3A98E600307732 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 0AE400602B3A98E600307732 /* Localizable.xcstrings */; }; 0AE400642B3AD5F800307732 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 0AE400632B3AD5F800307732 /* Sparkle */; }; 0AE400662B3AD84700307732 /* AppUpdater.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE400652B3AD84700307732 /* AppUpdater.swift */; }; @@ -63,7 +63,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 0A809A842B39EB0100C9A015 /* AppInfo in Frameworks */, 0A20744D2B3CD3E5008516D1 /* ModelPricingModule in Frameworks */, 0A809A632B397C3B00C9A015 /* ImageEditModule in Frameworks */, 0A809A612B397C3B00C9A015 /* CoreViews in Frameworks */, @@ -76,6 +75,7 @@ 0A809A812B39DDBA00C9A015 /* CoreModels in Frameworks */, 0A809A792B39986D00C9A015 /* Defaults in Frameworks */, 0A809A7F2B39DDB100C9A015 /* CoreExtensions in Frameworks */, + 0A211A2A2C42D1C900B9029F /* AppInfo in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -209,10 +209,10 @@ 0A809A782B39986D00C9A015 /* Defaults */, 0A809A7E2B39DDB100C9A015 /* CoreExtensions */, 0A809A802B39DDBA00C9A015 /* CoreModels */, - 0A809A832B39EB0100C9A015 /* AppInfo */, 0AE400632B3AD5F800307732 /* Sparkle */, 0A20744C2B3CD3E5008516D1 /* ModelPricingModule */, 0A03693C2B4D6FBB00D7DAD4 /* SettingsModule */, + 0A211A292C42D1C900B9029F /* AppInfo */, ); productName = Canvas; productReference = 0A809A3C2B39752200C9A015 /* Canvas.app */; @@ -244,8 +244,8 @@ mainGroup = 0A809A332B39752200C9A015; packageReferences = ( 0A809A772B39986D00C9A015 /* XCRemoteSwiftPackageReference "Defaults" */, - 0A809A822B39EB0100C9A015 /* XCRemoteSwiftPackageReference "AppInfo" */, 0AE400622B3AD5F800307732 /* XCRemoteSwiftPackageReference "Sparkle" */, + 0A211A282C42D1C900B9029F /* XCRemoteSwiftPackageReference "AppInfo" */, ); productRefGroup = 0A809A3D2B39752200C9A015 /* Products */; projectDirPath = ""; @@ -495,20 +495,20 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - 0A809A772B39986D00C9A015 /* XCRemoteSwiftPackageReference "Defaults" */ = { + 0A211A282C42D1C900B9029F /* XCRemoteSwiftPackageReference "AppInfo" */ = { isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/sindresorhus/Defaults.git"; + repositoryURL = "https://github.com/kevinhermawan/AppInfo.git"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 7.3.1; + minimumVersion = 1.0.2; }; }; - 0A809A822B39EB0100C9A015 /* XCRemoteSwiftPackageReference "AppInfo" */ = { + 0A809A772B39986D00C9A015 /* XCRemoteSwiftPackageReference "Defaults" */ = { isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/kevinhermawan/AppInfo"; + repositoryURL = "https://github.com/sindresorhus/Defaults.git"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 1.0.2; + minimumVersion = 8.2.0; }; }; 0AE400622B3AD5F800307732 /* XCRemoteSwiftPackageReference "Sparkle" */ = { @@ -516,7 +516,7 @@ repositoryURL = "https://github.com/sparkle-project/Sparkle.git"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 2.5.2; + minimumVersion = 2.6.4; }; }; /* End XCRemoteSwiftPackageReference section */ @@ -530,6 +530,11 @@ isa = XCSwiftPackageProductDependency; productName = ModelPricingModule; }; + 0A211A292C42D1C900B9029F /* AppInfo */ = { + isa = XCSwiftPackageProductDependency; + package = 0A211A282C42D1C900B9029F /* XCRemoteSwiftPackageReference "AppInfo" */; + productName = AppInfo; + }; 0A809A5A2B397B6100C9A015 /* CoreViewModels */ = { isa = XCSwiftPackageProductDependency; productName = CoreViewModels; @@ -567,11 +572,6 @@ isa = XCSwiftPackageProductDependency; productName = CoreModels; }; - 0A809A832B39EB0100C9A015 /* AppInfo */ = { - isa = XCSwiftPackageProductDependency; - package = 0A809A822B39EB0100C9A015 /* XCRemoteSwiftPackageReference "AppInfo" */; - productName = AppInfo; - }; 0AE400632B3AD5F800307732 /* Sparkle */ = { isa = XCSwiftPackageProductDependency; package = 0AE400622B3AD5F800307732 /* XCRemoteSwiftPackageReference "Sparkle" */; diff --git a/Canvas.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Canvas.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index fed68ce..8e1aa35 100644 --- a/Canvas.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Canvas.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -23,8 +23,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/sindresorhus/Defaults.git", "state" : { - "revision" : "3efef5a28ebdbbe922d4a2049493733ed14475a6", - "version" : "7.3.1" + "revision" : "38925e3cfacf3fb89a81a35b1cd44fd5a5b7e0fa", + "version" : "8.2.0" } }, { @@ -41,8 +41,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/kean/Nuke.git", "state" : { - "revision" : "1694798e876113d44f6ec6ead965d7286695981d", - "version" : "12.2.0" + "revision" : "0ead44350d2737db384908569c012fe67c421e4d", + "version" : "12.8.0" } }, { @@ -50,8 +50,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/MacPaw/OpenAI.git", "state" : { - "branch" : "main", - "revision" : "497266a278de1f32a609981e0012faabcf2091b4" + "revision" : "fd13a41e987004d14f1793c570721953a2767b03", + "version" : "0.2.9" } }, { @@ -86,8 +86,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/kevinhermawan/ViewState.git", "state" : { - "revision" : "8e5a5efbbf3fb5a2d2621533a115a9da031214cb", - "version" : "1.2.1" + "revision" : "6c85c207c23edf487007542651e3533a80dfa0bc", + "version" : "1.2.2" } } ], diff --git a/Canvas/Extensions/Defaults+Keys.swift b/Canvas/Extensions/Defaults+Keys.swift index 735629c..cfc57cd 100644 --- a/Canvas/Extensions/Defaults+Keys.swift +++ b/Canvas/Extensions/Defaults+Keys.swift @@ -12,14 +12,13 @@ import Foundation extension Defaults.Keys { static let ig_selectedModel = Key("ig_selectedModel", default: .dalle2) static let ig_selectedNumber = Key("ig_selectedNumber", default: DalleModel.dalle2.numbers[0]) - static let ig_selectedSize = Key("ig_selectedSize", default: DalleModel.dalle2.sizes[0]) + static let ig_selectedSize = Key("ig_selectedSize", default: ._1024) static let ig_selectedQuality = Key("ig_selectedQuality", default: .standard) static let ig_selectedStyle = Key("ig_selectedStyle", default: .vivid) static let ie_selectedNumber = Key("ie_selectedNumber", default: DalleModel.dalle2.numbers[0]) - static let ie_selectedSize = Key("ie_selectedSize", default: DalleModel.dalle2.sizes[0]) - + static let ie_selectedSize = Key("ie_selectedSize", default: ._1024) static let iv_selectedNumber = Key("iv_selectedNumber", default: DalleModel.dalle2.numbers[0]) - static let iv_selectedSize = Key("iv_selectedSize", default: DalleModel.dalle2.sizes[0]) + static let iv_selectedSize = Key("iv_selectedSize", default: ._1024) } diff --git a/CoreModels/Package.swift b/CoreModels/Package.swift index 36a2a65..29ca14b 100644 --- a/CoreModels/Package.swift +++ b/CoreModels/Package.swift @@ -12,7 +12,7 @@ let package = Package( targets: ["CoreModels"]), ], dependencies: [ - .package(url: "https://github.com/sindresorhus/Defaults.git", .upToNextMajor(from: "7.3.1")) + .package(url: "https://github.com/sindresorhus/Defaults.git", .upToNextMajor(from: "8.2.0")) ], targets: [ .target( diff --git a/CoreModels/Sources/CoreModels/DalleModel.swift b/CoreModels/Sources/CoreModels/DalleModel.swift index 2617d5c..632345c 100644 --- a/CoreModels/Sources/CoreModels/DalleModel.swift +++ b/CoreModels/Sources/CoreModels/DalleModel.swift @@ -7,6 +7,7 @@ import Defaults import Foundation +import OpenAI public enum DalleModel: String, CaseIterable { case dalle2 = "dall-e-2" @@ -29,15 +30,6 @@ public enum DalleModel: String, CaseIterable { return Array(arrayLiteral: 1) } } - - public var sizes: [String] { - switch self { - case .dalle2: - return ["256x256", "512x512", "1024x1024"] - case .dalle3: - return ["1024x1024", "1024x1792", "1792x1024"] - } - } } extension DalleModel: Identifiable { @@ -48,10 +40,58 @@ extension DalleModel: Identifiable { extension DalleModel: Codable, Defaults.Serializable {} +extension DalleModel { + public enum Size: String, CaseIterable, Identifiable, Codable, Defaults.Serializable { + case _256, _512, _1024, _1024_1792, _1792_1024 + + public var id: String { + self.rawValue + } + + public var title: String { + switch self { + case ._256: + return "256x256 (Square)" + case ._512: + return "512x512 (Square)" + case ._1024: + return "1024x1024 (Square)" + case ._1024_1792: + return "1024x1792 (Landscape)" + case ._1792_1024: + return "1792x1024 (Portrait)" + } + } + + public var imagesQuery: ImagesQuery.Size { + switch self { + case ._256: + return ._256 + case ._512: + return ._512 + case ._1024: + return ._1024 + case ._1024_1792: + return ._1024_1792 + case ._1792_1024: + return ._1792_1024 + } + } + } + + public var sizes: [Size] { + switch self { + case .dalle2: + return [._256, ._512, ._1024] + case .dalle3: + return [._1024, ._1024_1792, ._1792_1024] + } + } +} + extension DalleModel { public enum Quality: String, CaseIterable, Identifiable, Codable, Defaults.Serializable { - case standard - case hd + case standard, hd public var id: String { self.rawValue @@ -65,6 +105,15 @@ extension DalleModel { return "HD" } } + + public var imagesQuery: ImagesQuery.Quality { + switch self { + case .standard: + return .standard + case .hd: + return .hd + } + } } public var qualities: [Quality]? { @@ -79,8 +128,7 @@ extension DalleModel { extension DalleModel { public enum Style: String, CaseIterable, Identifiable, Defaults.Serializable { - case vivid - case natural + case vivid, natural public var id: String { self.rawValue @@ -94,6 +142,15 @@ extension DalleModel { return "Natural" } } + + public var imagesQuery: ImagesQuery.Style { + switch self { + case .vivid: + return .vivid + case .natural: + return .natural + } + } } public var styles: [Style]? { diff --git a/CoreViewModels/Package.swift b/CoreViewModels/Package.swift index 2bf73c1..8d0bdbc 100644 --- a/CoreViewModels/Package.swift +++ b/CoreViewModels/Package.swift @@ -15,8 +15,8 @@ let package = Package( .package(name: "CoreModels", path: "../CoreModels"), .package(url: "https://github.com/kishikawakatsumi/KeychainAccess.git", .upToNextMajor(from: "4.2.2")), .package(url: "https://github.com/kevinhermawan/AppInfo.git", .upToNextMajor(from: "1.0.2")), - .package(url: "https://github.com/kevinhermawan/ViewState.git", .upToNextMajor(from: "1.2.1")), - .package(url: "https://github.com/MacPaw/OpenAI.git", branch: "main") + .package(url: "https://github.com/kevinhermawan/ViewState.git", .upToNextMajor(from: "1.2.2")), + .package(url: "https://github.com/MacPaw/OpenAI.git", .upToNextMajor(from: "0.2.9")) ], targets: [ .target( diff --git a/CoreViews/Package.swift b/CoreViews/Package.swift index 3e9f3e5..92ba8a4 100644 --- a/CoreViews/Package.swift +++ b/CoreViews/Package.swift @@ -12,7 +12,7 @@ let package = Package( targets: ["CoreViews"]), ], dependencies: [ - .package(url: "https://github.com/kean/Nuke.git", .upToNextMajor(from: "12.2.0")), + .package(url: "https://github.com/kean/Nuke.git", .upToNextMajor(from: "12.8.0")), .package(url: "https://github.com/kevinhermawan/ChatField.git", .upToNextMajor(from: "1.0.0")) ], targets: [ diff --git a/ImageEditModule/Sources/ImageEditModule/ImageEditView.swift b/ImageEditModule/Sources/ImageEditModule/ImageEditView.swift index 40c723c..b7fada1 100644 --- a/ImageEditModule/Sources/ImageEditModule/ImageEditView.swift +++ b/ImageEditModule/Sources/ImageEditModule/ImageEditView.swift @@ -6,6 +6,7 @@ // import CoreExtensions +import CoreModels import CoreViewModels import CoreViews import Defaults @@ -20,13 +21,13 @@ public struct ImageEditView: View { @State private var prompt: String = "" private var number: Int - private var size: String + private var size: DalleModel.Size? private var imageData: Data? private var maskData: Data? public init( number: Int, - size: String, + size: DalleModel.Size? = nil, imageData: Data? = nil, maskData: Data? = nil ) { @@ -66,12 +67,9 @@ public struct ImageEditView: View { @MainActor func generationAction() { guard let image = imageData else { return } - let fileName = UUID().uuidString - - let mask = maskData - let maskFileName: String? = mask.isNotNil ? UUID().uuidString : nil - - let query = ImageEditsQuery(image: image, fileName: fileName, mask: mask, maskFileName: maskFileName, prompt: prompt, n: number, size: size) + guard let mask = maskData else { return } + let size = size?.imagesQuery + let query = ImageEditsQuery(image: image, prompt: prompt, mask: mask, size: size) dalleViewModel.setup(apiKey: settingsManager.apiKey) dalleViewModel.imageEdit(query: query) diff --git a/ImageGenerationModule/Sources/ImageGenerationModule/ImageGenerationView.swift b/ImageGenerationModule/Sources/ImageGenerationModule/ImageGenerationView.swift index b44e1f6..008d4d7 100644 --- a/ImageGenerationModule/Sources/ImageGenerationModule/ImageGenerationView.swift +++ b/ImageGenerationModule/Sources/ImageGenerationModule/ImageGenerationView.swift @@ -21,14 +21,14 @@ public struct ImageGenerationView: View { private var model: DalleModel private var number: Int - private var size: String + private var size: DalleModel.Size private var quality: DalleModel.Quality? private var style: DalleModel.Style? public init( model: DalleModel, number: Int, - size: String, + size: DalleModel.Size, quality: DalleModel.Quality? = nil, style: DalleModel.Style? = nil ) { @@ -69,9 +69,10 @@ public struct ImageGenerationView: View { @MainActor func generationAction() { let model = model.rawValue - let style = style?.rawValue - let quality = quality?.rawValue - let query = ImagesQuery(prompt: prompt, model: model, n: number, size: size, style: style, quality: quality) + let size = size.imagesQuery + let quality = quality?.imagesQuery + let style = style?.imagesQuery + let query = ImagesQuery(prompt: prompt, model: model, n: number, quality: quality, size: size, style: style) dalleViewModel.setup(apiKey: settingsManager.apiKey) dalleViewModel.imageGeneration(query: query) diff --git a/ImagePreferencesModule/Sources/ImagePreferencesModule/ImagePreferencesView.swift b/ImagePreferencesModule/Sources/ImagePreferencesModule/ImagePreferencesView.swift index 3bb43ef..73d8d84 100644 --- a/ImagePreferencesModule/Sources/ImagePreferencesModule/ImagePreferencesView.swift +++ b/ImagePreferencesModule/Sources/ImagePreferencesModule/ImagePreferencesView.swift @@ -18,10 +18,10 @@ public struct ImagePreferencesView: View { private var isMaskPickerVisible: Bool = false private var imageFootnote: LocalizedStringKey = "" private var maskFootnote: LocalizedStringKey = "" - + @Binding private var modelSelection: DalleModel @Binding private var numberSelection: Int - @Binding private var sizeSelection: String + @Binding private var sizeSelection: DalleModel.Size @Binding private var qualitySelection: DalleModel.Quality? @Binding private var styleSelection: DalleModel.Style? @Binding private var imageData: Data? @@ -33,7 +33,7 @@ public struct ImagePreferencesView: View { public init( modelSelection: Binding, numberSelection: Binding, - sizeSelection: Binding, + sizeSelection: Binding, qualitySelection: Binding, styleSelection: Binding, imageData: Binding, @@ -66,7 +66,7 @@ public struct ImagePreferencesView: View { SizePicker(modelSelection.sizes, selection: $sizeSelection) .visible(if: modelSelection.sizes.contains(sizeSelection), removeCompletely: true) - + if let qualities = modelSelection.qualities, let selection = Binding($qualitySelection) { QualityPicker(qualities, selection: selection) } @@ -79,8 +79,8 @@ public struct ImagePreferencesView: View { .onChange(of: modelSelection) { numberSelection = modelSelection.numbers[0] sizeSelection = modelSelection.sizes[0] - qualitySelection = modelSelection.qualities?.first - styleSelection = modelSelection.styles?.first + qualitySelection = modelSelection.qualities?.first ?? .standard + styleSelection = modelSelection.styles?.first ?? .vivid } } @@ -107,19 +107,3 @@ public struct ImagePreferencesView: View { return view } } - -#Preview { - @State var selectedModel: DalleModel = .dalle2 - @State var selectedNumber: Int = DalleModel.dalle2.numbers[0] - @State var selectedSize: String = DalleModel.dalle2.sizes[0] - - return ImagePreferencesView( - modelSelection: $selectedModel, - numberSelection: $selectedNumber, - sizeSelection: $selectedSize, - qualitySelection: .constant(nil), - styleSelection: .constant(nil), - imageData: .constant(nil), - maskData: .constant(nil) - ) -} diff --git a/ImagePreferencesModule/Sources/ImagePreferencesModule/Subviews/Pickers/SizePicker.swift b/ImagePreferencesModule/Sources/ImagePreferencesModule/Subviews/Pickers/SizePicker.swift index 246bfc4..beb6885 100644 --- a/ImagePreferencesModule/Sources/ImagePreferencesModule/Subviews/Pickers/SizePicker.swift +++ b/ImagePreferencesModule/Sources/ImagePreferencesModule/Subviews/Pickers/SizePicker.swift @@ -5,14 +5,15 @@ // Created by Kevin Hermawan on 26/12/23. // +import CoreModels import CoreViews import SwiftUI struct SizePicker: View { - private let sizes: [String] - @Binding private var selection: String + private let sizes: [DalleModel.Size] + @Binding private var selection: DalleModel.Size - init(_ sizes: [String], selection: Binding) { + init(_ sizes: [DalleModel.Size], selection: Binding) { self.sizes = sizes self._selection = selection } @@ -21,7 +22,7 @@ struct SizePicker: View { Section { Picker("Select size", selection: $selection) { ForEach(sizes, id: \.self) { size in - Text(getLabel(for: size)).tag(size) + Text(size.title).tag(size) } } } header: { @@ -30,18 +31,4 @@ struct SizePicker: View { FootnoteText("FOOTNOTE_SIZE") } } - - private func getLabel(for size: String) -> String { - let dimensions = size.split(separator: "x").compactMap { Int($0) } - let width = dimensions[0] - let height = dimensions[1] - - if width == height { - return "\(size) (Square)" - } else if height > width { - return "\(size) (Portrait)" - } else { - return "\(size) (Landscape)" - } - } } diff --git a/ImageVariationModule/Sources/ImageVariationModule/ImageVariationView.swift b/ImageVariationModule/Sources/ImageVariationModule/ImageVariationView.swift index 11971df..a5ce5de 100644 --- a/ImageVariationModule/Sources/ImageVariationModule/ImageVariationView.swift +++ b/ImageVariationModule/Sources/ImageVariationModule/ImageVariationView.swift @@ -5,6 +5,7 @@ // Created by Kevin Hermawan on 25/12/23. // +import CoreModels import CoreModels import CoreViewModels import CoreViews @@ -19,12 +20,12 @@ public struct ImageVariationView: View { @Environment(DalleViewModel.self) private var dalleViewModel private var number: Int - private var size: String + private var size: DalleModel.Size? private var imageData: Data? public init( number: Int, - size: String, + size: DalleModel.Size? = nil, imageData: Data? = nil ) { self.number = number @@ -80,10 +81,9 @@ public struct ImageVariationView: View { @MainActor func generationAction() { - let fileName = UUID().uuidString guard let image = imageData else { return } - - let query = ImageVariationsQuery(image: image, fileName: fileName, n: number, size: size) + let size = size?.rawValue + let query = ImageVariationsQuery(image: image, n: number, size: size) dalleViewModel.setup(apiKey: settingsManager.apiKey) dalleViewModel.imageVariation(query: query) diff --git a/SettingsModule/Package.swift b/SettingsModule/Package.swift index 34d7997..a240ca6 100644 --- a/SettingsModule/Package.swift +++ b/SettingsModule/Package.swift @@ -13,7 +13,7 @@ let package = Package( ], dependencies: [ .package(name: "CoreExtensions", path: "../CoreExtensions"), - .package(url: "https://github.com/sindresorhus/Defaults.git", .upToNextMajor(from: "7.3.1")) + .package(url: "https://github.com/sindresorhus/Defaults.git", .upToNextMajor(from: "8.2.0")) ], targets: [ .target(