无故事王国
2023-10-30 43574ebb55e06a2213d3097745f82968efc43b32
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
//
//  CommonWebVC.swift
//  WanPai
//
//  Created by 无故事王国 on 2023/9/11.
//
 
import UIKit
import WebKit
 
class CommonWebVC: BaseVC {
 
    private var type:AgreentType!
    private var content:String!
    @IBOutlet weak var webView: WKWebView!
 
    init(type:AgreentType,content:String? = nil) {
        super.init(nibName: nil, bundle: nil)
        self.type = type
        self.content = content
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        if type != .other{
            title = type.titleStr
            Services.queryProtocol(type,progress: false).subscribe(onNext: {[weak self] result in
                if let text = result.data?.jq_wrapHtml(){
                    self?.webView.loadHTMLString(text, baseURL: nil)
                }
            }).disposed(by: disposeBag)
        }else{
            webView.loadHTMLString(content?.jq_wrapHtml() ?? "", baseURL: nil)
        }
    }
 
    @IBAction func readAction(_ sender: UIButton) {
        UserDefaults.standard.set(object: true, forKey: type.titleStr)
        UserDefaults.standard.synchronize()
        navigationController?.popViewController()
    }
 
    override var preferredStatusBarStyle: UIStatusBarStyle{
        return .darkContent
    }
 
    override var shouldAutorotate: Bool{
        return false
    }
}