Manos Chorianopoulos

contest press handling

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -48,7 +48,7 @@ extension UIViewController {
//your custom view for back image with custom size
let view = UIView(frame: CGRect(x: 0, y: 0, width: 40, height: 40))
let imageView = UIImageView(frame: CGRect(x: 10, y: 10, width: 18, height: 18))
let imageView = UIImageView(frame: CGRect(x: 10, y: 12, width: 15, height: 15))
if let imgBackArrow = UIImage(named: icon, in: MyEmptyClass.resourceBundle(), compatibleWith: nil) {
imageView.image = imgBackArrow
......@@ -149,31 +149,31 @@ extension UIViewController {
self.navigationController?.navigationBar.layer.shadowRadius = 2
}
func setNavigationTitle(_ title: String, _ fontWeight: String? = "medium") {
func setNavigationTitle(_ title: String, _ fontWeight: String? = "bold") {
let uiscreen: CGRect = UIScreen.main.bounds
let titleLabel = UILabel(frame: CGRect(x: 0, y: 0, width: uiscreen.width * 0.7, height: uiscreen.height * 0.03))
titleLabel.text = title
titleLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
titleLabel.textColor = UIColor(rgb: 0x0D1B29)
// Fix width for ipad
if UIDevice.current.userInterfaceIdiom == .pad {
// iPad
if (fontWeight == "bold") {
titleLabel.font = UIFont(name: "PingLCG-Bold", size: 21)
titleLabel.font = UIFont(name: "PingLCG-Bold", size: 20)
} else {
titleLabel.font = UIFont(name: "PingLCG-Bold", size: 21)
titleLabel.font = UIFont(name: "PingLCG-Bold", size: 20)
}
} else {
// not iPad (iPhone, mac, tv, carPlay, unspecified)
if (fontWeight == "bold") {
titleLabel.font = UIFont(name: "PingLCG-Bold", size: 19)
titleLabel.font = UIFont(name: "PingLCG-Bold", size: 18)
} else {
titleLabel.font = UIFont(name: "PingLCG-Bold", size: 19)
titleLabel.font = UIFont(name: "PingLCG-Bold", size: 18)
}
}
titleLabel.adjustsFontSizeToFitWidth = true
titleLabel.textAlignment = .center
titleLabel.textAlignment = .left
self.navigationItem.titleView = titleLabel
}
......
......@@ -7,6 +7,10 @@
import UIKit
protocol MyRewardsBannerOffersScrollTableViewCellDelegate: AnyObject {
func didSelectBannerOffer(_ offer: OfferModel)
}
@objc public class MyRewardsBannerOffersScrollTableViewCell: UITableViewCell {
@IBOutlet weak var tagView1: UIView!
@IBOutlet weak var tagLabel1: UILabel!
......@@ -16,6 +20,7 @@ import UIKit
@IBOutlet weak var collectionView: UICollectionView!
@IBOutlet weak var pageControl: UIPageControl!
weak var delegate: MyRewardsBannerOffersScrollTableViewCellDelegate?
var data: SectionModel?
public override func awakeFromNib() {
......@@ -92,7 +97,7 @@ import UIKit
}
}
extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, UIScrollViewDelegate {
public func numberOfSections(in collectionView: UICollectionView) -> Int {
......@@ -113,7 +118,11 @@ extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource,
}
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
// TODO: open offer
// Get the selected offer
if let offer = self.data?.offers[indexPath.row] {
// Call the delegate method to notify the parent
delegate?.didSelectBannerOffer(offer)
}
}
// MARK: - UICollectionViewDelegateFlowLayout
......
......@@ -77,6 +77,7 @@ var timer2: DispatchSourceTimer?
if (showHeader) {
setBackButton()
setNavigationTitle("Προσφορά")
}
// Add observers for application state changes
......
......@@ -101,7 +101,7 @@ struct OfferModel {
discountType: "price",
bannerImage: "dominos_banner",
merchantLogo: "dominos_logo",
expirationDate: "έως 30-09",
expirationDate: "έως 30/09",
color: 0xEE417D,
isFavorite: true
),
......@@ -113,7 +113,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "dominos_banner",
merchantLogo: "dominos_logo",
expirationDate: "έως 30-09",
expirationDate: "έως 30/09",
color: 0xEE417D,
isFavorite: false
),
......@@ -127,7 +127,7 @@ struct OfferModel {
// discountType: "percentage",
// bannerImage: "car_rental_banner",
// merchantLogo: "avis_logo",
// expirationDate: "έως 30-09",
// expirationDate: "έως 30/09",
// color: 0xEE417D,
// isFavorite: true
// ),
......@@ -139,7 +139,7 @@ struct OfferModel {
// discountType: "amount",
// bannerImage: "hotel_banner",
// merchantLogo: "booking_logo",
// expirationDate: "έως 30-09",
// expirationDate: "έως 30/09",
// color: 0xEE417D,
// isFavorite: true
// ),
......@@ -153,7 +153,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "musa_banner",
merchantLogo: "musa_logo",
expirationDate: "έως 30-09",
expirationDate: "έως 30/09",
color: 0x09914E,
isFavorite: false
),
......@@ -165,7 +165,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "musa_banner",
merchantLogo: "musa_logo",
expirationDate: "έως 30-09",
expirationDate: "έως 30/09",
color: 0x09914E,
isFavorite: true
),
......@@ -179,7 +179,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "ranch_banner",
merchantLogo: "ranch_logo",
expirationDate: "έως 30-09",
expirationDate: "έως 30/09",
color: 0xFC9F25,
isFavorite: false
),
......@@ -191,7 +191,7 @@ struct OfferModel {
discountType: "buyOneGetOne",
bannerImage: "ranch_banner",
merchantLogo: "ranch_logo",
expirationDate: "έως 30-09",
expirationDate: "έως 30/09",
color: 0xFC9F25,
isFavorite: false
),
......@@ -205,7 +205,7 @@ struct OfferModel {
discountType: "amount",
bannerImage: "coffeeisland_banner",
merchantLogo: "coffeeisland_logo",
expirationDate: "έως 30-09",
expirationDate: "έως 30/09",
color: 0xEE417D,
isFavorite: false
),
......@@ -217,7 +217,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "coffeeisland_banner",
merchantLogo: "coffeeisland_logo",
expirationDate: "έως 30-09",
expirationDate: "έως 30/09",
color: 0xEE417D,
isFavorite: false
),
......@@ -231,7 +231,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "ninemia_banner",
merchantLogo: "ninemia_logo",
expirationDate: "έως 30-09",
expirationDate: "έως 30/09",
color: 0xEE417D,
isFavorite: true
),
......@@ -243,7 +243,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "ninemia_banner",
merchantLogo: "ninemia_logo",
expirationDate: "έως 30-09",
expirationDate: "έως 30/09",
color: 0xEE417D,
isFavorite: false
),
......@@ -257,7 +257,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "moustakas_banner",
merchantLogo: "moustakas_logo",
expirationDate: "έως 30-09",
expirationDate: "έως 30/09",
color: 0xEE417D,
isFavorite: false
),
......@@ -269,7 +269,7 @@ struct OfferModel {
discountType: "buyOneGetOne",
bannerImage: "moustakas_banner",
merchantLogo: "moustakas_logo",
expirationDate: "έως 30-09",
expirationDate: "έως 30/09",
color: 0xEE417D,
isFavorite: false
),
......@@ -283,7 +283,7 @@ struct OfferModel {
discountType: "amount",
bannerImage: "migato_banner",
merchantLogo: "migato_logo",
expirationDate: "έως 30-09",
expirationDate: "έως 30/09",
color: 0xEE417D,
isFavorite: false
),
......@@ -295,7 +295,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "migato_banner",
merchantLogo: "migato_logo",
expirationDate: "έως 30-09",
expirationDate: "έως 30/09",
color: 0xEE417D,
isFavorite: false
)
......@@ -314,6 +314,9 @@ struct OfferModel {
public override func viewDidLoad() {
super.viewDidLoad()
// Hide the navigation bar
// self.navigationController?.setNavigationBarHidden(true, animated: false)
// Register XIBs for table view cells
tableView.register(UINib(nibName: "MyRewardsBannerOffersScrollTableViewCell", bundle: Bundle(for: MyEmptyClass.self)), forCellReuseIdentifier: "MyRewardsBannerOffersScrollTableViewCell")
tableView.register(UINib(nibName: "MyRewardsOffersScrollTableViewCell", bundle: Bundle(for: MyEmptyClass.self)), forCellReuseIdentifier: "MyRewardsOffersScrollTableViewCell")
......@@ -328,6 +331,21 @@ struct OfferModel {
initializeSections()
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Hide navigation bar when this view appears
self.navigationController?.setNavigationBarHidden(true, animated: animated)
}
public override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Show navigation bar when leaving this view (for other screens)
self.navigationController?.setNavigationBarHidden(false, animated: animated)
}
// MARK: Function
func initializeSections() {
// Banner Offers (for the promotional banner at the top)
......@@ -405,6 +423,17 @@ struct OfferModel {
self.tableView.reloadData()
}
// Add navigation method
private func openCampaignViewController(with offer: OfferModel) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
if let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as? SwiftWarplyFramework.CampaignViewController {
vc.campaignUrl = "https://warply.s3.amazonaws.com/dei/campaigns/DehEasterContest_stage/index.html"
vc.showHeader = true
self.navigationController?.pushViewController(vc, animated: true)
// self.present(vc, animated: true)
}
}
}
// MARK: - TableView
......@@ -442,6 +471,7 @@ extension MyRewardsViewController: UITableViewDelegate, UITableViewDataSource{
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if (indexPath.section == 0) {
let cell = tableView.dequeueReusableCell(withIdentifier: "MyRewardsBannerOffersScrollTableViewCell", for: indexPath) as! MyRewardsBannerOffersScrollTableViewCell
cell.delegate = self
cell.configureCell(data: self.bannerOffersSection)
// cell.parent = self
return cell
......@@ -495,3 +525,11 @@ extension MyRewardsViewController: UITableViewDelegate, UITableViewDataSource{
}
}
}
// Add delegate conformance
extension MyRewardsViewController: MyRewardsBannerOffersScrollTableViewCellDelegate {
func didSelectBannerOffer(_ offer: OfferModel) {
// Navigate to CampaignViewController
openCampaignViewController(with: offer)
}
}
......