//
|
// UpdateVersionView.swift
|
// XQMuse
|
//
|
// Created by 无故事王国 on 2025/2/8.
|
//
|
|
import UIKit
|
import JQTools
|
|
class UpdateVersionView: UIView,JQNibView{
|
|
@IBOutlet weak var view_content: UIView!
|
@IBOutlet weak var label_content: UILabel!
|
|
@IBOutlet weak var btn_update: UIButton!
|
@IBOutlet weak var btn_last: UIButton!
|
|
private var model:VersionResultModel?
|
|
override func awakeFromNib() {
|
super.awakeFromNib()
|
view_content.transform = .init(scaleX: 0.1, y: 0.1)
|
alpha = 0
|
}
|
|
static func show(model:VersionResultModel){
|
let updateVersionView = UpdateVersionView.jq_loadNibView()
|
updateVersionView.frame = sceneDelegate?.window?.frame ?? .zero
|
updateVersionView.model = model
|
sceneDelegate?.window?.addSubview(updateVersionView)
|
updateVersionView.label_content.attributedText = AttributedStringbuilder.build().add(string: model.releaseNotes, withFont: .systemFont(ofSize: 14, weight: .medium), withColor: .black.withAlphaComponent(0.8), lineSpace: 5).mutableAttributedString
|
|
UIView.animate(withDuration: 0.5) {
|
updateVersionView.view_content.transform = .init(scaleX: 1.0, y: 1.0)
|
updateVersionView.alpha = 1
|
} completion: { _ in
|
|
}
|
}
|
|
override func layoutSubviews() {
|
super.layoutSubviews()
|
view_content.jq_cornerRadius = 10
|
btn_last.jq_cornerRadius = 20
|
|
btn_last.jq_borderWidth = 1
|
btn_last.jq_borderColor = UIColor(hexString: "#8EA47A")
|
|
btn_update.jq_gradientNibColor(colorArr: [UIColor(hexStr: "#8EA47A").cgColor,UIColor(hexStr: "#AFCA98").cgColor], cornerRadius: 20)
|
}
|
|
@IBAction func lastAction(_ sender: UIButton) {
|
UIView.animate(withDuration: 0.5) {
|
self.view_content.transform = .init(scaleX: 0.1, y: 0.1)
|
self.alpha = 0
|
} completion: { _ in
|
self.removeFromSuperview()
|
}
|
UserDefaults.standard.set(model?.version, forKey: "ignoreVersion")
|
UserDefaults.standard.synchronize()
|
}
|
|
@IBAction func updateNowAction(_ sender: UIButton) {
|
if let u = model?.trackViewUrl{
|
UIApplication.shared.open(URL(string: u)!)
|
}
|
UIView.animate(withDuration: 0.5) {
|
self.view_content.transform = .init(scaleX: 0.1, y: 0.1)
|
self.alpha = 0
|
} completion: { _ in
|
self.removeFromSuperview()
|
}
|
}
|
}
|