Commit 79d8b2a9 authored by Steven杜宇's avatar Steven杜宇

// 提示语UI

parent c1b819ce
...@@ -296,7 +296,22 @@ extension YHFamilyMemberInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -296,7 +296,22 @@ extension YHFamilyMemberInfoVC : UITableViewDelegate, UITableViewDataSource {
let detailItem = item as! YHFamilyMember let detailItem = item as! YHFamilyMember
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemEnterDetailCell.cellReuseIdentifier, for: indexPath) as! YHFormItemEnterDetailCell let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemEnterDetailCell.cellReuseIdentifier, for: indexPath) as! YHFormItemEnterDetailCell
cell.title = detailItem.getTitle() cell.title = detailItem.getTitle()
if detailItem.notFillNum > 0 {
cell.detailLabel.text = String(format: "有%d项未填写".local, detailItem.notFillNum) cell.detailLabel.text = String(format: "有%d项未填写".local, detailItem.notFillNum)
} else {
cell.detailLabel.text = "已填完".local
}
if detailItem.relationType == .child || detailItem.relationType == .brother {
if detailItem.subsetName == nil || detailItem.subsetName == "" { // 姓名为空
if detailItem.relationType == .child {
cell.title = String(format: "子女%d".local, indexPath.row)
} else if detailItem.relationType == .brother {
cell.title = String(format: "兄弟姐妹%d".local, indexPath.row)
}
} else {
cell.title = detailItem.subsetName
}
}
cell.isShowDeleteBtn = false cell.isShowDeleteBtn = false
cell.deleteBlock = nil cell.deleteBlock = nil
if detailItem.relationType == .child || detailItem.relationType == .brother { if detailItem.relationType == .child || detailItem.relationType == .brother {
...@@ -318,7 +333,11 @@ extension YHFamilyMemberInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -318,7 +333,11 @@ extension YHFamilyMemberInfoVC : UITableViewDelegate, UITableViewDataSource {
// 因为子女兄妹section第一行都是标题所以row-1 // 因为子女兄妹section第一行都是标题所以row-1
if (indexPath.row-1 >= childCount) { return } if (indexPath.row-1 >= childCount) { return }
guard let child = self.familyMemberInfo?.child?[indexPath.row-1] else { return } guard let child = self.familyMemberInfo?.child?[indexPath.row-1] else { return }
let msg = String(format: "确定要删除子女%d(%@)吗?".local, indexPath.row, "XXX") var name = String(format: "子女%d", indexPath.row)
if let subsetName = detailItem.subsetName, !subsetName.isEmpty {
name += "(\(subsetName))"
}
let msg = String(format: "确定要删除%@吗?".local, name)
YHTwoOptionAlertView.showAlertView(message:msg) { sure in YHTwoOptionAlertView.showAlertView(message:msg) { sure in
...@@ -340,7 +359,12 @@ extension YHFamilyMemberInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -340,7 +359,12 @@ extension YHFamilyMemberInfoVC : UITableViewDelegate, UITableViewDataSource {
// 因为子女兄妹section第一行都是标题所以row-1 // 因为子女兄妹section第一行都是标题所以row-1
if (indexPath.row-1 >= brotherCount) { return } if (indexPath.row-1 >= brotherCount) { return }
guard let brother = self.familyMemberInfo?.brother?[indexPath.row-1] else { return } guard let brother = self.familyMemberInfo?.brother?[indexPath.row-1] else { return }
let msg = String(format: "确定要删除兄弟%d(%@)吗?".local, indexPath.row, "XXX") var name = String(format: "兄弟姐妹%d", indexPath.row)
if let subsetName = detailItem.subsetName, !subsetName.isEmpty {
name += "(\(subsetName))"
}
let msg = String(format: "确定要删除%@吗?".local, name)
YHTwoOptionAlertView.showAlertView(message: msg) { sure in YHTwoOptionAlertView.showAlertView(message: msg) { sure in
if !sure { return } if !sure { return }
......
...@@ -96,12 +96,14 @@ class YHSpousePrimaryInfoVC: YHBaseViewController { ...@@ -96,12 +96,14 @@ class YHSpousePrimaryInfoVC: YHBaseViewController {
item22.value = area.joined(separator: "/") item22.value = area.joined(separator: "/")
} }
item22.placeHolder = "请选择城市".local item22.placeHolder = "请选择城市".local
item22.tips = "请选择城市".local
arr2.append(item22) arr2.append(item22)
} }
let item23 = YHFormDetailItem(type: .detailAddress) let item23 = YHFormDetailItem(type: .detailAddress)
item23.value = address.details item23.value = address.details
item23.placeHolder = (isLiveInChina ? "请填写小区、楼栋、单元室等".local : "请填写国外居住地".local) item23.placeHolder = (isLiveInChina ? "请填写小区、楼栋、单元室等".local : "请填写国外居住地".local)
item23.tips = "请填写详细地址".local
arr2.append(item23) arr2.append(item23)
if !isLiveInChina {// 在国外 if !isLiveInChina {// 在国外
...@@ -239,11 +241,18 @@ extension YHSpousePrimaryInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -239,11 +241,18 @@ extension YHSpousePrimaryInfoVC : UITableViewDelegate, UITableViewDataSource {
cell.title = detailItem.getTitle() cell.title = detailItem.getTitle()
cell.text = detailItem.value cell.text = detailItem.value
cell.placeHolder = detailItem.placeHolder cell.placeHolder = detailItem.placeHolder
cell.setTips(detailItem.tips, isShow:detailItem.isShowTips)
cell.isShowLine = indexPath.row != arr.count-1
cell.textChange = { cell.textChange = {
[weak self] (text, isEditEnd) in [weak self] (text, isEditEnd) in
guard let self = self else { return } guard let self = self else { return }
self.spouse?.address?.details = text self.spouse?.address?.details = text
if isEditEnd {
self.loadSponseInfo()
if let delegate = delegate {
delegate.saveInfo?()
}
}
} }
return cell return cell
} }
...@@ -277,18 +286,18 @@ extension YHSpousePrimaryInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -277,18 +286,18 @@ extension YHSpousePrimaryInfoVC : UITableViewDelegate, UITableViewDataSource {
if item is YHFormTitleItem { // 标题 if item is YHFormTitleItem { // 标题
return 52.0 return 52.0
} }
if item is YHFormDetailItem {
let detailItem = item as! YHFormDetailItem
if detailItem.type == .isLiveTother ||
detailItem.type == .isAccompanyToHK ||
detailItem.type == .isHandleHKPassPort ||
detailItem.type == .isLiveOverSeasMore1Year
{
return UITableView.automaticDimension return UITableView.automaticDimension
} // if item is YHFormDetailItem {
} // let detailItem = item as! YHFormDetailItem
return 52.0 // if detailItem.type == .isLiveTother ||
// detailItem.type == .isAccompanyToHK ||
// detailItem.type == .isHandleHKPassPort ||
// detailItem.type == .isLiveOverSeasMore1Year
// {
// return UITableView.automaticDimension
// }
// }
// return 52.0
} }
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
......
...@@ -329,6 +329,15 @@ class YHFormDetailItem : YHFormItemProtocol { ...@@ -329,6 +329,15 @@ class YHFormDetailItem : YHFormItemProtocol {
var value: String? var value: String?
var placeHolder: String? var placeHolder: String?
var tips:String?
// 是否需要展示Tips
var isShowTips:Bool {
if let value = value, !value.isEmpty {
return false
}
return true
}
init(type: YHFormDetailItemType, isNeed:Bool = true) { init(type: YHFormDetailItemType, isNeed:Bool = true) {
self.type = type self.type = type
...@@ -557,7 +566,7 @@ class YHFamilyMember: SmartCodable, YHFormItemProtocol { ...@@ -557,7 +566,7 @@ class YHFamilyMember: SmartCodable, YHFormItemProtocol {
var notFillNum: Int = 0 var notFillNum: Int = 0
// 是否在海外居住满1年及以上 // 是否在海外居住满1年及以上
var isLiveOverseaYear: Int = 0 var isLiveOverseaYear: Int = 0
// 婚前刑事 // 婚前姓氏
var surname: String? var surname: String?
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
......
...@@ -24,6 +24,7 @@ class YHFormChoiceItem { ...@@ -24,6 +24,7 @@ class YHFormChoiceItem {
class YHFormItemDoubleChoiceCell: UITableViewCell { class YHFormItemDoubleChoiceCell: UITableViewCell {
static let cellReuseIdentifier = "YHFormItemDoubleChoiceCell" static let cellReuseIdentifier = "YHFormItemDoubleChoiceCell"
let horizonalGap = 18.0
private let btnWidth = 70.0 private let btnWidth = 70.0
private let btnHeight = 32.0 private let btnHeight = 32.0
...@@ -80,11 +81,11 @@ class YHFormItemDoubleChoiceCell: UITableViewCell { ...@@ -80,11 +81,11 @@ class YHFormItemDoubleChoiceCell: UITableViewCell {
} }
} }
// 更新答案按钮选中状态 // 是否展示分割线
private func updateAnswerButton(_ btn:UIButton, _ isSelect:Bool) { var isShowLine:Bool = false {
btn.layer.borderColor = (isSelect ? btnTitleSelectColor : .clear).cgColor didSet {
btn.setTitleColor((isSelect ? btnTitleSelectColor : btnTitleDefaultColor), for: .normal) bottomLine.isHidden = !isShowLine
btn.backgroundColor = (isSelect ? btnBgSelectColor : btnBgDefaultColor) }
} }
private lazy var titleLabel: UILabel = { private lazy var titleLabel: UILabel = {
...@@ -128,6 +129,23 @@ class YHFormItemDoubleChoiceCell: UITableViewCell { ...@@ -128,6 +129,23 @@ class YHFormItemDoubleChoiceCell: UITableViewCell {
return btn return btn
}() }()
private lazy var tipsLabel: UILabel = {
let label = UILabel()
label.textColor = .failColor
label.textAlignment = .left
label.numberOfLines = 0
label.font = UIFont.PFSC_R(ofSize: 12)
label.isHidden = true
return label
}()
private lazy var bottomLine:UIView = {
let view = UIView()
view.backgroundColor = .separatorColor
view.isHidden = true
return view
}()
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
...@@ -145,12 +163,21 @@ class YHFormItemDoubleChoiceCell: UITableViewCell { ...@@ -145,12 +163,21 @@ class YHFormItemDoubleChoiceCell: UITableViewCell {
contentView.addSubview(titleLabel) contentView.addSubview(titleLabel)
contentView.addSubview(answer2Btn) contentView.addSubview(answer2Btn)
contentView.addSubview(answer1Btn) contentView.addSubview(answer1Btn)
contentView.addSubview(tipsLabel)
contentView.addSubview(bottomLine)
titleLabel.snp.makeConstraints { make in titleLabel.snp.makeConstraints { make in
make.top.equalTo(contentView.snp.top).offset(22) make.top.equalTo(contentView.snp.top).offset(16)
make.left.equalToSuperview().offset(16) make.left.equalToSuperview().offset(horizonalGap)
make.height.greaterThanOrEqualTo(btnHeight)
make.right.equalTo(answer1Btn.snp.left).offset(-8) make.right.equalTo(answer1Btn.snp.left).offset(-8)
make.bottom.equalTo(contentView.snp.bottom).offset(-22)
}
answer1Btn.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: btnWidth, height: btnHeight))
make.right.equalTo(answer2Btn.snp.left).offset(-8)
make.top.equalTo(answer2Btn)
} }
answer2Btn.snp.makeConstraints { make in answer2Btn.snp.makeConstraints { make in
...@@ -159,13 +186,43 @@ class YHFormItemDoubleChoiceCell: UITableViewCell { ...@@ -159,13 +186,43 @@ class YHFormItemDoubleChoiceCell: UITableViewCell {
make.top.equalToSuperview().offset(16) make.top.equalToSuperview().offset(16)
} }
answer1Btn.snp.makeConstraints { make in bottomLine.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: btnWidth, height: btnHeight)) make.left.equalToSuperview().offset(horizonalGap)
make.right.equalTo(answer2Btn.snp.left).offset(-8) make.right.equalToSuperview().offset(-horizonalGap)
make.top.equalTo(answer2Btn) make.height.equalTo(1.0)
make.bottom.equalToSuperview()
} }
setTips("", isShow: false)
} }
func setTips(_ tips:String?, isShow:Bool) {
tipsLabel.text = tips
tipsLabel.isHidden = !isShow
if isShow {
tipsLabel.snp.remakeConstraints { make in
make.left.equalToSuperview().offset(horizonalGap)
make.right.equalToSuperview().offset(-horizonalGap)
make.top.equalTo(titleLabel.snp.bottom)
make.bottom.equalToSuperview().offset(-16)
}
} else {
tipsLabel.snp.remakeConstraints { make in
make.left.equalToSuperview().offset(horizonalGap)
make.right.equalToSuperview().offset(-horizonalGap)
make.top.equalTo(titleLabel.snp.bottom)
make.height.equalTo(0)
make.bottom.equalToSuperview().offset(-16)
}
}
}
// 更新答案按钮选中状态
private func updateAnswerButton(_ btn:UIButton, _ isSelect:Bool) {
btn.layer.borderColor = (isSelect ? btnTitleSelectColor : .clear).cgColor
btn.setTitleColor((isSelect ? btnTitleSelectColor : btnTitleDefaultColor), for: .normal)
btn.backgroundColor = (isSelect ? btnBgSelectColor : btnBgDefaultColor)
}
@objc func didClickResponseBtn(btn: UIButton) { @objc func didClickResponseBtn(btn: UIButton) {
......
...@@ -11,9 +11,14 @@ import UIKit ...@@ -11,9 +11,14 @@ import UIKit
class YHFormItemExpireDateCell: UITableViewCell { class YHFormItemExpireDateCell: UITableViewCell {
static let cellReuseIdentifier = "YHFormItemExpireDateCell" static let cellReuseIdentifier = "YHFormItemExpireDateCell"
private let horizonalGap = 18.0
private let detailColor = UIColor.mainTextColor
private let placeHolderColor = UIColor.placeHolderColor
let longTimeBtnWidth = 40.0 let longTimeBtnWidth = 40.0
// 是否必填 如必填title会展示红色* // 是否必填 如必填title会展示红色*
var isMust = false var isMust = false
var placeHolder:String? = "请选择"
var clickBlock:(()->Void)? var clickBlock:(()->Void)?
...@@ -43,27 +48,19 @@ class YHFormItemExpireDateCell: UITableViewCell { ...@@ -43,27 +48,19 @@ class YHFormItemExpireDateCell: UITableViewCell {
} }
} }
var tips:String? {
didSet {
tipsLabel.text = tips
}
}
var detail:String? { var detail:String? {
didSet { didSet {
detailLabel.text = detail
if let detail = detail, !detail.isEmpty { if let detail = detail, !detail.isEmpty {
tipsLabel.isHidden = true detailLabel.text = detail
detailLabel.isHidden = false detailLabel.textColor = detailColor
} else { } else {
tipsLabel.isHidden = false detailLabel.text = placeHolder
detailLabel.isHidden = true detailLabel.textColor = placeHolderColor
} }
} }
} }
lazy var titleLabel: UILabel = { lazy var titleLabel: UILabel = {
let label = UILabel() let label = UILabel()
label.textColor = UIColor(hexString:"#333333") label.textColor = UIColor(hexString:"#333333")
...@@ -78,19 +75,9 @@ class YHFormItemExpireDateCell: UITableViewCell { ...@@ -78,19 +75,9 @@ class YHFormItemExpireDateCell: UITableViewCell {
label.textColor = UIColor(hexString: "#222222") label.textColor = UIColor(hexString: "#222222")
label.textAlignment = .left label.textAlignment = .left
label.font = UIFont.PFSC_R(ofSize: 14) label.font = UIFont.PFSC_R(ofSize: 14)
label.isHidden = true
return label return label
}() }()
private lazy var tipsLabel: UILabel = {
let label = UILabel()
label.textColor = UIColor(hexString: "#C0C0C0")
label.text = "请选择".local
label.textAlignment = .left
label.font = UIFont.PFSC_R(ofSize: 14)
label.isHidden = false
return label
}()
lazy var longTimeBtn: UIButton = { lazy var longTimeBtn: UIButton = {
let btn = UIButton(type: .custom) let btn = UIButton(type: .custom)
...@@ -104,6 +91,23 @@ class YHFormItemExpireDateCell: UITableViewCell { ...@@ -104,6 +91,23 @@ class YHFormItemExpireDateCell: UITableViewCell {
return btn return btn
}() }()
private lazy var tipsLabel: UILabel = {
let label = UILabel()
label.textColor = .failColor
label.textAlignment = .left
label.numberOfLines = 0
label.font = UIFont.PFSC_R(ofSize: 12)
label.isHidden = true
return label
}()
private lazy var bottomLine:UIView = {
let view = UIView()
view.backgroundColor = .separatorColor
view.isHidden = true
return view
}()
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
} }
...@@ -116,30 +120,60 @@ class YHFormItemExpireDateCell: UITableViewCell { ...@@ -116,30 +120,60 @@ class YHFormItemExpireDateCell: UITableViewCell {
func setupUI() { func setupUI() {
self.selectionStyle = .none self.selectionStyle = .none
detail = ""
contentView.addSubview(titleLabel) contentView.addSubview(titleLabel)
contentView.addSubview(detailLabel) contentView.addSubview(detailLabel)
contentView.addSubview(tipsLabel)
contentView.addSubview(longTimeBtn) contentView.addSubview(longTimeBtn)
contentView.addSubview(tipsLabel)
contentView.addSubview(bottomLine)
titleLabel.snp.makeConstraints { make in titleLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(16) make.left.equalToSuperview().offset(horizonalGap)
make.right.equalTo(detailLabel.snp.left).offset(-6) make.right.equalTo(detailLabel.snp.left).offset(-6)
make.width.equalTo(120) make.width.equalTo(120)
make.centerY.equalToSuperview() make.top.equalToSuperview().offset(horizonalGap)
} }
detailLabel.snp.makeConstraints { make in detailLabel.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-longTimeBtnWidth-16-6) make.right.equalToSuperview().offset(-longTimeBtnWidth-horizonalGap-6)
make.centerY.equalToSuperview() make.top.equalTo(titleLabel)
} }
tipsLabel.snp.makeConstraints { make in
make.edges.equalTo(detailLabel)
}
longTimeBtn.snp.makeConstraints { make in longTimeBtn.snp.makeConstraints { make in
make.size.equalTo(CGSizeMake(longTimeBtnWidth, 40)) make.size.equalTo(CGSizeMake(longTimeBtnWidth, 40))
make.right.equalToSuperview().offset(-16) make.right.equalToSuperview().offset(-horizonalGap)
make.centerY.equalToSuperview() make.centerY.equalTo(titleLabel)
}
bottomLine.snp.makeConstraints { make in
make.left.equalToSuperview().offset(horizonalGap)
make.right.equalToSuperview().offset(-horizonalGap)
make.height.equalTo(1.0)
make.bottom.equalToSuperview()
}
setTips("", isShow: false)
}
func setTips(_ tips:String?, isShow:Bool) {
tipsLabel.text = tips
tipsLabel.isHidden = !isShow
if isShow {
tipsLabel.snp.remakeConstraints { make in
make.left.equalToSuperview().offset(horizonalGap)
make.right.equalToSuperview().offset(-horizonalGap)
make.top.equalTo(titleLabel.snp.bottom).offset(6)
make.bottom.equalToSuperview().offset(-16)
}
} else {
tipsLabel.snp.remakeConstraints { make in
make.left.equalToSuperview().offset(horizonalGap)
make.right.equalToSuperview().offset(-horizonalGap)
make.top.equalTo(titleLabel.snp.bottom)
make.height.equalTo(0)
make.bottom.equalToSuperview().offset(-16)
}
} }
} }
......
...@@ -11,9 +11,15 @@ import UIKit ...@@ -11,9 +11,15 @@ import UIKit
class YHFormItemInputTextCell: UITableViewCell { class YHFormItemInputTextCell: UITableViewCell {
static let cellReuseIdentifier = "YHFormItemInputTextCell" static let cellReuseIdentifier = "YHFormItemInputTextCell"
let horizonalGap = 18.0
// 是否必填 如必填title会展示红色* // 是否必填 如必填title会展示红色*
var isMust = false var isMust = false
// 是否展示分割线
var isShowLine:Bool = false {
didSet {
bottomLine.isHidden = !isShowLine
}
}
// BOOL值表示编辑是否结束 // BOOL值表示编辑是否结束
var textChange:((String?, Bool)->Void)? var textChange:((String?, Bool)->Void)?
...@@ -43,7 +49,7 @@ class YHFormItemInputTextCell: UITableViewCell { ...@@ -43,7 +49,7 @@ class YHFormItemInputTextCell: UITableViewCell {
if let placeHolder = placeHolder { if let placeHolder = placeHolder {
textField.attributedPlaceholder = NSAttributedString(string: placeHolder, attributes: [NSAttributedString.Key.foregroundColor : UIColor.placeHolderColor]) textField.attributedPlaceholder = NSAttributedString(string: placeHolder, attributes: [NSAttributedString.Key.foregroundColor : UIColor.placeHolderColor])
} else { } else {
textField.attributedPlaceholder = nil textField.attributedPlaceholder = NSAttributedString(string: "请输入", attributes: [NSAttributedString.Key.foregroundColor : UIColor.placeHolderColor])
} }
} }
} }
...@@ -68,13 +74,30 @@ class YHFormItemInputTextCell: UITableViewCell { ...@@ -68,13 +74,30 @@ class YHFormItemInputTextCell: UITableViewCell {
textField.backgroundColor = .clear textField.backgroundColor = .clear
textField.placeholder = "请输入" textField.placeholder = "请输入"
textField.font = UIFont.PFSC_M(ofSize: 14) textField.font = UIFont.PFSC_M(ofSize: 14)
textField.tintColor = UIColor.mainTextColor textField.tintColor = UIColor.placeHolderColor
textField.textColor = UIColor.mainTextColor textField.textColor = UIColor.mainTextColor
textField.addTarget(self, action: #selector(textFieldChanged(textField:)), for: .editingChanged) textField.addTarget(self, action: #selector(textFieldChanged(textField:)), for: .editingChanged)
textField.addTarget(self, action: #selector(textFieldEditEnd(textField:)), for: .editingDidEnd) textField.addTarget(self, action: #selector(textFieldEditEnd(textField:)), for: .editingDidEnd)
return textField return textField
}() }()
private lazy var tipsLabel: UILabel = {
let label = UILabel()
label.textColor = .failColor
label.textAlignment = .left
label.numberOfLines = 0
label.font = UIFont.PFSC_R(ofSize: 12)
label.isHidden = true
return label
}()
private lazy var bottomLine:UIView = {
let view = UIView()
view.backgroundColor = .separatorColor
view.isHidden = true
return view
}()
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
} }
...@@ -89,21 +112,54 @@ class YHFormItemInputTextCell: UITableViewCell { ...@@ -89,21 +112,54 @@ class YHFormItemInputTextCell: UITableViewCell {
self.selectionStyle = .none self.selectionStyle = .none
contentView.addSubview(titleLabel) contentView.addSubview(titleLabel)
contentView.addSubview(textField) contentView.addSubview(textField)
contentView.addSubview(tipsLabel)
contentView.addSubview(bottomLine)
isMust = true isMust = true
titleLabel.snp.makeConstraints { make in titleLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(16) make.left.equalToSuperview().offset(horizonalGap)
make.width.equalTo(120) make.width.equalTo(120)
make.centerY.equalToSuperview() make.top.equalToSuperview().offset(16)
} }
textField.snp.makeConstraints { make in textField.snp.makeConstraints { make in
make.centerY.equalToSuperview() make.top.equalTo(titleLabel)
make.right.equalTo(contentView.snp.right).offset(-16) make.right.equalTo(contentView.snp.right).offset(-horizonalGap)
make.left.equalTo(titleLabel.snp.right).offset(10) make.left.equalTo(titleLabel.snp.right).offset(10)
} }
bottomLine.snp.makeConstraints { make in
make.left.equalToSuperview().offset(horizonalGap)
make.right.equalToSuperview().offset(-horizonalGap)
make.height.equalTo(1.0)
make.bottom.equalToSuperview()
}
setTips("", isShow: false)
}
func setTips(_ tips:String?, isShow:Bool) {
tipsLabel.text = tips
tipsLabel.isHidden = !isShow
if isShow {
tipsLabel.snp.remakeConstraints { make in
make.left.equalToSuperview().offset(horizonalGap)
make.right.equalToSuperview().offset(-horizonalGap)
make.top.equalTo(textField.snp.bottom).offset(6)
make.bottom.equalToSuperview().offset(-16)
} }
} else {
tipsLabel.snp.remakeConstraints { make in
make.left.equalToSuperview().offset(horizonalGap)
make.right.equalToSuperview().offset(-horizonalGap)
make.top.equalTo(textField.snp.bottom)
make.height.equalTo(0)
make.bottom.equalToSuperview().offset(-16)
}
}
}
@objc func textFieldChanged(textField:UITextField) { @objc func textFieldChanged(textField:UITextField) {
if let textChange = textChange { if let textChange = textChange {
......
...@@ -12,6 +12,8 @@ import UIKit ...@@ -12,6 +12,8 @@ import UIKit
class YHFormItemSelectSheetCell: UITableViewCell { class YHFormItemSelectSheetCell: UITableViewCell {
static let cellReuseIdentifier = "YHFormItemSelectSheetCell" static let cellReuseIdentifier = "YHFormItemSelectSheetCell"
let horizonalGap = 18.0
private let titleColor = UIColor.mainTextColor private let titleColor = UIColor.mainTextColor
private let detailColor = UIColor.mainTextColor private let detailColor = UIColor.mainTextColor
private let placeHolderColor = UIColor.placeHolderColor private let placeHolderColor = UIColor.placeHolderColor
...@@ -43,7 +45,6 @@ class YHFormItemSelectSheetCell: UITableViewCell { ...@@ -43,7 +45,6 @@ class YHFormItemSelectSheetCell: UITableViewCell {
var detail:String? { var detail:String? {
didSet { didSet {
detailLabel.text = detail
if let detail = detail, !detail.isEmpty { if let detail = detail, !detail.isEmpty {
detailLabel.text = detail detailLabel.text = detail
...@@ -55,6 +56,13 @@ class YHFormItemSelectSheetCell: UITableViewCell { ...@@ -55,6 +56,13 @@ class YHFormItemSelectSheetCell: UITableViewCell {
} }
} }
// 是否展示分割线
var isShowLine:Bool = false {
didSet {
bottomLine.isHidden = !isShowLine
}
}
private lazy var titleLabel: UILabel = { private lazy var titleLabel: UILabel = {
let label = UILabel() let label = UILabel()
...@@ -78,6 +86,23 @@ class YHFormItemSelectSheetCell: UITableViewCell { ...@@ -78,6 +86,23 @@ class YHFormItemSelectSheetCell: UITableViewCell {
return imgView return imgView
}() }()
private lazy var tipsLabel: UILabel = {
let label = UILabel()
label.textColor = .failColor
label.textAlignment = .left
label.numberOfLines = 0
label.font = UIFont.PFSC_R(ofSize: 12)
label.isHidden = true
return label
}()
private lazy var bottomLine:UIView = {
let view = UIView()
view.backgroundColor = .separatorColor
view.isHidden = true
return view
}()
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
} }
...@@ -93,23 +118,55 @@ class YHFormItemSelectSheetCell: UITableViewCell { ...@@ -93,23 +118,55 @@ class YHFormItemSelectSheetCell: UITableViewCell {
contentView.addSubview(titleLabel) contentView.addSubview(titleLabel)
contentView.addSubview(detailLabel) contentView.addSubview(detailLabel)
contentView.addSubview(arrowImgView) contentView.addSubview(arrowImgView)
contentView.addSubview(tipsLabel)
contentView.addSubview(bottomLine)
titleLabel.snp.makeConstraints { make in titleLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(16) make.top.equalToSuperview().offset(16)
make.left.equalToSuperview().offset(horizonalGap)
make.right.equalTo(detailLabel.snp.left).offset(-8) make.right.equalTo(detailLabel.snp.left).offset(-8)
make.width.equalTo(120) make.width.equalTo(120)
make.centerY.equalToSuperview()
} }
detailLabel.snp.makeConstraints { make in detailLabel.snp.makeConstraints { make in
make.top.equalTo(titleLabel)
make.right.equalTo(arrowImgView.snp.left) make.right.equalTo(arrowImgView.snp.left)
make.centerY.equalToSuperview()
} }
arrowImgView.snp.makeConstraints { make in arrowImgView.snp.makeConstraints { make in
make.size.equalTo(CGSizeMake(20, 20)) make.size.equalTo(CGSizeMake(20, 20))
make.right.equalToSuperview().offset(-16) make.right.equalToSuperview().offset(-horizonalGap)
make.centerY.equalToSuperview() make.centerY.equalTo(detailLabel)
}
bottomLine.snp.makeConstraints { make in
make.left.equalToSuperview().offset(horizonalGap)
make.right.equalToSuperview().offset(-horizonalGap)
make.height.equalTo(1.0)
make.bottom.equalToSuperview()
}
setTips("", isShow: false)
}
func setTips(_ tips:String?, isShow:Bool) {
tipsLabel.text = tips
tipsLabel.isHidden = !isShow
if isShow {
tipsLabel.snp.remakeConstraints { make in
make.left.equalToSuperview().offset(horizonalGap)
make.right.equalToSuperview().offset(-horizonalGap)
make.top.equalTo(titleLabel.snp.bottom).offset(6)
make.bottom.equalToSuperview().offset(-16)
}
} else {
tipsLabel.snp.remakeConstraints { make in
make.left.equalToSuperview().offset(horizonalGap)
make.right.equalToSuperview().offset(-horizonalGap)
make.top.equalTo(titleLabel.snp.bottom)
make.height.equalTo(0)
make.bottom.equalToSuperview().offset(-16)
}
} }
} }
} }
...@@ -11,6 +11,8 @@ import UIKit ...@@ -11,6 +11,8 @@ import UIKit
class YHFormItemTitleCell: UITableViewCell { class YHFormItemTitleCell: UITableViewCell {
static let cellReuseIdentifier = "YHFormItemTitleCell" static let cellReuseIdentifier = "YHFormItemTitleCell"
private let horizonalGap = 18.0
let editTag = 9527 let editTag = 9527
let cancelTag = 9528 let cancelTag = 9528
...@@ -56,7 +58,7 @@ class YHFormItemTitleCell: UITableViewCell { ...@@ -56,7 +58,7 @@ class YHFormItemTitleCell: UITableViewCell {
return btn return btn
}() }()
lazy var bottomLineView:UIView = { lazy var bottomLine:UIView = {
let view = UIView() let view = UIView()
view.backgroundColor = .separatorColor view.backgroundColor = .separatorColor
return view return view
...@@ -76,7 +78,7 @@ class YHFormItemTitleCell: UITableViewCell { ...@@ -76,7 +78,7 @@ class YHFormItemTitleCell: UITableViewCell {
self.selectionStyle = .none self.selectionStyle = .none
contentView.addSubview(titleLabel) contentView.addSubview(titleLabel)
contentView.addSubview(subTitleLabel) contentView.addSubview(subTitleLabel)
contentView.addSubview(bottomLineView) contentView.addSubview(bottomLine)
contentView.addSubview(editButton) contentView.addSubview(editButton)
contentView.addSubview(cancelButton) contentView.addSubview(cancelButton)
...@@ -109,9 +111,11 @@ class YHFormItemTitleCell: UITableViewCell { ...@@ -109,9 +111,11 @@ class YHFormItemTitleCell: UITableViewCell {
make.right.equalToSuperview() make.right.equalToSuperview()
} }
bottomLineView.snp.makeConstraints { make in bottomLine.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview() make.left.equalToSuperview().offset(horizonalGap)
make.right.equalToSuperview().offset(-horizonalGap)
make.height.equalTo(1.0) make.height.equalTo(1.0)
make.bottom.equalToSuperview()
} }
} }
......
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