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

import UIKit
import FSPagerView
import MJExtension
import SDWebImage

class WP_RankingVC: WP_RootVC {

    @IBOutlet weak var pagerView: FSPagerView!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
 
        setFSpageV()
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.navigationBar.isHidden = true
    }
    
    func setFSpageV(){
        self.pagerView.delegate = self
        self.pagerView.dataSource = self
        pagerView.register(UINib(nibName: "WP_RankingCell", bundle: nil), forCellWithReuseIdentifier: "WP_RankingCell")
        pagerView.transformer = FSPagerViewTransformer(type: .overlap)
        pagerView.automaticSlidingInterval = 0
        pagerView.isInfinite = true
        pagerView.decelerationDistance = 1
        pagerView.itemSize = CGSize(width: UIScreen.main.bounds.size.width - 80, height: self.pagerView.frame.size.height)
//        pagerView.itemSize = pagerView.frame.size
        pagerView.interitemSpacing = 0

        
    }

}
extension WP_RankingVC:FSPagerViewDelegate,FSPagerViewDataSource{
    public func numberOfItems(in pagerView: FSPagerView) -> Int {
        return rankarr.count
    }
    
    public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
        let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "WP_RankingCell", at: index) as! WP_RankingCell
        cell.wallpaperImageV.image = UIImage(named: "\(rankarr[index])")
        return cell
    }
    
    func pagerView(_ pagerView: FSPagerView, didSelectItemAt index: Int) {
        let vc = WP_WallPaPerDetailsVC()
        vc.imageName = rankarr[index]
        self.navigationController?.pushViewController(vc, animated: true)
    }
    
}
