//
//  UITablviewCell+Extention.swift

import Foundation
import UIKit


extension UITableView {
    func reloadDatawithAnimation(with animation: UITableView.RowAnimation) {
        reloadSections(IndexSet(integersIn: 0..<numberOfSections), with: animation)
    }
    func scrollToBottom(animated: Bool = true) {
        DispatchQueue.main.async {
            let sections = self.numberOfSections
            if (sections > 0){
                let rows = self.numberOfRows(inSection: sections - 1)
                if (rows > 0){
                    self.scrollToRow(at: IndexPath(row: rows - 1, section: sections - 1), at: .bottom, animated: animated)
                }
            }
        }
    }
}
extension UICollectionView {
    func scrollToNextItem() {
        let contentOffset = CGFloat(floor(self.contentOffset.x + self.bounds.size.width))
        self.moveToFrame(contentOffset: contentOffset)
    }
    func moveToFrame(contentOffset : CGFloat) {
        self.setContentOffset(CGPoint(x: contentOffset, y: self.contentOffset.y), animated: true)
    }
}

extension UIView {
    
    class var identifier: String {
        return String(describing: self)
    }
    
}
