// // SecretsViewController.swift // Guibe // // Created by Max Hunt on 16/06/2019. // Copyright © 2019 8. All rights reserved. // import UIKit class SecretsViewController: UIViewController { let defaults = UserDefaults.standard // @IBOutlet weak var menuView: UIView! @IBOutlet weak var resetCfg: UIButton! @IBOutlet weak var easterEgg: UIButton! @IBOutlet weak var backBtn: UIButton! @IBOutlet weak var DLblSwitch: UISwitch! @IBOutlet weak var label1: UILabel! @IBOutlet weak var label0: UILabel! @IBOutlet var vc: UIView! @IBAction func resetBtnPressed(_ sender: Any) { defaults.set(0, forKey: "setupDone") self.resetCfg.alpha = 0.0 } @IBAction func valueToggled(_ sender: Any) { if self.DLblSwitch.isOn == true { defaults.set(2, forKey: "debug") } else { defaults.set(1, forKey: "debug") } } @IBAction func darkBtnPressed(_ sender: Any) { if UIApplication.shared.supportsAlternateIcons { if let alternateIconName = UIApplication.shared.alternateIconName { print("current icon is \(alternateIconName), change to primary icon") UIApplication.shared.setAlternateIconName(nil) } else { print("current icon is primary icon, change to alternative icon") UIApplication.shared.setAlternateIconName("ad"){ error in if let error = error { print(error.localizedDescription) } else { print("Done!") } } } } } @IBAction func lightBtnPresssed(_ sender: Any) { changeIcon(to: "appLogo-60") } @IBAction func easterBtnPressed(_ sender: Any) { UIView.animate(withDuration: 0.2, animations: {self.view.backgroundColor = .green}) DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) {UIView.animate(withDuration: 0.3, animations:{self.view.backgroundColor = .red})} DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) {UIView.animate(withDuration: 0.3, animations:{self.view.backgroundColor = .blue})} DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) {UIView.animate(withDuration: 0.3, animations:{self.view.backgroundColor = .yellow})} DispatchQueue.main.asyncAfter(deadline: .now() + 1.6) {UIView.animate(withDuration: 0.3, animations:{self.view.backgroundColor = .cyan})} DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {UIView.animate(withDuration: 0.3, animations:{self.view.backgroundColor = .magenta})} DispatchQueue.main.asyncAfter(deadline: .now() + 2.4) {UIView.animate(withDuration: 0.3, animations:{self.view.backgroundColor = .white})} } @IBAction func backBtnPressed(_ sender: Any) { self.dismiss(animated: true, completion: nil) } override func viewDidLoad() { super.viewDidLoad() label1.textColor = UIColor.secondaryLabel label0.textColor = UIColor.secondaryLabel vc.backgroundColor = UIColor.systemBackground let DBVal = defaults.integer(forKey: "debug") if DBVal == 2 { DLblSwitch.isOn = true } else { defaults.set(1, forKey: "debug") DLblSwitch.isOn = false } } func changeIcon(to iconName: String) { // 1 guard UIApplication.shared.supportsAlternateIcons else { return } // 2 UIApplication.shared.setAlternateIconName(iconName, completionHandler: { (error) in // 3 if let error = error { print("App icon failed to change due to \(error.localizedDescription)") } else { print("App icon changed successfully") } }) } // defaults.set(0, forKey: "setupDone") }