Showing
17 changed files
with
232 additions
and
10 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>0</integer> | 10 | + <integer>1</integer> |
11 | </dict> | 11 | </dict> |
12 | </dict> | 12 | </dict> |
13 | </dict> | 13 | </dict> | ... | ... |
... | @@ -7,6 +7,7 @@ | ... | @@ -7,6 +7,7 @@ |
7 | objects = { | 7 | objects = { |
8 | 8 | ||
9 | /* Begin PBXBuildFile section */ | 9 | /* Begin PBXBuildFile section */ |
10 | + 1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */; }; | ||
10 | 7630AD9A6242D60846D6750C /* Pods_SwiftWarplyFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */; }; | 11 | 7630AD9A6242D60846D6750C /* Pods_SwiftWarplyFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */; }; |
11 | E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */ = {isa = PBXBuildFile; fileRef = E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */; }; | 12 | E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */ = {isa = PBXBuildFile; fileRef = E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */; }; |
12 | E6A77854282933340045BBA8 /* SwiftWarplyFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A77851282933340045BBA8 /* SwiftWarplyFramework.h */; settings = {ATTRIBUTES = (Public, ); }; }; | 13 | E6A77854282933340045BBA8 /* SwiftWarplyFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A77851282933340045BBA8 /* SwiftWarplyFramework.h */; settings = {ATTRIBUTES = (Public, ); }; }; |
... | @@ -137,6 +138,7 @@ | ... | @@ -137,6 +138,7 @@ |
137 | /* End PBXBuildFile section */ | 138 | /* End PBXBuildFile section */ |
138 | 139 | ||
139 | /* Begin PBXFileReference section */ | 140 | /* Begin PBXFileReference section */ |
141 | + 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponsTableViewCell.swift; sourceTree = "<group>"; }; | ||
140 | A9B7BE01A4E812DE49866EF8 /* Pods-SwiftWarplyFramework.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.debug.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.debug.xcconfig"; sourceTree = "<group>"; }; | 142 | A9B7BE01A4E812DE49866EF8 /* Pods-SwiftWarplyFramework.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.debug.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.debug.xcconfig"; sourceTree = "<group>"; }; |
141 | B9EB8A451EF0C5AD75094EEE /* Pods-SwiftWarplyFramework.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.release.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.release.xcconfig"; sourceTree = "<group>"; }; | 143 | B9EB8A451EF0C5AD75094EEE /* Pods-SwiftWarplyFramework.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.release.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.release.xcconfig"; sourceTree = "<group>"; }; |
142 | C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftWarplyFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; }; | 144 | C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftWarplyFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; }; |
... | @@ -320,6 +322,7 @@ | ... | @@ -320,6 +322,7 @@ |
320 | isa = PBXGroup; | 322 | isa = PBXGroup; |
321 | children = ( | 323 | children = ( |
322 | E6A7785E282933E40045BBA8 /* CouponsViewController.swift */, | 324 | E6A7785E282933E40045BBA8 /* CouponsViewController.swift */, |
325 | + 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */, | ||
323 | E6A7785D282933E40045BBA8 /* CouponViewController.swift */, | 326 | E6A7785D282933E40045BBA8 /* CouponViewController.swift */, |
324 | E6A77863282933E50045BBA8 /* DetailsViewController.swift */, | 327 | E6A77863282933E50045BBA8 /* DetailsViewController.swift */, |
325 | E6A778DE282933E60045BBA8 /* GiftsViewController.swift */, | 328 | E6A778DE282933E60045BBA8 /* GiftsViewController.swift */, |
... | @@ -750,6 +753,7 @@ | ... | @@ -750,6 +753,7 @@ |
750 | E6A77935282933E70045BBA8 /* UIWebView+AFNetworking.m in Sources */, | 753 | E6A77935282933E70045BBA8 /* UIWebView+AFNetworking.m in Sources */, |
751 | E6A77925282933E70045BBA8 /* UIProgressView+AFNetworking.m in Sources */, | 754 | E6A77925282933E70045BBA8 /* UIProgressView+AFNetworking.m in Sources */, |
752 | E6A77944282933E70045BBA8 /* AFSecurityPolicy.m in Sources */, | 755 | E6A77944282933E70045BBA8 /* AFSecurityPolicy.m in Sources */, |
756 | + 1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */, | ||
753 | E6A77A32282BA9C60045BBA8 /* CampaignViewController.swift in Sources */, | 757 | E6A77A32282BA9C60045BBA8 /* CampaignViewController.swift in Sources */, |
754 | E6A77917282933E60045BBA8 /* UIViewController+WLAdditions.m in Sources */, | 758 | E6A77917282933E60045BBA8 /* UIViewController+WLAdditions.m in Sources */, |
755 | E6A77943282933E70045BBA8 /* AFNetworkReachabilityManager.m in Sources */, | 759 | E6A77943282933E70045BBA8 /* AFNetworkReachabilityManager.m in Sources */, | ... | ... |
... | @@ -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>1</integer> | 10 | + <integer>0</integer> |
11 | </dict> | 11 | </dict> |
12 | </dict> | 12 | </dict> |
13 | </dict> | 13 | </dict> | ... | ... |
No preview for this file type
... | @@ -9,6 +9,7 @@ import UIKit | ... | @@ -9,6 +9,7 @@ import UIKit |
9 | 9 | ||
10 | class CouponViewController: UIViewController { | 10 | class CouponViewController: UIViewController { |
11 | @IBOutlet weak var mainView: UIView! | 11 | @IBOutlet weak var mainView: UIView! |
12 | + @IBOutlet weak var backgroundImage: UIImageView! | ||
12 | @IBOutlet weak var scrollView: UIScrollView! | 13 | @IBOutlet weak var scrollView: UIScrollView! |
13 | @IBOutlet weak var scrollContentView: UIView! | 14 | @IBOutlet weak var scrollContentView: UIView! |
14 | @IBOutlet weak var couponImageHeight: NSLayoutConstraint! | 15 | @IBOutlet weak var couponImageHeight: NSLayoutConstraint! |
... | @@ -28,6 +29,8 @@ class CouponViewController: UIViewController { | ... | @@ -28,6 +29,8 @@ class CouponViewController: UIViewController { |
28 | setBackButton() | 29 | setBackButton() |
29 | setNavigationTitle("Εκπτωτικό κουπόνι") | 30 | setNavigationTitle("Εκπτωτικό κουπόνι") |
30 | 31 | ||
32 | + backgroundImage.image = UIImage(named: "coupons_scrollview_white") | ||
33 | + | ||
31 | scrollView.clipsToBounds = true | 34 | scrollView.clipsToBounds = true |
32 | scrollView.layer.cornerRadius = 30 | 35 | scrollView.layer.cornerRadius = 30 |
33 | scrollView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius | 36 | scrollView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius | ... | ... |
1 | +// | ||
2 | +// CouponsTableViewCell.swift | ||
3 | +// SwiftWarplyFramework | ||
4 | +// | ||
5 | +// Created by Manos Chorianopoulos on 18/5/22. | ||
6 | +// | ||
7 | + | ||
8 | +import Foundation | ||
9 | +import UIKit | ||
10 | +import WarplySDKFrameworkIOS | ||
11 | + | ||
12 | +class CouponsTableViewCell: UITableViewCell { | ||
13 | + @IBOutlet weak var couponBgImage: UIImageView! | ||
14 | + @IBOutlet weak var couponImage: UIImageView! | ||
15 | + @IBOutlet weak var borderView: UIView! | ||
16 | + @IBOutlet weak var nameLabel: UILabel! | ||
17 | + @IBOutlet weak var dicountLabel: UILabel! | ||
18 | + @IBOutlet weak var discriptionLabel: UILabel! | ||
19 | + @IBOutlet weak var expirationLabel: UILabel! | ||
20 | + | ||
21 | + | ||
22 | + override func awakeFromNib() { | ||
23 | + super.awakeFromNib() | ||
24 | + // Initialization code | ||
25 | + | ||
26 | + couponBgImage.image = UIImage(named: "coupon_bg") | ||
27 | + | ||
28 | + borderView.addDashedBorderVertical(color: UIColor(red: 0.44, green: 0.44, blue: 0.44, alpha: 1.00), width: 1.0, height: 110.0) | ||
29 | + } | ||
30 | + | ||
31 | + override func setSelected(_ selected: Bool, animated: Bool) { | ||
32 | + super.setSelected(selected, animated: animated) | ||
33 | + | ||
34 | + // Configure the view for the selected state | ||
35 | + } | ||
36 | + | ||
37 | + override func layoutSubviews() { | ||
38 | + super.layoutSubviews() | ||
39 | + //set the values for top,left,bottom,right margins | ||
40 | + let margins = UIEdgeInsets(top: 0, left: 0, bottom: 30, right: 0) | ||
41 | + contentView.frame = contentView.frame.inset(by: margins) | ||
42 | + } | ||
43 | + | ||
44 | + | ||
45 | + func configureCell(coupon: swiftApi.CouponItemModel) { | ||
46 | +// COUPONSET: desc, img_preview, name, terms | ||
47 | +// COUPON: coupon, expiration, discount, status | ||
48 | + | ||
49 | + let couponSetData: swiftApi.CouponSetItemModel? = coupon.couponset_data | ||
50 | + | ||
51 | + couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache()) | ||
52 | + nameLabel.text = couponSetData?.name ?? "" | ||
53 | + dicountLabel.text = (coupon.discount ?? "") + "€" | ||
54 | + discriptionLabel.text = couponSetData?.short_description ?? "" | ||
55 | + expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "") | ||
56 | + } | ||
57 | + | ||
58 | +} |
... | @@ -7,21 +7,86 @@ | ... | @@ -7,21 +7,86 @@ |
7 | 7 | ||
8 | import Foundation | 8 | import Foundation |
9 | import UIKit | 9 | import UIKit |
10 | +import WarplySDKFrameworkIOS | ||
10 | 11 | ||
11 | @objc public class CouponsViewController: UIViewController { | 12 | @objc public class CouponsViewController: UIViewController { |
13 | + @IBOutlet weak var backgroundImage: UIImageView! | ||
14 | + @IBOutlet weak var tableView: UITableView! | ||
12 | 15 | ||
13 | - @IBOutlet weak var couponButton: UIButton! | 16 | + var coupons:Array<swiftApi.CouponItemModel> = [] |
17 | + | ||
18 | + override func viewDidLoad() { | ||
19 | + super.viewDidLoad() | ||
20 | + | ||
21 | + getCouponsRequest() | ||
14 | 22 | ||
15 | - public override func viewWillAppear(_ animated: Bool) { | ||
16 | - super.viewWillAppear(animated) | ||
17 | setBackButton() | 23 | setBackButton() |
18 | - setNavigationTitle("Εκπτωτικό κουπόνι") | 24 | + setNavigationTitle("Ενεργά κουπόνια") |
25 | + | ||
26 | + backgroundImage.image = UIImage(named: "coupons_scrollview_dark") | ||
27 | + | ||
28 | + tableView.delegate = self | ||
29 | + tableView.dataSource = self | ||
30 | + | ||
31 | + tableView.clipsToBounds = true | ||
32 | + tableView.layer.cornerRadius = 30 | ||
33 | + tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius | ||
34 | + tableView.contentInset.top = 50 | ||
19 | } | 35 | } |
20 | 36 | ||
21 | 37 | ||
22 | - @IBAction func navigateToCoupon(_ sender: Any) { | 38 | + |
23 | - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 39 | + // MARK: - API Functions |
24 | - let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as UIViewController | 40 | + func getCouponsRequest() { |
25 | - self.navigationController?.pushViewController(vc, animated: true) | 41 | + swiftApi().getCouponsAsync(getCouponsCallback) |
26 | } | 42 | } |
43 | + | ||
44 | + func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void { | ||
45 | + if (couponsData != nil) { | ||
46 | + let activeCouponData = swiftApi().filterActiveCoupons(couponsData ?? []) | ||
47 | + | ||
48 | + self.coupons = activeCouponData | ||
49 | + | ||
50 | + DispatchQueue.main.async { | ||
51 | + self.tableView.reloadData() | ||
52 | + } | ||
53 | + } else { | ||
54 | + self.coupons = [] | ||
55 | + } | ||
56 | + } | ||
57 | + | ||
58 | +} | ||
59 | + | ||
60 | +// MARK: - TableView | ||
61 | +extension CouponsViewController: UITableViewDelegate, UITableViewDataSource{ | ||
62 | + | ||
63 | + func numberOfSections(in tableView: UITableView) -> Int { | ||
64 | + return 1 | ||
65 | + } | ||
66 | + | ||
67 | + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
68 | + return self.coupons.count | ||
69 | + } | ||
70 | + | ||
71 | + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | ||
72 | + return 120.0 + 30.0 | ||
73 | +// return UITableViewAutomaticDimension | ||
74 | + } | ||
75 | + | ||
76 | + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
77 | + let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell | ||
78 | + | ||
79 | + cell.configureCell(coupon: coupons[indexPath.row]) | ||
80 | + | ||
81 | + return cell | ||
82 | + } | ||
83 | + | ||
84 | + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
85 | + | ||
86 | + // TODO: navigate to CouponBarcode | ||
87 | + // let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | ||
88 | + // let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as UIViewController | ||
89 | + // self.navigationController?.pushViewController(vc, animated: true) | ||
90 | + } | ||
91 | + | ||
27 | } | 92 | } | ... | ... |
This diff is collapsed. Click to expand it.
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/coupon_bg.imageset/Contents.json
0 → 100644
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "coupon_bg.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "coupon_bg-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "coupon_bg-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/coupon_bg.imageset/coupon_bg-1.png
0 → 100644
2.28 KB
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/coupon_bg.imageset/coupon_bg-2.png
0 → 100644
2.28 KB
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/coupon_bg.imageset/coupon_bg.png
0 → 100644
2.28 KB
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "coupons_scrollview_dark.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "coupons_scrollview_dark-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "coupons_scrollview_dark-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
9.93 KB
9.93 KB
9.93 KB
... | @@ -63,3 +63,49 @@ extension String { | ... | @@ -63,3 +63,49 @@ extension String { |
63 | return htmlToAttributedString?.string ?? "" | 63 | return htmlToAttributedString?.string ?? "" |
64 | } | 64 | } |
65 | } | 65 | } |
66 | + | ||
67 | +extension UIView { | ||
68 | + | ||
69 | + func addDashedBorderVertical(color: UIColor, width: CGFloat, height: CGFloat) { | ||
70 | + | ||
71 | + let color = color.cgColor | ||
72 | + let frameSize = self.frame.size | ||
73 | + | ||
74 | + let lineLayer = CAShapeLayer() | ||
75 | + lineLayer.strokeColor = color | ||
76 | + lineLayer.lineWidth = width | ||
77 | + lineLayer.lineDashPattern = [5,5] | ||
78 | + | ||
79 | + let path = CGMutablePath() | ||
80 | + path.addLines(between: [CGPoint(x: frameSize.width/2, y: 0), CGPoint(x: frameSize.width/2, y: height)]) | ||
81 | + lineLayer.path = path | ||
82 | + self.layer.addSublayer(lineLayer) | ||
83 | + } | ||
84 | +} | ||
85 | + | ||
86 | +extension UIImageView { | ||
87 | + | ||
88 | + func load(link: String, placeholder: UIImage?, cache: URLCache? = nil) { | ||
89 | + guard let url = URL(string: link) else { return } | ||
90 | + | ||
91 | + let cache = cache ?? URLCache.shared | ||
92 | + let request = URLRequest(url: url) | ||
93 | + if let data = cache.cachedResponse(for: request)?.data, let image = UIImage(data: data) { | ||
94 | + DispatchQueue.main.async { | ||
95 | + self.image = image | ||
96 | + } | ||
97 | + } else { | ||
98 | + self.image = placeholder | ||
99 | + URLSession.shared.dataTask(with: request, completionHandler: { (data, response, error) in | ||
100 | + if let data = data, let response = response, ((response as? HTTPURLResponse)?.statusCode ?? 500) < 300, let image = UIImage(data: data) { | ||
101 | + let cachedData = CachedURLResponse(response: response, data: data) | ||
102 | + cache.storeCachedResponse(cachedData, for: request) | ||
103 | + DispatchQueue.main.async { | ||
104 | + self.image = image | ||
105 | + } | ||
106 | + | ||
107 | + } | ||
108 | + }).resume() | ||
109 | + } | ||
110 | + } | ||
111 | +} | ... | ... |
-
Please register or login to post a comment