Commit 5bc12209 authored by Steven杜宇's avatar Steven杜宇

Merge branch 'develop' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS into develop

parents 22e0f9ac 62363544
......@@ -18,6 +18,7 @@
0411CEF32D153FB700644D35 /* YHGCWorkExperienceViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0411CEF22D153FB700644D35 /* YHGCWorkExperienceViewModel.swift */; };
0411CEF52D1548AF00644D35 /* YHGCWorkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0411CEF42D1548AF00644D35 /* YHGCWorkModel.swift */; };
0411CEF72D15525400644D35 /* YHGCWorkExperienceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0411CEF62D15525400644D35 /* YHGCWorkExperienceModel.swift */; };
04307B662D1942F500ED8E8D /* YHDynamicSheetPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04307B652D1942F500ED8E8D /* YHDynamicSheetPickerView.swift */; };
045C0F7F2D12CA5F00BD2DC0 /* submit_page_scroll.gif in Resources */ = {isa = PBXBuildFile; fileRef = 045C0F4F2D12CA5E00BD2DC0 /* submit_page_scroll.gif */; };
045C0F802D12CA5F00BD2DC0 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 045C0F762D12CA5E00BD2DC0 /* Localizable.xcstrings */; };
045C0F812D12CA5F00BD2DC0 /* img_0.png in Resources */ = {isa = PBXBuildFile; fileRef = 045C0F5E2D12CA5E00BD2DC0 /* img_0.png */; };
......@@ -1100,6 +1101,9 @@
047A96832D1674010033BB4E /* YHGCSchemeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047A96822D1674010033BB4E /* YHGCSchemeTableViewCell.swift */; };
047A96862D1698150033BB4E /* YHGCMySchemeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047A96852D1698150033BB4E /* YHGCMySchemeViewModel.swift */; };
047A96892D169A5F0033BB4E /* YHGCMySchemeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047A96882D169A5F0033BB4E /* YHGCMySchemeModel.swift */; };
047A968F2D16AA410033BB4E /* YHGCIncomeRecordViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047A968A2D16AA410033BB4E /* YHGCIncomeRecordViewController.swift */; };
047A96902D16AA410033BB4E /* YHGCIncomeRecordWorkExperienceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047A968B2D16AA410033BB4E /* YHGCIncomeRecordWorkExperienceViewController.swift */; };
047A96932D16C0900033BB4E /* YHInfoQuestionSelectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047A96922D16C0900033BB4E /* YHInfoQuestionSelectionCell.swift */; };
04AE200F2D12CFAF00891D24 /* YHGCMineSchemeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04AE1FF82D12CFAF00891D24 /* YHGCMineSchemeViewController.swift */; };
04AE20102D12CFAF00891D24 /* YHGCApplicationTypeController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04AE1FFD2D12CFAF00891D24 /* YHGCApplicationTypeController.swift */; };
04AE20112D12CFAF00891D24 /* YHGCApplicationTypeResultController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04AE1FFE2D12CFAF00891D24 /* YHGCApplicationTypeResultController.swift */; };
......@@ -1183,6 +1187,7 @@
0411CEF22D153FB700644D35 /* YHGCWorkExperienceViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCWorkExperienceViewModel.swift; sourceTree = "<group>"; };
0411CEF42D1548AF00644D35 /* YHGCWorkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCWorkModel.swift; sourceTree = "<group>"; };
0411CEF62D15525400644D35 /* YHGCWorkExperienceModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCWorkExperienceModel.swift; sourceTree = "<group>"; };
04307B652D1942F500ED8E8D /* YHDynamicSheetPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHDynamicSheetPickerView.swift; sourceTree = "<group>"; };
045C09A12D12C2A800BD2DC0 /* YHGCMineSchemeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCMineSchemeViewController.swift; sourceTree = "<group>"; };
045C0A142D12CA5E00BD2DC0 /* YHBaseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHBaseViewController.swift; sourceTree = "<group>"; };
045C0A152D12CA5E00BD2DC0 /* YHBaseViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHBaseViewModel.swift; sourceTree = "<group>"; };
......@@ -2272,6 +2277,9 @@
047A96822D1674010033BB4E /* YHGCSchemeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCSchemeTableViewCell.swift; sourceTree = "<group>"; };
047A96852D1698150033BB4E /* YHGCMySchemeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCMySchemeViewModel.swift; sourceTree = "<group>"; };
047A96882D169A5F0033BB4E /* YHGCMySchemeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCMySchemeModel.swift; sourceTree = "<group>"; };
047A968A2D16AA410033BB4E /* YHGCIncomeRecordViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCIncomeRecordViewController.swift; sourceTree = "<group>"; };
047A968B2D16AA410033BB4E /* YHGCIncomeRecordWorkExperienceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCIncomeRecordWorkExperienceViewController.swift; sourceTree = "<group>"; };
047A96922D16C0900033BB4E /* YHInfoQuestionSelectionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHInfoQuestionSelectionCell.swift; sourceTree = "<group>"; };
04AE1FF82D12CFAF00891D24 /* YHGCMineSchemeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCMineSchemeViewController.swift; sourceTree = "<group>"; };
04AE1FFA2D12CFAF00891D24 /* YHGCSchemeTableHeadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCSchemeTableHeadView.swift; sourceTree = "<group>"; };
04AE1FFD2D12CFAF00891D24 /* YHGCApplicationTypeController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCApplicationTypeController.swift; sourceTree = "<group>"; };
......@@ -4744,6 +4752,7 @@
isa = PBXGroup;
children = (
045C0DB32D12CA5E00BD2DC0 /* YHSheetPickerView.swift */,
04307B652D1942F500ED8E8D /* YHDynamicSheetPickerView.swift */,
045C0DB42D12CA5E00BD2DC0 /* YHSheetPickerViewType.swift */,
);
path = PickerView;
......@@ -5937,6 +5946,32 @@
path = M;
sourceTree = "<group>";
};
047A968D2D16AA410033BB4E /* C */ = {
isa = PBXGroup;
children = (
047A968A2D16AA410033BB4E /* YHGCIncomeRecordViewController.swift */,
047A968B2D16AA410033BB4E /* YHGCIncomeRecordWorkExperienceViewController.swift */,
);
path = C;
sourceTree = "<group>";
};
047A968E2D16AA410033BB4E /* IncomeRecord(收入记录) */ = {
isa = PBXGroup;
children = (
047A96942D1900D00033BB4E /* V */,
047A968D2D16AA410033BB4E /* C */,
);
path = "IncomeRecord(收入记录)";
sourceTree = "<group>";
};
047A96942D1900D00033BB4E /* V */ = {
isa = PBXGroup;
children = (
047A96922D16C0900033BB4E /* YHInfoQuestionSelectionCell.swift */,
);
path = V;
sourceTree = "<group>";
};
04AE1FF92D12CFAF00891D24 /* C */ = {
isa = PBXGroup;
children = (
......@@ -6031,6 +6066,7 @@
04AE200D2D12CFAF00891D24 /* ServiceProcess(我的信息流程) */ = {
isa = PBXGroup;
children = (
047A968E2D16AA410033BB4E /* IncomeRecord(收入记录) */,
0411CEE32D15063F00644D35 /* WorkExperience(工作经验) */,
0411CED92D14000D00644D35 /* MainApplicantInformation(主申请人信息) */,
04AE20382D13BAC400891D24 /* Education&Qualification(学历专业资格填写) */,
......@@ -6624,6 +6660,7 @@
045C10142D12CA5F00BD2DC0 /* YHResignCertificateDetailViewModel.swift in Sources */,
045C10152D12CA5F00BD2DC0 /* YHAdopterTravelCardTableViewCell.swift in Sources */,
045C10162D12CA5F00BD2DC0 /* YHOtherServiceViewController.swift in Sources */,
047A96932D16C0900033BB4E /* YHInfoQuestionSelectionCell.swift in Sources */,
045C10172D12CA5F00BD2DC0 /* YHHKImmigrationEditRecordModel.swift in Sources */,
045C10182D12CA5F00BD2DC0 /* YHMyFileMethodTableViewCell.swift in Sources */,
045C10192D12CA5F00BD2DC0 /* YHVisaRenewalPresenceStatus.swift in Sources */,
......@@ -6943,6 +6980,8 @@
045C11412D12CA5F00BD2DC0 /* AppDelegate.swift in Sources */,
045C11422D12CA5F00BD2DC0 /* YHEditHonorViewController.swift in Sources */,
045C11432D12CA5F00BD2DC0 /* YHMyFriendsNoDataView.swift in Sources */,
047A968F2D16AA410033BB4E /* YHGCIncomeRecordViewController.swift in Sources */,
047A96902D16AA410033BB4E /* YHGCIncomeRecordWorkExperienceViewController.swift in Sources */,
045C11442D12CA5F00BD2DC0 /* YHLoginStyleButton.swift in Sources */,
045C11452D12CA5F00BD2DC0 /* YHListViewModel.swift in Sources */,
045C11462D12CA5F00BD2DC0 /* YHSearchInfoHistoryView.swift in Sources */,
......@@ -7055,6 +7094,7 @@
045C11AC2D12CA5F00BD2DC0 /* YHSpousePrimaryInfoVC.swift in Sources */,
045C11AD2D12CA5F00BD2DC0 /* YHLiveMessageListView.swift in Sources */,
045C11AE2D12CA5F00BD2DC0 /* YHItemModel.swift in Sources */,
04307B662D1942F500ED8E8D /* YHDynamicSheetPickerView.swift in Sources */,
045C11AF2D12CA5F00BD2DC0 /* YHHUD.swift in Sources */,
045C11B02D12CA5F00BD2DC0 /* YHResignDocumentCell.swift in Sources */,
045C11B12D12CA5F00BD2DC0 /* YHYHAdopterTravelViewModel.swift in Sources */,
......
//
// YHDynamicSheetPickerView.swift
// galaxy
//
// Created by alexzzw on 2024/12/23.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHDynamicSheetPickerView: UIView {
let dataSource: [String]
// 选择的行
var selectRow: Int = 0
private var selectBlock: ((Int) -> Void)?
var title: String? {
didSet {
titleLabel.text = title
}
}
lazy var pickerView: UIPickerView = {
let view = UIPickerView()
view.dataSource = self
view.delegate = self
return view
}()
lazy var blackMaskView: UIView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0x0F1214, alpha: 0.5)
let tap = UITapGestureRecognizer(target: self, action: #selector(dismiss))
view.addGestureRecognizer(tap)
return view
}()
lazy var whiteContentView: UIView = {
let view = UIView()
view.backgroundColor = .white
return view
}()
lazy var topView: UIView = {
let view = UIView()
view.addSubview(titleLabel)
view.addSubview(cancelBtn)
view.addSubview(confirmBtn)
view.addSubview(topLineView)
titleLabel.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
cancelBtn.snp.makeConstraints { make in
make.left.equalToSuperview().offset(21)
make.centerY.equalToSuperview()
make.size.equalTo(CGSizeMake(30, 20))
}
confirmBtn.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-21)
make.centerY.equalToSuperview()
make.size.equalTo(CGSizeMake(30, 20))
}
topLineView.snp.makeConstraints { make in
make.left.equalToSuperview().offset(21)
make.right.equalToSuperview().offset(-21)
make.bottom.equalToSuperview()
make.height.equalTo(1)
}
return view
}()
lazy var topLineView: UIView = {
let view = UIView()
view.backgroundColor = UIColor(hexString: "#F0F0F0")
return view
}()
lazy var titleLabel: UILabel = {
let label = UILabel()
label.textColor = UIColor.mainTextColor
label.textAlignment = .center
label.font = UIFont.PFSC_M(ofSize: 17)
label.text = "请选择"
return label
}()
lazy var cancelBtn: UIButton = {
let btn = UIButton()
btn.setTitle("取消".local, for: .normal)
btn.titleLabel?.font = UIFont.PFSC_M(ofSize: 14)
btn.setTitleColor(UIColor.mainTextColor, for: .normal)
btn.addTarget(self, action: #selector(didClickCancelButton), for: .touchUpInside)
btn.YH_clickEdgeInsets = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
return btn
}()
lazy var confirmBtn: UIButton = {
let btn = UIButton()
btn.setTitle("确定".local, for: .normal)
btn.titleLabel?.font = UIFont.PFSC_M(ofSize: 14)
btn.setTitleColor(UIColor.brandMainColor, for: .normal)
btn.addTarget(self, action: #selector(didClickConfirmButton), for: .touchUpInside)
btn.YH_clickEdgeInsets = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
return btn
}()
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
init(dataSource: [String]) {
self.dataSource = dataSource
super.init(frame: UIScreen.main.bounds)
createUI()
}
func show() {
showSelectRow()
UIApplication.shared.yhKeyWindow()?.addSubview(self)
}
func showSelectRow() {
if selectRow < dataSource.count {
pickerView.selectRow(selectRow, inComponent: 0, animated: true)
} else {
selectRow = 0
pickerView.selectRow(0, inComponent: 0, animated: true)
}
}
static func show(dataSource: [String], title: String, selectIndex: Int, callBack: @escaping ((Int) -> Void)) {
let picker = YHDynamicSheetPickerView(dataSource: dataSource)
picker.title = title
picker.selectRow = selectIndex < dataSource.count ? selectIndex : 0
picker.selectBlock = callBack
picker.show()
}
static func show(dataSource: [String], title: String, selectTitle: String?, callBack: @escaping ((Int) -> Void)) {
let picker = YHDynamicSheetPickerView(dataSource: dataSource)
picker.title = title
if let selectTitle = selectTitle, let firstIndex = dataSource.firstIndex(of: selectTitle) {
picker.selectRow = firstIndex
} else {
picker.selectRow = 0
}
picker.selectBlock = callBack
picker.show()
}
func createUI() {
addSubview(blackMaskView)
addSubview(whiteContentView)
whiteContentView.addSubview(topView)
whiteContentView.addSubview(pickerView)
let corner = UIRectCorner(rawValue: UIRectCorner.topLeft.rawValue | UIRectCorner.topRight.rawValue)
let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: corner, cornerRadii: CGSizeMake(kCornerRadius6, kCornerRadius6))
let layer = CAShapeLayer()
layer.frame = whiteContentView.bounds
layer.path = path.cgPath
whiteContentView.layer.mask = layer
if let title = title {
titleLabel.text = title
}
blackMaskView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
let whiteContentHeight = 322.0
whiteContentView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(whiteContentHeight)
}
topView.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
make.height.equalTo(52)
}
pickerView.snp.makeConstraints { make in
make.top.equalTo(topView.snp.bottom)
make.left.right.bottom.equalToSuperview()
}
}
}
extension YHDynamicSheetPickerView {
@objc func didClickCancelButton() {
dismiss()
}
@objc func didClickConfirmButton() {
selectBlock?(selectRow)
dismiss()
}
@objc func dismiss() {
removeFromSuperview()
}
}
// MARK: - UIPickerViewDelegate
extension YHDynamicSheetPickerView: UIPickerViewDelegate, UIPickerViewDataSource {
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
if !dataSource.isEmpty {
return dataSource.count
}
return 0
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
if 0 <= row && row < dataSource.count {
return dataSource[row]
}
return ""
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if 0 <= row && row < dataSource.count {
selectRow = row
// 刷新picker,看上面的代理
pickerView.reloadComponent(component)
}
}
func pickerView(_ pickerView: UIPickerView, widthForComponent component: Int) -> CGFloat {
return KScreenWidth - 16 * 2
}
func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat {
return 42.0
}
func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {
let label = UILabel()
label.textColor = UIColor.mainTextColor
label.font = UIFont.PFSC_R(ofSize: 14)
label.textAlignment = .center
label.numberOfLines = 2
label.text = ""
if 0 <= row && row < dataSource.count {
label.text = dataSource[row]
}
if selectRow == row {
label.font = UIFont.PFSC_M(ofSize: 14)
} else {
label.font = UIFont.PFSC_R(ofSize: 14)
}
// 选中背景色
if #available(iOS 14.0, *), pickerView.subviews.count > 1 {
pickerView.subviews[1].backgroundColor = UIColor.brandMainColor6
}
return label
}
}
......@@ -88,6 +88,8 @@ extension YHEmploymentVerificationAvailableCell {
infoTitleLabel.snp.makeConstraints { make in
make.left.equalTo(dotIcon.snp.right).offset(2)
make.centerY.equalToSuperview()
make.top.greaterThanOrEqualToSuperview().offset(16)
make.bottom.lessThanOrEqualToSuperview().offset(-16)
}
rightArrowIcon.snp.makeConstraints { make in
......
//
// YHInfoQuestionSelectionCell.swift
// galaxy
//
// Created by alexzzw on 2024/12/21.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHInfoQuestionSelectionCell: YHResignDocumentCell {
static let cellReuseIdentifier = "YHInfoQuestionSelectionCell"
var didSelectSureButton: ((YHCheckboxSelectType) -> Void)?
var selectedSureButton: YHCheckboxSelectType = .unknown {
didSet {
updateButtonsState(selectedSureButton)
}
}
private lazy var dotIcon: UIImageView = {
let imageView = UIImageView(image: UIImage(named: "red_dot_6"))
return imageView
}()
private lazy var infoQuestionLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_R(ofSize: 14)
label.textColor = UIColor.mainTextColor
label.numberOfLines = 0
label.lineBreakMode = .byWordWrapping
return label
}()
private lazy var sureButton: UIButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = .PFSC_M(ofSize: 13)
button.setTitle("是", for: .normal)
button.setTitleColor(.mainTextColor, for: .normal)
button.setTitleColor(.brandMainColor, for: .selected)
button.addTarget(self, action: #selector(sureButtonDidClick(_:)), for: .touchUpInside)
button.layer.cornerRadius = 16.0
button.clipsToBounds = true
return button
}()
private lazy var cancelButton: UIButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = .PFSC_M(ofSize: 13)
button.setTitle("否", for: .normal)
button.setTitleColor(.mainTextColor, for: .normal)
button.setTitleColor(.brandMainColor, for: .selected)
button.addTarget(self, action: #selector(cancelButtonDidClick(_:)), for: .touchUpInside)
button.layer.cornerRadius = 16
button.clipsToBounds = true
return button
}()
private lazy var infoFailLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_R(ofSize: 12)
label.textColor = .failColor
label.text = "请选择"
return label
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupCellInfo(question: String, showBottomLine: Bool = false, needShowFailButton: Bool) {
infoQuestionLabel.text = question
updateFailLabel(needShowFailButton)
}
}
extension YHInfoQuestionSelectionCell {
private func updateFailLabel(_ needShowFailButton: Bool) {
if needShowFailButton {
infoFailLabel.isHidden = false
infoQuestionLabel.snp.remakeConstraints { make in
make.left.equalTo(dotIcon.snp.right).offset(2)
make.top.equalToSuperview().offset(16)
make.height.greaterThanOrEqualTo(40)
make.width.lessThanOrEqualTo(113)
}
infoFailLabel.snp.remakeConstraints { make in
make.top.equalTo(infoQuestionLabel.snp.bottom).offset(6)
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
} else {
infoFailLabel.isHidden = true
infoQuestionLabel.snp.remakeConstraints { make in
make.left.equalTo(dotIcon.snp.right).offset(2)
make.top.equalToSuperview().offset(16)
make.height.greaterThanOrEqualTo(40)
make.width.lessThanOrEqualTo(113)
make.bottom.equalToSuperview().offset(-16)
}
infoFailLabel.snp.remakeConstraints { make in
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
}
}
@objc private func cancelButtonDidClick(_ sender: UIButton) {
guard !sender.isSelected else {
return
}
selectedSureButton = .false
didSelectSureButton?(.false)
}
@objc private func sureButtonDidClick(_ sender: UIButton) {
guard !sender.isSelected else {
return
}
selectedSureButton = .true
didSelectSureButton?(.true)
}
private func setupUI() {
updateCellCorner(.mid)
subContainerView.addSubview(dotIcon)
subContainerView.addSubview(infoQuestionLabel)
subContainerView.addSubview(sureButton)
subContainerView.addSubview(cancelButton)
subContainerView.addSubview(infoFailLabel)
sureButton.setContentCompressionResistancePriority(.required, for: .horizontal)
cancelButton.setContentCompressionResistancePriority(.required, for: .horizontal)
infoQuestionLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
dotIcon.snp.makeConstraints { make in
make.left.equalToSuperview().offset(18)
make.height.width.equalTo(6)
make.top.equalTo(infoQuestionLabel.snp.top).offset(7)
}
infoQuestionLabel.snp.makeConstraints { make in
make.left.equalTo(dotIcon.snp.right).offset(2)
make.top.equalToSuperview().offset(16)
make.height.greaterThanOrEqualTo(40)
make.width.lessThanOrEqualTo(113)
make.bottom.equalToSuperview().offset(-16)
}
cancelButton.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-18)
make.height.equalTo(32)
make.width.equalTo(69)
make.centerY.equalTo(infoQuestionLabel)
}
sureButton.snp.makeConstraints { make in
make.right.equalTo(cancelButton.snp.left).offset(-8)
make.height.equalTo(32)
make.width.equalTo(69)
make.centerY.equalTo(infoQuestionLabel)
make.left.greaterThanOrEqualTo(infoQuestionLabel.snp.right).offset(8)
}
infoFailLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
infoFailLabel.isHidden = true
selectedSureButton = .unknown
}
private func updateButtonsState(_ state: YHCheckboxSelectType) {
switch state {
case .unknown:
sureButton.isSelected = false
sureButton.backgroundColor = .contentBkgColor
sureButton.layer.borderColor = nil
sureButton.layer.borderWidth = 0
cancelButton.isSelected = false
cancelButton.backgroundColor = .contentBkgColor
cancelButton.layer.borderColor = nil
cancelButton.layer.borderWidth = 0
case .true:
sureButton.isSelected = true
sureButton.backgroundColor = UIColor(hexString: "#EBF0F9")
sureButton.layer.borderColor = UIColor.brandMainColor.cgColor
sureButton.layer.borderWidth = 1
cancelButton.isSelected = false
cancelButton.backgroundColor = .contentBkgColor
cancelButton.layer.borderColor = nil
cancelButton.layer.borderWidth = 0
case .false:
cancelButton.isSelected = true
cancelButton.backgroundColor = UIColor(hexString: "#EBF0F9")
cancelButton.layer.borderColor = UIColor.brandMainColor.cgColor
cancelButton.layer.borderWidth = 1
sureButton.isSelected = false
sureButton.backgroundColor = .contentBkgColor
sureButton.layer.borderColor = nil
sureButton.layer.borderWidth = 0
}
}
}
//
// YHInfoQuestionSelectionCell.swift
// galaxy
//
// Created by alexzzw on 2024/12/21.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHInfoQuestionSelectionCell: YHResignDocumentCell {
static let cellReuseIdentifier = "YHInfoQuestionSelectionCell"
var didSelectSureButton: ((YHCheckboxSelectType) -> Void)?
var selectedSureButton: YHCheckboxSelectType = .unknown {
didSet {
updateButtonsState(selectedSureButton)
}
}
private lazy var dotIcon: UIImageView = {
let imageView = UIImageView(image: UIImage(named: "red_dot_6"))
return imageView
}()
private lazy var infoQuestionLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_R(ofSize: 14)
label.textColor = UIColor.mainTextColor
label.numberOfLines = 0
label.lineBreakMode = .byWordWrapping
return label
}()
private lazy var sureButton: UIButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = .PFSC_M(ofSize: 13)
button.setTitle("是", for: .normal)
button.setTitleColor(.mainTextColor, for: .normal)
button.setTitleColor(.brandMainColor, for: .selected)
button.addTarget(self, action: #selector(sureButtonDidClick(_:)), for: .touchUpInside)
button.layer.cornerRadius = 16.0
button.clipsToBounds = true
return button
}()
private lazy var cancelButton: UIButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = .PFSC_M(ofSize: 13)
button.setTitle("否", for: .normal)
button.setTitleColor(.mainTextColor, for: .normal)
button.setTitleColor(.brandMainColor, for: .selected)
button.addTarget(self, action: #selector(cancelButtonDidClick(_:)), for: .touchUpInside)
button.layer.cornerRadius = 16
button.clipsToBounds = true
return button
}()
private lazy var infoFailLabel: UILabel = {
let label = UILabel()
label.font = .PFSC_R(ofSize: 12)
label.textColor = .failColor
label.text = "请选择"
return label
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupCellInfo(question: String, showBottomLine: Bool = false, needShowFailButton: Bool) {
infoQuestionLabel.text = question
updateFailLabel(needShowFailButton)
}
}
extension YHInfoQuestionSelectionCell {
private func updateFailLabel(_ needShowFailButton: Bool) {
if needShowFailButton {
infoFailLabel.isHidden = false
infoQuestionLabel.snp.remakeConstraints { make in
make.left.equalTo(dotIcon.snp.right).offset(2)
make.top.equalToSuperview().offset(16)
make.height.greaterThanOrEqualTo(40)
make.width.lessThanOrEqualTo(113)
}
infoFailLabel.snp.remakeConstraints { make in
make.top.equalTo(infoQuestionLabel.snp.bottom).offset(6)
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
} else {
infoFailLabel.isHidden = true
infoQuestionLabel.snp.remakeConstraints { make in
make.left.equalTo(dotIcon.snp.right).offset(2)
make.top.equalToSuperview().offset(16)
make.height.greaterThanOrEqualTo(40)
make.width.lessThanOrEqualTo(113)
make.bottom.equalToSuperview().offset(-16)
}
infoFailLabel.snp.remakeConstraints { make in
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
}
}
@objc private func cancelButtonDidClick(_ sender: UIButton) {
guard !sender.isSelected else {
return
}
selectedSureButton = .false
didSelectSureButton?(.false)
}
@objc private func sureButtonDidClick(_ sender: UIButton) {
guard !sender.isSelected else {
return
}
selectedSureButton = .true
didSelectSureButton?(.true)
}
private func setupUI() {
updateCellCorner(.mid)
subContainerView.addSubview(dotIcon)
subContainerView.addSubview(infoQuestionLabel)
subContainerView.addSubview(sureButton)
subContainerView.addSubview(cancelButton)
subContainerView.addSubview(infoFailLabel)
sureButton.setContentCompressionResistancePriority(.required, for: .horizontal)
cancelButton.setContentCompressionResistancePriority(.required, for: .horizontal)
infoQuestionLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
dotIcon.snp.makeConstraints { make in
make.left.equalToSuperview().offset(18)
make.height.width.equalTo(6)
make.top.equalTo(infoQuestionLabel.snp.top).offset(7)
}
infoQuestionLabel.snp.makeConstraints { make in
make.left.equalTo(dotIcon.snp.right).offset(2)
make.top.equalToSuperview().offset(16)
make.height.greaterThanOrEqualTo(40)
make.width.lessThanOrEqualTo(113)
make.bottom.equalToSuperview().offset(-16)
}
cancelButton.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-18)
make.height.equalTo(32)
make.width.equalTo(69)
make.centerY.equalTo(infoQuestionLabel)
}
sureButton.snp.makeConstraints { make in
make.right.equalTo(cancelButton.snp.left).offset(-8)
make.height.equalTo(32)
make.width.equalTo(69)
make.centerY.equalTo(infoQuestionLabel)
make.left.greaterThanOrEqualTo(infoQuestionLabel.snp.right).offset(8)
}
infoFailLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.bottom.equalToSuperview().offset(-16)
}
infoFailLabel.isHidden = true
selectedSureButton = .unknown
}
private func updateButtonsState(_ state: YHCheckboxSelectType) {
switch state {
case .unknown:
sureButton.isSelected = false
sureButton.backgroundColor = .contentBkgColor
sureButton.layer.borderColor = nil
sureButton.layer.borderWidth = 0
cancelButton.isSelected = false
cancelButton.backgroundColor = .contentBkgColor
cancelButton.layer.borderColor = nil
cancelButton.layer.borderWidth = 0
case .true:
sureButton.isSelected = true
sureButton.backgroundColor = UIColor(hexString: "#EBF0F9")
sureButton.layer.borderColor = UIColor.brandMainColor.cgColor
sureButton.layer.borderWidth = 1
cancelButton.isSelected = false
cancelButton.backgroundColor = .contentBkgColor
cancelButton.layer.borderColor = nil
cancelButton.layer.borderWidth = 0
case .false:
cancelButton.isSelected = true
cancelButton.backgroundColor = UIColor(hexString: "#EBF0F9")
cancelButton.layer.borderColor = UIColor.brandMainColor.cgColor
cancelButton.layer.borderWidth = 1
sureButton.isSelected = false
sureButton.backgroundColor = .contentBkgColor
sureButton.layer.borderColor = nil
sureButton.layer.borderWidth = 0
}
}
}
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