2 // LibraryEarlyAccessTableViewCell.swift
5 // Created by Pawel Dabrowski on 18/06/2018.
6 // Copyright © 2018 Fundacja Nowoczesna Polska. All rights reserved.
12 protocol LibraryEarlyAccessTableViewCellDelegate: class {
13 func libraryEarlyAccessTableViewCellRefreshButtonTapped()
16 class LibraryEarlyAccessTableViewCell: WLTableViewCell {
17 var delegate: LibraryEarlyAccessTableViewCellDelegate?
19 class func instance() -> LibraryEarlyAccessTableViewCell{
20 let cell = LibraryEarlyAccessTableViewCell.instance(type: LibraryEarlyAccessTableViewCell.self)
24 @IBOutlet weak var containerView: UIView!
25 @IBOutlet weak var bookDescriptionView: BookDescriptionView!
26 @IBOutlet weak var miniatureImageView: UIImageView!
27 @IBOutlet weak var miniatureOverlayView: BookImageOverlayView!
28 @IBOutlet weak var miniatureBgView: UIView!
29 @IBOutlet weak var refreshButton: ActivityIndicatorButton!
31 @IBOutlet weak var noPremiumBookLabel: UILabel!
32 private var height: CGFloat = 199
34 override func awakeFromNib() {
36 miniatureBgView.layer.cornerRadius = 5
37 noPremiumBookLabel.text = "library_empty_header".localized
40 func setup(state: ActivityIndicatorButtonState, bookModel: BookModel?) {
44 noPremiumBookLabel.isHidden = true
45 containerView.isHidden = true
46 refreshButton.setIndicatorButtonState(state: state)
50 if let book = self.book {
51 containerView.isHidden = false
52 bookDescriptionView.setup(bookModel: book, isPremium: true)
53 miniatureOverlayView.setup(bookModel: book)
54 miniatureImageView.kf.cancelDownloadTask()
55 miniatureImageView.image = #imageLiteral(resourceName: "list_nocover")
57 if let url = book.getCoverThumbUrl() {
59 miniatureImageView.kf.setImage(with: ImageResource(downloadURL: url),
60 placeholder: #imageLiteral(resourceName: "list_nocover"),
61 options: [.transition(.fade(1))],
63 completionHandler: { (image, error, cacheType, url) in
68 noPremiumBookLabel.isHidden = false
71 case .button, .loading:
76 @IBAction func refreshButtonAction(_ sender: Any) {
77 delegate?.libraryEarlyAccessTableViewCellRefreshButtonTapped()
80 override func getHeight() -> CGFloat {