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

// 原则批

parent d7190bc2
......@@ -24,7 +24,7 @@ class YHPrincipleReviewListVC: YHBaseViewController {
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
tableView.register(YHPrincipleGroupReviewListCell.self, forCellReuseIdentifier: YHPrincipleGroupReviewListCell.cellReuseIdentifier)
tableView.register(YHPrincipleGroupUploadCell.self, forCellReuseIdentifier: YHPrincipleGroupUploadCell.cellReuseIdentifier)
tableView.register(YHPrincipleUnapprovedCell.self, forCellReuseIdentifier: YHPrincipleUnapprovedCell.cellReuseIdentifier)
return tableView
}()
......@@ -81,24 +81,40 @@ extension YHPrincipleReviewListVC: UITableViewDelegate, UITableViewDataSource {
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
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: YHPrincipleGroupReviewListCell.cellReuseIdentifier, for: indexPath) as! YHPrincipleGroupReviewListCell
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()
} else if indexPath.section%3 == 1 {
let cell = tableView.dequeueReusableCell(withIdentifier: YHPrincipleGroupReviewListCell.cellReuseIdentifier, for: indexPath) as! YHPrincipleGroupReviewListCell
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
}
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
}
......
......@@ -10,6 +10,8 @@ import UIKit
class YHPrincipleUnapprovedItemView: UIView {
static let viewH: CGFloat = 20.0
lazy var pointView:UIView = {
let view = UIView()
view.backgroundColor = UIColor.brandMainColor(alpha: 0.16)
......@@ -74,6 +76,9 @@ class YHPrincipleUnapprovedItemView: UIView {
class YHPrincipleUnapprovedCell: UITableViewCell {
static let cellReuseIdentifier = "YHPrincipleUnapprovedCell"
var itemModel:YHPrincleGroupModel?
var items: [String] = []
var expandClick:((Bool)->())?
lazy var titleLabel: UILabel = {
let label = UILabel()
......@@ -107,16 +112,42 @@ class YHPrincipleUnapprovedCell: UITableViewCell {
lazy var expandBtn:UIButton = {
let btn = UIButton()
btn.setImage(UIImage(named: "custom_service_expand_0"), for: .normal)
btn.addTarget(self, action: #selector(didExpandBtnClicked), for: .touchUpInside)
return btn
}()
func updateModel(_ model:YHPrincleGroupModel) {
itemModel = model
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
make.top.equalTo(titleLabel.snp.bottom).offset(16.0)
make.left.equalTo(20)
......@@ -124,6 +155,22 @@ class YHPrincipleUnapprovedCell: UITableViewCell {
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 {
setupUI()
}
@objc func didExpandBtnClicked() {
guard let model = itemModel else { return }
expandClick?(!model.isExpand)
}
func setupUI() {
self.selectionStyle = .none
......@@ -156,7 +208,7 @@ class YHPrincipleUnapprovedCell: UITableViewCell {
make.left.equalTo(iconImgView.snp.right).offset(6)
make.right.equalTo(expandBtn.snp.left)
make.top.equalTo(0)
make.height.equalTo(22)
make.height.equalTo(20)
}
expandBtn.snp.makeConstraints { make in
......
......@@ -280,12 +280,11 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource {
return
}
if true {
// YHPrincipleReviewListVC
let vc = YHPrincipleReviewListVC()
self.navigationController?.pushViewController(vc)
return
}
// if true {
// let vc = YHPrincipleReviewListVC()
// self.navigationController?.pushViewController(vc)
// return
// }
let item: PersonalModuleItem = items[indexPath.row]
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