added iOS source code
[wl-app.git] / iOS / WolneLektury / Screens / Filter / Cells / FilterSectionHeaderCollectionReusableView.swift
1 //
2 //  FilterSectionHeaderCollectionReusableView.swift
3 //  WolneLektury
4 //
5 //  Created by Pawel Dabrowski on 12/06/2018.
6 //  Copyright © 2018 Fundacja Nowoczesna Polska. All rights reserved.
7 //
8
9 import UIKit
10
11 protocol FilterSectionHeaderCollectionReusableViewDelegate: class {
12     func filterSectionRefreshButtonTapped(section: FilterSection)
13 }
14
15 class FilterSectionHeaderCollectionReusableView: UICollectionReusableView {
16     var delegate: FilterSectionHeaderCollectionReusableViewDelegate?
17
18     @IBOutlet weak var titleLabel: UILabel!
19     @IBOutlet weak var refreshButton: ActivityIndicatorButton!
20     var filterSection : FilterSection!
21     
22     func setup(filterSection: FilterSection, isDownloading: Bool){
23         self.filterSection = filterSection
24         titleLabel.text = filterSection.title
25         refreshButton.setIndicatorButtonState(state: isDownloading ?  .loading : .button)
26     }
27     
28     @IBAction func refreshButtonAction(_ sender: Any) {
29         delegate?.filterSectionRefreshButtonTapped(section: filterSection)
30     }
31 }