Manos Chorianopoulos

add WalletViewController

Showing 31 changed files with 344 additions and 11 deletions
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>1</integer> 10 + <integer>0</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>0</integer> 10 + <integer>1</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
1 +{
2 + "images" : [
3 + {
4 + "filename" : "active_code_logo.png",
5 + "idiom" : "universal",
6 + "scale" : "1x"
7 + },
8 + {
9 + "filename" : "active_code_logo-1.png",
10 + "idiom" : "universal",
11 + "scale" : "2x"
12 + },
13 + {
14 + "filename" : "active_code_logo-2.png",
15 + "idiom" : "universal",
16 + "scale" : "3x"
17 + }
18 + ],
19 + "info" : {
20 + "author" : "xcode",
21 + "version" : 1
22 + }
23 +}
1 +{
2 + "images" : [
3 + {
4 + "filename" : "dfy_logo_white.png",
5 + "idiom" : "universal",
6 + "scale" : "1x"
7 + },
8 + {
9 + "filename" : "dfy_logo_white-1.png",
10 + "idiom" : "universal",
11 + "scale" : "2x"
12 + },
13 + {
14 + "filename" : "dfy_logo_white-2.png",
15 + "idiom" : "universal",
16 + "scale" : "3x"
17 + }
18 + ],
19 + "info" : {
20 + "author" : "xcode",
21 + "version" : 1
22 + }
23 +}
1 +{
2 + "images" : [
3 + {
4 + "filename" : "heart.png",
5 + "idiom" : "universal",
6 + "scale" : "1x"
7 + },
8 + {
9 + "filename" : "heart-1.png",
10 + "idiom" : "universal",
11 + "scale" : "2x"
12 + },
13 + {
14 + "filename" : "heart-2.png",
15 + "idiom" : "universal",
16 + "scale" : "3x"
17 + }
18 + ],
19 + "info" : {
20 + "author" : "xcode",
21 + "version" : 1
22 + }
23 +}
1 +{
2 + "images" : [
3 + {
4 + "filename" : "ic_background_circle.png",
5 + "idiom" : "universal",
6 + "scale" : "1x"
7 + },
8 + {
9 + "filename" : "ic_background_circle-1.png",
10 + "idiom" : "universal",
11 + "scale" : "2x"
12 + },
13 + {
14 + "filename" : "ic_background_circle-2.png",
15 + "idiom" : "universal",
16 + "scale" : "3x"
17 + }
18 + ],
19 + "info" : {
20 + "author" : "xcode",
21 + "version" : 1
22 + }
23 +}
1 +{
2 + "images" : [
3 + {
4 + "filename" : "wallet_coupons.png",
5 + "idiom" : "universal",
6 + "scale" : "1x"
7 + },
8 + {
9 + "filename" : "wallet_coupons-1.png",
10 + "idiom" : "universal",
11 + "scale" : "2x"
12 + },
13 + {
14 + "filename" : "wallet_coupons-2.png",
15 + "idiom" : "universal",
16 + "scale" : "3x"
17 + }
18 + ],
19 + "info" : {
20 + "author" : "xcode",
21 + "version" : 1
22 + }
23 +}
1 +{
2 + "images" : [
3 + {
4 + "filename" : "wallet_dfy_earn.png",
5 + "idiom" : "universal",
6 + "scale" : "1x"
7 + },
8 + {
9 + "filename" : "wallet_dfy_earn-1.png",
10 + "idiom" : "universal",
11 + "scale" : "2x"
12 + },
13 + {
14 + "filename" : "wallet_dfy_earn-2.png",
15 + "idiom" : "universal",
16 + "scale" : "3x"
17 + }
18 + ],
19 + "info" : {
20 + "author" : "xcode",
21 + "version" : 1
22 + }
23 +}
...@@ -136,3 +136,55 @@ extension UIImageView { ...@@ -136,3 +136,55 @@ extension UIImageView {
136 } 136 }
137 } 137 }
138 } 138 }
139 +
140 +typealias GradientPoints = (startPoint: CGPoint, endPoint: CGPoint)
141 +
142 +enum GradientOrientation {
143 + case topRightBottomLeft
144 + case topLeftBottomRight
145 + case horizontal
146 + case vertical
147 +
148 + var startPoint : CGPoint {
149 + return points.startPoint
150 + }
151 +
152 + var endPoint : CGPoint {
153 + return points.endPoint
154 + }
155 +
156 + var points : GradientPoints {
157 + switch self {
158 + case .topRightBottomLeft:
159 + return (CGPoint(x: 0.0,y: 1.0), CGPoint(x: 1.0,y: 0.0))
160 + case .topLeftBottomRight:
161 + return (CGPoint(x: 0.0,y: 0.0), CGPoint(x: 1,y: 1))
162 + case .horizontal:
163 + return (CGPoint(x: 0.0,y: 0.5), CGPoint(x: 1.0,y: 0.5))
164 + case .vertical:
165 + return (CGPoint(x: 0.0,y: 0.0), CGPoint(x: 0.0,y: 1.0))
166 + }
167 + }
168 +}
169 +
170 +extension UIView {
171 +
172 + func applyGradient(colours: [UIColor], locations: [NSNumber]? = nil, cornerRadius: CGFloat) {
173 + let gradient = CAGradientLayer()
174 + gradient.frame = self.bounds
175 + gradient.colors = colours.map { $0.cgColor }
176 + gradient.locations = locations
177 + gradient.cornerRadius = cornerRadius
178 + self.layer.insertSublayer(gradient, at: 0)
179 + }
180 +
181 + func applyGradient(colours: [UIColor], gradient orientation: GradientOrientation, cornerRadius: CGFloat) {
182 + let gradient = CAGradientLayer()
183 + gradient.frame = self.bounds
184 + gradient.colors = colours.map { $0.cgColor }
185 + gradient.startPoint = orientation.startPoint
186 + gradient.endPoint = orientation.endPoint
187 + gradient.cornerRadius = cornerRadius
188 + self.layer.insertSublayer(gradient, at: 0)
189 + }
190 +}
......
...@@ -9,18 +9,161 @@ import Foundation ...@@ -9,18 +9,161 @@ import Foundation
9 import UIKit 9 import UIKit
10 10
11 @objc public class WalletViewController: UIViewController { 11 @objc public class WalletViewController: UIViewController {
12 + @IBOutlet weak var headerImage: UIImageView!
13 + @IBOutlet weak var profileImage: UIImageView!
14 + @IBOutlet weak var profileNameLabel: UILabel!
15 + @IBOutlet weak var questionnaireButton: UIButton!
16 + @IBOutlet weak var dfyEarnView: UIView!
17 + @IBOutlet weak var dfyEarnLabel: UILabel!
18 + @IBOutlet weak var dfyEarnAmountLabel: UILabel!
19 + @IBOutlet weak var dfyEarnImage: UIImageView!
20 + @IBOutlet weak var couponEarnView: UIView!
21 + @IBOutlet weak var couponEarnLabel: UILabel!
22 + @IBOutlet weak var couponEarnAmountLabel: UILabel!
23 + @IBOutlet weak var couponEarnImage: UIImageView!
24 + @IBOutlet weak var dfyLogoImage: UIImageView!
25 + @IBOutlet weak var activeCodeView: UIView!
26 + @IBOutlet weak var activeCodeLabel: UILabel!
27 + @IBOutlet weak var activeCodeExpirationLabel: UILabel!
28 + @IBOutlet weak var tableView: UITableView!
29 + @IBOutlet weak var activeCodeImage: UIImageView!
30 +
31 + public var coupons:Array<swiftApi.CouponItemModel> = []
32 +
33 + public override func viewDidLoad() {
34 + super.viewDidLoad()
35 +
36 + getCouponsRequest()
37 +
38 + setBackButton()
39 + setNavigationTitle("For You")
40 +
41 + tableView.delegate = self
42 + tableView.dataSource = self
43 +
44 + headerImage.image = UIImage(named: "ic_background_circle", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
45 + dfyEarnImage.image = UIImage(named: "wallet_dfy_earn", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
46 + couponEarnImage.image = UIImage(named: "wallet_coupons", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
47 + dfyLogoImage.image = UIImage(named: "dfy_logo_white", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
48 + activeCodeImage.image = UIImage(named: "active_code_logo", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
49 +
50 + profileImage.layer.cornerRadius = 32.5
51 + profileImage.layer.borderWidth = 1
52 + profileImage.layer.borderColor = UIColor(red: 0.13, green: 0.66, blue: 0.71, alpha: 1.00).cgColor
53 + // TODO: dynamic
54 +// profileImage.load(link: profile_image ?? "", placeholder: UIImage(), cache: URLCache())
55 + profileNameLabel.text = "Γιώργος Γεωργίου"
56 +
57 + // TODO: dynamic
58 + questionnaireButton.setTitle("Traveller", for: .normal)
59 + questionnaireButton.titleLabel?.font = UIFont.systemFont(ofSize: 13, weight: .semibold)
60 +// questionnaireButton.sizeToFit()
61 + questionnaireButton.frame = CGRect(x: 0.0, y: 0.0, width: questionnaireButton.intrinsicContentSize.width, height: questionnaireButton.intrinsicContentSize.height)
62 + questionnaireButton.applyGradient(colours: [UIColor(red: 0.40, green: 0.77, blue: 0.28, alpha: 1.00), UIColor(red: 0.10, green: 0.66, blue: 0.72, alpha: 1.00)], gradient: GradientOrientation.horizontal, cornerRadius: 7.0)
63 + // Shadow Color and Radius
64 + questionnaireButton.layer.shadowColor = UIColor(red: 0.33, green: 0.38, blue: 0.43, alpha: 1.00).cgColor
65 + questionnaireButton.layer.shadowOffset = CGSize(width: 0.0, height: 2.0)
66 + questionnaireButton.layer.shadowOpacity = 1.0
67 + questionnaireButton.layer.shadowRadius = 0.0
68 + questionnaireButton.layer.masksToBounds = false
69 + questionnaireButton.layer.cornerRadius = 7.0
70 +
71 + dfyEarnView.layer.cornerRadius = 5.0
72 + dfyEarnView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
73 + dfyEarnView.layer.shadowOffset = CGSize(width: 0.0, height: 3.0)
74 + dfyEarnView.layer.shadowOpacity = 1.0
75 + dfyEarnView.layer.shadowRadius = 3.0
76 +
77 + // TODO: dynamic
78 + dfyEarnLabel.text = "Μέχρι τώρα έχεις κερδίσει 18,00€ με το DEALS for YOU!"
79 + dfyEarnAmountLabel.text = "18,00€"
80 +
81 + couponEarnView.layer.cornerRadius = 5.0
82 + couponEarnView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
83 + couponEarnView.layer.shadowOffset = CGSize(width: 0.0, height: 3.0)
84 + couponEarnView.layer.shadowOpacity = 1.0
85 + couponEarnView.layer.shadowRadius = 3.0
86 +
87 + // TODO: dynamic
88 + couponEarnLabel.text = "Μέχρι τώρα έχεις κερδίσει 20,00€ σε προσφορές από 3 κουπόνια!"
89 + couponEarnAmountLabel.text = "20,00€"
90 +
91 + activeCodeView.layer.cornerRadius = 5.0
92 + activeCodeView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
93 + activeCodeView.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
94 + activeCodeView.layer.shadowOpacity = 1.0
95 + activeCodeView.layer.shadowRadius = 6.0
96 +
97 + // TODO: dynamic
98 + activeCodeLabel.text = "961544809"
99 + activeCodeExpirationLabel.text = "Λήγει σε 4 ημέρες"
100 + }
101 +
102 + // MARK: - API Functions
103 + func getCouponsRequest() {
104 + swiftApi().getCouponsAsync(getCouponsCallback)
105 + }
12 106
13 - @IBOutlet weak var activeGiftsButton: UIButton! 107 + func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
108 + if (couponsData != nil) {
109 + let activeCouponData = swiftApi().filterActiveCoupons(couponsData ?? [])
110 +
111 + self.coupons = activeCouponData
112 +
113 + DispatchQueue.main.async {
114 + self.tableView.reloadData()
115 + }
116 + } else {
117 + self.coupons = []
118 + }
119 + }
14 120
15 - public override func viewWillAppear(_ animated: Bool) { 121 + // MARK: - Actions
16 - super.viewWillAppear(animated) 122 + @IBAction func qustionnaireButtonAction(_ sender: Any) {
17 - setBackButton() 123 + swiftApi().openQuestionnaire(self);
18 - setNavigationTitle("My loyalty wallet") 124 + }
125 +
126 + @IBAction func dfyEarnButtonAction(_ sender: Any) {
127 + // TODO: dfyEarnButtonAction
128 + print("dfyEarnButtonAction Tapped!")
129 + }
130 + @IBAction func couponEarnButtonAction(_ sender: Any) {
131 + // TODO: couponEarnButtonAction
132 + print("couponEarnButtonAction Tapped!")
133 + }
134 +
135 +}
136 +
137 +// MARK: - TableView
138 +extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
139 +
140 + public func numberOfSections(in tableView: UITableView) -> Int {
141 + return 1
142 + }
143 +
144 + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
145 + return self.coupons.count
146 + }
147 +
148 + public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
149 + return 120.0 + 30.0
150 +// return UITableViewAutomaticDimension
151 + }
152 +
153 + public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
154 + let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell
155 +
156 + cell.configureCell(coupon: coupons[indexPath.row])
157 +
158 + return cell
19 } 159 }
20 160
21 - @IBAction func navigateToActiveGifts(_ sender: Any) { 161 + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
22 - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) 162 +
23 - let vc = storyboard.instantiateViewController(withIdentifier: "ActiveGiftsViewController") as UIViewController 163 + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
24 - self.navigationController?.pushViewController(vc, animated: true) 164 + let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! CouponBarcodeViewController
165 + vc.coupon = coupons[indexPath.row]
166 + self.navigationController?.pushViewController(vc, animated: true)
167 +
25 } 168 }
26 } 169 }
......