Commit 07838037 authored by Steven杜宇's avatar Steven杜宇

// add 搜索列表

parent 38ea9c10
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
044E1E852BC3BEC300A3B4AF /* YHSearchInfoHistoryCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044E1E842BC3BEC300A3B4AF /* YHSearchInfoHistoryCell.swift */; }; 044E1E852BC3BEC300A3B4AF /* YHSearchInfoHistoryCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044E1E842BC3BEC300A3B4AF /* YHSearchInfoHistoryCell.swift */; };
044E1E872BC3D00E00A3B4AF /* YHSearchItemLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044E1E862BC3D00E00A3B4AF /* YHSearchItemLayout.swift */; }; 044E1E872BC3D00E00A3B4AF /* YHSearchItemLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044E1E862BC3D00E00A3B4AF /* YHSearchItemLayout.swift */; };
044E1E892BC3D7DF00A3B4AF /* YHSearchInfoBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044E1E882BC3D7DF00A3B4AF /* YHSearchInfoBar.swift */; }; 044E1E892BC3D7DF00A3B4AF /* YHSearchInfoBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044E1E882BC3D7DF00A3B4AF /* YHSearchInfoBar.swift */; };
044E1E8B2BC3E1CE00A3B4AF /* YHSearchInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044E1E8A2BC3E1CE00A3B4AF /* YHSearchInfoCell.swift */; };
045EEE792B9F171A0022A143 /* YHPreviewViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 045EED9A2B9F171A0022A143 /* YHPreviewViewModel.swift */; }; 045EEE792B9F171A0022A143 /* YHPreviewViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 045EED9A2B9F171A0022A143 /* YHPreviewViewModel.swift */; };
045EEE7A2B9F171A0022A143 /* YHPreviewForOtherInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 045EED9C2B9F171A0022A143 /* YHPreviewForOtherInfoModel.swift */; }; 045EEE7A2B9F171A0022A143 /* YHPreviewForOtherInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 045EED9C2B9F171A0022A143 /* YHPreviewForOtherInfoModel.swift */; };
045EEE7B2B9F171A0022A143 /* YHPersonInfoCellModel2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 045EED9D2B9F171A0022A143 /* YHPersonInfoCellModel2.swift */; }; 045EEE7B2B9F171A0022A143 /* YHPersonInfoCellModel2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 045EED9D2B9F171A0022A143 /* YHPersonInfoCellModel2.swift */; };
...@@ -464,6 +465,7 @@ ...@@ -464,6 +465,7 @@
044E1E842BC3BEC300A3B4AF /* YHSearchInfoHistoryCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSearchInfoHistoryCell.swift; sourceTree = "<group>"; }; 044E1E842BC3BEC300A3B4AF /* YHSearchInfoHistoryCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSearchInfoHistoryCell.swift; sourceTree = "<group>"; };
044E1E862BC3D00E00A3B4AF /* YHSearchItemLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHSearchItemLayout.swift; sourceTree = "<group>"; }; 044E1E862BC3D00E00A3B4AF /* YHSearchItemLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHSearchItemLayout.swift; sourceTree = "<group>"; };
044E1E882BC3D7DF00A3B4AF /* YHSearchInfoBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSearchInfoBar.swift; sourceTree = "<group>"; }; 044E1E882BC3D7DF00A3B4AF /* YHSearchInfoBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSearchInfoBar.swift; sourceTree = "<group>"; };
044E1E8A2BC3E1CE00A3B4AF /* YHSearchInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSearchInfoCell.swift; sourceTree = "<group>"; };
045EED9A2B9F171A0022A143 /* YHPreviewViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHPreviewViewModel.swift; sourceTree = "<group>"; }; 045EED9A2B9F171A0022A143 /* YHPreviewViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHPreviewViewModel.swift; sourceTree = "<group>"; };
045EED9C2B9F171A0022A143 /* YHPreviewForOtherInfoModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHPreviewForOtherInfoModel.swift; sourceTree = "<group>"; }; 045EED9C2B9F171A0022A143 /* YHPreviewForOtherInfoModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHPreviewForOtherInfoModel.swift; sourceTree = "<group>"; };
045EED9D2B9F171A0022A143 /* YHPersonInfoCellModel2.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHPersonInfoCellModel2.swift; sourceTree = "<group>"; }; 045EED9D2B9F171A0022A143 /* YHPersonInfoCellModel2.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHPersonInfoCellModel2.swift; sourceTree = "<group>"; };
...@@ -2159,6 +2161,7 @@ ...@@ -2159,6 +2161,7 @@
044E1E862BC3D00E00A3B4AF /* YHSearchItemLayout.swift */, 044E1E862BC3D00E00A3B4AF /* YHSearchItemLayout.swift */,
044E1E822BC3BBFC00A3B4AF /* YHSearchInfoHistoryView.swift */, 044E1E822BC3BBFC00A3B4AF /* YHSearchInfoHistoryView.swift */,
044E1E842BC3BEC300A3B4AF /* YHSearchInfoHistoryCell.swift */, 044E1E842BC3BEC300A3B4AF /* YHSearchInfoHistoryCell.swift */,
044E1E8A2BC3E1CE00A3B4AF /* YHSearchInfoCell.swift */,
044E1E882BC3D7DF00A3B4AF /* YHSearchInfoBar.swift */, 044E1E882BC3D7DF00A3B4AF /* YHSearchInfoBar.swift */,
A5173D692BC3C187007D4E74 /* YHHkLifeAndIdView.swift */, A5173D692BC3C187007D4E74 /* YHHkLifeAndIdView.swift */,
A5173D6B2BC3C273007D4E74 /* YHHomeKingKongBlockView.swift */, A5173D6B2BC3C273007D4E74 /* YHHomeKingKongBlockView.swift */,
...@@ -2447,6 +2450,7 @@ ...@@ -2447,6 +2450,7 @@
045EEED22B9F171A0022A143 /* YHScoreTitleView.swift in Sources */, 045EEED22B9F171A0022A143 /* YHScoreTitleView.swift in Sources */,
A5ACE95E2B4571BF002C94D2 /* YHHomeViewController.swift in Sources */, A5ACE95E2B4571BF002C94D2 /* YHHomeViewController.swift in Sources */,
045EEEA72B9F171A0022A143 /* YHWorkExperienceViewController.swift in Sources */, 045EEEA72B9F171A0022A143 /* YHWorkExperienceViewController.swift in Sources */,
044E1E8B2BC3E1CE00A3B4AF /* YHSearchInfoCell.swift in Sources */,
A5FD63BD2B623C2C00D1D9DA /* YHInformationPerfectListVC.swift in Sources */, A5FD63BD2B623C2C00D1D9DA /* YHInformationPerfectListVC.swift in Sources */,
045EEE8D2B9F171A0022A143 /* YHPreviewInfoCell.swift in Sources */, 045EEE8D2B9F171A0022A143 /* YHPreviewInfoCell.swift in Sources */,
045EEF0C2B9F171A0022A143 /* YHBasicInfoFillBottomView.swift in Sources */, 045EEF0C2B9F171A0022A143 /* YHBasicInfoFillBottomView.swift in Sources */,
......
...@@ -10,16 +10,121 @@ import UIKit ...@@ -10,16 +10,121 @@ import UIKit
class YHSearchInfomationVC: YHBaseViewController { class YHSearchInfomationVC: YHBaseViewController {
var searchHistoryView: YHSearchInfoHistoryView = { var items:[String] = ["阿斯顿法师法师法师","发大水发生大法师懂法守法三大发沙发沙发沙发沙发沙发啥打法上大V撒大V啊三大发啥打法四大法守法","发大水发生大法师懂法守法三大发沙发沙发沙发沙发沙发啥打法上大V撒大V啊三大发啥打法四大法守法发大水发生大法师懂法守法三大发沙发沙发沙发沙发沙发啥打法上大V撒大V啊三大发啥打法四大法守法","啊发顺丰"]
let view = YHSearchInfoHistoryView(frame: CGRect(x: 0, y: k_Height_NavigationtBarAndStatuBar, width: KScreenWidth, height: KScreenHeight-k_Height_NavigationtBarAndStatuBar))
lazy var searchBar: YHSearchInfoBar = {
let bar = YHSearchInfoBar(frame: CGRect(x: 20, y: k_Height_NavigationtBarAndStatuBar+8.0, width: KScreenWidth-40, height: 36.0))
return bar
}()
lazy var searchHistoryView: YHSearchInfoHistoryView = {
let view = YHSearchInfoHistoryView(frame: CGRect(x: 0, y: searchBar.frame.maxY+8, width: KScreenWidth, height: KScreenHeight-searchBar.frame.maxY-8))
view.selectBlock = {
[weak self] text in
guard let self = self else { return }
self.searchHistoryView.isHidden = true
self.tableView.isHidden = false
}
return view return view
}() }()
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
tableView.estimatedSectionHeaderHeight = 0.1
tableView.estimatedSectionFooterHeight = 20.0
tableView.showsVerticalScrollIndicator = false
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.backgroundColor = .white
tableView.register(YHSearchInfoCell.self, forCellReuseIdentifier: YHSearchInfoCell.cellReuseIdentifier)
return tableView
}()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = .white view.backgroundColor = .white
view.addSubview(searchBar)
view.addSubview(searchHistoryView) view.addSubview(searchHistoryView)
view.addSubview(tableView)
searchBar.snp.makeConstraints { make in
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar+8.0)
make.height.equalTo(36.0)
}
searchHistoryView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(searchBar.snp.bottom).offset(20)
make.bottom.equalToSuperview()
}
tableView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(searchBar.snp.bottom).offset(8+20)
make.bottom.equalToSuperview()
}
}
}
extension YHSearchInfomationVC: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return items.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHSearchInfoCell.cellReuseIdentifier, for: indexPath) as! YHSearchInfoCell
if 0 <= indexPath.section && indexPath.section < items.count {
let item = items[indexPath.section]
cell.titleLabel.text = items[indexPath.section]
}
return cell
} }
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 70.0
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if 0 <= indexPath.section && indexPath.section < items.count {
let text = items[indexPath.section]
self.tableView.isHidden = true
self.searchHistoryView.isHidden = false
}
}
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
return 0.1
}
private func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> CGFloat {
return 20.0
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return UIView()
}
} }
...@@ -11,7 +11,6 @@ import UIKit ...@@ -11,7 +11,6 @@ import UIKit
class YHSearchInfoBar: UIView { class YHSearchInfoBar: UIView {
static let height = 36.0 static let height = 36.0
static let cancelBtnHeight = height-8.0
static let maxWordsCount = 50 static let maxWordsCount = 50
var textChange:((String?)->Void)? var textChange:((String?)->Void)?
...@@ -25,24 +24,23 @@ class YHSearchInfoBar: UIView { ...@@ -25,24 +24,23 @@ class YHSearchInfoBar: UIView {
} }
private lazy var contentView = { private lazy var contentView = {
let view = UIView() let view = UIView()
view.backgroundColor = .contentBkgColor view.backgroundColor = UIColor(hex: 0xF4F6FA)
view.layer.cornerRadius = Self.height/2.0
view.clipsToBounds = true view.clipsToBounds = true
return view return view
}() }()
lazy var searchImgView: UIImageView = { lazy var searchImgView: UIImageView = {
let imgView = UIImageView(image: UIImage(named: "")) let imgView = UIImageView(image: UIImage(named: "home_search_icon"))
return imgView return imgView
}() }()
lazy var textField:UITextField = { lazy var textField:UITextField = {
let textField = UITextField() let textField = UITextField()
textField.backgroundColor = .clear textField.backgroundColor = .clear
textField.attributedPlaceholder = NSAttributedString(string: "请输入关键词搜索".local, attributes: [NSAttributedString.Key.foregroundColor : UIColor.placeHolderColor]) textField.attributedPlaceholder = NSAttributedString(string: "大家正在搜香港身份".local, attributes: [NSAttributedString.Key.foregroundColor : UIColor(hex: 0x94A3B8)])
textField.font = UIFont.PFSC_M(ofSize: 12) textField.font = UIFont.PFSC_M(ofSize: 12)
textField.tintColor = UIColor(hexString: "#3D88F8") textField.tintColor = UIColor(hex: 0x3570DC)
textField.textColor = UIColor.mainTextColor textField.textColor = UIColor(hexString: "#121A26")
textField.clearButtonMode = .whileEditing textField.clearButtonMode = .whileEditing
textField.addTarget(self, action: #selector(textFieldChanged(textField:)), for: .editingChanged) textField.addTarget(self, action: #selector(textFieldChanged(textField:)), for: .editingChanged)
textField.delegate = self textField.delegate = self
...@@ -52,10 +50,9 @@ class YHSearchInfoBar: UIView { ...@@ -52,10 +50,9 @@ class YHSearchInfoBar: UIView {
lazy var searchBtn: UIButton = { lazy var searchBtn: UIButton = {
let btn = UIButton() let btn = UIButton()
btn.setTitle("搜索".local, for: .normal) btn.setTitle("搜索".local, for: .normal)
btn.titleLabel?.font = UIFont.PFSC_M(ofSize: 12) btn.titleLabel?.font = UIFont.PFSC_R(ofSize: 12)
btn.setTitleColor(.white, for: .normal) btn.setTitleColor(.white, for: .normal)
btn.backgroundColor = UIColor(hexString: "#3D88F8") btn.backgroundColor = UIColor(hexString: "#3570DC")
btn.layer.cornerRadius = Self.cancelBtnHeight/2.0
btn.addTarget(self, action: #selector(searchBtnClicked), for: .touchUpInside) btn.addTarget(self, action: #selector(searchBtnClicked), for: .touchUpInside)
return btn return btn
}() }()
...@@ -69,11 +66,6 @@ class YHSearchInfoBar: UIView { ...@@ -69,11 +66,6 @@ class YHSearchInfoBar: UIView {
super.init(coder: coder) super.init(coder: coder)
} }
static func createBar() -> YHCertificateSearchBar {
let view = YHCertificateSearchBar(frame: CGRect(x: 0, y: 0, width: KScreenWidth-32, height: height))
return view
}
@objc func searchBtnClicked() { @objc func searchBtnClicked() {
if let searchBlock = searchBlock { if let searchBlock = searchBlock {
searchBlock(textField.text) searchBlock(textField.text)
...@@ -90,6 +82,7 @@ class YHSearchInfoBar: UIView { ...@@ -90,6 +82,7 @@ class YHSearchInfoBar: UIView {
self.backgroundColor = .white self.backgroundColor = .white
setSearchButtonEnable(false) setSearchButtonEnable(false)
contentView.addSubview(searchImgView)
contentView.addSubview(textField) contentView.addSubview(textField)
contentView.addSubview(searchBtn) contentView.addSubview(searchBtn)
self.addSubview(contentView) self.addSubview(contentView)
...@@ -98,14 +91,20 @@ class YHSearchInfoBar: UIView { ...@@ -98,14 +91,20 @@ class YHSearchInfoBar: UIView {
make.edges.equalToSuperview() make.edges.equalToSuperview()
} }
searchImgView.snp.makeConstraints { make in
make.width.height.equalTo(16.0)
make.centerY.equalToSuperview()
make.left.equalToSuperview().offset(12.0)
}
textField.snp.makeConstraints { make in textField.snp.makeConstraints { make in
make.left.equalToSuperview().offset(Self.height/2.0) make.left.equalTo(searchImgView.snp.right).offset(8)
make.right.equalTo(searchBtn.snp.left).offset(-4) make.right.equalTo(searchBtn.snp.left).offset(-4)
make.centerY.equalToSuperview() make.top.bottom.equalToSuperview()
} }
searchBtn.snp.makeConstraints { make in searchBtn.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: 66, height: Self.height-8.0)) make.size.equalTo(CGSize(width: 56, height: Self.height-8.0))
make.centerY.equalToSuperview() make.centerY.equalToSuperview()
make.right.equalToSuperview().offset(-4) make.right.equalToSuperview().offset(-4)
} }
......
//
// YHSearchInfoCell.swift
// galaxy
//
// Created by edy on 2024/4/8.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHSearchInfoCell: UITableViewCell {
static let cellReuseIdentifier = "YHSearchInfoCell"
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")
}
lazy var headImgView: UIImageView = {
let imagV = UIImageView()
imagV.contentMode = .scaleAspectFill
imagV.clipsToBounds = true
imagV.image = UIImage(named: "home_cell0_head_icon")
return imagV
}()
lazy var titleLabel: UILabel = {
var label = UILabel()
label.font = .PFSC_R(ofSize: 12)
label.textAlignment = .left
label.textColor = UIColor(hex: 0x121A26)
label.numberOfLines = 2
return label
}()
func setupUI() {
contentView.backgroundColor = .white
contentView.addSubview(headImgView)
contentView.addSubview(titleLabel)
headImgView.snp.makeConstraints { make in
make.width.height.equalTo(70.0)
make.centerY.equalToSuperview()
make.left.equalToSuperview().offset(20)
}
titleLabel.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.left.equalTo(headImgView.snp.right).offset(20)
make.right.equalToSuperview().offset(-20)
}
}
}
...@@ -12,6 +12,9 @@ class YHSearchInfoHistoryView: UIView { ...@@ -12,6 +12,9 @@ class YHSearchInfoHistoryView: UIView {
var historyItems:[String] = ["阿法守法发生懂法守法阿法守法发生懂法守法阿法守法发生懂法守法阿法守法发生懂法守法", "几天萨法", "阿德", "守法", "几天萨法", "德", "阿法守法发生懂法守法", "阿德", "几天", "阿德", "守法", "几天萨法"] var historyItems:[String] = ["阿法守法发生懂法守法阿法守法发生懂法守法阿法守法发生懂法守法阿法守法发生懂法守法", "几天萨法", "阿德", "守法", "几天萨法", "德", "阿法守法发生懂法守法", "阿德", "几天", "阿德", "守法", "几天萨法"]
// var historyItems:[String] = ["几天2345", "阿", "萨法", "阿德"] // var historyItems:[String] = ["几天2345", "阿", "萨法", "阿德"]
var selectBlock:((String)->())?
let interItemSpacing: CGFloat = 12.0 // 相邻单元格之间的水平间距 let interItemSpacing: CGFloat = 12.0 // 相邻单元格之间的水平间距
let gap: CGFloat = 12.0 let gap: CGFloat = 12.0
let cellHeight: CGFloat = 30.0 // 单元格的固定高度 let cellHeight: CGFloat = 30.0 // 单元格的固定高度
...@@ -103,4 +106,11 @@ extension YHSearchInfoHistoryView: UICollectionViewDelegate, UICollectionViewDat ...@@ -103,4 +106,11 @@ extension YHSearchInfoHistoryView: UICollectionViewDelegate, UICollectionViewDat
} }
return cell return cell
} }
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if 0 <= indexPath.item && indexPath.item < historyItems.count {
let text = historyItems[indexPath.item]
selectBlock?(text)
}
}
} }
...@@ -198,11 +198,11 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource { ...@@ -198,11 +198,11 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource {
if (indexPath.row >= items.count) { return } if (indexPath.row >= items.count) { return }
if true { // if true {
let vc = YHSearchInfomationVC() // let vc = YHSearchInfomationVC()
self.navigationController?.pushViewController(vc) // self.navigationController?.pushViewController(vc)
return // return
} // }
if !checkLogin() { if !checkLogin() {
let vc = UINavigationController(rootVC: YHPhoneLoginViewController()) let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
......
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