2024-03-22 11:54:23 +08:00
|
|
|
//
|
|
|
|
// HomeSearchVC.swift
|
|
|
|
// yinmeng-ios
|
|
|
|
//
|
2024-03-23 20:47:19 +08:00
|
|
|
// Created by yinmeng on 2024/3/21.
|
2024-03-22 11:54:23 +08:00
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
class HomeSearchVC: BaseViewController,HiddenNavigationBarProtocol {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
setUILayout()
|
|
|
|
requestData()
|
|
|
|
}
|
|
|
|
private func setUILayout(){
|
|
|
|
view.addSubview(navView)
|
|
|
|
view.addSubview(pageTitleView)
|
|
|
|
view.addSubview(containerView)
|
|
|
|
view.backgroundColor = ThemeColor(hexStr: "#F8F8FB")
|
|
|
|
navView.snp.makeConstraints { make in
|
|
|
|
make.leading.trailing.top.equalTo(view)
|
|
|
|
make.height.equalTo(NavHeight)
|
|
|
|
}
|
|
|
|
|
|
|
|
pageTitleView.snp.makeConstraints { make in
|
|
|
|
make.leading.trailing.equalTo(view).inset(UIDevice.scaleWidth(width: 0))
|
|
|
|
make.top.equalTo(navView.snp.bottom).offset(UIDevice.scaleWidth(width: 10))
|
|
|
|
make.height.equalTo(UIDevice.scaleWidth(width: 50))
|
|
|
|
}
|
|
|
|
containerView.snp.makeConstraints { make in
|
|
|
|
make.top.equalTo(pageTitleView.snp.bottom).offset(UIDevice.scaleWidth(width: 10))
|
|
|
|
make.leading.trailing.bottom.equalTo(view)
|
|
|
|
}
|
|
|
|
navView.textField.delegate = self
|
|
|
|
navView.clickSearchBlcok = {[weak self] type in
|
|
|
|
guard let self = self else { return }
|
|
|
|
if type == 0{
|
|
|
|
self.dismiss(animated: true, completion: nil)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
self.roomView.requestData(text:self.navView.textField.text ?? "")
|
|
|
|
self.userView.requestData(text: self.navView.textField.text ?? "")
|
|
|
|
|
|
|
|
}
|
|
|
|
pageTitleView.listContainer = containerView
|
|
|
|
}
|
|
|
|
private func requestData(){
|
|
|
|
|
|
|
|
}
|
|
|
|
//MARK: - 懒加载
|
|
|
|
private lazy var navView:HomeSearchNavView = {
|
|
|
|
let _navView = HomeSearchNavView(frame: .zero)
|
|
|
|
|
|
|
|
return _navView
|
|
|
|
}()
|
|
|
|
|
|
|
|
private lazy var pageTitleView:JXCategoryTitleView = {
|
|
|
|
let _pageTitleView = JXCategoryTitleView()
|
|
|
|
_pageTitleView.delegate = self
|
|
|
|
_pageTitleView.titles = ["房间","用户"]
|
|
|
|
_pageTitleView.titleColor = ThemeColor(hexStr: "#878B9C")
|
|
|
|
_pageTitleView.titleSelectedColor = ThemeColor(hexStr: "#282828")
|
|
|
|
_pageTitleView.titleFont = UIFont.getScaleFont(ofSize: 16, weight: .medium)
|
|
|
|
_pageTitleView.titleSelectedFont = UIFont.getScaleFont(ofSize: 16, weight: .medium)
|
|
|
|
_pageTitleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyle.center
|
|
|
|
_pageTitleView.isContentScrollViewClickTransitionAnimationEnabled = false
|
|
|
|
_pageTitleView.defaultSelectedIndex = 0
|
|
|
|
let lineView = JXCategoryIndicatorLineView()
|
|
|
|
lineView.indicatorColor = ThemeColor(hexStr: "#FFE710")
|
|
|
|
lineView.indicatorWidth = UIDevice.scaleWidth(width: 8)
|
|
|
|
lineView.indicatorHeight = UIDevice.scaleWidth(width: 8) / 2
|
|
|
|
lineView.indicatorCornerRadius = UIDevice.scaleWidth(width: 8) / 4
|
|
|
|
_pageTitleView.indicators = [lineView]
|
|
|
|
return _pageTitleView
|
|
|
|
}()
|
|
|
|
private lazy var containerView:JXCategoryListContainerView = {
|
|
|
|
let _containerView = JXCategoryListContainerView.init(type: .scrollView, delegate: self)!
|
|
|
|
_containerView.setDefaultSelectedIndex(0)
|
|
|
|
return _containerView
|
|
|
|
}()
|
|
|
|
private lazy var roomView:HomeSearchRoomVC = {
|
|
|
|
let _roomView = HomeSearchRoomVC(type: 0)
|
|
|
|
|
|
|
|
return _roomView
|
|
|
|
}()
|
|
|
|
private lazy var userView:HomeSearchRoomVC = {
|
|
|
|
let _userView = HomeSearchRoomVC(type: 1)
|
|
|
|
|
|
|
|
return _userView
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
extension HomeSearchVC:JXCategoryListContainerViewDelegate,JXCategoryViewDelegate,UITextFieldDelegate{
|
|
|
|
func number(ofListsInlistContainerView listContainerView: JXCategoryListContainerView!) -> Int {
|
|
|
|
return 2
|
|
|
|
}
|
|
|
|
|
|
|
|
func listContainerView(_ listContainerView: JXCategoryListContainerView!, initListFor index: Int) -> JXCategoryListContentViewDelegate! {
|
|
|
|
return index == 0 ? roomView : userView
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
|
|
|
guard let text = textField.text else {
|
|
|
|
HUDTool.show(with: "请输入需要搜索的内容")
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
if text.count > 0{
|
|
|
|
textField.resignFirstResponder()
|
|
|
|
roomView.requestData(text: text)
|
|
|
|
userView.requestData(text: text)
|
|
|
|
}else{
|
|
|
|
HUDTool.show(with: "请输入需要搜索的内容")
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|