//
//  WP_InkVC.swift
//  WallpaperHD_Live
//
//  Created by 忆海16 on 2024/7/22.
//

import UIKit
import JXSegmentedView

import MJRefresh
import SDWebImage

class WP_InkVC: WP_RootVC {

    @IBOutlet weak var collectionView: UICollectionView!
    

    override func viewDidLoad() {
        super.viewDidLoad()
        setCollectionView()
        
    }
    
    
  
    
    func setCollectionView(){
        collectionView.delegate = self
        collectionView.dataSource = self
        
        // 设置 collection view 的布局
        let layout = CustomCollectionViewFlowLayout()
        collectionView.collectionViewLayout = layout
        layout.scrollDirection = .vertical
        
        collectionView.register(UINib(nibName: "WP_WallpaperCollectionCell", bundle: nil), forCellWithReuseIdentifier: "WP_WallpaperCollectionCell")
        
    }
   
}
extension WP_InkVC:JXSegmentedListContainerViewListDelegate{
    func listView() -> UIView {
        return view
    }
}
extension WP_InkVC:UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout{
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        
        return inkarr.count
        
    }
    
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "WP_WallpaperCollectionCell", for: indexPath)as!WP_WallpaperCollectionCell
        cell.wpImagV.image = UIImage(named: "\(inkarr[indexPath.row])")
        
        return cell
        
        
    }
    
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let vc = WP_WallPaPerDetailsVC()
        vc.imageName = inkarr[indexPath.row]
        self.navigationController?.pushViewController(vc, animated: true)
//        
        
    }
}
