Wallpaper_Home/wallpaper_project/Mine/C/WA_SettingSVC.swift
忆海16 5ff1070967 mtg
2024-07-23 11:44:01 +08:00

162 lines
4.7 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// WA_SettingSVC.swift
// wallpaper_project
import UIKit
import SVProgressHUD
class WA_SettingSVC: WA_RootVC {
@IBOutlet weak var btnstar: UIButton!
@IBOutlet weak var bgView: UIView!
var overlayWindow: UIWindow?
var tapCount = 0
var timer: Timer?
override func viewDidLoad() {
super.viewDidLoad()
bgView.layer.cornerRadius = 10
bgView.clipsToBounds = true
let hasLaunchedBefore = UserDefaults.standard.bool(forKey: "star")
if !hasLaunchedBefore {
// UserDefaults
self.btnstar.isSelected = false
UserDefaults.standard.set(false, forKey: "star")
}else{
self.btnstar.isSelected = true
UserDefaults.standard.set(true, forKey: "star")
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.isHidden = true
if let currentAccount = AccountManager.currentAccount {
print("当前登录的账户是:\(currentAccount.username)")
} else {
print("没有登录的账户")
}
}
@IBAction func starBtn(_ sender: UIButton) {
let hasLaunchedBefore = UserDefaults.standard.bool(forKey: "star")
if hasLaunchedBefore == true{
self.btnstar.isSelected = false
UserDefaults.standard.set(false, forKey: "star")
}else{
self.btnstar.isSelected = true
UserDefaults.standard.set(true, forKey: "star")
}
}
@IBAction func back(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
@IBAction func privacyBtn(_ sender: Any) {
let vc = WA_PrivacyVC()
vc.type = 0
self.present(vc, animated: true)
}
@IBAction func scBtn(_ sender: Any) {
if isLoggedIn(){
let vc = WA_SCVC()
self.navigationController?.pushViewController(vc, animated: true)
}else{
let vc = WA_LoginVC()
self.navigationController?.pushViewController(vc, animated: true)
}
}
@IBAction func btnLoginCancel(_ sender: UIButton) {
if isLoggedIn(){
// UIAlertController
let alertController = UIAlertController(title: "prompt", message: "Are you sure you want to Delete your account?", preferredStyle: .alert)
let confirmAction = UIAlertAction(title: "sure", style: .default) { (_) in
let currentAccount = AccountManager.currentAccount
let loggedInUsername = currentAccount!.username
AccountManager.logoutSpecificAccount(username: loggedInUsername)
setLoggedIn(false)
}
confirmAction.setValue(UIColor.red, forKey: "titleTextColor")
alertController.addAction(confirmAction)
let secondAction = UIAlertAction(title: "cancle", style: .default) { (_) in
}
alertController.addAction(secondAction)
self.present(alertController, animated: true, completion: nil)
}else{
let vc = WA_LoginVC()
self.navigationController?.pushViewController(vc, animated: true)
}
}
@IBAction func browseBtn(_ sender: Any) {
let vc = WA_HistoryVC()
navigationController?.pushViewController(vc, animated: true)
}
@IBAction func touchv(_ sender: Any) {
//
tapCount += 1
//
if timer == nil {
timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(resetTapCount), userInfo: nil, repeats: false)
}
//
if tapCount == 6 {
//
print("连点6下")
let appDelegate = UIApplication.shared.delegate
appDelegate?.window??.rootViewController = WA_RootNAV(rootViewController: WA_playerVC())
// UserDefaults.standard.set(true, forKey: "iswindows")
UserDefaults.standard.set(true, forKey: "iswindows")
resetTapCount()
}
}
@objc func resetTapCount() {
//
tapCount = 0
timer?.invalidate()
timer = nil
}
}