| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- //
- // QSLMineFuncView.swift
- // QuickSearchLocation
- //
- // Created by Destiny on 2024/4/16.
- //
- import UIKit
- protocol QSLMineFuncViewDelegate: NSObjectProtocol {
-
- func didSelectRowAt(indexPath: IndexPath)
- }
- class QSLMineFuncView: UIView {
-
- struct UX {
- static let collectionWidth = (QSLConst.qsl_kScreenW - 24.0) / 4
- static let collectionHeight = 76.0
- }
-
- weak var delegate: QSLMineFuncViewDelegate?
-
- var viewModel: QSLMineViewModel?
-
- lazy var funcTableView: UITableView = {
-
- let tableView = UITableView(frame: .zero, style: .grouped)
- tableView.backgroundColor = .clear
- tableView.separatorStyle = .none
- tableView.showsVerticalScrollIndicator = false
- tableView.delegate = self
- tableView.dataSource = self
- tableView.tableViewNeverAdjustContentInset()
- tableView.bounces = false
- tableView.isUserInteractionEnabled = true
- tableView.isScrollEnabled = false
- tableView.contentInsetAdjustmentBehavior = .never
- tableView.register(cellClass: QSLMineFuncTableViewCell.self)
-
- return tableView
- }()
-
- override init(frame: CGRect) {
- super.init(frame: frame)
-
- setUpUI()
- }
-
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
- // MARK: - 设置UI
- extension QSLMineFuncView {
-
- func setUpUI() {
-
- addSubview(funcTableView)
-
- self.addRadius(radius: 6)
- self.backgroundColor = .white
-
- funcTableView.snp.makeConstraints { make in
- make.left.right.bottom.equalTo(0)
- make.top.equalTo(0)
- }
- }
- }
- // MARK: - 设置Tableview
- extension QSLMineFuncView: UITableViewDelegate, UITableViewDataSource {
-
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- guard let funcLists = viewModel?.funcLists else { return 0 }
- return funcLists.count
- }
-
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-
- let cell = tableView.dequeueReusableCell(cellType: QSLMineFuncTableViewCell.self, cellForRowAt: indexPath)
- cell.selectionStyle = .none
- let funcModel = viewModel?.funcLists[indexPath.row]
- cell.cellDict = funcModel
- return cell
- }
-
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- delegate?.didSelectRowAt(indexPath: indexPath)
- }
-
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- return QSLMineViewModel.UX.funcCellHeight
- }
-
- func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
- return 14.rpx
- }
-
- func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
- return 14.rpx
- }
-
- }
|