Commit 8e6715af authored by Steven杜宇's avatar Steven杜宇

// 首页身份tab子页面

parent c9f40434
......@@ -23,6 +23,9 @@
04174D7A2BCD5B74000BA46D /* YHDetailMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D722BCD5B74000BA46D /* YHDetailMessageCell.swift */; };
04213B202C47ADEA00797900 /* ATAuthSDK_D.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04213B1F2C47ADEA00797900 /* ATAuthSDK_D.framework */; };
04213B212C47AE0100797900 /* ATAuthSDK_D.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 04213B1F2C47ADEA00797900 /* ATAuthSDK_D.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
04213B232C48B7F700797900 /* YHIdentityTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04213B222C48B7F700797900 /* YHIdentityTabBar.swift */; };
04213B252C48C15400797900 /* YHHomeIdentityViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04213B242C48C15400797900 /* YHHomeIdentityViewController.swift */; };
04213B272C48C95E00797900 /* YHHomeIdentityCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04213B262C48C95E00797900 /* YHHomeIdentityCell.swift */; };
0425E63D2BA9345200A5E763 /* YHSchemeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0425E63C2BA9345200A5E763 /* YHSchemeTableViewCell.swift */; };
0425E6402BA9357D00A5E763 /* YHScemeItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0425E63F2BA9357D00A5E763 /* YHScemeItemModel.swift */; };
0425E6422BA95B1B00A5E763 /* YHSchemeTableFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0425E6412BA95B1B00A5E763 /* YHSchemeTableFooterView.swift */; };
......@@ -602,6 +605,9 @@
04174D712BCD5B74000BA46D /* YHMessageSessionCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHMessageSessionCell.swift; sourceTree = "<group>"; };
04174D722BCD5B74000BA46D /* YHDetailMessageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHDetailMessageCell.swift; sourceTree = "<group>"; };
04213B1F2C47ADEA00797900 /* ATAuthSDK_D.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ATAuthSDK_D.framework; path = framework/ATAuthSDK_D.framework; sourceTree = "<group>"; };
04213B222C48B7F700797900 /* YHIdentityTabBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHIdentityTabBar.swift; sourceTree = "<group>"; };
04213B242C48C15400797900 /* YHHomeIdentityViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeIdentityViewController.swift; sourceTree = "<group>"; };
04213B262C48C95E00797900 /* YHHomeIdentityCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeIdentityCell.swift; sourceTree = "<group>"; };
0425E63C2BA9345200A5E763 /* YHSchemeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSchemeTableViewCell.swift; sourceTree = "<group>"; };
0425E63F2BA9357D00A5E763 /* YHScemeItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHScemeItemModel.swift; sourceTree = "<group>"; };
0425E6412BA95B1B00A5E763 /* YHSchemeTableFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSchemeTableFooterView.swift; sourceTree = "<group>"; };
......@@ -2524,6 +2530,7 @@
A567E57A2BD7643D00D5D5A0 /* YHConfigManager.swift */,
A567E5762BD7643D00D5D5A0 /* YHHomePageViewController.swift */,
A5000F502C3BC28B00843452 /* YHHomeHoldViewPageViewController.swift */,
04213B242C48C15400797900 /* YHHomeIdentityViewController.swift */,
);
path = C;
sourceTree = "<group>";
......@@ -2559,6 +2566,8 @@
A566A7992C219FA400980D06 /* YHHomeSalonAreaView.swift */,
A566A79B2C227C9B00980D06 /* YHOrderTipsItemView.swift */,
04C85DE02C3677CB008B20D6 /* YHConsultantQRCodeView.swift */,
04213B222C48B7F700797900 /* YHIdentityTabBar.swift */,
04213B262C48C95E00797900 /* YHHomeIdentityCell.swift */,
);
path = V;
sourceTree = "<group>";
......@@ -3206,6 +3215,7 @@
045EEEF62B9F171A0022A143 /* YHSpousePrimaryInfoVC.swift in Sources */,
044867B82BA1C75700DFAD4A /* YHCertificateUploadFailTipsView.swift in Sources */,
044D0C062C22736F00C5CF5E /* YHSetExplainView.swift in Sources */,
04213B252C48C15400797900 /* YHHomeIdentityViewController.swift in Sources */,
045EEF002B9F171A0022A143 /* YHFormItemEnterDetailCell.swift in Sources */,
04FB01CE2C23DDBD0040115D /* YHPeopleMatchNoDataView.swift in Sources */,
A5ACE9362B4564F7002C94D2 /* YHNetworkStatusManager.swift in Sources */,
......@@ -3248,6 +3258,7 @@
04B9EE5B2C06CC3100A4018D /* YHOtherLoginViewController.swift in Sources */,
045EEF0C2B9F171A0022A143 /* YHBasicInfoFillBottomView.swift in Sources */,
A5ACE93D2B4564F7002C94D2 /* UIButton+Extension.swift in Sources */,
04213B232C48B7F700797900 /* YHIdentityTabBar.swift in Sources */,
04F5F86C2C1A9B52004A463C /* YHOtherServiceListViewController.swift in Sources */,
04CC2EF02BC3DDB2000305DD /* YHServiceBannerView.swift in Sources */,
045EEEA32B9F171A0022A143 /* YHCompanyModel.swift in Sources */,
......@@ -3475,6 +3486,7 @@
045EEECF2B9F171A0022A143 /* YHScoreOptionsView.swift in Sources */,
04CE1AD22C2AD91F001CB80A /* YHActivityModel.swift in Sources */,
0445E6AF2BE9CFF6003C52F9 /* YHAppVersionForceUpdateView.swift in Sources */,
04213B272C48C95E00797900 /* YHHomeIdentityCell.swift in Sources */,
04CE1AD32C2AD91F001CB80A /* YHTravelModel.swift in Sources */,
04B9EE5A2C06CC3100A4018D /* YHCodeSueecssViewController.swift in Sources */,
045EEEC12B9F171A0022A143 /* YHOtherInfoFillModel.swift in Sources */,
......
//
// YHHomeIdentityViewController.swift
// galaxy
//
// Created by edy on 2024/7/18.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import JXSegmentedView
class YHHomeIdentityViewController: YHBaseViewController {
lazy var subTabBar: YHIdentityTabBar = {
let items = [YHIdentityTabBarItem(title: "优才", type: .talent),
YHIdentityTabBarItem(title: "高才", type: .high),
YHIdentityTabBarItem(title: "专才", type: .expert),
YHIdentityTabBarItem(title: "留学", type: .study)]
let bar = YHIdentityTabBar.tabBarForItems(items)
bar.selectBlock = {
[weak self] type in
guard let self = self else { return }
}
return bar
}()
lazy var tableView: UITableView = {
let tableView = UITableView(frame: CGRect.zero, style:.grouped)
tableView.contentInsetAdjustmentBehavior = .never
tableView.showsVerticalScrollIndicator = false
tableView.backgroundColor = UIColor.white
tableView.separatorStyle = .none
tableView.register(YHHomeIdentityCell.self, forCellReuseIdentifier: YHHomeIdentityCell.cellReuseIdentifier)
tableView.delegate = self
tableView.dataSource = self
tableView.tableHeaderView = self.headerView
return tableView
}()
lazy var headerView:UIView = {
let view = UIView(frame: CGRectMake(0, 0, KScreenWidth, KScreenWidth+44.0+8.0))
view.backgroundColor = .white
let imgView = UIImageView()
imgView.backgroundColor = .red
view.addSubview(imgView)
imgView.snp.makeConstraints { make in
make.left.top.right.equalToSuperview()
make.height.equalTo(imgView.snp.width)
}
self.segmentedView.dataSource = segmentedDataSource
view.addSubview(self.segmentedView)
segmentedView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.height.equalTo(44)
make.top.equalTo(imgView.snp.bottom).offset(8.0)
}
return view
}()
lazy var segmentedView : JXSegmentedView = {
let segmentedView = JXSegmentedView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 44))
segmentedView.delegate = self
//配置指示器
let indicator = JXSegmentedIndicatorLineView()
indicator.indicatorWidth = 16
indicator.indicatorHeight = 2
indicator.indicatorCornerRadius = 0.0
indicator.indicatorColor = .brandMainColor
segmentedView.indicators = [indicator]
segmentedView.defaultSelectedIndex = 0
return segmentedView
}()
lazy var segmentedDataSource: JXSegmentedTitleDataSource = {
let dataSource = JXSegmentedTitleDataSource()
dataSource.titles = ["项目介绍", "申请条件", "申请流程", "费用详情"]
dataSource.titleNormalFont = UIFont.PFSC_R(ofSize: 16)
dataSource.titleNormalColor = UIColor.init(hex: 0x94A3B8)
dataSource.titleSelectedFont = UIFont.PFSC_M(ofSize: 16)
dataSource.titleSelectedColor = .mainTextColor
dataSource.itemWidth = JXSegmentedViewAutomaticDimension
dataSource.itemSpacing = 22.0
return dataSource
}()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
createUI()
}
func createUI() {
self.view.addSubview(self.tableView)
self.view.addSubview(self.subTabBar)
self.subTabBar.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.equalTo(20)
make.right.equalTo(-20)
make.height.equalTo(44)
}
self.tableView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar+44)
make.left.right.bottom.equalToSuperview()
}
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
printLog("offset: \(scrollView.contentOffset.y)")
}
}
extension YHHomeIdentityViewController: JXSegmentedViewDelegate {
func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
let sectionRect = self.tableView.rectForHeader(inSection: index)
printLog("sectionRect:\(sectionRect)")
self.tableView.scrollToRow(at: IndexPath(row: 0, section: index), at: .top, animated: true)
// DispatchQueue.main.asyncAfter(deadline: .now() + 0.2, execute: {
// var gap = 0.0
// // 此处处理内容总长度不够滚到相应tab的差距
// let sectionRect = self.tableView.rectForHeader(inSection: index)
// if self.tableView.contentOffset.y >= 0.0, sectionRect.origin.y > self.tableView.contentOffset.y {
// gap = sectionRect.origin.y - self.tableView.contentOffset.y
// }
// let offsetY = self.tableView.contentOffset.y + gap
// self.tableView.setContentOffset(CGPointMake(0, offsetY+4), animated: true)
// })
}
}
extension YHHomeIdentityViewController: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHHomeIdentityCell.cellReuseIdentifier, for: indexPath) as! YHHomeIdentityCell
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 300
}
func numberOfSections(in tableView: UITableView) -> Int {
return 4
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 0.01
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.01
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
}
//
// YHHomeIdentityCell.swift
// galaxy
//
// Created by edy on 2024/7/18.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeIdentityCell: UITableViewCell {
static let cellReuseIdentifier = "YHHomeIdentityCell"
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 setupUI() {
let randomRed = CGFloat.random(in: 0...1)
let randomGreen = CGFloat.random(in: 0...1)
let randomBlue = CGFloat.random(in: 0...1)
let randomColor = UIColor(displayP3Red: randomRed, green: randomGreen, blue: randomBlue, alpha: 1.0)
self.contentView.backgroundColor = randomColor
}
}
//
// YHIdentityTabBar.swift
// galaxy
//
// Created by edy on 2024/7/18.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
enum YHIdentityTabBarType:Int {
case none = 0
case talent = 1 // 优才
case high = 2 // 高才
case expert = 3 // 专才
case study = 4 // 留学
}
class YHIdentityTabBarItem {
var title: String = ""
var type: YHIdentityTabBarType = .none
init(title: String, type: YHIdentityTabBarType) {
self.title = title
self.type = type
}
}
class YHIdentityTabBar: UIView {
static let baseTag = 9527
static let itemWidth = 50.0
static let itemHeight = 26.0
static let gap = 10.0
var selectType: YHIdentityTabBarType = .talent
var selectBlock:((YHIdentityTabBarType)->Void)?
static func tabBarForItems(_ items: [YHIdentityTabBarItem]) -> YHIdentityTabBar {
let width = Self.itemWidth * Double(items.count) + Self.gap * Double(items.count-1)
let bar = YHIdentityTabBar(frame: CGRect(x: 0, y: 0, width: width, height: 44.0))
bar.updateItems(items)
return bar
}
func updateItems(_ items: [YHIdentityTabBarItem]) {
self.removeSubviews()
for (index, item) in items.enumerated() {
let x = (Self.itemWidth+Self.gap) * Double(index)
let btn = UIButton(type: .custom)
btn.titleLabel?.font = UIFont.PFSC_R(ofSize: 13)
btn.setTitle(item.title, for: .normal)
btn.layer.borderWidth = 0.5
self.setButton(btn, isSelected: index == 0)
btn.tag = Self.baseTag + index + 1
btn.addTarget(self, action: #selector(didTabButtonClicked(_:)), for: .touchUpInside)
self.addSubview(btn)
btn.snp.makeConstraints { make in
make.left.equalTo(x)
make.centerY.equalToSuperview()
make.width.equalTo(Self.itemWidth)
make.height.equalTo(Self.itemHeight)
}
}
}
func setButton(_ btn: UIButton, isSelected:Bool) {
let titleColor = isSelected ? UIColor.mainTextColor : UIColor.mainTextColor50
let borderColor = isSelected ? UIColor.mainTextColor : UIColor.mainTextColor(alpha:0.18)
btn.setTitleColor(titleColor, for: .normal)
btn.layer.borderColor = borderColor.cgColor
}
@objc func didTabButtonClicked(_ selectBtn: UIButton) {
self.selectType = YHIdentityTabBarType(rawValue: selectBtn.tag-Self.baseTag) ?? .talent
for (index, item) in self.subviews.enumerated() {
if item.isKind(of: UIButton.self) {
let itemBtn = item as! UIButton
self.setButton(itemBtn, isSelected: itemBtn.tag == selectBtn.tag)
}
}
self.selectBlock?(self.selectType)
}
}
......@@ -42,6 +42,10 @@ extension UIColor {
static let mainTextColor50 : UIColor = UIColor(hexString: "#121A26",transparency: 0.5)!
static let mainTextColor70 : UIColor = UIColor(hexString: "#121A26",transparency: 0.7)!
public static func mainTextColor(alpha:CGFloat) -> UIColor {
return UIColor(hexString: "#121A26",transparency: alpha)!
}
//次内容一
static let subTextColor : UIColor = UIColor(hexString: "#4E4E4E")!
......
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