//
|
// AwardListView.swift
|
// DolphinEnglishLearnStudent
|
//
|
// Created by 无故事王国 on 2024/5/23.
|
//
|
|
import UIKit
|
|
class AwardListView: UIView,JQNibView{
|
|
@IBOutlet weak var collectionView: UICollectionView!
|
@IBOutlet weak var view_container: UIView!
|
override func awakeFromNib() {
|
super.awakeFromNib()
|
self.alpha = 0
|
collectionView.delegate = self
|
collectionView.dataSource = self
|
collectionView.register(UINib(nibName: "AwardListCCell", bundle: nil), forCellWithReuseIdentifier: "_AwardListCCell")
|
view_container.transform = .init(scaleX: 0.1, y: 0.1)
|
collectionView.contentInset = UIEdgeInsets(top: 0, left: 37, bottom: 0, right: 37)
|
layoutIfNeeded()
|
}
|
|
static func show(clouse:@escaping ()->Void){
|
let awardListView = AwardListView.jq_loadNibView()
|
sceneDelegate?.window?.addSubview(awardListView)
|
awardListView.frame = sceneDelegate?.window?.frame ?? .zero
|
|
UIView.animate(withDuration: 0.4) {
|
awardListView.alpha = 1
|
awardListView.view_container.transform = .init(translationX: 1.0, y: 1.0)
|
awardListView.layoutIfNeeded()
|
}
|
}
|
|
@IBAction func closeAction(_ sender: UIButton) {
|
UIView.animate(withDuration: 0.4) {
|
self.alpha = 0
|
self.view_container.transform = .init(scaleX: 0.1, y: 0.1)
|
} completion: { _ in
|
self.removeFromSuperview()
|
}
|
}
|
}
|
|
extension AwardListView:UICollectionViewDelegate{
|
|
}
|
|
extension AwardListView:UICollectionViewDataSource{
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_AwardListCCell", for: indexPath) as! AwardListCCell
|
return cell
|
}
|
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
return 6
|
}
|
}
|
|
extension AwardListView:UICollectionViewDelegateFlowLayout{
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
let w = (self.jq_width - 74 - 190) / 3.0
|
return CGSize(width: w, height: w * 1.552)
|
}
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
|
return 44
|
}
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
|
return 44
|
}
|
}
|