fix
杨锴
2025-02-18 c5e51c0ec3cbf1016f3bfbd58b0f0a004aaa9900
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
//  TreeTeskFirstRuleView.swift
//  XQMuse
//
//  Created by 无故事王国 on 2024/9/11.
//
 
import UIKit
import JQTools
 
class TreeTeskFirstRuleView: UIView,JQNibView{
 
                @IBOutlet weak var label_title: UILabel!
                @IBOutlet weak var view_container: UIView!
                @IBOutlet weak var label_content: UILabel!
                @IBOutlet weak var btn_complete: UIButton!
//                @IBOutlet weak var cons_hei: NSLayoutConstraint!
                @IBOutlet weak var cons_textTop: NSLayoutConstraint!
                private var settingModel = UserDefaultSettingViewModel.getSetting()
    private var clickClouse:(()->Void)?
 
                override func awakeFromNib() {
                                super.awakeFromNib()
                                alpha = 0
                                view_container.transform = .init(scaleX: 0.1, y: 0.1)
 
                                layoutIfNeeded()
                                view_container.jq_cornerRadius = 14
                }
 
    @discardableResult
    static func show(title:String,content:String,textAlignment:NSTextAlignment,height:Double,textTopOffset:Double,clickClouse: (()->Void)? = nil)->TreeTeskFirstRuleView{
                                let ruleView = TreeTeskFirstRuleView.jq_loadNibView()
                                ruleView.frame = sceneDelegate?.window?.frame ?? .zero
        ruleView.clickClouse = clickClouse
 
                                ruleView.label_title.text = title
                                ruleView.label_content.attributedText = AttributedStringbuilder.build().add(string:content, withFont: .systemFont(ofSize: 14), withColor: .black.withAlphaComponent(0.59), lineSpace: 7).mutableAttributedString
                                ruleView.label_content.textAlignment = textAlignment
//                                ruleView.cons_hei.constant = height
                                ruleView.cons_textTop.constant = textTopOffset
 
                                sceneDelegate?.window?.addSubview(ruleView)
 
                                UIView.animate(withDuration: 0.6) {
                                                ruleView.alpha = 1.0
                                                ruleView.view_container.transform = .init(scaleX: 1.0, y: 1.0)
                                }
        return ruleView
                }
 
                @IBAction func completeAction(_ sender: UIButton) {
                                UIView.animate(withDuration: 0.3) {
                                                self.alpha = 0
                                                self.view_container.transform = .init(scaleX: 0.1, y: 0.1)
                                } completion: { _ in
                                                self.removeFromSuperview()
                                                self.settingModel?.userFirstOpenTreeTask = false
                                                UserDefaultSettingViewModel.saveSetting(self.settingModel!)
                                }
        clickClouse?()
                }
 
    func setEnableBtn(state:Bool){
        btn_complete.isEnabled = state
        if state{
            btn_complete.localGradientColor(cornerRadius: 20,bounds: CGRect(x: 0, y: 0, width: JQ_ScreenW - 85 * 2, height: 40))
        }else{
            btn_complete.jq_gradientColor(colorArr: [UIColor(hexString: "#CDCDCD")!.cgColor,UIColor(hexString: "#CDCDCD")!.cgColor], cornerRadius: 20, startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 1, y: 0), bounds: CGRect(x: 0, y: 0, width: JQ_ScreenW - 85 * 2, height: 40),clear: true)
        }
 
    }
 
//                override func layoutSubviews() {
//                                super.layoutSubviews()
        /*btn_complete.localGradientColor(cornerRadius: 20,bounds: CGRect(x: 0, y: 0, width: JQ_ScreenW - 85 * 2, height: 40))*/
//                }
}