     }
     
     private let book: Book
-    private let size: CGFloat = 50.0
     
     init(book: Book) {
         self.book = book

    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ChapterNumCell",
                                                      for: indexPath as IndexPath)
        let chapter = indexPath.row + 1
        let label = UILabel(frame: CGRect(x: 0, y: 0, width: self.size, height: self.size))
        label.textAlignment = .center
        label.text = String(chapter)
        label.textColor = UIColor(red: 0.24, green: 0.5, blue: 0.96, alpha: 1.0)
        
        label.bounds = CGRect(x: 0.0, y: 0.0, width: self.size, height: self.size)
        label.layer.cornerRadius = self.size / 2
        label.layer.borderWidth = 2.0
        label.layer.borderColor = UIColor.init(white: 0.8, alpha: 1.0).cgColor
        let lastRef = HistoryModel.shared.current()
        if lastRef.bookId == self.book.bookId && lastRef.chapter == chapter {
            let alpha = AppFont.nightMode ? 0.3 : 1.0
            label.backgroundColor = UIColor(red: 0.89, green: 0.98, blue: 0.96, alpha: CGFloat(alpha))
            label.layer.masksToBounds = true
        }
        cell.contentView.addSubview(label)
        return cell
    }
    

    }
}

class ChapterNumCell : UICollectionViewCell {
    
    fileprivate static let SIZE: CGFloat = 50.0
    
    let label: UILabel
    
    override init(frame: CGRect) {
        let frame = CGRect(x: 0.0, y: 0.0, width: ChapterNumCell.SIZE, height: ChapterNumCell.SIZE)
        self.label = UILabel(frame: frame)
        self.label.textAlignment = .center
        //self.label.bounds = CGRect(x: 0.0, y: 0.0, width: self.size, height: self.size)
        self.label.layer.cornerRadius = ChapterNumCell.SIZE / 2
        self.label.layer.borderWidth = 2.0
        self.label.layer.borderColor = UIColor.init(white: 0.8, alpha: 1.0).cgColor
        self.label.textColor = UIColor(red: 0.24, green: 0.5, blue: 0.96, alpha: 1.0)

        super.init(frame: frame)
        self.contentView.addSubview(self.label)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

