Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhermawan committed Dec 26, 2023
0 parents commit e463eab
Show file tree
Hide file tree
Showing 89 changed files with 3,333 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## General
.DS_Store
*.moved-aside
*.xccheckout
*.xcscmblueprint

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/gems
561 changes: 561 additions & 0 deletions Canvas.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Canvas.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"pins" : [
{
"identity" : "appinfo",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kevinhermawan/AppInfo",
"state" : {
"revision" : "4b60b10c94c327083cb5fe5e73cdff21d1082b4c",
"version" : "1.0.2"
}
},
{
"identity" : "chatfield",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kevinhermawan/ChatField.git",
"state" : {
"revision" : "36833e4ddc23308c3754083d4bdcfa837fa17799",
"version" : "1.0.1"
}
},
{
"identity" : "defaults",
"kind" : "remoteSourceControl",
"location" : "https://github.com/sindresorhus/Defaults.git",
"state" : {
"revision" : "3efef5a28ebdbbe922d4a2049493733ed14475a6",
"version" : "7.3.1"
}
},
{
"identity" : "keychainaccess",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kishikawakatsumi/KeychainAccess.git",
"state" : {
"revision" : "84e546727d66f1adc5439debad16270d0fdd04e7",
"version" : "4.2.2"
}
},
{
"identity" : "nuke",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kean/Nuke.git",
"state" : {
"revision" : "1694798e876113d44f6ec6ead965d7286695981d",
"version" : "12.2.0"
}
},
{
"identity" : "openai",
"kind" : "remoteSourceControl",
"location" : "https://github.com/MacPaw/OpenAI.git",
"state" : {
"branch" : "main",
"revision" : "497266a278de1f32a609981e0012faabcf2091b4"
}
},
{
"identity" : "sparkle",
"kind" : "remoteSourceControl",
"location" : "https://github.com/sparkle-project/Sparkle.git",
"state" : {
"revision" : "47d3d90aee3c52b6f61d04ceae426e607df62347",
"version" : "2.5.2"
}
},
{
"identity" : "swiftui-introspect",
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/swiftui-introspect.git",
"state" : {
"revision" : "9e1cc02a65b22e09a8251261cccbccce02731fc5",
"version" : "1.1.1"
}
},
{
"identity" : "viewcondition",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kevinhermawan/ViewCondition.git",
"state" : {
"revision" : "a3d0aaf943271247dfd4870a2a0696693165c884",
"version" : "1.0.5"
}
},
{
"identity" : "viewstate",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kevinhermawan/ViewState.git",
"state" : {
"revision" : "8e5a5efbbf3fb5a2d2621533a115a9da031214cb",
"version" : "1.2.1"
}
}
],
"version" : 2
}
21 changes: 21 additions & 0 deletions Canvas/App/AppUpdater.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// AppUpdater.swift
// Canvas
//
// Created by Kevin Hermawan on 26/12/23.
//

import Combine
import Sparkle
import SwiftUI

@Observable
final class AppUpdater {
private var cancellable: AnyCancellable?
var canCheckForUpdates = false

init(_ updater: SPUUpdater) {
cancellable = updater.publisher(for: \.canCheckForUpdates)
.assign(to: \.canCheckForUpdates, on: self)
}
}
53 changes: 53 additions & 0 deletions Canvas/App/CanvasApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// CanvasApp.swift
// Canvas
//
// Created by Kevin Hermawan on 25/12/23.
//

import AppInfo
import CoreViewModels
import Sparkle
import SwiftUI

@main
struct CanvasApp: App {
@State private var appUpdater: AppUpdater
private var updater: SPUUpdater

@State private var apiKeyViewModel: APIKeyViewModel
@State private var dalleViewModel: DalleViewModel

init() {
self._apiKeyViewModel = State(initialValue: APIKeyViewModel())
self._dalleViewModel = State(initialValue: DalleViewModel())

let updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
updater = updaterController.updater

let appUpdater = AppUpdater(updater)
_appUpdater = State(initialValue: appUpdater)
}

var body: some Scene {
WindowGroup {
AppView()
.environment(apiKeyViewModel)
.environment(dalleViewModel)
}
.commands {
CommandGroup(after: .appInfo) {
Button("Check for Updates...") {
updater.checkForUpdates()
}
.disabled(appUpdater.canCheckForUpdates == false)
}

CommandGroup(replacing: .help) {
if let helpURL = AppInfo.value(for: "HELP_URL"), let url = URL(string: helpURL) {
Link("Canvas Help", destination: url)
}
}
}
}
}
39 changes: 39 additions & 0 deletions Canvas/Enums/AppSidebar.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// AppSidebar.swift
// Canvas
//
// Created by Kevin Hermawan on 25/12/23.
//

import Foundation

enum AppSidebar: String, CaseIterable {
case dalle
case dalle2

var title: String {
switch self {
case .dalle:
return "DALL·E"
case .dalle2:
return "DALL·E 2"
}
}
}

extension AppSidebar: Identifiable {
var id: String {
self.rawValue
}
}

extension AppSidebar {
var items: [AppSidebarItem] {
switch self {
case .dalle:
return [.imageGeneration]
case .dalle2:
return [.imageEdit, .imageVariation]
}
}
}
42 changes: 42 additions & 0 deletions Canvas/Enums/AppSidebarItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// AppSidebarItem.swift
// Canvas
//
// Created by Kevin Hermawan on 25/12/23.
//

import Foundation

enum AppSidebarItem: String, CaseIterable {
case imageGeneration
case imageEdit
case imageVariation

var title: String {
switch self {
case .imageGeneration:
return "Image Generation"
case .imageEdit:
return "Image Edit"
case .imageVariation:
return "Image Variation"
}
}

var systemImage: String {
switch self {
case .imageGeneration:
return "paintbrush"
case .imageEdit:
return "theatermask.and.paintbrush"
case .imageVariation:
return "paintpalette"
}
}
}

extension AppSidebarItem: Identifiable {
var id: String {
self.rawValue
}
}
25 changes: 25 additions & 0 deletions Canvas/Extensions/Defaults+Keys.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Defaults+Keys.swift
// Canvas
//
// Created by Kevin Hermawan on 25/12/23.
//

import CoreModels
import Defaults
import Foundation

extension Defaults.Keys {
static let ig_selectedModel = Key<DalleModel>("ig_selectedModel", default: .dalle2)
static let ig_selectedNumber = Key<Int>("ig_selectedNumber", default: DalleModel.dalle2.numbers[0])
static let ig_selectedSize = Key<String>("ig_selectedSize", default: DalleModel.dalle2.sizes[0])
static let ig_selectedQuality = Key<DalleModel.Quality?>("ig_selectedQuality", default: .standard)
static let ig_selectedStyle = Key<DalleModel.Style?>("ig_selectedStyle", default: .vivid)

static let ie_selectedNumber = Key<Int>("ie_selectedNumber", default: DalleModel.dalle2.numbers[0])
static let ie_selectedSize = Key<String>("ie_selectedSize", default: DalleModel.dalle2.sizes[0])


static let iv_selectedNumber = Key<Int>("iv_selectedNumber", default: DalleModel.dalle2.numbers[0])
static let iv_selectedSize = Key<String>("iv_selectedSize", default: DalleModel.dalle2.sizes[0])
}
6 changes: 6 additions & 0 deletions Canvas/Preview Content/Preview Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"colors" : [
{
"color" : {
"platform" : "universal",
"reference" : "systemBlueColor"
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e463eab

Please sign in to comment.