Skip to content

Commit

Permalink
test 1
Browse files Browse the repository at this point in the history
  • Loading branch information
cranci1 committed May 24, 2024
1 parent 4e89004 commit 92ab60a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
Binary file not shown.
13 changes: 12 additions & 1 deletion AnimeGen/Settings/Developer/waifu-it-pref.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,25 @@ import SwiftUI

struct waifuitView: View {
@State private var waifuittoken: String
@ObservedObject var viewController = ViewController()


init() {
_waifuittoken = State(initialValue: UserDefaults.standard.string(forKey: "waifuItToken") ?? Secrets.waifuItToken)
}

var body: some View {
VStack {

Stepper(value: $viewController.widthMultiplier, in: 0...2, step: 0.1) {
Text("Width Multiplier: \(viewController.widthMultiplier, specifier: "%.2f")")
}
.padding()

Stepper(value: $viewController.heightMultiplier, in: 0...2, step: 0.1) {
Text("Height Multiplier: \(viewController.heightMultiplier, specifier: "%.2f")")
}
.padding()

VStack(spacing: 20) {
TextField("API Token", text: $waifuittoken)
.padding()
Expand Down
32 changes: 29 additions & 3 deletions AnimeGen/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
//

import UIKit
import Combine

class ViewController: UIViewController {
class ViewController: UIViewController, ObservableObject {

var imageHistory: [(UIImage, [String])] = []
var currentPosition: Int = -1
Expand Down Expand Up @@ -187,8 +188,8 @@ class ViewController: UIViewController {
// Image View
imageView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
imageView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: -20),
imageView.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 1),
imageView.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.60),
imageView.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: ViewController.imageViewWidthMultiplier),
imageView.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: ViewController.imageViewHeightMultiplier),

// API button
apiButton.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 5),
Expand Down Expand Up @@ -296,5 +297,30 @@ class ViewController: UIViewController {

apiLoaders[title]?()
}

static var imageViewWidthMultiplier: CGFloat = 1.0 {
didSet {
// Add your handling code here if needed
}
}

static var imageViewHeightMultiplier: CGFloat = 1.0 {
didSet {
// Add your handling code here if needed
}
}

@Published var widthMultiplier: CGFloat = 1.0 {
didSet {
ViewController.imageViewWidthMultiplier = widthMultiplier
}
}

@Published var heightMultiplier: CGFloat = 1.0 {
didSet {
ViewController.imageViewHeightMultiplier = heightMultiplier
}
}

}

0 comments on commit 92ab60a

Please sign in to comment.