87 lines
2.7 KiB
Swift
87 lines
2.7 KiB
Swift
//
|
|
// BRHomeHeaderView.swift
|
|
// BeeReel
|
|
//
|
|
// Created by 长沙鸿瑶 on 2025/6/25.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class BRHomeHeaderView: UIView {
|
|
|
|
var bannerArr: [BRShortModel]? {
|
|
didSet {
|
|
bannerParam.wData = bannerArr ?? []
|
|
bannerView.updateUI()
|
|
}
|
|
}
|
|
|
|
var contentHeight: CGFloat = UIScreen.statusBarHeight + 107 + 280
|
|
|
|
private lazy var bgIconImageView: UIImageView = {
|
|
let imageView = UIImageView(image: UIImage(named: "home_header_icon_01"))
|
|
return imageView
|
|
}()
|
|
|
|
private lazy var bannerParam: WMZBannerParam = {
|
|
let param = WMZBannerParam()
|
|
param.wFrame = .init(x: 0, y: UIScreen.statusBarHeight + 107, width: UIScreen.width, height: 280)
|
|
param.wItemSize = .init(width: 180, height: 230)
|
|
param.wMyCell = { [weak self] (indexPath, collectionView, model, bgImageView, dataArr) in
|
|
let cell = collectionView?.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath ?? .init(row: 0, section: 0)) as? BRHomeHeaderBannerCell
|
|
cell?.model = model as? BRShortModel
|
|
return cell
|
|
}
|
|
param.wEventClick = { [weak self] (anyId, index) in
|
|
guard let self = self else { return }
|
|
guard let model = anyId as? BRShortModel else { return }
|
|
|
|
let vc = BRVideoDetailViewController()
|
|
vc.shortPlayId = model.short_play_id
|
|
self.viewController?.navigationController?.pushViewController(vc, animated: true)
|
|
}
|
|
param.wSectionInset = .init(top: 0, left: 27, bottom: 0, right: 27)
|
|
param.wCardOverLapCount = 4
|
|
param.wLineSpacing = 40
|
|
param.wCardOverLap = true
|
|
param.wEffect = false
|
|
param.wAutoScroll = false
|
|
///开启无限循环
|
|
param.wRepeat = false
|
|
param.wHideBannerControl = true
|
|
param.wCanFingerSliding = false
|
|
|
|
return param
|
|
}()
|
|
|
|
private lazy var bannerView: WMZBannerView = {
|
|
let view = WMZBannerView(configureWithModel: bannerParam)
|
|
view.register(BRHomeHeaderBannerCell.self, forCellWithReuseIdentifier: "cell")
|
|
return view
|
|
}()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
br_setupUI()
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
}
|
|
|
|
extension BRHomeHeaderView {
|
|
|
|
private func br_setupUI() {
|
|
addSubview(bannerView)
|
|
addSubview(bgIconImageView)
|
|
|
|
bgIconImageView.snp.makeConstraints { make in
|
|
make.left.equalToSuperview().offset(0)
|
|
make.top.equalToSuperview().offset(UIScreen.statusBarHeight)
|
|
}
|
|
}
|
|
|
|
}
|