Commit 8a93d915 authored by Steven杜宇's avatar Steven杜宇

// 子女信息

parent 6a1e4b75
......@@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */
04010B952B6A1DE90093F3BB /* YHSaveAndSubmitView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04010B942B6A1DE90093F3BB /* YHSaveAndSubmitView.swift */; };
041B52872B5657B3007EBCEB /* IMAppKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 041B52862B5657B3007EBCEB /* IMAppKey.swift */; };
041B528B2B5E15F1007EBCEB /* YHFormItemQuestionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 041B528A2B5E15F1007EBCEB /* YHFormItemQuestionCell.swift */; };
041B528D2B5E58FA007EBCEB /* YHFormItemDoubleChoiceCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 041B528C2B5E58FA007EBCEB /* YHFormItemDoubleChoiceCell.swift */; };
041B528F2B5E620E007EBCEB /* YHFormItemInputTextCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 041B528E2B5E620E007EBCEB /* YHFormItemInputTextCell.swift */; };
041B52912B5E67F3007EBCEB /* YHFormItemEnterDetailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 041B52902B5E67F3007EBCEB /* YHFormItemEnterDetailCell.swift */; };
......@@ -32,6 +31,7 @@
042FBBD62B67BDD500F9DE23 /* YHBrotherInfoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 042FBBD52B67BDD500F9DE23 /* YHBrotherInfoVC.swift */; };
043955212B70955200955D49 /* YHFormPickerViewType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 043955202B70955200955D49 /* YHFormPickerViewType.swift */; };
043955232B70BC2500955D49 /* YHChildInfoContainerVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 043955222B70BC2500955D49 /* YHChildInfoContainerVC.swift */; };
043955252B70D20300955D49 /* YHFormItemQuestionsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 043955242B70D20300955D49 /* YHFormItemQuestionsCell.swift */; };
0468D4202B49320900CFB916 /* YHVerificationCodeLoginController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D41F2B49320900CFB916 /* YHVerificationCodeLoginController.swift */; };
0468D4222B493A5E00CFB916 /* YHPhoneMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4212B493A5E00CFB916 /* YHPhoneMessageView.swift */; };
0468D4242B494BEA00CFB916 /* YHCodeResultViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4232B494BEA00CFB916 /* YHCodeResultViewController.swift */; };
......@@ -230,7 +230,6 @@
/* Begin PBXFileReference section */
04010B942B6A1DE90093F3BB /* YHSaveAndSubmitView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSaveAndSubmitView.swift; sourceTree = "<group>"; };
041B52862B5657B3007EBCEB /* IMAppKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IMAppKey.swift; sourceTree = "<group>"; };
041B528A2B5E15F1007EBCEB /* YHFormItemQuestionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFormItemQuestionCell.swift; sourceTree = "<group>"; };
041B528C2B5E58FA007EBCEB /* YHFormItemDoubleChoiceCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFormItemDoubleChoiceCell.swift; sourceTree = "<group>"; };
041B528E2B5E620E007EBCEB /* YHFormItemInputTextCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFormItemInputTextCell.swift; sourceTree = "<group>"; };
041B52902B5E67F3007EBCEB /* YHFormItemEnterDetailCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFormItemEnterDetailCell.swift; sourceTree = "<group>"; };
......@@ -253,6 +252,7 @@
042FBBD52B67BDD500F9DE23 /* YHBrotherInfoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHBrotherInfoVC.swift; sourceTree = "<group>"; };
043955202B70955200955D49 /* YHFormPickerViewType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFormPickerViewType.swift; sourceTree = "<group>"; };
043955222B70BC2500955D49 /* YHChildInfoContainerVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHChildInfoContainerVC.swift; sourceTree = "<group>"; };
043955242B70D20300955D49 /* YHFormItemQuestionsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFormItemQuestionsCell.swift; sourceTree = "<group>"; };
0468D41F2B49320900CFB916 /* YHVerificationCodeLoginController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHVerificationCodeLoginController.swift; sourceTree = "<group>"; };
0468D4212B493A5E00CFB916 /* YHPhoneMessageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPhoneMessageView.swift; sourceTree = "<group>"; };
0468D4232B494BEA00CFB916 /* YHCodeResultViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCodeResultViewController.swift; sourceTree = "<group>"; };
......@@ -484,8 +484,8 @@
042FBBD22B67A2F900F9DE23 /* PickerView */,
041B52922B5E6CBA007EBCEB /* YHFormItemTitleCell.swift */,
041B52942B5E7037007EBCEB /* YHFormItemAddCell.swift */,
041B528A2B5E15F1007EBCEB /* YHFormItemQuestionCell.swift */,
041B528C2B5E58FA007EBCEB /* YHFormItemDoubleChoiceCell.swift */,
043955242B70D20300955D49 /* YHFormItemQuestionsCell.swift */,
041B528E2B5E620E007EBCEB /* YHFormItemInputTextCell.swift */,
041B52902B5E67F3007EBCEB /* YHFormItemEnterDetailCell.swift */,
042FBBBC2B63519C00F9DE23 /* YHFormItemSelectSheetCell.swift */,
......@@ -1374,6 +1374,7 @@
A5FD63E62B67908000D1D9DA /* YHPersonInfoControllerHoldViewController.swift in Sources */,
A514E5DC2B60A2B700C93951 /* YHServiceCenterSecondViewController.swift in Sources */,
0468D4202B49320900CFB916 /* YHVerificationCodeLoginController.swift in Sources */,
043955252B70D20300955D49 /* YHFormItemQuestionsCell.swift in Sources */,
0468D4532B6782BE00CFB916 /* YHCardExampleView.swift in Sources */,
04010B952B6A1DE90093F3BB /* YHSaveAndSubmitView.swift in Sources */,
A5ACE9362B4564F7002C94D2 /* YHNetworkStatusManager.swift in Sources */,
......@@ -1437,7 +1438,6 @@
A5FD63CD2B64E2D600D1D9DA /* YHScoreDetailViewController.swift in Sources */,
A5FD63ED2B688A7000D1D9DA /* YHPersonInfoSessionView.swift in Sources */,
A5C5B2FB2B5535DF00A7C5D1 /* YHHomeBannerView.swift in Sources */,
041B528B2B5E15F1007EBCEB /* YHFormItemQuestionCell.swift in Sources */,
A5F78C822B68F39600EEA170 /* YHPersonInfoCommonCell.swift in Sources */,
A5ACE94B2B4564F7002C94D2 /* YHHUDRotatingImageView.swift in Sources */,
041B52DD2B60A889007EBCEB /* YHTest.swift in Sources */,
......
......@@ -35,7 +35,7 @@ class YHChildPrimaryInfoVC: YHBaseViewController {
tableView.register(YHFormItemEnterDetailCell.self, forCellReuseIdentifier: YHFormItemEnterDetailCell.cellReuseIdentifier)
tableView.register(YHFormItemTitleCell.self, forCellReuseIdentifier: YHFormItemTitleCell.cellReuseIdentifier)
tableView.register(YHFormItemAddCell.self, forCellReuseIdentifier: YHFormItemAddCell.cellReuseIdentifier)
tableView.register(YHFormItemQuestionCell.self, forCellReuseIdentifier: YHFormItemQuestionCell.cellReuseIdentifier)
tableView.register(YHFormItemQuestionsCell.self, forCellReuseIdentifier: YHFormItemQuestionsCell.cellReuseIdentifier)
tableView.register(YHFormItemSelectSheetCell.self, forCellReuseIdentifier: YHFormItemSelectSheetCell.cellReuseIdentifier)
return tableView
......@@ -45,10 +45,10 @@ class YHChildPrimaryInfoVC: YHBaseViewController {
super.viewDidLoad()
gk_navTitle = "子女信息填写".local
createUI()
loadSponseInfo()
loadChildInfo()
}
func loadSponseInfo() {
func loadChildInfo() {
guard let child = child else { return }
......@@ -57,9 +57,11 @@ class YHChildPrimaryInfoVC: YHBaseViewController {
// 随行
let title0 = YHFormTitleItem(type: .accompany)
let item00 = YHFormDetailItem(type: .ownCustody)
item00.value = String(child.isOwnCustody())
let item01 = YHFormDetailItem(type: .birthday)
item01.value = child.birthday
let item02 = YHFormDetailItem(type: .isAccompanyToHK)
item02.value = String(child.follow == 1)
item02.value = String(child.isFollow())
let arr0:[YHFormItemProtocol] = [title0, item00, item01, item02]
items.append(arr0)
......@@ -112,7 +114,6 @@ class YHChildPrimaryInfoVC: YHBaseViewController {
item24.value = String(child.isOverSeasOver1Year())
arr2.append(item24)
}
}
}
}
......@@ -125,7 +126,6 @@ class YHChildPrimaryInfoVC: YHBaseViewController {
items.append(contentsOf:[arr1, arr2, arr3])
}
tableView.reloadData()
}
......@@ -142,12 +142,47 @@ class YHChildPrimaryInfoVC: YHBaseViewController {
}
}
@objc func didClickSubmitBtn() {
func getCellType(_ item: Any) ->HKFormItemCellType {
if item is YHFormTitleItem {
return .title
}
if item is YHFormDetailItem {
let detailItem = item as! YHFormDetailItem
if detailItem.type == .birthCity {
var isBirthOverSeas = false
if let child = child {
isBirthOverSeas = child.isBirthOverSeas()
}
if isBirthOverSeas {
return .inputText
} else {
return .selectSheet
}
}
@objc func didClickSaveBtn() {
if detailItem.type == .detailAddress {
return .inputText
}
if detailItem.type == .nationOrArea
|| detailItem.type == .nationOrArea
|| detailItem.type == .liveCity
|| detailItem.type == .birthday
{
return .selectSheet
}
if detailItem.type == .isAccompanyToHK
|| detailItem.type == .isHandleHKPassPort
|| detailItem.type == .isLiveTother
|| detailItem.type == .isLiveOverSeasMore1Year
|| detailItem.type == .ownCustody
{
return .twoChoice
}
}
return .defaultType
}
}
......@@ -181,10 +216,12 @@ extension YHChildPrimaryInfoVC : UITableViewDelegate, UITableViewDataSource {
} else if item is YHFormDetailItem { // 具体信息
let detailItem = item as! YHFormDetailItem
let cellType = self.getCellType(detailItem)
if detailItem.type == .isAccompanyToHK || detailItem.type == .isHandleHKPassPort || detailItem.type == .isLiveTother {
if cellType == .twoChoice {
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemDoubleChoiceCell.cellReuseIdentifier, for: indexPath) as! YHFormItemDoubleChoiceCell
cell.isMust = detailItem.isNeed
cell.title = detailItem.getTitle()
var select = false
......@@ -206,14 +243,12 @@ extension YHChildPrimaryInfoVC : UITableViewDelegate, UITableViewDataSource {
if detailItem.type == .isAccompanyToHK { // 是否随行
self.child?.setFollow(option)
self.loadSponseInfo()
if let delegate = self.delegate {
delegate.updateStepView?()
}
} else if detailItem.type == .isHandleHKPassPort { // 是否办理港澳通行证
self.child?.setNeedHandleHKPassPort(option)
self.loadSponseInfo()
} else if detailItem.type == .isLiveTother { // 是否与主申请人同住
self.child?.setLiveTother(option)
......@@ -222,23 +257,49 @@ extension YHChildPrimaryInfoVC : UITableViewDelegate, UITableViewDataSource {
self.child?.address?.details = nil
self.child?.address?.area = nil
}
self.loadSponseInfo()
} else if detailItem.type == .isLiveOverSeasMore1Year { // 是否在海外居住满1年及以上
self.child?.setOverSearsOver1Year(option)
} else if detailItem.type == .ownCustody { // 抚养权
self.child?.setOwnCustody(option)
}
self.loadChildInfo()
if let delegate = delegate {
delegate.saveInfo?()
}
}
return cell
} else if detailItem.type == .nationOrArea || detailItem.type == .nationOrArea || detailItem.type == .liveCity || detailItem.type == .detailAddress || detailItem.type == .birthday {
} else if cellType == .selectSheet { // 选择列表面板
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemSelectSheetCell.cellReuseIdentifier, for: indexPath) as! YHFormItemSelectSheetCell
cell.isMust = detailItem.isNeed
cell.title = detailItem.getTitle()
cell.detail = detailItem.value
return cell
} else if detailItem.type == .ownCustody {
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemQuestionCell.cellReuseIdentifier, for: indexPath) as! YHFormItemQuestionCell
} else if cellType == .inputText { // 输入文字cell
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemInputTextCell.cellReuseIdentifier, for: indexPath) as! YHFormItemInputTextCell
cell.isMust = detailItem.isNeed
cell.placeHolder = detailItem.placeHolder
cell.title = detailItem.getTitle()
cell.text = detailItem.value
cell.textChange = {
[weak self] (text, isEditEnd) in
guard let self = self else { return }
if detailItem.type == .detailAddress {
self.child?.address?.details = text
}
if isEditEnd {
self.loadChildInfo()
if let delegate = delegate {
delegate.saveInfo?()
}
}
}
return cell
}
}
......@@ -276,7 +337,9 @@ extension YHChildPrimaryInfoVC : UITableViewDelegate, UITableViewDataSource {
if detailItem.type == .isLiveTother ||
detailItem.type == .isAccompanyToHK ||
detailItem.type == .isHandleHKPassPort ||
detailItem.type == .ownCustody
detailItem.type == .ownCustody ||
detailItem.type == .isLiveOverSeasMore1Year
{
return UITableView.automaticDimension
}
......@@ -302,8 +365,54 @@ extension YHChildPrimaryInfoVC : UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let vc = YHChildBasicInfoVC()
if !(0..<items.count).contains(indexPath.section) { return }
let arr:[YHFormItemProtocol] = items[indexPath.section]
if !(0..<arr.count).contains(indexPath.row) { return }
let item = arr[indexPath.row]
if item is YHFormDetailItem {
let detailItem = item as! YHFormDetailItem
// 选国籍/现居住城市/详细地址
if detailItem.type == .nationOrArea {
let vc = YHSelectCountryViewController()
vc.backLocationStringController = {
[weak self] country in
guard let self = self else { return }
let title = arr[0] as! YHFormTitleItem
if title.type == .nationality {
self.child?.nationality = country
} else if title.type == .liveInfo {
self.child?.address?.country = country
}
self.loadChildInfo()
}
self.navigationController?.pushViewController(vc)
} else if detailItem.type == .liveCity {
let vc = YHAddressViewController()
vc.backLocationStringController = {
[weak self] (string1, string2, string3, string4) in
guard let self = self else { return }
print("\(string1)\n\(string2)\n\(string3)\n\(string4)")
self.child?.address?.area = [string2, string3, string4]
self.loadChildInfo()
}
self.present(vc, animated: true)
} else if detailItem.type == .birthday { // 出生日期
YHDatePickView.show(type: .yyyymmdd) { [weak self] date in
guard let self = self else { return }
if detailItem.type == .birthday {
self.child?.birthday = date
}
self.loadChildInfo()
}
}
}
}
func createCorner(cell:UITableViewCell, arr:Array<Any>, indexPath:IndexPath) {
......
......@@ -306,6 +306,13 @@ extension YHSpouseBasicInfoVC : UITableViewDelegate, UITableViewDataSource {
} else if detailItem.type == .hkIdentityCardNumber {
self.spouse?.hkIdentityCard = text
}
if isEditEnd {
self.loadBasicInfo()
if let delegate = delegate {
delegate.saveInfo?()
}
}
}
return cell
}
......
......@@ -483,6 +483,7 @@ class YHFamilyMember: SmartCodable, YHFormItemProtocol {
var id: Int = 0
// 是否已故
var deceased: Int = 0
// 主申请人和现配偶是否拥有孩子抚养权
var custody: Int = 0
// 国籍
var nationality: String?
......@@ -711,6 +712,15 @@ class YHFamilyMember: SmartCodable, YHFormItemProtocol {
return self.occupation == "在职"
}
// 主申请人和现配偶是否拥有孩子抚养权
func isOwnCustody() -> Bool {
return self.custody == 1
}
func setOwnCustody(_ val:Bool) {
self.custody = val ? 1 : 0
}
var relationType:YHFamilyMemberType {
if relation == "1" {
......
//
// YHCheckQuestionCell.swift
// YHFormItemQuestionsCell.swift
// galaxy
//
// Created by edy on 2024/1/22.
// Created by edy on 2024/2/5.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHFormItemQuestionsCell: UITableViewCell {
static let cellReuseIdentifier = "YHFormItemQuestionsCell"
private let btnWidth = 70.0
private let btnHeight = 32.0
private let btnTitleSelectColor = UIColor.brandMainColor
private let btnTitleDefaultColor = UIColor.mainTextColor
private let btnBgDefaultColor = UIColor.contentBkgColor
private let btnBgSelectColor = UIColor.brandMainColor.withAlphaComponent(0.08)
private let answerBaseTag = 9527
class YHFormItemQuestionCell: UITableViewCell {
static let cellReuseIdentifier = "YHFormItemQuestionCell"
let btnWidth = 70.0
let btnHeight = 32.0
let btnTitleSelectColor = UIColor(hex: 0x4487F9)
let btnTitleDefaultColor = UIColor(hex:0x222222)
let btnBgColor = UIColor(hex:0xF8F9FB)
let confirmTag = 9527
let negativeTag = 9528
var responseBlock:((Bool)->Void)?
// 是否必须字段
var isMust:Bool = false
var answerBlock:(([YHFormChoiceItem], Int)->Void)?
var title:String? {
didSet {
if let question = title {
let str = "*"+question
if let title = title, !title.isEmpty {
let str = (isMust ? ("*"+title) : title)
let attributes: [NSAttributedString.Key: Any] = [
.font: UIFont.PFSC_R(ofSize: 14),
.foregroundColor: UIColor(hex:0x222222)
]
.foregroundColor: UIColor.mainTextColor]
let questionAttrStr = NSMutableAttributedString(string: str, attributes: attributes)
if isMust {
let starRange = NSRange(location: 0, length: 1)
questionAttrStr.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor(hex:0xFF3A3A), range: starRange)
}
titleLabel.attributedText = questionAttrStr
} else {
titleLabel.text = ""
}
}
}
var response:Bool = false {
// 必须传2个item的arr
var answerArr:[YHFormChoiceItem]? {
didSet {
showResponse(response)
if let answerArr = answerArr, answerArr.count == 2 {
for i in 0...1 {
let answerBtn = self.viewWithTag(answerBaseTag+i) as! UIButton
let item = answerArr[i]
answerBtn.setTitle(item.title, for: .normal)
updateAnswerButton(answerBtn, item.isSelect)
}
} else {
// 重置所有答案状态
for i in 0...1 {
let answerBtn = self.viewWithTag(answerBaseTag+i) as! UIButton
answerBtn.setTitle("", for: .normal)
updateAnswerButton(answerBtn, false)
}
}
}
}
// 更新答案按钮选中状态
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)
}
lazy var titleLabel: UILabel = {
private lazy var titleLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.textColor = UIColor(hexString:"#333333")
label.textColor = .mainTextColor
label.textAlignment = .left
label.numberOfLines = 0
label.font = UIFont.PFSC_R(ofSize: 14)
label.lineBreakMode = .byCharWrapping
return label
}()
lazy var confirmBtn: UIButton = {
private lazy var answer1Btn: UIButton = {
let btn = UIButton()
btn.setTitle("是".local, for: .normal)
btn.setTitle("", for: .normal)
btn.titleLabel?.font = UIFont.PFSC_R(ofSize: 14)
btn.setTitleColor(btnTitleDefaultColor, for: .normal)
btn.backgroundColor = btnBgColor
btn.backgroundColor = btnBgDefaultColor
btn.layer.cornerRadius = btnHeight/2.0
btn.layer.masksToBounds = true
btn.layer.borderWidth = 1
btn.tag = confirmTag
btn.layer.borderColor = UIColor.clear.cgColor
btn.tag = answerBaseTag
btn.addTarget(self, action: #selector(didClickResponseBtn(btn:)), for: .touchUpInside)
return btn
}()
lazy var negativeBtn: UIButton = {
private lazy var answer2Btn: UIButton = {
let btn = UIButton()
btn.setTitle("否".local, for: .normal)
btn.setTitle("", for: .normal)
btn.titleLabel?.font = UIFont.PFSC_R(ofSize: 14)
btn.setTitleColor(btnTitleDefaultColor, for: .normal)
btn.backgroundColor = btnBgColor
btn.backgroundColor = btnBgDefaultColor
btn.layer.cornerRadius = btnHeight/2.0
btn.layer.masksToBounds = true
btn.layer.borderWidth = 1
btn.tag = negativeTag
btn.layer.borderColor = UIColor.clear.cgColor
btn.tag = answerBaseTag+1
btn.addTarget(self, action: #selector(didClickResponseBtn(btn:)), for: .touchUpInside)
return btn
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
......@@ -98,44 +129,44 @@ class YHFormItemQuestionCell: UITableViewCell {
self.selectionStyle = .none
title = " 1、是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪? "
contentView.addSubview(titleLabel)
contentView.addSubview(negativeBtn)
contentView.addSubview(confirmBtn)
// 默认选择否按钮
response = false
contentView.addSubview(answer2Btn)
contentView.addSubview(answer1Btn)
titleLabel.snp.makeConstraints { make in
make.top.equalTo(contentView.snp.top).offset(12)
make.top.equalTo(contentView.snp.top).offset(22)
make.left.equalToSuperview().offset(16)
make.right.equalToSuperview().offset(-16)
make.bottom.equalTo(answer1Btn.snp.top).offset(-16)
}
negativeBtn.snp.makeConstraints { make in
answer1Btn.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: btnWidth, height: btnHeight))
make.left.equalTo(titleLabel)
make.top.equalTo(titleLabel.snp.bottom).offset(12)
make.bottom.equalToSuperview().offset(-16)
}
confirmBtn.snp.makeConstraints { make in
answer2Btn.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: btnWidth, height: btnHeight))
make.left.equalTo(negativeBtn.snp.right).offset(12)
make.centerY.equalTo(negativeBtn)
make.left.equalTo(answer1Btn.snp.right).offset(16)
make.centerY.equalTo(answer1Btn)
}
}
@objc func didClickResponseBtn(btn: UIButton) {
response = (btn.tag == confirmTag)
if let responseBlock = responseBlock {
responseBlock(btn.tag==confirmTag)
let selectIndex = btn.tag-answerBaseTag
if let resultArr = answerArr, resultArr.count == 2 {
for i in 0...1 {
let item = resultArr[i]
item.isSelect = (i == selectIndex)
}
answerArr = resultArr
if let answerBlock = answerBlock {
answerBlock(resultArr, selectIndex)
}
}
func showResponse(_ isConfirm: Bool) {
confirmBtn.layer.borderColor = (isConfirm ? btnTitleSelectColor : .clear).cgColor
confirmBtn.setTitleColor((isConfirm ? btnTitleSelectColor : btnTitleDefaultColor), for: .normal)
negativeBtn.layer.borderColor = (isConfirm ? .clear : btnTitleSelectColor).cgColor
negativeBtn.setTitleColor((isConfirm ? btnTitleDefaultColor: btnTitleSelectColor), for: .normal)
}
}
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