//
|
// HomeItemListVC.swift
|
// XQMuse
|
//
|
// Created by 无故事王国 on 2024/8/14.
|
//
|
|
import UIKit
|
import JQTools
|
|
class HomeItemViewModel:RefreshModel<SimpleModel>{
|
|
}
|
|
|
class HomeItemListVC: BaseVC {
|
|
private var collectionView:UICollectionView!
|
private var topTitle:String!
|
private var id:Int!
|
|
private var viewModel = HomeItemViewModel()
|
|
init(topTitle:String,id:Int) {
|
super.init(nibName: nil, bundle: nil)
|
self.topTitle = topTitle
|
self.id = id
|
}
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
title = self.topTitle
|
|
viewModel.configure(collectionView)
|
}
|
|
override func setUI() {
|
view.backgroundColor = UIColor(hexString: "#f6f6f6")
|
let layout = UICollectionViewFlowLayout()
|
let w = (JQ_ScreenW - 21.5 * 2 - 13.5) / 2
|
let h = w * 1.3142
|
layout.itemSize = CGSize(width: w, height: h)
|
layout.minimumLineSpacing = 13.5
|
layout.minimumInteritemSpacing = 13.5
|
layout.headerReferenceSize = CGSize(width: JQ_ScreenW, height: 20)
|
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
collectionView.delegate = self
|
collectionView.dataSource = self
|
collectionView.backgroundColor = UIColor(hexString: "#f6f6f6")
|
collectionView.contentInset = UIEdgeInsets(top: 0, left: 21.5, bottom: 0, right: 21.5)
|
collectionView.register(UINib(nibName: "HomeRelaxBanner_2_CCell", bundle: nil), forCellWithReuseIdentifier: "_HomeRelaxBanner_2_CCell")
|
view.addSubview(collectionView)
|
collectionView.snp.makeConstraints { make in
|
make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top).offset(0)
|
make.right.bottom.left.equalToSuperview()
|
}
|
}
|
|
required init?(coder: NSCoder) {
|
fatalError("init(coder:) has not been implemented")
|
}
|
}
|
|
extension HomeItemListVC:UICollectionViewDelegate & UICollectionViewDataSource{
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBanner_2_CCell", for: indexPath) as! HomeRelaxBanner_2_CCell
|
cell.backgroundColor = .jq_randomColor
|
return cell
|
}
|
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
return 50
|
}
|
|
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
let vc = HomeItemDetailVC()
|
push(vc: vc)
|
}
|
}
|