Showing
5 changed files
with
64 additions
and
5 deletions
No preview for this file type
... | @@ -8,5 +8,12 @@ | ... | @@ -8,5 +8,12 @@ |
8 | import UIKit | 8 | import UIKit |
9 | 9 | ||
10 | @objc public class FiltersCollectionViewCell: UICollectionViewCell { | 10 | @objc public class FiltersCollectionViewCell: UICollectionViewCell { |
11 | + @IBOutlet weak var filterLabel: UILabel! | ||
12 | + @IBOutlet weak var borderView: UIView! | ||
11 | 13 | ||
14 | + func configureCell(filterName: String, isSelected: Bool) { | ||
15 | + filterLabel.text = filterName | ||
16 | + borderView.backgroundColor = isSelected ? UIColor(rgb: 0xE8002A) : .clear | ||
17 | + filterLabel.textColor = isSelected ? UIColor(rgb: 0x484848) : UIColor(rgb: 0xD3D3D3) | ||
18 | + } | ||
12 | } | 19 | } | ... | ... |
... | @@ -11,9 +11,11 @@ import UIKit | ... | @@ -11,9 +11,11 @@ import UIKit |
11 | @IBOutlet weak var headerView: UIView! | 11 | @IBOutlet weak var headerView: UIView! |
12 | @IBOutlet weak var closeImage: UIImageView! | 12 | @IBOutlet weak var closeImage: UIImageView! |
13 | @IBOutlet weak var logoImage: UIImageView! | 13 | @IBOutlet weak var logoImage: UIImageView! |
14 | + @IBOutlet weak var filtersView: UIView! | ||
15 | + @IBOutlet weak var collectionView: UICollectionView! | ||
14 | 16 | ||
15 | - var selectedScreen: String = "" | 17 | + var selectedScreen: String = "Offers" |
16 | - var filtersList: Array<String> = ["Όλα", "Σπίτι", "Έξοδος", "Υγεία"] | 18 | + var filtersList: Array<String> = ["Screen", "Όλα", "Σπίτι", "Έξοδος", "Υγεία"] |
17 | var selectedFilter: String = "Όλα" | 19 | var selectedFilter: String = "Όλα" |
18 | 20 | ||
19 | public override func viewDidLoad() { | 21 | public override func viewDidLoad() { |
... | @@ -24,6 +26,15 @@ import UIKit | ... | @@ -24,6 +26,15 @@ import UIKit |
24 | 26 | ||
25 | closeImage.image = UIImage(named: "close_btn_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) | 27 | closeImage.image = UIImage(named: "close_btn_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) |
26 | logoImage.image = UIImage(named: "epistrofi_logo", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) | 28 | logoImage.image = UIImage(named: "epistrofi_logo", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) |
29 | + | ||
30 | + // Add shadow | ||
31 | + filtersView.layer.shadowColor = UIColor(rgb: 0x000000).cgColor | ||
32 | + filtersView.layer.shadowOffset = CGSize(width: 0.0, height: 10.0) | ||
33 | + filtersView.layer.shadowOpacity = 0.05 | ||
34 | + filtersView.layer.shadowRadius = 6.0 | ||
35 | + | ||
36 | + collectionView.contentInset.left = 20 | ||
37 | + collectionView.contentInset.right = 20 | ||
27 | } | 38 | } |
28 | 39 | ||
29 | } | 40 | } |
... | @@ -38,8 +49,29 @@ extension LoyaltyViewController: UICollectionViewDataSource,UICollectionViewDele | ... | @@ -38,8 +49,29 @@ extension LoyaltyViewController: UICollectionViewDataSource,UICollectionViewDele |
38 | } | 49 | } |
39 | 50 | ||
40 | public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | 51 | public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |
41 | - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ScreenCollectionViewCellId", for: indexPath) as! ScreenCollectionViewCell | 52 | + if (indexPath.row == 0) { |
42 | -// cell.myLabel.text = "ABCD" | 53 | + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ScreenCollectionViewCellId", for: indexPath) as! ScreenCollectionViewCell |
43 | - return cell; | 54 | + cell.configureCell(screen: selectedScreen) |
55 | + return cell; | ||
56 | + | ||
57 | + } else { | ||
58 | + let currentFilter = filtersList[indexPath.row]; | ||
59 | + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "FiltersCollectionViewCellId", for: indexPath) as! FiltersCollectionViewCell | ||
60 | + cell.configureCell(filterName: currentFilter, isSelected: currentFilter == selectedFilter) | ||
61 | + return cell; | ||
62 | + } | ||
63 | + } | ||
64 | + | ||
65 | + public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { | ||
66 | + if (indexPath.row == 0) { | ||
67 | + let offersSelected = selectedScreen == "Offers"; | ||
68 | + selectedScreen = offersSelected ? "Map" : "Offers" | ||
69 | + | ||
70 | + } else { | ||
71 | + let currentFilter = filtersList[indexPath.row]; | ||
72 | + selectedFilter = currentFilter; | ||
73 | + } | ||
74 | + | ||
75 | + collectionView.reloadData(); | ||
44 | } | 76 | } |
45 | } | 77 | } | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -8,5 +8,25 @@ | ... | @@ -8,5 +8,25 @@ |
8 | import UIKit | 8 | import UIKit |
9 | 9 | ||
10 | @objc public class ScreenCollectionViewCell: UICollectionViewCell { | 10 | @objc public class ScreenCollectionViewCell: UICollectionViewCell { |
11 | + @IBOutlet weak var containerView: UIView! | ||
12 | + @IBOutlet weak var filterImage: UIImageView! | ||
13 | + @IBOutlet weak var filterLabel: UILabel! | ||
11 | 14 | ||
15 | + public override func awakeFromNib() { | ||
16 | + super.awakeFromNib() | ||
17 | + | ||
18 | + containerView.layer.cornerRadius = 23.0 | ||
19 | + containerView.clipsToBounds = true | ||
20 | + } | ||
21 | + | ||
22 | + func configureCell(screen: String) { | ||
23 | + if (screen == "Offers") { | ||
24 | + filterImage.image = UIImage(named: "list", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) | ||
25 | + filterLabel.text = "Λίστα" | ||
26 | + | ||
27 | + } else { | ||
28 | + filterImage.image = UIImage(named: "map_pin", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) | ||
29 | + filterLabel.text = "Χάρτης" | ||
30 | + } | ||
31 | + } | ||
12 | } | 32 | } | ... | ... |
-
Please register or login to post a comment