Commit 6e96038b authored by David黄金龙's avatar David黄金龙

基本资料 完成 全部的UI展示

parent 5e30ed6e
......@@ -12,9 +12,13 @@ class YHBasicInfoCellModel {
var question : String = ""
var answer : String = ""
var additionDes : String = ""
init(question: String, answer: String, additionDes: String) {
var model : backgroundModel?
var type : Int = 0 //0- 输入型 1-选择型
init(question: String, answer: String, additionDes: String, type : Int = 0) {
self.question = question
self.answer = answer
self.additionDes = additionDes
self.type = type
}
}
......@@ -93,6 +93,16 @@ class YHBasicInfoFillView: UIView, UITextViewDelegate {
}()
//多选框 holdView
private lazy var mutilChoiceHoldView : UIView = {
let view = UIView()
view.backgroundColor = UIColor.contentBkgColor
view.layer.cornerRadius = kCornerRadius6
view.clipsToBounds = true
return view
}()
var title:String? {
didSet {
if let question = title {
......@@ -158,28 +168,37 @@ private extension YHBasicInfoFillView {
addSubview(additionHoldView)
additionHoldView.isHidden = true
let redStar = UILabel()
redStar.text = "*"
redStar.textColor = UIColor.failColor
additionHoldView.addSubview(redStar)
redStar.snp.makeConstraints { make in
let redDot = UIImageView(image: UIImage(named: "basic_info_red_dot"))
additionHoldView.addSubview(redDot)
redDot.snp.makeConstraints { make in
make.left.equalTo(12)
make.top.equalTo(19)
make.width.height.equalTo(6)
}
let textView : UITextView = UITextView()
textView.backgroundColor = .clear
textView.font = UIFont.PFSC_R(ofSize: 14)
additionHoldView.addSubview(textView)
textView.snp.makeConstraints { make in
make.top.equalTo(redStar.snp.top).offset(-7)
make.left.equalTo(redStar.snp.right).offset(2)
make.right.equalTo(12)
make.height.lessThanOrEqualTo(66)
make.top.equalTo(redDot.snp.top).offset(-7)
make.left.equalTo(redDot.snp.right).offset(2)
make.right.equalTo(-12)
make.bottom.equalTo(-6)
}
myTextView = textView
myTextView.delegate = self
textView.contentInset = UIEdgeInsets(top: -8, left: 0, bottom: 0, right: 0)
addSubview(mutilChoiceHoldView)
mutilChoiceHoldView.isHidden = true
mutilChoiceHoldView.snp.makeConstraints { make in
make.edges.equalTo(0)
}
}
@objc func didClickResponseBtn(btn: UIButton) {
......@@ -200,6 +219,8 @@ private extension YHBasicInfoFillView {
updateAnswerButton(answer2Btn, false)
additionHoldView.snp.removeConstraints()
mutilChoiceHoldView.snp.removeConstraints()
bottomLine.snp.remakeConstraints { make in
make.top.equalTo(answer1Btn.snp.bottom).offset(12)
make.left.right.equalToSuperview()
......@@ -208,14 +229,16 @@ private extension YHBasicInfoFillView {
}
additionHoldView.isHidden = true
bottomLine.isHidden = false
mutilChoiceHoldView.isHidden = true
model?.answer = "N"
} else {
answer1Btn.isSelected = false
updateAnswerButton(answer1Btn, false)
bottomLine.snp.removeConstraints()
if model?.type == 0 {
additionHoldView.snp.remakeConstraints { make in
make.top.equalTo(answer1Btn.snp.bottom).offset(12)
make.left.right.equalToSuperview()
......@@ -228,11 +251,33 @@ private extension YHBasicInfoFillView {
additionHoldView.isHidden = false
bottomLine.isHidden = true
mutilChoiceHoldView.isHidden = true
} else {
mutilChoiceHoldView.snp.remakeConstraints { make in
make.top.equalTo(answer1Btn.snp.bottom).offset(12)
make.left.right.equalToSuperview()
// make.height.equalTo(78)
make.bottom.equalToSuperview().offset(-18)
}
model?.answer = "Y"
additionHoldView.isHidden = true
bottomLine.isHidden = true
mutilChoiceHoldView.isHidden = false
}
}
additionHoldView.layoutIfNeeded()
bottomLine.layoutIfNeeded()
mutilChoiceHoldView.layoutIfNeeded()
block?()
}
......@@ -248,14 +293,112 @@ private extension YHBasicInfoFillView {
private func updateUI() {
guard let model = model else { return }
if model.type == 1 {
additionHoldView.isHidden = true
mutilChoiceHoldView.isHidden = false
let lable = UILabel()
let str = "*选择成员:"
let attributes: [NSAttributedString.Key: Any] = [
.font: UIFont.PFSC_R(ofSize: 14),
.foregroundColor: UIColor.mainTextColor
]
let questionAttrStr = NSMutableAttributedString(string: str, attributes: attributes)
let starRange = NSRange(location: 0, length: 1)
questionAttrStr.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.failColor, range: starRange)
lable.attributedText = questionAttrStr
mutilChoiceHoldView.addSubview(lable)
lable.snp.makeConstraints { make in
make.top.equalTo(12)
make.left.equalTo(12)
make.height.equalTo(20)
make.right.equalTo(-12)
}
guard let subModel = model.model else { return }
var targetView : UIView = lable
let targetId = Int(subModel.background_member?.info ?? "0")
for (index,item) in subModel.subset.enumerated() {
let name = item.subset_name.count > 0 ? item.subset_name : "--"
let btn = UIButton(type: .custom)
btn.setTitle(name, for: .normal)
btn.setTitle(name, for: .selected)
btn.titleLabel?.font = UIFont.PFSC_R(ofSize: 13)
btn.setTitleColor(UIColor.mainTextColor, for: .normal)
btn.setTitleColor(UIColor.brandMainColor, for: .selected)
btn.setImage(UIImage(named: "basic_info_check_0"), for: .normal)
btn.setImage(UIImage(named: "basic_info_check_1"), for: .selected)
btn.iconInLeft(spacing: 6)
btn.tag = item.id
btn.addTarget(self, action: #selector(clickCheckBtn(sender:)), for: .touchUpInside)
mutilChoiceHoldView.addSubview(btn)
// btn.backgroundColor = .red//for test hjl
if targetId == item.id {
btn.isSelected = true
} else {
btn.isSelected = false
}
if index == subModel.subset.count - 1 {
btn.snp.makeConstraints { make in
make.top.equalTo(targetView.snp.bottom).offset(kMargin)
make.left.equalTo(16)
make.height.equalTo(30)
make.bottom.equalToSuperview().offset(-kMargin)
}
} else {
btn.snp.makeConstraints { make in
make.top.equalTo(targetView.snp.bottom).offset(kMargin)
make.left.equalTo(16)
make.height.equalTo(30)
}
}
title = model.question
if model.answer == "Y" {
didClickResponseBtn(btn: answer2Btn)
myTextView.text = model.additionDes
} else {
if model.answer == "N" {
didClickResponseBtn(btn: answer1Btn)
}
}
targetView = btn
}
} else {
additionHoldView.isHidden = false
mutilChoiceHoldView.isHidden = true
title = model.question
if model.answer == "Y" {
didClickResponseBtn(btn: answer2Btn)
myTextView.text = model.additionDes
} else {
if model.answer == "N" {
didClickResponseBtn(btn: answer1Btn)
}
}
}
}
}
......@@ -263,7 +406,7 @@ private extension YHBasicInfoFillView {
extension YHBasicInfoFillView : UITextFieldDelegate {
private func textViewDidBeginEditing (textView: UITextView) {
// if myTextView.textColor == ph_TextColor && myTextView.isFirstResponder() {
// if myTextView.isFirstResponder {
// myTextView.text = nil
// myTextView.textColor = .white
// }
......@@ -271,10 +414,17 @@ extension YHBasicInfoFillView : UITextFieldDelegate {
private func textViewDidEndEditing (textView: UITextView) {
// if myTxtView.text.isEmpty || myTxtView.text == "" {
// myTxtView.textColor = .lightGray
// myTxtView.text = "Type your thoughts here..."
// }
if textView.text.isEmpty || textView.text == "" {
textView.textColor = UIColor(hexString: "#C0C0C0")
textView.text = "如选择“是”,请详细说明"
} else {
textView.textColor = UIColor.mainTextColor
}
}
@objc func clickCheckBtn(sender : UIButton) {
sender.isSelected = !sender.isSelected
}
}
......@@ -127,7 +127,8 @@ extension YHBasicInfoFillViewModel {
do {
//家庭背景
let model1 = YHBasicInfoCellModel(question:"1、至少一名直系家庭成员(已婚配偶、父母、兄弟姊妹、子女)是现居于香港的香港永久性居民", answer: dataModelForBasicInfo.background?.background_member?.has ?? "", additionDes: dataModelForBasicInfo.background?.background_member?.info ?? "")
let model1 = YHBasicInfoCellModel(question:"1、至少一名直系家庭成员(已婚配偶、父母、兄弟姊妹、子女)是现居于香港的香港永久性居民", answer: dataModelForBasicInfo.background?.background_member?.has ?? "", additionDes: dataModelForBasicInfo.background?.background_member?.info ?? "",type: 1)
model1.model = dataModelForBasicInfo.background
let arr = [model1]
let sessionModel = YHBasicInfoSessionModel(sessionTitle: "家庭背景", arrQuestionItem: arr)
......@@ -141,8 +142,8 @@ extension YHBasicInfoFillViewModel {
extension YHBasicInfoFillViewModel {
//获取我的评分结果
func getBasicInfo( params:[String : Any],callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
createOrgBasiceInfoData()
callBackBlock(true,nil)//先返回数据 让界面展示相关的UI
// createOrgBasiceInfoData()
// callBackBlock(true,nil)//先返回数据 让界面展示相关的UI
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Basics.basicInfoApi
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Rectangle 2490@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Rectangle 2490@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group 3040@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 3040@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "_@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "_@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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