Commit b69179bf authored by Steven杜宇's avatar Steven杜宇

// 原则批

parent d7190bc2
...@@ -24,7 +24,7 @@ class YHPrincipleReviewListVC: YHBaseViewController { ...@@ -24,7 +24,7 @@ class YHPrincipleReviewListVC: YHBaseViewController {
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell") tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
tableView.register(YHPrincipleGroupReviewListCell.self, forCellReuseIdentifier: YHPrincipleGroupReviewListCell.cellReuseIdentifier) tableView.register(YHPrincipleGroupReviewListCell.self, forCellReuseIdentifier: YHPrincipleGroupReviewListCell.cellReuseIdentifier)
tableView.register(YHPrincipleGroupUploadCell.self, forCellReuseIdentifier: YHPrincipleGroupUploadCell.cellReuseIdentifier) tableView.register(YHPrincipleGroupUploadCell.self, forCellReuseIdentifier: YHPrincipleGroupUploadCell.cellReuseIdentifier)
tableView.register(YHPrincipleUnapprovedCell.self, forCellReuseIdentifier: YHPrincipleUnapprovedCell.cellReuseIdentifier)
return tableView return tableView
}() }()
...@@ -81,10 +81,12 @@ extension YHPrincipleReviewListVC: UITableViewDelegate, UITableViewDataSource { ...@@ -81,10 +81,12 @@ extension YHPrincipleReviewListVC: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section%2 == 0 { if indexPath.section%3 == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: YHPrincipleGroupUploadCell.cellReuseIdentifier, for: indexPath) as! YHPrincipleGroupUploadCell let cell = tableView.dequeueReusableCell(withIdentifier: YHPrincipleGroupUploadCell.cellReuseIdentifier, for: indexPath) as! YHPrincipleGroupUploadCell
return cell return cell
}
} else if indexPath.section%3 == 1 {
let cell = tableView.dequeueReusableCell(withIdentifier: YHPrincipleGroupReviewListCell.cellReuseIdentifier, for: indexPath) as! YHPrincipleGroupReviewListCell let cell = tableView.dequeueReusableCell(withIdentifier: YHPrincipleGroupReviewListCell.cellReuseIdentifier, for: indexPath) as! YHPrincipleGroupReviewListCell
if 0 <= indexPath.section && indexPath.section < items.count { if 0 <= indexPath.section && indexPath.section < items.count {
...@@ -98,7 +100,21 @@ extension YHPrincipleReviewListVC: UITableViewDelegate, UITableViewDataSource { ...@@ -98,7 +100,21 @@ extension YHPrincipleReviewListVC: UITableViewDelegate, UITableViewDataSource {
self.tableView.reloadData() self.tableView.reloadData()
} }
} }
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: YHPrincipleUnapprovedCell.cellReuseIdentifier, for: indexPath) as! YHPrincipleUnapprovedCell
if 0 <= indexPath.section && indexPath.section < items.count {
let model = items[indexPath.section]
cell.updateModel(model)
cell.expandClick = {
[weak self] isExpand in
guard let self = self else { return }
model.isExpand = isExpand
self.tableView.reloadData()
}
}
return cell return cell
} }
......
...@@ -10,6 +10,8 @@ import UIKit ...@@ -10,6 +10,8 @@ import UIKit
class YHPrincipleUnapprovedItemView: UIView { class YHPrincipleUnapprovedItemView: UIView {
static let viewH: CGFloat = 20.0
lazy var pointView:UIView = { lazy var pointView:UIView = {
let view = UIView() let view = UIView()
view.backgroundColor = UIColor.brandMainColor(alpha: 0.16) view.backgroundColor = UIColor.brandMainColor(alpha: 0.16)
...@@ -74,6 +76,9 @@ class YHPrincipleUnapprovedItemView: UIView { ...@@ -74,6 +76,9 @@ class YHPrincipleUnapprovedItemView: UIView {
class YHPrincipleUnapprovedCell: UITableViewCell { class YHPrincipleUnapprovedCell: UITableViewCell {
static let cellReuseIdentifier = "YHPrincipleUnapprovedCell" static let cellReuseIdentifier = "YHPrincipleUnapprovedCell"
var itemModel:YHPrincleGroupModel?
var items: [String] = []
var expandClick:((Bool)->())?
lazy var titleLabel: UILabel = { lazy var titleLabel: UILabel = {
let label = UILabel() let label = UILabel()
...@@ -107,15 +112,41 @@ class YHPrincipleUnapprovedCell: UITableViewCell { ...@@ -107,15 +112,41 @@ class YHPrincipleUnapprovedCell: UITableViewCell {
lazy var expandBtn:UIButton = { lazy var expandBtn:UIButton = {
let btn = UIButton() let btn = UIButton()
btn.setImage(UIImage(named: "custom_service_expand_0"), for: .normal) btn.setImage(UIImage(named: "custom_service_expand_0"), for: .normal)
btn.addTarget(self, action: #selector(didExpandBtnClicked), for: .touchUpInside)
return btn return btn
}() }()
func updateModel(_ model:YHPrincleGroupModel) { func updateModel(_ model:YHPrincleGroupModel) {
whiteView.removeSubviews() itemModel = model
whiteView.addSubview(self.listTitleLabel) items.removeAll()
items.append(contentsOf: model.fileList)
whiteView.isHidden = !model.isExpand
let imgName = model.isExpand ? "custom_service_expand_1" : "custom_service_expand_0"
expandBtn.setImage(UIImage(named: imgName), for: .normal)
expandBtn.isHidden = items.count <= 0
if !model.isExpand || items.count <= 0 {
whiteView.removeSubviews()
whiteView.snp.remakeConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(0.0)
make.height.equalTo(0.0)
make.left.equalTo(20)
make.right.equalTo(-20)
make.bottom.equalTo(-32)
}
self.setNeedsLayout()
self.layoutIfNeeded()
return
}
whiteView.removeSubviews()
whiteView.addSubview(self.listTitleLabel)
listTitleLabel.snp.remakeConstraints { make in
make.top.equalTo(16)
make.left.equalTo(16)
make.right.equalTo(-16)
}
whiteView.snp.remakeConstraints { make in whiteView.snp.remakeConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(16.0) make.top.equalTo(titleLabel.snp.bottom).offset(16.0)
...@@ -124,6 +155,22 @@ class YHPrincipleUnapprovedCell: UITableViewCell { ...@@ -124,6 +155,22 @@ class YHPrincipleUnapprovedCell: UITableViewCell {
make.bottom.equalTo(-32) make.bottom.equalTo(-32)
} }
var lastItemView: UIView = listTitleLabel
for (index, title) in items.enumerated() {
let itemView = YHPrincipleUnapprovedItemView(frame: .zero)
whiteView.addSubview(itemView)
itemView.snp.makeConstraints { make in
make.left.right.equalTo(0)
make.height.equalTo(YHPrincipleUnapprovedItemView.viewH)
make.top.equalTo(lastItemView.snp.bottom).offset(16.0)
if index == items.count-1 {
make.bottom.equalTo(-16.0)
}
}
lastItemView = itemView
}
self.setNeedsLayout()
self.layoutIfNeeded()
} }
...@@ -137,6 +184,11 @@ class YHPrincipleUnapprovedCell: UITableViewCell { ...@@ -137,6 +184,11 @@ class YHPrincipleUnapprovedCell: UITableViewCell {
setupUI() setupUI()
} }
@objc func didExpandBtnClicked() {
guard let model = itemModel else { return }
expandClick?(!model.isExpand)
}
func setupUI() { func setupUI() {
self.selectionStyle = .none self.selectionStyle = .none
...@@ -156,7 +208,7 @@ class YHPrincipleUnapprovedCell: UITableViewCell { ...@@ -156,7 +208,7 @@ class YHPrincipleUnapprovedCell: UITableViewCell {
make.left.equalTo(iconImgView.snp.right).offset(6) make.left.equalTo(iconImgView.snp.right).offset(6)
make.right.equalTo(expandBtn.snp.left) make.right.equalTo(expandBtn.snp.left)
make.top.equalTo(0) make.top.equalTo(0)
make.height.equalTo(22) make.height.equalTo(20)
} }
expandBtn.snp.makeConstraints { make in expandBtn.snp.makeConstraints { make in
......
...@@ -280,12 +280,11 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource { ...@@ -280,12 +280,11 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource {
return return
} }
if true { // if true {
// YHPrincipleReviewListVC // let vc = YHPrincipleReviewListVC()
let vc = YHPrincipleReviewListVC() // self.navigationController?.pushViewController(vc)
self.navigationController?.pushViewController(vc) // return
return // }
}
let item: PersonalModuleItem = items[indexPath.row] let item: PersonalModuleItem = items[indexPath.row]
switch item.type { switch item.type {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment