Commit 62363544 authored by Alex朱枝文's avatar Alex朱枝文

高才收入记录ui

parent b7352795
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
0411CEF32D153FB700644D35 /* YHGCWorkExperienceViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0411CEF22D153FB700644D35 /* YHGCWorkExperienceViewModel.swift */; }; 0411CEF32D153FB700644D35 /* YHGCWorkExperienceViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0411CEF22D153FB700644D35 /* YHGCWorkExperienceViewModel.swift */; };
0411CEF52D1548AF00644D35 /* YHGCWorkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0411CEF42D1548AF00644D35 /* YHGCWorkModel.swift */; }; 0411CEF52D1548AF00644D35 /* YHGCWorkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0411CEF42D1548AF00644D35 /* YHGCWorkModel.swift */; };
0411CEF72D15525400644D35 /* YHGCWorkExperienceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0411CEF62D15525400644D35 /* YHGCWorkExperienceModel.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 */; }; 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 */; }; 045C0F802D12CA5F00BD2DC0 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 045C0F762D12CA5E00BD2DC0 /* Localizable.xcstrings */; };
045C0F812D12CA5F00BD2DC0 /* img_0.png in Resources */ = {isa = PBXBuildFile; fileRef = 045C0F5E2D12CA5E00BD2DC0 /* img_0.png */; }; 045C0F812D12CA5F00BD2DC0 /* img_0.png in Resources */ = {isa = PBXBuildFile; fileRef = 045C0F5E2D12CA5E00BD2DC0 /* img_0.png */; };
...@@ -1100,6 +1101,9 @@ ...@@ -1100,6 +1101,9 @@
047A96832D1674010033BB4E /* YHGCSchemeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047A96822D1674010033BB4E /* YHGCSchemeTableViewCell.swift */; }; 047A96832D1674010033BB4E /* YHGCSchemeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047A96822D1674010033BB4E /* YHGCSchemeTableViewCell.swift */; };
047A96862D1698150033BB4E /* YHGCMySchemeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047A96852D1698150033BB4E /* YHGCMySchemeViewModel.swift */; }; 047A96862D1698150033BB4E /* YHGCMySchemeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047A96852D1698150033BB4E /* YHGCMySchemeViewModel.swift */; };
047A96892D169A5F0033BB4E /* YHGCMySchemeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047A96882D169A5F0033BB4E /* YHGCMySchemeModel.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 */; }; 04AE200F2D12CFAF00891D24 /* YHGCMineSchemeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04AE1FF82D12CFAF00891D24 /* YHGCMineSchemeViewController.swift */; };
04AE20102D12CFAF00891D24 /* YHGCApplicationTypeController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04AE1FFD2D12CFAF00891D24 /* YHGCApplicationTypeController.swift */; }; 04AE20102D12CFAF00891D24 /* YHGCApplicationTypeController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04AE1FFD2D12CFAF00891D24 /* YHGCApplicationTypeController.swift */; };
04AE20112D12CFAF00891D24 /* YHGCApplicationTypeResultController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04AE1FFE2D12CFAF00891D24 /* YHGCApplicationTypeResultController.swift */; }; 04AE20112D12CFAF00891D24 /* YHGCApplicationTypeResultController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04AE1FFE2D12CFAF00891D24 /* YHGCApplicationTypeResultController.swift */; };
...@@ -1185,6 +1189,7 @@ ...@@ -1185,6 +1189,7 @@
0411CEF22D153FB700644D35 /* YHGCWorkExperienceViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCWorkExperienceViewModel.swift; sourceTree = "<group>"; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; 045C0A152D12CA5E00BD2DC0 /* YHBaseViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHBaseViewModel.swift; sourceTree = "<group>"; };
...@@ -2274,6 +2279,9 @@ ...@@ -2274,6 +2279,9 @@
047A96822D1674010033BB4E /* YHGCSchemeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCSchemeTableViewCell.swift; sourceTree = "<group>"; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; 04AE1FFD2D12CFAF00891D24 /* YHGCApplicationTypeController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCApplicationTypeController.swift; sourceTree = "<group>"; };
...@@ -4748,6 +4756,7 @@ ...@@ -4748,6 +4756,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
045C0DB32D12CA5E00BD2DC0 /* YHSheetPickerView.swift */, 045C0DB32D12CA5E00BD2DC0 /* YHSheetPickerView.swift */,
04307B652D1942F500ED8E8D /* YHDynamicSheetPickerView.swift */,
045C0DB42D12CA5E00BD2DC0 /* YHSheetPickerViewType.swift */, 045C0DB42D12CA5E00BD2DC0 /* YHSheetPickerViewType.swift */,
); );
path = PickerView; path = PickerView;
...@@ -5941,6 +5950,32 @@ ...@@ -5941,6 +5950,32 @@
path = M; path = M;
sourceTree = "<group>"; 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 */ = { 04AE1FF92D12CFAF00891D24 /* C */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -6035,6 +6070,7 @@ ...@@ -6035,6 +6070,7 @@
04AE200D2D12CFAF00891D24 /* ServiceProcess(我的信息流程) */ = { 04AE200D2D12CFAF00891D24 /* ServiceProcess(我的信息流程) */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
047A968E2D16AA410033BB4E /* IncomeRecord(收入记录) */,
0411CEE32D15063F00644D35 /* WorkExperience(工作经验) */, 0411CEE32D15063F00644D35 /* WorkExperience(工作经验) */,
0411CED92D14000D00644D35 /* MainApplicantInformation(主申请人信息) */, 0411CED92D14000D00644D35 /* MainApplicantInformation(主申请人信息) */,
04AE20382D13BAC400891D24 /* Education&Qualification(学历专业资格填写) */, 04AE20382D13BAC400891D24 /* Education&Qualification(学历专业资格填写) */,
...@@ -6646,6 +6682,7 @@ ...@@ -6646,6 +6682,7 @@
045C10142D12CA5F00BD2DC0 /* YHResignCertificateDetailViewModel.swift in Sources */, 045C10142D12CA5F00BD2DC0 /* YHResignCertificateDetailViewModel.swift in Sources */,
045C10152D12CA5F00BD2DC0 /* YHAdopterTravelCardTableViewCell.swift in Sources */, 045C10152D12CA5F00BD2DC0 /* YHAdopterTravelCardTableViewCell.swift in Sources */,
045C10162D12CA5F00BD2DC0 /* YHOtherServiceViewController.swift in Sources */, 045C10162D12CA5F00BD2DC0 /* YHOtherServiceViewController.swift in Sources */,
047A96932D16C0900033BB4E /* YHInfoQuestionSelectionCell.swift in Sources */,
045C10172D12CA5F00BD2DC0 /* YHHKImmigrationEditRecordModel.swift in Sources */, 045C10172D12CA5F00BD2DC0 /* YHHKImmigrationEditRecordModel.swift in Sources */,
045C10182D12CA5F00BD2DC0 /* YHMyFileMethodTableViewCell.swift in Sources */, 045C10182D12CA5F00BD2DC0 /* YHMyFileMethodTableViewCell.swift in Sources */,
045C10192D12CA5F00BD2DC0 /* YHVisaRenewalPresenceStatus.swift in Sources */, 045C10192D12CA5F00BD2DC0 /* YHVisaRenewalPresenceStatus.swift in Sources */,
...@@ -6965,6 +7002,8 @@ ...@@ -6965,6 +7002,8 @@
045C11412D12CA5F00BD2DC0 /* AppDelegate.swift in Sources */, 045C11412D12CA5F00BD2DC0 /* AppDelegate.swift in Sources */,
045C11422D12CA5F00BD2DC0 /* YHEditHonorViewController.swift in Sources */, 045C11422D12CA5F00BD2DC0 /* YHEditHonorViewController.swift in Sources */,
045C11432D12CA5F00BD2DC0 /* YHMyFriendsNoDataView.swift in Sources */, 045C11432D12CA5F00BD2DC0 /* YHMyFriendsNoDataView.swift in Sources */,
047A968F2D16AA410033BB4E /* YHGCIncomeRecordViewController.swift in Sources */,
047A96902D16AA410033BB4E /* YHGCIncomeRecordWorkExperienceViewController.swift in Sources */,
045C11442D12CA5F00BD2DC0 /* YHLoginStyleButton.swift in Sources */, 045C11442D12CA5F00BD2DC0 /* YHLoginStyleButton.swift in Sources */,
045C11452D12CA5F00BD2DC0 /* YHListViewModel.swift in Sources */, 045C11452D12CA5F00BD2DC0 /* YHListViewModel.swift in Sources */,
045C11462D12CA5F00BD2DC0 /* YHSearchInfoHistoryView.swift in Sources */, 045C11462D12CA5F00BD2DC0 /* YHSearchInfoHistoryView.swift in Sources */,
...@@ -7077,6 +7116,7 @@ ...@@ -7077,6 +7116,7 @@
045C11AC2D12CA5F00BD2DC0 /* YHSpousePrimaryInfoVC.swift in Sources */, 045C11AC2D12CA5F00BD2DC0 /* YHSpousePrimaryInfoVC.swift in Sources */,
045C11AD2D12CA5F00BD2DC0 /* YHLiveMessageListView.swift in Sources */, 045C11AD2D12CA5F00BD2DC0 /* YHLiveMessageListView.swift in Sources */,
045C11AE2D12CA5F00BD2DC0 /* YHItemModel.swift in Sources */, 045C11AE2D12CA5F00BD2DC0 /* YHItemModel.swift in Sources */,
04307B662D1942F500ED8E8D /* YHDynamicSheetPickerView.swift in Sources */,
045C11AF2D12CA5F00BD2DC0 /* YHHUD.swift in Sources */, 045C11AF2D12CA5F00BD2DC0 /* YHHUD.swift in Sources */,
045C11B02D12CA5F00BD2DC0 /* YHResignDocumentCell.swift in Sources */, 045C11B02D12CA5F00BD2DC0 /* YHResignDocumentCell.swift in Sources */,
045C11B12D12CA5F00BD2DC0 /* YHYHAdopterTravelViewModel.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 { ...@@ -88,6 +88,8 @@ extension YHEmploymentVerificationAvailableCell {
infoTitleLabel.snp.makeConstraints { make in infoTitleLabel.snp.makeConstraints { make in
make.left.equalTo(dotIcon.snp.right).offset(2) make.left.equalTo(dotIcon.snp.right).offset(2)
make.centerY.equalToSuperview() make.centerY.equalToSuperview()
make.top.greaterThanOrEqualToSuperview().offset(16)
make.bottom.lessThanOrEqualToSuperview().offset(-16)
} }
rightArrowIcon.snp.makeConstraints { make in rightArrowIcon.snp.makeConstraints { make in
......
//
// YHGCIncomeRecordViewController.swift
// galaxy
//
// Created by alexzzw on 2024/11/13.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import IQKeyboardManagerSwift
import AttributedString
import UIKit
class YHGCIncomeRecordViewController: YHBaseViewController {
enum TableRow {
case incomeSummary(_ isEditing: Bool = false, _ isEditEnable: Bool = false)
case incomeItem(_ isEditState: Bool = false, _ company: String, _ money: String, _ timeStr: String, _ incomeId: Int, _ showBottomLine: Bool)
case addItem
case totalIncome(_ money: ASAttributedString)
case consentForHKTravel(_ title: String, _ detail: ASAttributedString, _ question: String)
case questionSelect(_ question: String)
case employmentVerification
}
private lazy var datas: [[TableRow]] = []
/// 是否超过
private var isOver100OK = true
private var over100IndexPath: IndexPath?
private var selectedEmployment: String?
private var employments: [String] = ["华为科技有限公司有限公司", "阿里巴巴有限公司"]
private lazy var viewModel = YHIncomeRecordViewModel()
private var incomeModel = YHIncomeRecordCompleteModel()
private lazy var saveButton: UIButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
button.setTitle("保存", for: .normal)
button.setTitle("保存", for: .highlighted)
button.setTitleColor(.mainTextColor, for: .normal)
button.setTitleColor(.mainTextColor, for: .highlighted)
button.addTarget(self, action: #selector(clickSaveButton), for: .touchUpInside)
button.layer.cornerRadius = kCornerRadius3
button.clipsToBounds = true
button.backgroundColor = .contentBkgColor
return button
}()
private lazy var submitButton: UIButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
button.setTitle("提交", for: .normal)
button.setTitle("提交", for: .highlighted)
button.setTitleColor(UIColor(hex: 0xFFFFFF), for: .normal)
button.setTitleColor(UIColor(hex: 0xFFFFFF), for: .highlighted)
button.addTarget(self, action: #selector(clickSubmitButton), for: .touchUpInside)
button.layer.cornerRadius = kCornerRadius3
button.clipsToBounds = true
button.backgroundColor = .brandMainColor
return button
}()
private lazy var bottomView: UIView = {
let view = UIView()
view.backgroundColor = .white
return view
}()
private lazy var tableView: UITableView = {
let view = UITableView(frame: .zero, style: .grouped)
view.estimatedSectionHeaderHeight = 16.0
view.estimatedSectionFooterHeight = 0.01
view.sectionHeaderHeight = 16.0
view.sectionFooterHeight = 0.01
view.contentInsetAdjustmentBehavior = .never
view.showsVerticalScrollIndicator = false
view.separatorStyle = .none
view.delegate = self
view.dataSource = self
view.backgroundColor = .clear
view.tableFooterView = UITableViewHeaderFooterView()
view.rowHeight = UITableView.automaticDimension
view.register(YHIncomeRecordSummaryCell.self, forCellReuseIdentifier: YHIncomeRecordSummaryCell.cellReuseIdentifier)
view.register(YHIncomeRecordItemCell.self, forCellReuseIdentifier: YHIncomeRecordItemCell.cellReuseIdentifier)
view.register(YHInfoConsentForHKTravelCell.self, forCellReuseIdentifier: YHInfoConsentForHKTravelCell.cellReuseIdentifier)
view.register(YHTotalIncomeCell.self, forCellReuseIdentifier: YHTotalIncomeCell.cellReuseIdentifier)
view.register(YHAddIncomeRecordCell.self, forCellReuseIdentifier: YHAddIncomeRecordCell.cellReuseIdentifier)
view.register(YHInfoQuestionSelectionCell.self, forCellReuseIdentifier: YHInfoQuestionSelectionCell.cellReuseIdentifier)
view.register(YHEmploymentVerificationAvailableCell.self, forCellReuseIdentifier: YHEmploymentVerificationAvailableCell.cellReuseIdentifier)
view.keyboardDismissMode = .onDrag
return view
}()
private let orderId: Int
init(orderId: Int) {
self.orderId = orderId
super.init(nibName: nil, bundle: nil)
}
@MainActor required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
requestData(isNeedLoading: true)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
IQKeyboardManager.shared.isEnabled = true
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
IQKeyboardManager.shared.isEnabled = false
}
}
extension YHGCIncomeRecordViewController {
@objc private func clickSaveButton() {
updateIncome(.save)
}
@objc private func clickSubmitButton() {
guard checkInput() else {
return
}
updateIncome(.submit)
}
private func setupUI() {
gk_navTitle = "收入记录信息填写"
gk_navBarAlpha = 1.0
gk_navBackgroundColor = .white
view.backgroundColor = UIColor.contentBkgColor
view.addSubview(tableView)
view.addSubview(bottomView)
bottomView.addSubview(saveButton)
bottomView.addSubview(submitButton)
bottomView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.bottom.equalToSuperview()
make.top.equalTo(view.safeAreaLayoutGuide.snp.bottom).offset(-64)
}
saveButton.snp.makeConstraints { make in
make.left.equalToSuperview().offset(16)
make.top.equalToSuperview().offset(10)
make.height.equalTo(44)
make.width.equalTo(86)
}
submitButton.snp.makeConstraints { make in
make.left.equalTo(saveButton.snp.right).offset(10)
make.right.equalToSuperview().offset(-16)
make.top.equalToSuperview().offset(10)
make.height.equalTo(44)
}
tableView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalTo(bottomView.snp.top)
}
tableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 44))
}
private func setupData() {
let hkdFormatter = currencyFormat("")
var money: Double = 0
var firstSection: [TableRow] = [.incomeSummary(false, false)]
let rate = self.incomeModel.rate > 0 ? self.incomeModel.rate : 0.92
let listCount = incomeModel.list.count
incomeModel.list.enumerated().forEach { index, companyModel in
money += companyModel.income_money
let moneyStr = companyModel.income_money == 0 ? "" : "约" + (hkdFormatter.string(from: NSNumber(value: companyModel.income_money / rate)) ?? "0") + "港币"
let timeStr: String = companyModel.fill_status ? "已填写" : "有\(companyModel.unfilled_count)项未填写"
let incomeItem: TableRow = .incomeItem(false, companyModel.company_name, moneyStr, timeStr, companyModel.income_id, index != listCount - 1)
firstSection.append(incomeItem)
}
firstSection.append(.addItem)
if listCount > 0 {
let totalNum = hkdFormatter.string(from: NSNumber(value: money / rate)) ?? "0"
let totalMoney: ASAttributedString = .init(string: "约 ", .font(.PFSC_R(ofSize: 14))) + .init(string: totalNum, .font(UIFont(name: "DINAlternate-Bold", size: 20) ?? UIFont.systemFont(ofSize: 20))) + .init(string: " 港币", .font(.PFSC_R(ofSize: 14)))
firstSection.append(.totalIncome(totalMoney))
} else {
let incomeItem: TableRow = .incomeItem(false, "收入信息1", "", "待填写", 0, false)
firstSection.append(incomeItem)
}
let detail: ASAttributedString = .init(string: "备注:赴港同意书为目前在职公司盖章提供,若目前未就职于任何公司,则由档案所在地人才中心盖章提供,", .font(UIFont.PFSC_R(ofSize: 13)), .foreground(UIColor(hexString: "#8993A2") ?? .gray))
let actionStr = ASAttributedString.init(string: "查看示例模板", .font(UIFont.PFSC_R(ofSize: 13)), .foreground(UIColor.brandMainColor), .underline(.init(rawValue: 1)), .action {
//
})
var secondSection: [TableRow] = [.consentForHKTravel("赴港同意书提供", detail + actionStr, "在职公司是否可以提供赴港同意书")]
secondSection.append(.questionSelect("人才中心是否可以提供赴港同意书"))
secondSection.append(.employmentVerification)
datas = [firstSection, secondSection]
tableView.reloadData()
}
private func currencyFormat(_ currencySymbol: String) -> NumberFormatter {
let formatter = NumberFormatter()
formatter.numberStyle = .currency
formatter.currencySymbol = currencySymbol
formatter.maximumFractionDigits = 0
return formatter
}
}
extension YHGCIncomeRecordViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return datas.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
guard datas.count > section else {
return 0
}
let sectionArr = datas[section]
return sectionArr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard datas.count > indexPath.section else {
return UITableViewCell()
}
let sectionArr = datas[indexPath.section]
guard sectionArr.count > indexPath.row else {
return UITableViewCell()
}
let tableRow = sectionArr[indexPath.row]
switch tableRow {
case let .incomeSummary(isEditState, isEditEnable):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHIncomeRecordSummaryCell.cellReuseIdentifier) as? YHIncomeRecordSummaryCell {
cell.setupCellInfo(isEditState, isEditEnable, showRightButton: false)
return cell
}
case let .incomeItem(isEditState, company, money, timeStr, _, showBottomLine):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHIncomeRecordItemCell.cellReuseIdentifier) as? YHIncomeRecordItemCell {
cell.setupCellInfo(title: company, detail: money, rightText: timeStr, isEditing: isEditState, showBottomLine: showBottomLine)
return cell
}
case let .totalIncome(money):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHTotalIncomeCell.cellReuseIdentifier) as? YHTotalIncomeCell {
cell.setupCellInfo(detail: money)
cell.didClickInfoButton = { [weak self, weak cell] in
guard let self = self else {
return
}
guard let cell = cell else {
return
}
let rate = self.incomeModel.rate > 0 ? self.incomeModel.rate : 0.92
YHWholeScreenTipsView.show(type: .hkdToRmbRateTips("注:按1港币≈\(rate)人民币计算,实际金额按递交时入境处给出的汇率为准"), targetView: cell.infoButton)
}
return cell
}
case let .consentForHKTravel(title, detail, question):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHInfoConsentForHKTravelCell.cellReuseIdentifier) as? YHInfoConsentForHKTravelCell {
over100IndexPath = indexPath
cell.setupCellInfo(title: title, detail: detail, question: question, needShowFailButton: !isOver100OK)
cell.didSelectSureButton = { [weak self] selected in
guard let self = self else {
return
}
switch selected {
case .true:
self.incomeModel.income_over_100 = YHIncomeOver100.true.rawValue
isOver100OK = true
case .false:
self.incomeModel.income_over_100 = YHIncomeOver100.false.rawValue
isOver100OK = true
case .unknown:
self.incomeModel.income_over_100 = YHIncomeOver100.unknown.rawValue
isOver100OK = false
}
self.setupData()
}
let over100Type = YHIncomeOver100(rawValue: incomeModel.income_over_100) ?? .unknown
switch over100Type {
case .true:
cell.selectedSureButton = .true
case .false:
cell.selectedSureButton = .false
case .unknown:
cell.selectedSureButton = .unknown
}
return cell
}
case .addItem:
if let cell = tableView.dequeueReusableCell(withIdentifier: YHAddIncomeRecordCell.cellReuseIdentifier) as? YHAddIncomeRecordCell {
cell.addButtonClickEvent = {
//
}
return cell
}
case let .questionSelect(question):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHInfoQuestionSelectionCell.cellReuseIdentifier) as? YHInfoQuestionSelectionCell {
over100IndexPath = indexPath
cell.setupCellInfo(question: question, needShowFailButton: !isOver100OK)
cell.didSelectSureButton = { [weak self] selected in
guard let self = self else {
return
}
switch selected {
case .true:
self.incomeModel.income_over_100 = YHIncomeOver100.true.rawValue
isOver100OK = true
case .false:
self.incomeModel.income_over_100 = YHIncomeOver100.false.rawValue
isOver100OK = true
case .unknown:
self.incomeModel.income_over_100 = YHIncomeOver100.unknown.rawValue
isOver100OK = false
}
self.setupData()
}
let over100Type = YHIncomeOver100(rawValue: incomeModel.income_over_100) ?? .unknown
switch over100Type {
case .true:
cell.selectedSureButton = .true
case .false:
cell.selectedSureButton = .false
case .unknown:
cell.selectedSureButton = .unknown
}
return cell
}
case .employmentVerification:
if let cell = tableView.dequeueReusableCell(withIdentifier: YHEmploymentVerificationAvailableCell.cellReuseIdentifier) as? YHEmploymentVerificationAvailableCell {
cell.setupCellInfo(detail: selectedEmployment)
return cell
}
}
return UITableViewCell()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
guard datas.count > indexPath.section else {
return
}
let sectionArr = datas[indexPath.section]
guard sectionArr.count > indexPath.row else {
return
}
let tableRow = sectionArr[indexPath.row]
if case let .incomeItem(_, _, _, _, incomeId, _) = tableRow {
let ctl = YHGCIncomeRecordWorkExperienceViewController(incomeId: incomeId)
ctl.submitSuccess = { [weak self] in
guard let self = self else {
return
}
self.requestData(isNeedLoading: true, lastSelectedIncomeOver100: self.incomeModel.income_over_100)
}
navigationController?.pushViewController(ctl, animated: true)
} else if case .employmentVerification = tableRow {
guard employments.count > 1 else {
return
}
YHDynamicSheetPickerView.show(dataSource: ["华为科技有限公司有限公司", "阿里巴巴有限公司"], title: "选择可提供的在职公司", selectIndex: 0) { index in
//
}
}
}
}
extension YHGCIncomeRecordViewController {
private func checkInput() -> Bool {
if incomeModel.income_over_100 == YHIncomeOver100.unknown.rawValue {
isOver100OK = false
if let over100IndexPath = over100IndexPath, tableView.numberOfSections > over100IndexPath.section, tableView.numberOfRows(inSection: over100IndexPath.section) > over100IndexPath.row {
tableView.reloadRows(at: [over100IndexPath], with: .none)
}
return false
}
isOver100OK = true
return true
}
private func requestData(isNeedLoading: Bool = false, lastSelectedIncomeOver100: Int? = nil) {
if isNeedLoading {
YHHUD.show(.progress(message: "加载中..."))
}
viewModel.getIncomeList(orderId: orderId) { [weak self] incomeModel, error in
guard let self = self else {
return
}
if isNeedLoading {
YHHUD.hide()
}
guard let incomeModel = incomeModel else {
printLog("YHGCIncomeRecordViewController: 请求失败")
if let errorMsg = error?.errorMsg, errorMsg.count > 0 {
YHHUD.flash(message: errorMsg)
}
self.datas = []
self.tableView.reloadData()
self.navigationController?.popViewController(animated: true)
return
}
self.incomeModel = incomeModel
if let lastSelectedIncomeOver100 = lastSelectedIncomeOver100 {
self.incomeModel.income_over_100 = lastSelectedIncomeOver100
}
self.setupData()
}
}
private func updateIncome(_ type: YHIncomeRecordUpdateType) {
let msg = type == .save ? "保存中..." : "提交中..."
YHHUD.show(.progress(message: msg))
viewModel.incomeUpdate(orderId: orderId, incomeOver100: incomeModel.income_over_100, type: type) { [weak self] success, error in
guard let self = self else {
return
}
YHHUD.hide()
if success {
let msg = type == .save ? "保存成功" : "提交成功"
YHHUD.flash(message: msg)
if type == .submit {
self.navigationController?.popViewController(animated: true)
} else {
self.requestData(isNeedLoading: true)
}
} else if let errorMsg = error?.errorMsg, errorMsg.count > 0 {
YHHUD.flash(message: errorMsg)
}
}
}
}
//
// YHGCIncomeRecordWorkExperienceViewController.swift
// galaxy
//
// Created by alexzzw on 2024/11/15.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import IQKeyboardManagerSwift
import UIKit
class YHGCIncomeRecordWorkExperienceViewController: YHBaseViewController {
enum TableRow {
case header(_ title: String)
case incomeFrom(_ title: String, _ detail: String)
case incomeTypeSelect(_ title: String, _ detail: String, _ isSelectedOne: Bool)
case incomeTypes(_ types: [YHIncomeType])
case inputMoney(_ title: String, _ detail: String?, _ inputStr: String?, _ showBottomLine: Bool, _ showStar: Bool, _ isIncomeMoney: Bool)
case inputRemark(_ detail: String)
case documentComfirm(_ title: String, _ question: String, _ docs: [String])
}
private lazy var datas: [[TableRow]] = []
private var selectedTypes: [YHIncomeType] = []
private let currencyRate = 0.92
private var isSaving = false
var submitSuccess: (() -> Void)?
// 校验字段控制
/// 是否选定收入类型
private var isIncomeTypeOK = true
private var incomeTypeIndexPath: IndexPath?
/// 是否选定文件
private var isHasAllFileOK = true
private var hasAllFileIndexPath: IndexPath?
/// 是否收入金额已填写
private var isIncomeMoneyOK = true
private var incomMoneyIndexPath: IndexPath?
private lazy var viewModel = YHIncomeRecordViewModel()
private var companyModel = YHIncomeCompanyDetailModel()
private lazy var submitButton: UIButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
button.setTitle("提交", for: .normal)
button.setTitle("提交", for: .highlighted)
button.setTitleColor(UIColor(hex: 0xFFFFFF), for: .normal)
button.setTitleColor(UIColor(hex: 0xFFFFFF), for: .highlighted)
button.addTarget(self, action: #selector(clickSubmitButton), for: .touchUpInside)
button.layer.cornerRadius = kCornerRadius3
button.clipsToBounds = true
button.backgroundColor = .brandMainColor
return button
}()
private lazy var bottomView: UIView = {
let view = UIView()
view.backgroundColor = .white
return view
}()
private lazy var tableView: UITableView = {
let view = UITableView(frame: .zero, style: .grouped)
view.estimatedSectionHeaderHeight = 16.0
view.estimatedSectionFooterHeight = 0.01
view.sectionHeaderHeight = 16.0
view.sectionFooterHeight = 0.01
view.contentInsetAdjustmentBehavior = .never
view.showsVerticalScrollIndicator = false
view.separatorStyle = .none
view.delegate = self
view.dataSource = self
view.backgroundColor = .clear
view.tableFooterView = UITableViewHeaderFooterView()
view.rowHeight = UITableView.automaticDimension
view.register(YHWorkingHourHeaderCell.self, forCellReuseIdentifier: YHWorkingHourHeaderCell.cellReuseIdentifier)
view.register(YHIncomeRecordFromCell.self, forCellReuseIdentifier: YHIncomeRecordFromCell.cellReuseIdentifier)
view.register(YHIncomeTypeSelectCell.self, forCellReuseIdentifier: YHIncomeTypeSelectCell.cellReuseIdentifier)
view.register(YHIncomeTypesCell.self, forCellReuseIdentifier: YHIncomeTypesCell.cellReuseIdentifier)
view.register(YHIncomeInputMoneyCell.self, forCellReuseIdentifier: YHIncomeInputMoneyCell.cellReuseIdentifier)
view.register(YHIncomeRemarkCell.self, forCellReuseIdentifier: YHIncomeRemarkCell.cellReuseIdentifier)
view.register(YHIncomeDocumentationConfirmationCell.self, forCellReuseIdentifier: YHIncomeDocumentationConfirmationCell.cellReuseIdentifier)
view.keyboardDismissMode = .onDrag
return view
}()
private let incomeId: Int
init(incomeId: Int) {
self.incomeId = incomeId
super.init(nibName: nil, bundle: nil)
}
@MainActor required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
requestData(isNeedLoading: true)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
IQKeyboardManager.shared.isEnabled = true
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
IQKeyboardManager.shared.isEnabled = false
}
override func backItemClick(_ sender: Any) {
guard !isSaving else {
return
}
isSaving = true
submitIncome(.save) { [weak self] _ in
self?.isSaving = false
}
}
/// 是否可以返回,包括点击返回和手势返回,默认YES
override func navigationShouldPop() -> Bool {
guard !isSaving else {
return false
}
isSaving = true
submitIncome(.save) { [weak self] _ in
self?.isSaving = false
}
return false
}
}
extension YHGCIncomeRecordWorkExperienceViewController {
@objc private func clickSubmitButton() {
submitIncome(.submit, complete: { _ in })
}
private func setupUI() {
gk_navTitle = "收入记录信息填写"
gk_navBarAlpha = 1.0
gk_navBackgroundColor = .white
view.backgroundColor = UIColor.contentBkgColor
view.addSubview(tableView)
view.addSubview(bottomView)
bottomView.addSubview(submitButton)
bottomView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.bottom.equalToSuperview()
make.top.equalTo(view.safeAreaLayoutGuide.snp.bottom).offset(-64)
}
submitButton.snp.makeConstraints { make in
make.left.equalToSuperview().offset(16)
make.right.equalToSuperview().offset(-16)
make.top.equalToSuperview().offset(10)
make.height.equalTo(44)
}
tableView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalTo(bottomView.snp.top)
}
tableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 44))
}
private func setupData() {
selectedTypes = companyModel.income_type.compactMap {
YHIncomeType(rawValue: $0)
}
var firstSection: [TableRow] = [.header("收入信息"), .incomeFrom("收入来源公司", companyModel.company_name), .incomeTypeSelect("收入类型(多选)", "请选择", selectedTypes.count > 0)]
if selectedTypes.count > 0 {
firstSection.append(.incomeTypes(selectedTypes))
}
let hkdFmt = currencyFormat("")
let rmbFmt = currencyFormat("¥")
let rate = companyModel.rate > 0 ? companyModel.rate : 0.92
if selectedTypes.contains(.incomeOfMainland) || selectedTypes.contains(.incomeOfHKCompanies) || selectedTypes.contains(.incomeOfMacauCompanies) || selectedTypes.contains(.incomeOfOtherOverseasCompanies) {
firstSection.append(.inputMoney("公司营业额(近一年)", "约\(hkdFmt.string(from: NSNumber(value: companyModel.corporate_turnover / rate)) ?? "0")港币", rmbFmt.string(from: NSNumber(value: companyModel.corporate_turnover)) ?? "0", true, false, false))
}
firstSection.append(.inputMoney("收入金额", "约\(hkdFmt.string(from: NSNumber(value: companyModel.income_money / rate)) ?? "0")港币", rmbFmt.string(from: NSNumber(value: companyModel.income_money)) ?? "0", false, true, true))
firstSection.append(.inputRemark("注:按1港币≈\(rate)人民币计算,实际金额按递交时入境处给出的汇率为准"))
let set = Set(selectedTypes.map { $0.docsArray() }.flatMap { $0 })
var arr = Array(set)
if set.count == 0 {
arr = YHIncomeType.defaultDocs()
}
let secondSection: [TableRow] = [.documentComfirm("证件提供确认", "您是否可以提供以下所有证明文件", arr)]
datas = [firstSection, secondSection]
tableView.reloadData()
}
private func showSelectIncomeTypePopVC(selectedTypes: [YHIncomeType]) {
let ctl = YHIncomeTypeSelectViewController(selectedTypes: selectedTypes)
let bpc = YHBottomPresentationController(presentedViewController: ctl, presenting: self)
bpc.customRadius = 8.0
ctl.transitioningDelegate = bpc
ctl.sureButtonEvent = { [weak self] selectedTypes in
guard let self = self else {
return
}
self.selectedTypes = selectedTypes
self.updateSelectTypes()
}
present(ctl, animated: true, completion: nil)
}
private func updateSelectTypes() {
companyModel.income_type = selectedTypes.map { $0.rawValue }
if companyModel.income_type.count > 0 {
isIncomeTypeOK = true
}
var incomeTypesIndexPath: IndexPath?
var incomeTypeSelectIndexPath: IndexPath?
var docIndexPath: IndexPath?
var incomeCompanyIndexPath: IndexPath?
datas = datas.enumerated().map { section, sectionArr in
sectionArr.enumerated().map { row, tableRow in
switch tableRow {
case .incomeTypes:
incomeTypesIndexPath = IndexPath(row: row, section: section)
return .incomeTypes(selectedTypes)
case let .incomeTypeSelect(title, detail, _):
incomeTypeSelectIndexPath = IndexPath(row: row, section: section)
return .incomeTypeSelect(title, detail, selectedTypes.count > 0)
case let .documentComfirm(title, question, _):
docIndexPath = IndexPath(row: row, section: section)
let set = Set(selectedTypes.map { $0.docsArray() }.flatMap { $0 })
if set.count > 0 {
return .documentComfirm(title, question, Array(set))
} else {
return .documentComfirm(title, question, YHIncomeType.defaultDocs())
}
case let .inputMoney(_, _, _, _, _, isIncomeMoney):
if !isIncomeMoney {
incomeCompanyIndexPath = IndexPath(row: row, section: section)
}
return tableRow
default:
return tableRow
}
}
}
guard let incomeTypeSelectIndexPath = incomeTypeSelectIndexPath else {
return
}
if selectedTypes.count > 0 {
if incomeTypesIndexPath == nil {
var sectionArr = datas[incomeTypeSelectIndexPath.section]
sectionArr.insert(.incomeTypes(selectedTypes), at: incomeTypeSelectIndexPath.row + 1)
datas[incomeTypeSelectIndexPath.section] = sectionArr
}
} else {
guard let incomeTypesIndexPath = incomeTypesIndexPath else {
return
}
var sectionArr = datas[incomeTypesIndexPath.section]
sectionArr.remove(at: incomeTypesIndexPath.row)
datas[incomeTypesIndexPath.section] = sectionArr
}
if selectedTypes.contains(.incomeOfMainland) || selectedTypes.contains(.incomeOfHKCompanies) || selectedTypes.contains(.incomeOfMacauCompanies) || selectedTypes.contains(.incomeOfOtherOverseasCompanies) {
if incomeCompanyIndexPath == nil {
var sectionArr = datas[incomeTypeSelectIndexPath.section]
if let incomeIndex = sectionArr.firstIndex(where: { tableRow in
if case let .inputMoney(_, _, _, _, _, isIncomeMoney) = tableRow, isIncomeMoney == true {
return true
} else {
return false
}
}) {
let newIndex = incomeIndex //> 1 ? incomeIndex - 1 : 0
let hkdFmt = currencyFormat("")
let rmbFmt = currencyFormat("¥")
let rate = companyModel.rate > 0 ? companyModel.rate : 0.92
sectionArr.insert(.inputMoney("公司营业额(近一年)", "约\(hkdFmt.string(from: NSNumber(value: companyModel.corporate_turnover / rate)) ?? "0")港币", rmbFmt.string(from: NSNumber(value: companyModel.corporate_turnover)) ?? "0", true, false, false), at: newIndex)
datas[incomeTypeSelectIndexPath.section] = sectionArr
}
}
} else {
if incomeCompanyIndexPath != nil {
var sectionArr = datas[incomeTypeSelectIndexPath.section]
if let companyIndex = sectionArr.firstIndex(where: { tableRow in
if case let .inputMoney(_, _, _, _, _, isIncomeMoney) = tableRow, isIncomeMoney == false {
return true
} else {
return false
}
}) {
sectionArr.remove(at: companyIndex)
datas[incomeTypeSelectIndexPath.section] = sectionArr
}
}
}
if let secondSection = docIndexPath?.section {
tableView.performBatchUpdates { [weak tableView] in
tableView?.reloadSections(IndexSet(arrayLiteral: incomeTypeSelectIndexPath.section, secondSection), with: .automatic)
}
} else {
tableView.performBatchUpdates { [weak tableView] in
tableView?.reloadSections(IndexSet(integer: incomeTypeSelectIndexPath.section), with: .automatic)
}
}
}
private func currencyFormat(_ currencySymbol: String) -> NumberFormatter {
let formatter = NumberFormatter()
formatter.numberStyle = .currency
formatter.currencySymbol = currencySymbol
formatter.maximumFractionDigits = 0
return formatter
}
}
extension YHGCIncomeRecordWorkExperienceViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return datas.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
guard datas.count > section else {
return 0
}
let sectionArr = datas[section]
return sectionArr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard datas.count > indexPath.section else {
return UITableViewCell()
}
let sectionArr = datas[indexPath.section]
guard sectionArr.count > indexPath.row else {
return UITableViewCell()
}
let tableRow = sectionArr[indexPath.row]
switch tableRow {
case let .header(title):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHWorkingHourHeaderCell.cellReuseIdentifier) as? YHWorkingHourHeaderCell {
cell.setupCellInfo(title)
return cell
}
case let .incomeFrom(title, detail):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHIncomeRecordFromCell.cellReuseIdentifier) as? YHIncomeRecordFromCell {
cell.setupCellInfo(title: title, detail: detail, showBottomLine: true)
return cell
}
case let .incomeTypeSelect(title, detail, isSelectedOne):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHIncomeTypeSelectCell.cellReuseIdentifier) as? YHIncomeTypeSelectCell {
cell.setupCellInfo(title: title, detail: detail, isSelectedOne: isSelectedOne, showBottomLine: !isSelectedOne, needShowFailButton: !isIncomeTypeOK)
incomeTypeIndexPath = indexPath
return cell
}
case let .incomeTypes(types):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHIncomeTypesCell.cellReuseIdentifier) as? YHIncomeTypesCell {
cell.setupCellInfo(types: types.map { $0.nameString() })
cell.didClickTypeView = { [weak self] index in
guard let self = self else {
return
}
self.selectedTypes.remove(at: index)
self.updateSelectTypes()
}
return cell
}
case let .inputMoney(title, detail, inputStr, showBottomLine, showStar, isIncomeMoney):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHIncomeInputMoneyCell.cellReuseIdentifier) as? YHIncomeInputMoneyCell {
var needShowFailButton = false
if isIncomeMoney {
incomMoneyIndexPath = indexPath
needShowFailButton = !isIncomeMoneyOK
}
cell.setupCellInfo(title: title, detail: detail, inputValue: inputStr, showBottomLine: showBottomLine, showStarIcon: showStar, needShowFailButton: needShowFailButton)
cell.didBeginEditing = { textField in
var text = textField.text ?? ""
text = text.replacingOccurrences(of: "¥", with: "")
text = text.replacingOccurrences(of: ",", with: "")
if text == "0" {
text = ""
}
textField.text = text
}
cell.didEndEditing = { [weak self] textField in
guard let self = self else {
return
}
guard let text = textField.text, text.count > 0 else {
if self.datas.count > indexPath.section {
let sectionArr = self.datas[indexPath.section]
if sectionArr.count > indexPath.row {
let currentRow = sectionArr[indexPath.row]
if case let .inputMoney(title, _, _, showBottomLine, showStar, isIncomeMoney) = currentRow {
self.datas[indexPath.section][indexPath.row] = .inputMoney(title, nil, nil, showBottomLine, showStar, isIncomeMoney)
self.tableView.reloadRows(at: [indexPath], with: .automatic)
if isIncomeMoney {
self.companyModel.income_money = 0
} else {
self.companyModel.corporate_turnover = 0
}
}
}
}
return
}
// 转换为数字
let number = Double(text) ?? 0
// 格式化为带货币符号和千分位
let detail = number / self.currencyRate
if isIncomeMoney {
self.isIncomeMoneyOK = true
self.companyModel.income_money = number
} else {
self.companyModel.corporate_turnover = number
}
let rmbFormatter = self.currencyFormat("¥")
let hkdFormatter = self.currencyFormat("")
if let formattedString = rmbFormatter.string(from: NSNumber(value: number)) {
textField.text = formattedString
let detailStr = "约" + (hkdFormatter.string(from: NSNumber(value: detail)) ?? "") + "港币"
if self.datas.count > indexPath.section {
let sectionArr = self.datas[indexPath.section]
if sectionArr.count > indexPath.row {
let currentRow = sectionArr[indexPath.row]
if case let .inputMoney(title, _, _, showBottomLine, showStar, isIncomeMoney) = currentRow {
self.datas[indexPath.section][indexPath.row] = .inputMoney(title, detailStr, formattedString, showBottomLine, showStar, isIncomeMoney)
self.tableView.reloadRows(at: [indexPath], with: .automatic)
}
}
}
}
}
return cell
}
case let .inputRemark(detail):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHIncomeRemarkCell.cellReuseIdentifier) as? YHIncomeRemarkCell {
cell.setupCellInfo(detail)
return cell
}
case let .documentComfirm(title, question, docs):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHIncomeDocumentationConfirmationCell.cellReuseIdentifier) as? YHIncomeDocumentationConfirmationCell {
hasAllFileIndexPath = indexPath
cell.selectedSureButton = YHIncomeRecordHasAllFile(rawValue: companyModel.has_all_file) ?? .unknown
cell.setupCellInfo(title: title, question: question, documents: docs, needShowFailButton: !isHasAllFileOK)
cell.didSelectSureButton = { [weak self] flag in
guard let self = self else {
return
}
self.companyModel.has_all_file = flag.rawValue
self.isHasAllFileOK = flag != .unknown
self.tableView.reloadRows(at: [indexPath], with: .automatic)
}
return cell
}
}
return UITableViewCell()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
guard datas.count > indexPath.section else {
return
}
let sectionArr = datas[indexPath.section]
guard sectionArr.count > indexPath.row else {
return
}
let tableRow = sectionArr[indexPath.row]
if case .incomeTypeSelect = tableRow {
showSelectIncomeTypePopVC(selectedTypes: selectedTypes)
}
}
}
extension YHGCIncomeRecordWorkExperienceViewController {
private func checkInput() -> Bool {
var retValue = true
var updateRows: [IndexPath] = []
if companyModel.has_all_file == YHIncomeRecordHasAllFile.unknown.rawValue {
isHasAllFileOK = false
if let hasAllFileIndexPath = hasAllFileIndexPath, tableView.numberOfSections > hasAllFileIndexPath.section, tableView.numberOfRows(inSection: hasAllFileIndexPath.section) > hasAllFileIndexPath.row {
updateRows.append(hasAllFileIndexPath)
}
retValue = false
}
if companyModel.income_type.count == 0 {
isIncomeTypeOK = false
if let incomeTypeIndexPath = incomeTypeIndexPath, tableView.numberOfSections > incomeTypeIndexPath.section, tableView.numberOfRows(inSection: incomeTypeIndexPath.section) > incomeTypeIndexPath.row {
updateRows.append(incomeTypeIndexPath)
}
retValue = false
}
if companyModel.income_money == 0 {
isIncomeMoneyOK = false
if let incomMoneyIndexPath = incomMoneyIndexPath, tableView.numberOfSections > incomMoneyIndexPath.section, tableView.numberOfRows(inSection: incomMoneyIndexPath.section) > incomMoneyIndexPath.row {
updateRows.append(incomMoneyIndexPath)
}
retValue = false
}
if updateRows.count > 0 {
tableView.reloadRows(at: updateRows, with: .none)
isHasAllFileOK = true
isIncomeTypeOK = true
isIncomeMoneyOK = true
}
return retValue
}
private func requestData(isNeedLoading: Bool = false) {
if isNeedLoading {
YHHUD.show(.progress(message: "加载中..."))
}
viewModel.getIncomeDetail(incomeId: incomeId) { [weak self] companyModel, error in
guard let self = self else {
return
}
if isNeedLoading {
YHHUD.hide()
}
guard let companyModel = companyModel else {
printLog("YHGCIncomeRecordWorkExperienceViewController: 请求失败")
if let errorMsg = error?.errorMsg, errorMsg.count > 0 {
YHHUD.flash(message: errorMsg)
}
self.datas = []
self.tableView.reloadData()
return
}
self.companyModel = companyModel
self.setupData()
}
}
private func submitIncome(_ type: YHIncomeRecordUpdateType, complete: @escaping (Bool) -> Void) {
view.endEditing(true)
let msg = type == .save ? "保存中..." : "提交中..."
if type == .submit {
if checkInput() == false {
return
}
}
YHHUD.show(.progress(message: msg))
viewModel.updateDetail(incomeId: incomeId, incomeMoney: companyModel.income_money, corporateTurnover: companyModel.corporate_turnover, incomeType: companyModel.income_type, hasAllFile: companyModel.has_all_file) { [weak self] success, error in
guard let self = self else {
complete(false)
return
}
YHHUD.hide()
complete(success)
if success {
let msg = type == .save ? "保存成功" : "提交成功"
YHHUD.flash(message: msg)
self.submitSuccess?()
self.navigationController?.popViewController(animated: true)
} else {
if let errorMsg = error?.errorMsg, errorMsg.count > 0 {
YHHUD.flash(message: errorMsg)
}
if type == .save {
self.navigationController?.popViewController(animated: true)
}
}
}
}
}
//
// 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