无故事王国
2024-03-08 4966eb10cbf5ce9c6ee37a13d393fb0ae2d85b60
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
//
//  AgreentView.swift
//  WanPai
//
//  Created by 杨锴 on 2023/6/7.
//
 
import UIKit
import JQTools
import RxSwift
import WebKit
 
class AgreentView: UIView,JQNibView{
 
                @IBOutlet weak var label_title: UILabel!
                @IBOutlet weak var view_container: UIView!
                //    @IBOutlet weak var webView: WKWebView!
                @IBOutlet weak var bottom_cons: NSLayoutConstraint!
                @IBOutlet weak var label_content: UILabel!
                private var type:AgreentType!
                private var content:String?
                private let disposeBag = DisposeBag()
 
                override func awakeFromNib() {
                                super.awakeFromNib()
                                bottom_cons.constant = -(JQ_ScreenH - JQ_ScreenW * 0.69)
                                layoutIfNeeded()
                }
 
 
                static func show(type:AgreentType,content:String? = nil){
                                let alertView = AgreentView.jq_loadNibView()
                                alertView.frame = sceneDelegate?.window?.frame ?? .zero
                                alertView.type = type
                                alertView.label_title.text = type.titleStr
                                alertView.content = content
                                sceneDelegate?.window?.addSubview(alertView)
                                alertView.bottom_cons.constant = 0
 
                                UIView.animate(withDuration: 0.4) {
                                                alertView.layoutIfNeeded()
                                }
 
                                let attributed = AttributedStringbuilder.build()
 
                                if type != .other && type != .matchStore && type != .useStore && type != .matchPoint{
                                                Services.queryProtocol(type,progress: false).subscribe(onNext: { result in
                                                                if let text = result.data?.jq_wrapHtml(){
                                                                                attributed.add(string: text, withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "727272"), lineSpace: 4)
                                                                }
                                                }).disposed(by: alertView.disposeBag)
                                }else{
                                                attributed.add(string: content!, withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "727272"), lineSpace: 4)
                                }
                                alertView.label_content.attributedText = attributed.mutableAttributedString
                                alertView.label_content.textAlignment = .center
                }
 
 
                override func layoutSubviews() {
                                super.layoutSubviews()
                                view_container.jq_addCorners(corner: [.topLeft,.topRight], radius: 20)
                }
 
                @IBAction func completeAction(_ sender: UIButton) {
                                bottom_cons.constant = -(JQ_ScreenH - JQ_ScreenW * 0.69)
                                UIView.animate(withDuration: 0.4) {
                                                self.layoutIfNeeded()
                                                self.alpha = 0
                                }completion: { _ in
                                                self.removeFromSuperview()
                                }
                }
}