Commit f8e9342a authored by David黄金龙's avatar David黄金龙

优化一个重大问题

parent 195d513c
...@@ -331,6 +331,7 @@ ...@@ -331,6 +331,7 @@
A5C5B3292B57CCBE00A7C5D1 /* YHDavidCell4.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5C5B3282B57CCBE00A7C5D1 /* YHDavidCell4.swift */; }; A5C5B3292B57CCBE00A7C5D1 /* YHDavidCell4.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5C5B3282B57CCBE00A7C5D1 /* YHDavidCell4.swift */; };
A5C5B32B2B57D17600A7C5D1 /* YHDavidCell5.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5C5B32A2B57D17600A7C5D1 /* YHDavidCell5.swift */; }; A5C5B32B2B57D17600A7C5D1 /* YHDavidCell5.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5C5B32A2B57D17600A7C5D1 /* YHDavidCell5.swift */; };
A5C5B32D2B57D66000A7C5D1 /* YHBbxCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5C5B32C2B57D66000A7C5D1 /* YHBbxCollectionViewCell.swift */; }; A5C5B32D2B57D66000A7C5D1 /* YHBbxCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5C5B32C2B57D66000A7C5D1 /* YHBbxCollectionViewCell.swift */; };
A5D001212BAA9D99001F003C /* YHChoiceButtonHoldView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5D001202BAA9D99001F003C /* YHChoiceButtonHoldView.swift */; };
A5D6AB1B2B46A1CC001C10A5 /* YHHomeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5D6AB1A2B46A1CC001C10A5 /* YHHomeModel.swift */; }; A5D6AB1B2B46A1CC001C10A5 /* YHHomeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5D6AB1A2B46A1CC001C10A5 /* YHHomeModel.swift */; };
A5D6AB1D2B46AAFB001C10A5 /* YHHomePageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5D6AB1C2B46AAFB001C10A5 /* YHHomePageViewModel.swift */; }; A5D6AB1D2B46AAFB001C10A5 /* YHHomePageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5D6AB1C2B46AAFB001C10A5 /* YHHomePageViewModel.swift */; };
A5E69D512BA304D400411932 /* DIN Alternate Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A5E69D502BA304D400411932 /* DIN Alternate Bold.ttf */; }; A5E69D512BA304D400411932 /* DIN Alternate Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A5E69D502BA304D400411932 /* DIN Alternate Bold.ttf */; };
...@@ -711,6 +712,7 @@ ...@@ -711,6 +712,7 @@
A5C5B3282B57CCBE00A7C5D1 /* YHDavidCell4.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHDavidCell4.swift; sourceTree = "<group>"; }; A5C5B3282B57CCBE00A7C5D1 /* YHDavidCell4.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHDavidCell4.swift; sourceTree = "<group>"; };
A5C5B32A2B57D17600A7C5D1 /* YHDavidCell5.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHDavidCell5.swift; sourceTree = "<group>"; }; A5C5B32A2B57D17600A7C5D1 /* YHDavidCell5.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHDavidCell5.swift; sourceTree = "<group>"; };
A5C5B32C2B57D66000A7C5D1 /* YHBbxCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHBbxCollectionViewCell.swift; sourceTree = "<group>"; }; A5C5B32C2B57D66000A7C5D1 /* YHBbxCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHBbxCollectionViewCell.swift; sourceTree = "<group>"; };
A5D001202BAA9D99001F003C /* YHChoiceButtonHoldView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHChoiceButtonHoldView.swift; sourceTree = "<group>"; };
A5D6AB1A2B46A1CC001C10A5 /* YHHomeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeModel.swift; sourceTree = "<group>"; }; A5D6AB1A2B46A1CC001C10A5 /* YHHomeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeModel.swift; sourceTree = "<group>"; };
A5D6AB1C2B46AAFB001C10A5 /* YHHomePageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomePageViewModel.swift; sourceTree = "<group>"; }; A5D6AB1C2B46AAFB001C10A5 /* YHHomePageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomePageViewModel.swift; sourceTree = "<group>"; };
A5E69D502BA304D400411932 /* DIN Alternate Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "DIN Alternate Bold.ttf"; sourceTree = "<group>"; }; A5E69D502BA304D400411932 /* DIN Alternate Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "DIN Alternate Bold.ttf"; sourceTree = "<group>"; };
...@@ -1297,6 +1299,7 @@ ...@@ -1297,6 +1299,7 @@
045EEE592B9F171A0022A143 /* YHBasicInfoFillBottomView.swift */, 045EEE592B9F171A0022A143 /* YHBasicInfoFillBottomView.swift */,
045EEE5A2B9F171A0022A143 /* YHBasicInfoFillCell.swift */, 045EEE5A2B9F171A0022A143 /* YHBasicInfoFillCell.swift */,
045EEE5B2B9F171A0022A143 /* YHBasicInfoFillView.swift */, 045EEE5B2B9F171A0022A143 /* YHBasicInfoFillView.swift */,
A5D001202BAA9D99001F003C /* YHChoiceButtonHoldView.swift */,
); );
path = V; path = V;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2188,6 +2191,7 @@ ...@@ -2188,6 +2191,7 @@
04A6715C2B9FE9EA00C1FB91 /* YHUploadContentVC.swift in Sources */, 04A6715C2B9FE9EA00C1FB91 /* YHUploadContentVC.swift in Sources */,
A592FE972BA6DB340062FACA /* YHCertificateViewModel.swift in Sources */, A592FE972BA6DB340062FACA /* YHCertificateViewModel.swift in Sources */,
045EEEF02B9F171A0022A143 /* YHChildPrimaryInfoVC.swift in Sources */, 045EEEF02B9F171A0022A143 /* YHChildPrimaryInfoVC.swift in Sources */,
A5D001212BAA9D99001F003C /* YHChoiceButtonHoldView.swift in Sources */,
0468D4202B49320900CFB916 /* YHVerificationCodeLoginController.swift in Sources */, 0468D4202B49320900CFB916 /* YHVerificationCodeLoginController.swift in Sources */,
045EEEF62B9F171A0022A143 /* YHSpousePrimaryInfoVC.swift in Sources */, 045EEEF62B9F171A0022A143 /* YHSpousePrimaryInfoVC.swift in Sources */,
044867B82BA1C75700DFAD4A /* YHCertificateUploadFailTipsView.swift in Sources */, 044867B82BA1C75700DFAD4A /* YHCertificateUploadFailTipsView.swift in Sources */,
...@@ -2667,7 +2671,7 @@ ...@@ -2667,7 +2671,7 @@
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual; CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 6; CURRENT_PROJECT_VERSION = 7;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7;
ENABLE_USER_SCRIPT_SANDBOXING = NO; ENABLE_USER_SCRIPT_SANDBOXING = NO;
...@@ -2709,7 +2713,7 @@ ...@@ -2709,7 +2713,7 @@
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual; CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 6; CURRENT_PROJECT_VERSION = 7;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7;
ENABLE_USER_SCRIPT_SANDBOXING = NO; ENABLE_USER_SCRIPT_SANDBOXING = NO;
......
...@@ -300,15 +300,12 @@ private extension YHBasicInfoFillView { ...@@ -300,15 +300,12 @@ private extension YHBasicInfoFillView {
make.right.equalTo(-12) make.right.equalTo(-12)
} }
guard let subModel = model.model else { guard let subModel = model.model else {
printLog("errorr: 数据有问题") printLog("errorr: 数据有问题")
title = model.question title = model.question
if model.answer == "Y" { if model.answer == "Y" {
didClickResponseBtn(btn: answer2Btn) didClickResponseBtn(btn: answer2Btn)
} else { } else {
if model.answer == "N" { if model.answer == "N" {
didClickResponseBtn(btn: answer1Btn) didClickResponseBtn(btn: answer1Btn)
} else { } else {
...@@ -318,55 +315,22 @@ private extension YHBasicInfoFillView { ...@@ -318,55 +315,22 @@ private extension YHBasicInfoFillView {
return return
} }
let tmpHoldView : YHChoiceButtonHoldView = YHChoiceButtonHoldView()
var targetView : UIView = lable tmpHoldView.targetId = Int(subModel.background_member?.info ?? "0") ?? 0
tmpHoldView.dataModel = subModel.subset
let targetId = Int(subModel.background_member?.info ?? "0") tmpHoldView.callBackBlock = { tag in
for (index,item) in subModel.subset.enumerated() { self.model?.info = tag
// self.layoutForYES()
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_M(ofSize: 14)
btn.setTitleColor(UIColor.mainTextColor, for: .normal)
btn.setTitleColor(UIColor.brandMainColor, for: .selected)
btn.setImage(UIImage(named: "basic_info_radio_0"), for: .normal)
btn.setImage(UIImage(named: "basic_info_radio_1"), for: .selected)
btn.iconInLeft(spacing: 6)
btn.tag = item.id
btn.addTarget(self, action: #selector(clickCheckBtn(sender:)), for: .touchUpInside)
mutilChoiceHoldView.addSubview(btn)
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)
}
}
targetView = btn
arrCheckBtns.append(btn)
} }
mutilChoiceHoldView.addSubview(tmpHoldView)
tmpHoldView.snp.makeConstraints { make in
make.top.equalTo(lable.snp.bottom).offset(kMargin)
make.left.equalTo(lable.snp.left)
make.right.equalTo(lable.snp.right)
make.bottom.equalToSuperview().offset(-kMargin)
}
title = model.question title = model.question
if model.answer == "Y" { if model.answer == "Y" {
...@@ -451,18 +415,18 @@ extension YHBasicInfoFillView : UITextFieldDelegate { ...@@ -451,18 +415,18 @@ extension YHBasicInfoFillView : UITextFieldDelegate {
@objc func clickCheckBtn(sender : UIButton) { // @objc func clickCheckBtn(sender : UIButton) {
//修改成单选逻辑 // //修改成单选逻辑
if sender.isSelected != true { // if sender.isSelected != true {
for item in arrCheckBtns { // for item in arrCheckBtns {
item.isSelected = false // item.isSelected = false
} // }
sender.isSelected = true // sender.isSelected = true
model?.info = String(sender.tag) // model?.info = String(sender.tag)
} // }
//
layoutForYES() // layoutForYES()
} // }
} }
...@@ -531,7 +495,6 @@ private extension YHBasicInfoFillView { ...@@ -531,7 +495,6 @@ private extension YHBasicInfoFillView {
} }
else { else {
//需要展示提示的情况 //需要展示提示的情况
if model.type == 0 { if model.type == 0 {
additionHoldView.isHidden = false additionHoldView.isHidden = false
bottomLine.isHidden = false bottomLine.isHidden = false
......
//
// YHChoiceButtonHoldView.swift
// galaxy
//
// Created by davidhuangA on 2024/3/20.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHChoiceButtonHoldView: UIView {
typealias block = (_ index: String) -> ()
var callBackBlock: block?
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .clear
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private var arrCheckBtns : [UIButton] = []
var targetId : Int = -1
var dataModel : [subsetModel] = [] {
didSet {
updateView()
}
}
private func updateView() {
var x = 0
var y = 0
arrCheckBtns.removeAll()
for (index,item) in dataModel.enumerated() {
let string = item.subset_name.count > 0 ? item.subset_name : "--"
let font = UIFont.PFSC_M(ofSize: 14)// 设置字体样式及大小
let maxWidth = KScreenWidth - 28 * 2 // label最大宽度限制
let butGap : CGFloat = 25
var boundingBox = CGRect()
boundingBox = NSString(string: string).boundingRect(with: CGSize(width: maxWidth, height: .greatestFiniteMagnitude), options: [.usesLineFragmentOrigin], attributes: [.font : font], context: nil)
let width = boundingBox.size.width
if CGFloat(x) + width + 18 + butGap > maxWidth {
x = 0
y = y + 1
}
let btn = UIButton(type: .custom)
btn.setTitle(string, for: .normal)
btn.setTitle(string, for: .selected)
btn.titleLabel?.font = UIFont.PFSC_M(ofSize: 14)
btn.setTitleColor(UIColor.mainTextColor, for: .normal)
btn.setTitleColor(UIColor.brandMainColor, for: .selected)
btn.setImage(UIImage(named: "basic_info_radio_0"), for: .normal)
btn.setImage(UIImage(named: "basic_info_radio_1"), for: .selected)
btn.iconInLeft(spacing: 6)
btn.tag = item.id
btn.addTarget(self, action: #selector(clickCheckBtn(sender:)), for: .touchUpInside)
addSubview(btn)
let offy = y * 36
if dataModel.count - 1 == index {
//最后一个控件
btn.snp.makeConstraints { make in
make.left.equalTo(x)
make.top.equalTo(offy)
make.height.equalTo(20)
make.width.equalTo(width + 18 + butGap)
make.bottom.equalToSuperview()
}
} else {
btn.snp.makeConstraints { make in
make.left.equalTo(x)
make.top.equalTo(offy)
make.height.equalTo(20)
make.width.equalTo(width + 18 + butGap)
}
}
if targetId == item.id {
btn.isSelected = true
} else {
btn.isSelected = false
}
x = Int(CGFloat(x + Int(width)) + 18.0 + butGap)
arrCheckBtns.append(btn)
}
}
@objc func clickCheckBtn(sender : UIButton) {
//修改成单选逻辑
if sender.isSelected != true {
for item in arrCheckBtns {
item.isSelected = false
}
sender.isSelected = true
// model?.info = String(sender.tag)
// block?(String(sender.tag))
callBackBlock?(String(sender.tag))
}
}
}
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