younger_times
2023-06-13 47bc190ccc89050b2a15cc1a8fc4818ba440844d
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
79
80
81
82
83
84
85
86
87
88
89
90
//
//  StudentChooseView.swift
//  WanPai
//
//  Created by 杨锴 on 2023/6/12.
//
 
import UIKit
import JQTools
import QMUIKit
 
class StudentChooseView: UIView,JQNibView{
 
    @IBOutlet weak var tableView: UITableView!
    @IBOutlet weak var view_container: UIView!
    @IBOutlet weak var cons_bottom: NSLayoutConstraint!
    @IBOutlet weak var btn_add: QMUIButton!
    
    private var clickClouse:(()->Void)!
    private var needAddClouse:(()->Void)!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        btn_add.imagePosition = .right
        btn_add.spacingBetweenImageAndTitle = 5
        cons_bottom.constant = -(JQ_ScreenW * 1.1)
        tableView.delegate = self
        tableView.dataSource = self
        tableView.separatorStyle = .none
        tableView.register(UINib(nibName: "StudentInfoTCell", bundle: nil), forCellReuseIdentifier: "_StudentInfoTCell")
        alpha = 0
        layoutIfNeeded()
    }
    
    static func show(clickClouse:@escaping ()->Void,needAddClouse:@escaping ()->Void){
        let studentChooseView = StudentChooseView.jq_loadNibView()
        studentChooseView.frame = screnDelegate?.window?.frame ?? .zero
        studentChooseView.clickClouse = clickClouse
        studentChooseView.needAddClouse = needAddClouse
        screnDelegate?.window?.addSubview(studentChooseView)
        
        studentChooseView.cons_bottom.constant = 0
        
        UIView.animate(withDuration: 0.4) {
            studentChooseView.alpha = 1
            studentChooseView.layoutIfNeeded()
        }
    }
    
    
    @IBAction func addNewStudentAction(_ sender: QMUIButton) {
        needAddClouse()
    }
    
    
    override func layoutSubviews() {
        super.layoutSubviews()
        DispatchQueue.main.asyncAfter(wallDeadline: .now()+0.1) {
            self.view_container.jq_addCorners(corner: [.topLeft,.topRight], radius: 20)
        }
    }
    
    @IBAction func completeAction(_ sender: UIButton) {
        
    
        self.cons_bottom.constant = -(JQ_ScreenW * 1.1)
        UIView.animate(withDuration: 0.4) {
            self.alpha = 0
        } completion: { _ in
            self.removeFromSuperview()
            self.clickClouse()
        }
    }
}
 
extension StudentChooseView:UITableViewDelegate{
    
}
 
extension StudentChooseView:UITableViewDataSource{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 5
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "_StudentInfoTCell") as! StudentInfoTCell
        return cell
    }
}