Commit 830dc0dd authored by pete谢兆麟's avatar pete谢兆麟

stepView 封装

parent cb7fd7f1
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
0468D4342B56587B00CFB916 /* YHOSSManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4332B56587B00CFB916 /* YHOSSManager.swift */; }; 0468D4342B56587B00CFB916 /* YHOSSManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4332B56587B00CFB916 /* YHOSSManager.swift */; };
0468D4362B57752F00CFB916 /* YHUserModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4352B57752F00CFB916 /* YHUserModel.swift */; }; 0468D4362B57752F00CFB916 /* YHUserModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4352B57752F00CFB916 /* YHUserModel.swift */; };
0468D43A2B579EAC00CFB916 /* YHLoginViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4392B579EAC00CFB916 /* YHLoginViewModel.swift */; }; 0468D43A2B579EAC00CFB916 /* YHLoginViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4392B579EAC00CFB916 /* YHLoginViewModel.swift */; };
0468D4432B61F76800CFB916 /* YHMainApplicantInformationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4422B61F76800CFB916 /* YHMainApplicantInformationViewController.swift */; };
0468D4452B62064700CFB916 /* YHStepView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4442B62064700CFB916 /* YHStepView.swift */; };
04808C062B4686510056D53C /* ATAuthSDK.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 04808C042B4686510056D53C /* ATAuthSDK.bundle */; }; 04808C062B4686510056D53C /* ATAuthSDK.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 04808C042B4686510056D53C /* ATAuthSDK.bundle */; };
04808C082B4686C10056D53C /* ATAuthSDK_D.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 04808C032B4686510056D53C /* ATAuthSDK_D.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 04808C082B4686C10056D53C /* ATAuthSDK_D.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 04808C032B4686510056D53C /* ATAuthSDK_D.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
049A48A82B49417300D0C641 /* YHAboutUsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */; }; 049A48A82B49417300D0C641 /* YHAboutUsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */; };
...@@ -171,6 +173,8 @@ ...@@ -171,6 +173,8 @@
0468D4332B56587B00CFB916 /* YHOSSManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHOSSManager.swift; sourceTree = "<group>"; }; 0468D4332B56587B00CFB916 /* YHOSSManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHOSSManager.swift; sourceTree = "<group>"; };
0468D4352B57752F00CFB916 /* YHUserModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = YHUserModel.swift; path = "galaxy/Classes/Modules/Login(登录)/M/YHUserModel.swift"; sourceTree = SOURCE_ROOT; }; 0468D4352B57752F00CFB916 /* YHUserModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = YHUserModel.swift; path = "galaxy/Classes/Modules/Login(登录)/M/YHUserModel.swift"; sourceTree = SOURCE_ROOT; };
0468D4392B579EAC00CFB916 /* YHLoginViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLoginViewModel.swift; sourceTree = "<group>"; }; 0468D4392B579EAC00CFB916 /* YHLoginViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLoginViewModel.swift; sourceTree = "<group>"; };
0468D4422B61F76800CFB916 /* YHMainApplicantInformationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMainApplicantInformationViewController.swift; sourceTree = "<group>"; };
0468D4442B62064700CFB916 /* YHStepView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHStepView.swift; sourceTree = "<group>"; };
04808C032B4686510056D53C /* ATAuthSDK_D.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ATAuthSDK_D.framework; sourceTree = "<group>"; }; 04808C032B4686510056D53C /* ATAuthSDK_D.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ATAuthSDK_D.framework; sourceTree = "<group>"; };
04808C042B4686510056D53C /* ATAuthSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = ATAuthSDK.bundle; sourceTree = "<group>"; }; 04808C042B4686510056D53C /* ATAuthSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = ATAuthSDK.bundle; sourceTree = "<group>"; };
049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAboutUsViewController.swift; sourceTree = "<group>"; }; 049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAboutUsViewController.swift; sourceTree = "<group>"; };
...@@ -375,6 +379,47 @@ ...@@ -375,6 +379,47 @@
path = VM; path = VM;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
0468D43D2B61F68100CFB916 /* MainApplicantInformation */ = {
isa = PBXGroup;
children = (
0468D4412B61F6CA00CFB916 /* VM */,
0468D4402B61F6C400CFB916 /* V */,
0468D43F2B61F6BD00CFB916 /* M */,
0468D43E2B61F6B100CFB916 /* C */,
);
path = MainApplicantInformation;
sourceTree = "<group>";
};
0468D43E2B61F6B100CFB916 /* C */ = {
isa = PBXGroup;
children = (
0468D4422B61F76800CFB916 /* YHMainApplicantInformationViewController.swift */,
);
path = C;
sourceTree = "<group>";
};
0468D43F2B61F6BD00CFB916 /* M */ = {
isa = PBXGroup;
children = (
);
path = M;
sourceTree = "<group>";
};
0468D4402B61F6C400CFB916 /* V */ = {
isa = PBXGroup;
children = (
0468D4442B62064700CFB916 /* YHStepView.swift */,
);
path = V;
sourceTree = "<group>";
};
0468D4412B61F6CA00CFB916 /* VM */ = {
isa = PBXGroup;
children = (
);
path = VM;
sourceTree = "<group>";
};
04808C022B4686510056D53C /* Frameworks */ = { 04808C022B4686510056D53C /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -770,6 +815,7 @@ ...@@ -770,6 +815,7 @@
A5C382C82B5E101E00C5E65C /* ServiceProcess(流程) */ = { A5C382C82B5E101E00C5E65C /* ServiceProcess(流程) */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
0468D43D2B61F68100CFB916 /* MainApplicantInformation */,
041B52882B5E13EB007EBCEB /* FamilyMember */, 041B52882B5E13EB007EBCEB /* FamilyMember */,
); );
path = "ServiceProcess(流程)"; path = "ServiceProcess(流程)";
...@@ -1007,6 +1053,7 @@ ...@@ -1007,6 +1053,7 @@
A5551FFE2B4C26CE00510980 /* YHBaseViewModel.swift in Sources */, A5551FFE2B4C26CE00510980 /* YHBaseViewModel.swift in Sources */,
A5C5B2F92B5515CE00A7C5D1 /* YHPageContentView.swift in Sources */, A5C5B2F92B5515CE00A7C5D1 /* YHPageContentView.swift in Sources */,
A5C382CA2B5E1F4C00C5E65C /* YHLoginTipsView.swift in Sources */, A5C382CA2B5E1F4C00C5E65C /* YHLoginTipsView.swift in Sources */,
0468D4452B62064700CFB916 /* YHStepView.swift in Sources */,
A5C5B3232B57BF8F00A7C5D1 /* YHDavidCell1.swift in Sources */, A5C5B3232B57BF8F00A7C5D1 /* YHDavidCell1.swift in Sources */,
A5C5B2FB2B5535DF00A7C5D1 /* YHHomeBannerView.swift in Sources */, A5C5B2FB2B5535DF00A7C5D1 /* YHHomeBannerView.swift in Sources */,
041B528B2B5E15F1007EBCEB /* YHDoubleChoiceQuestionCell.swift in Sources */, 041B528B2B5E15F1007EBCEB /* YHDoubleChoiceQuestionCell.swift in Sources */,
...@@ -1017,6 +1064,7 @@ ...@@ -1017,6 +1064,7 @@
A5ACE94E2B4564F7002C94D2 /* AlignedCollectionViewFlowLayout.swift in Sources */, A5ACE94E2B4564F7002C94D2 /* AlignedCollectionViewFlowLayout.swift in Sources */,
A5ACE93B2B4564F7002C94D2 /* UIFont+Extension.swift in Sources */, A5ACE93B2B4564F7002C94D2 /* UIFont+Extension.swift in Sources */,
A5ACE9282B4564F7002C94D2 /* YHSmsCodeView.swift in Sources */, A5ACE9282B4564F7002C94D2 /* YHSmsCodeView.swift in Sources */,
0468D4432B61F76800CFB916 /* YHMainApplicantInformationViewController.swift in Sources */,
0468D4262B495A5400CFB916 /* YHPickPhoneAddressViewController.swift in Sources */, 0468D4262B495A5400CFB916 /* YHPickPhoneAddressViewController.swift in Sources */,
A5C5B32D2B57D66000A7C5D1 /* YHBbxCollectionViewCell.swift in Sources */, A5C5B32D2B57D66000A7C5D1 /* YHBbxCollectionViewCell.swift in Sources */,
A5ACE9342B4564F7002C94D2 /* YHAllApiName.swift in Sources */, A5ACE9342B4564F7002C94D2 /* YHAllApiName.swift in Sources */,
......
...@@ -147,5 +147,7 @@ extension YHServiceCenterMainViewController : UITableViewDelegate,UITableViewDat ...@@ -147,5 +147,7 @@ extension YHServiceCenterMainViewController : UITableViewDelegate,UITableViewDat
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true) tableView.deselectRow(at: indexPath, animated: true)
printLog("点击了 tableView Cell \(indexPath.row)") printLog("点击了 tableView Cell \(indexPath.row)")
let vc = YHMainApplicantInformationViewController()
self.navigationController?.pushViewController(vc)
} }
} }
//
// YHMainApplicantInformationViewController.swift
// galaxy
//
// Created by EDY on 2024/1/25.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHMainApplicantInformationViewController: YHBaseViewController {
var stepView: YHStepView!
var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
gk_navTitle = "主申请人信息填写"
setView()
// Do any additional setup after loading the view.
}
func setView() {
stepView = {
let step = YHStepView()
step.dataSource = ["初始信息", "证件上传", "基本信息", "证件信息"]
return step
}()
view.addSubview(stepView)
stepView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.right.equalTo(view)
make.height.equalTo(104)
}
tableView = {
let tableView = UITableView(frame:.zero, style:.plain)
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
tableView.register(YHDoubleChoiceFormCell.self, forCellReuseIdentifier: YHDoubleChoiceFormCell.cellReuseIdentifier)
tableView.register(YHSingleLineInputCell.self, forCellReuseIdentifier: YHSingleLineInputCell.cellReuseIdentifier)
tableView.register(YHSingleLineSelectCell.self, forCellReuseIdentifier: YHSingleLineSelectCell.cellReuseIdentifier)
tableView.register(YHFormTitleCell.self, forCellReuseIdentifier: YHFormTitleCell.cellReuseIdentifier)
tableView.register(YHFormAddInfoCell.self, forCellReuseIdentifier: YHFormAddInfoCell.cellReuseIdentifier)
return tableView
}()
view.addSubview(tableView)
tableView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar + 104)
make.left.right.bottom.equalTo(view)
}
}
}
extension YHMainApplicantInformationViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// let cell = tableView.dequeueReusableCell(withClass: <#T##T.Type#>)
let cell = UITableViewCell()
return cell
}
}
//
// YHStepView.swift
// galaxy
//
// Created by EDY on 2024/1/25.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHStepView: UIScrollView {
var dataSource: [String]? {
didSet {
setUpView(dataSource ?? [])
}
}
var currentIndex: Int = 3 {
didSet {
updateView(dataSource ?? [])
}
}
var stepSpace: CGFloat = 6
var lineWidth: CGFloat {
guard let dataSource = dataSource else { return 0 }
if dataSource.count <= 2 {
return 157
} else if dataSource.count <= 4 {
return 75
} else {
return 55
}
}
var spaceWidth: CGFloat {
guard let dataSource = dataSource else { return 0 }
if dataSource.count <= 2 {
return 89
} else if dataSource.count <= 4 {
return 43
} else {
return 43
}
}
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .white
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setUpView(_ array: [String]) {
for i in 0 ..< array.count {
let button = UIButton(type: .custom)
button.setBackgroundImage(UIImage(named: "service_step_fail"), for: .normal)
button.tag = 1000 + i
button.addTarget(self, action: #selector(buttonClick(_:)), for: .touchUpInside)
addSubview(button)
button.snp.makeConstraints { make in
make.top.equalTo(28)
make.left.equalTo(spaceWidth + i.cgFloat * (lineWidth + stepSpace * 2 + 14))
make.width.height.equalTo(14)
}
let label = UILabel()
label.text = array[i]
label.font = kFont(size: 13)
label.textAlignment = .center
label.tag = 2000 + i
label.textColor = UIColor.init(hex: 0x222222)
addSubview(label)
label.snp.makeConstraints { make in
make.centerX.equalTo(button.snp.centerX)
make.top.equalTo(button.snp.bottom).offset(14)
make.height.equalTo(20)
}
if i < array.count - 1 {
let line = UIImageView()
line.image = UIImage(named: "service_progress_success")
line.tag = 3000 + i
addSubview(line)
line.snp.makeConstraints { make in
make.centerY.equalTo(button.snp.centerY)
make.left.equalTo(button.snp.right).offset(stepSpace)
make.height.equalTo(3)
make.width.equalTo(lineWidth)
}
if i < currentIndex {
line.image = UIImage(named: "service_progress_success")
} else {
line.image = UIImage(named: "service_progress_fail")
}
}
if currentIndex == i {
button.setBackgroundImage(UIImage(named: "service_step_now"), for: .normal)
label.textColor = UIColor.init(hex: 0x4388ff)
} else if i < currentIndex {
button.setBackgroundImage(UIImage(named: "service_step_success"), for: .normal)
label.textColor = UIColor.init(hex: 0x222222)
} else {
button.setBackgroundImage(UIImage(named: "service_step_fail"), for: .normal)
label.textColor = UIColor.init(hex: 0xc0c0c0)
}
}
}
func updateView(_ array: [String]) {
for i in 0 ..< array.count {
let button = viewWithTag(1000 + i) as? UIButton
let lable = viewWithTag(2000 + i) as? UILabel
if i < array.count - 1 {
let line = viewWithTag(3000 + i) as? UIImageView
if i < currentIndex {
line?.image = UIImage(named: "service_progress_success")
} else {
line?.image = UIImage(named: "service_progress_fail")
}
}
if currentIndex == i {
button?.setBackgroundImage(UIImage(named: "service_step_now"), for: .normal)
lable?.textColor = UIColor.init(hex: 0x4388ff)
} else if i < currentIndex {
button?.setBackgroundImage(UIImage(named: "service_step_success"), for: .normal)
lable?.textColor = UIColor.init(hex: 0x222222)
} else {
button?.setBackgroundImage(UIImage(named: "service_step_fail"), for: .normal)
lable?.textColor = UIColor.init(hex: 0xc0c0c0)
}
}
}
@objc func buttonClick(_ button: UIButton) {
let tag = button.tag
if tag - 1000 < currentIndex {
currentIndex = tag - 1000
}
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "service_progress_fail@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "service_progress_fail@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "service_progress_success@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "service_progress_success@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "service_step_fail@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "service_step_fail@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "service_step_now@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "service_step_now@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "service_step_success@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "service_step_success@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment