//
//  PhotoCellCollectionViewCell.swift
//  Em-call
//
//  Created by Alex Sh on 06.03.2022.
//

import UIKit

class PhotoCellCollectionViewCell: UICollectionViewCell, UICollectionViewDataSource, UICollectionViewDelegate {
 
    @IBOutlet weak var imageView: UIImageView!
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
       /* self.itemSize = CGSizeMake(480, 626);
          self.minimumInteritemSpacing = 112;
          self.minimumLineSpacing = 112;
          self.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        layout.sectionInset = UIEdgeInsetsMake(0, 272, 0, 272);*/
    }
    
    func configure(by image: UIImage, count: Int) {
      imageView.image = image
     // countLabel.text = "\(count)"
    } 
    var collectionView: UICollectionView?

    func initCell () {
        let layout = UICollectionViewFlowLayout()
        layout.scrollDirection = .horizontal
        layout.sectionInset = UIEdgeInsets(top: 0, left: 27, bottom: 0, right: 27);
        var collectionViewBounds = self.bounds
        collectionViewBounds.size.height -= 80
        collectionViewBounds.origin.y = 40
        collectionView = UICollectionView(frame: collectionViewBounds, collectionViewLayout: layout)

        collectionView!.dataSource = self
        collectionView!.delegate = self

        // Setting the collection view's scrolling behaviour
        collectionView!.isPagingEnabled = true
        collectionView!.isScrollEnabled = true
        collectionView!.setContentOffset(CGPoint(x: 0,y: 0), animated: true)

        collectionView!.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "cellWithCollectionView")
        addSubview(collectionView!)

    }

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 10
    }
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellWithCollectionView", for: indexPath as IndexPath)
        if indexPath.item%2 == 0
        {
            cell.backgroundColor = .blue
        }
        else
        {
            cell.backgroundColor = .white
        }
        return cell
    }
/*
    func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
    {
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cellWithCollectionView", forIndexPath: indexPath as IndexPath)
        if indexPath.item%2 == 0
        {
            cell.backgroundColor = .blueColor()
        }
        else
        {
            cell.backgroundColor = .whiteColor()
        }
        return cell
    }

    func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize
    {
        return CGSizeMake(100, collectionView.frame.height)
    }
     */
    func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat
    {
        return 10
    }

}
