Music_Player3/MusicPlayer/MP/MPPositive/ViewControllers/Home(首页,各项列表页,艺术家页)/MPPositive_MoreContentViewController.swift
2024-05-29 13:20:07 +08:00

99 lines
4.3 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// MPPositive_MoreContentViewController.swift
// MusicPlayer
//
// Created by Mr.Zhou on 2024/4/28.
//
import UIKit
/////
class MPPositive_MoreContentViewController: MPPositive_BaseViewController {
//
enum MoreShowType: Int {
case Single = 0
case List = 1
//Layout
var layout:UICollectionViewFlowLayout{
let layout = UICollectionViewFlowLayout()
layout.sectionInset = .init(top: 0, left: 18*width, bottom: 50*width, right: 16*width)
switch self {
case .Single:
layout.itemSize = .init(width: 339*width, height: 237*width)
layout.minimumLineSpacing = 32*width
case .List:
layout.itemSize = .init(width: 162*width, height: 210*width)
layout.minimumLineSpacing = 32*width
layout.minimumInteritemSpacing = 15*width
}
return layout
}
}
///
private var showType:MoreShowType = .Single{
didSet{
collectionView.collectionViewLayout = showType.layout
collectionView.reloadData()
}
}
private lazy var collectionView:UICollectionView = {
let collectionView:UICollectionView = .init(frame: .init(x: 0, y: 0, width: screen_Width, height: screen_Height), collectionViewLayout: showType.layout)
collectionView.showsVerticalScrollIndicator = false
collectionView.showsHorizontalScrollIndicator = false
collectionView.backgroundColor = .clear
collectionView.dataSource = self
collectionView.delegate = self
collectionView.register(MPPositive_MoreListContentCollectionViewCell.self, forCellWithReuseIdentifier: MPPositive_MoreListContentCollectionViewCellID)
collectionView.register(MPPositive_HomeListFifthCollectionViewCell.self, forCellWithReuseIdentifier: MPPositive_HomeListFifthCollectionViewCellID)
collectionView.contentInset = .init(top: 0, left: 0, bottom: 70*width, right: 0)
return collectionView
}()
//cell
private let MPPositive_MoreListContentCollectionViewCellID = "MPPositive_MoreListContentCollectionViewCell"
//cell
private let MPPositive_HomeListFifthCollectionViewCellID = "MPPositive_HomeListFifthCollectionViewCell"
//
var browseModuleList:MPPositive_BrowseModuleListViewModel!
override func viewDidLoad() {
super.viewDidLoad()
setTitle("Report")
setPopBtn()
confirgue()
}
private func confirgue() {
view.backgroundColor = .init(hex: "#121212")
view.addSubview(collectionView)
collectionView.snp.makeConstraints { make in
make.top.equalTo(navView.snp.bottom).offset(32*width)
make.left.right.bottom.equalToSuperview()
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
reload()
}
//
private func reload() {
//
showType = .init(rawValue: browseModuleList.items.first?.browseItem.itemType.rawValue ?? 0)!
}
}
//MARK: - collectionView
extension MPPositive_MoreContentViewController: UICollectionViewDataSource, UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return browseModuleList.items.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
switch showType {
case .Single:
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MPPositive_HomeListFifthCollectionViewCellID, for: indexPath) as! MPPositive_HomeListFifthCollectionViewCell
cell.itemViewModel = browseModuleList.items[indexPath.row]
return cell
case .List:
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MPPositive_MoreListContentCollectionViewCellID, for: indexPath) as! MPPositive_MoreListContentCollectionViewCell
cell.itemViewModel = browseModuleList.items[indexPath.row]
return cell
}
}
}