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