| | |
| | | |
| | | @IBOutlet weak var collectionView: UICollectionView! |
| | | @IBOutlet weak var view_container: UIView! |
| | | private var items = [RecommendModel]() |
| | | private var clickClouse:((RecommendModel)->Void)! |
| | | override func awakeFromNib() { |
| | | super.awakeFromNib() |
| | | self.alpha = 0 |
| | |
| | | layoutIfNeeded() |
| | | } |
| | | |
| | | static func show(clouse:@escaping ()->Void){ |
| | | static func show(items:[RecommendModel],clouse:@escaping (RecommendModel)->Void){ |
| | | |
| | | if items.count == 0{return} |
| | | |
| | | let awardListView = AwardListView.jq_loadNibView() |
| | | awardListView.items = items |
| | | awardListView.clickClouse = clouse |
| | | sceneDelegate?.window?.addSubview(awardListView) |
| | | awardListView.frame = sceneDelegate?.window?.frame ?? .zero |
| | | |
| | |
| | | awardListView.alpha = 1 |
| | | awardListView.view_container.transform = .init(translationX: 1.0, y: 1.0) |
| | | awardListView.layoutIfNeeded() |
| | | }completion: { _ in |
| | | awardListView.collectionView.reloadData() |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | extension AwardListView:UICollectionViewDelegate{ |
| | | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| | | |
| | | |
| | | UIView.animate(withDuration: 0.4) { |
| | | self.alpha = 0 |
| | | self.view_container.transform = .init(scaleX: 0.1, y: 0.1) |
| | | } completion: { _ in |
| | | self.removeFromSuperview() |
| | | let item = self.items[indexPath.row] |
| | | self.clickClouse(item) |
| | | } |
| | | } |
| | | } |
| | | |
| | | extension AwardListView:UICollectionViewDataSource{ |
| | | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |
| | | let item = items[indexPath.row] |
| | | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_AwardListCCell", for: indexPath) as! AwardListCCell |
| | | cell.setModel(item) |
| | | return cell |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { |
| | | return 6 |
| | | return items.count |
| | | } |
| | | } |
| | | |
| | | extension AwardListView:UICollectionViewDelegateFlowLayout{ |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { |
| | | let w = (self.jq_width - 74 - 190) / 3.0 |
| | | let w = (JQ_ScreenW - 37 * 2 - 144 * 2 - 44 * 2) / 3.0 |
| | | return CGSize(width: w, height: w * 1.552) |
| | | } |
| | | |