Manos Chorianopoulos

LoyaltyViewController part2

......@@ -8,5 +8,12 @@
import UIKit
@objc public class FiltersCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var filterLabel: UILabel!
@IBOutlet weak var borderView: UIView!
func configureCell(filterName: String, isSelected: Bool) {
filterLabel.text = filterName
borderView.backgroundColor = isSelected ? UIColor(rgb: 0xE8002A) : .clear
filterLabel.textColor = isSelected ? UIColor(rgb: 0x484848) : UIColor(rgb: 0xD3D3D3)
}
}
......
......@@ -11,9 +11,11 @@ import UIKit
@IBOutlet weak var headerView: UIView!
@IBOutlet weak var closeImage: UIImageView!
@IBOutlet weak var logoImage: UIImageView!
@IBOutlet weak var filtersView: UIView!
@IBOutlet weak var collectionView: UICollectionView!
var selectedScreen: String = ""
var filtersList: Array<String> = ["Όλα", "Σπίτι", "Έξοδος", "Υγεία"]
var selectedScreen: String = "Offers"
var filtersList: Array<String> = ["Screen", "Όλα", "Σπίτι", "Έξοδος", "Υγεία"]
var selectedFilter: String = "Όλα"
public override func viewDidLoad() {
......@@ -24,6 +26,15 @@ import UIKit
closeImage.image = UIImage(named: "close_btn_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
logoImage.image = UIImage(named: "epistrofi_logo", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// Add shadow
filtersView.layer.shadowColor = UIColor(rgb: 0x000000).cgColor
filtersView.layer.shadowOffset = CGSize(width: 0.0, height: 10.0)
filtersView.layer.shadowOpacity = 0.05
filtersView.layer.shadowRadius = 6.0
collectionView.contentInset.left = 20
collectionView.contentInset.right = 20
}
}
......@@ -38,8 +49,29 @@ extension LoyaltyViewController: UICollectionViewDataSource,UICollectionViewDele
}
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ScreenCollectionViewCellId", for: indexPath) as! ScreenCollectionViewCell
// cell.myLabel.text = "ABCD"
return cell;
if (indexPath.row == 0) {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ScreenCollectionViewCellId", for: indexPath) as! ScreenCollectionViewCell
cell.configureCell(screen: selectedScreen)
return cell;
} else {
let currentFilter = filtersList[indexPath.row];
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "FiltersCollectionViewCellId", for: indexPath) as! FiltersCollectionViewCell
cell.configureCell(filterName: currentFilter, isSelected: currentFilter == selectedFilter)
return cell;
}
}
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if (indexPath.row == 0) {
let offersSelected = selectedScreen == "Offers";
selectedScreen = offersSelected ? "Map" : "Offers"
} else {
let currentFilter = filtersList[indexPath.row];
selectedFilter = currentFilter;
}
collectionView.reloadData();
}
}
......
......@@ -8,5 +8,25 @@
import UIKit
@objc public class ScreenCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var containerView: UIView!
@IBOutlet weak var filterImage: UIImageView!
@IBOutlet weak var filterLabel: UILabel!
public override func awakeFromNib() {
super.awakeFromNib()
containerView.layer.cornerRadius = 23.0
containerView.clipsToBounds = true
}
func configureCell(screen: String) {
if (screen == "Offers") {
filterImage.image = UIImage(named: "list", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
filterLabel.text = "Λίστα"
} else {
filterImage.image = UIImage(named: "map_pin", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
filterLabel.text = "Χάρτης"
}
}
}
......