//
|
// 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()
|
}
|
}
|
}
|