Manos Chorianopoulos

added PopupMerchantsViewController

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -26,6 +26,8 @@
1E46B4C12BEBBDD800D5B488 /* WalletActiveCouponCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E46B4C02BEBBDD800D5B488 /* WalletActiveCouponCollectionViewCell.swift */; };
1E479FB329DD948B00C38193 /* WalletBadgesTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E479FB229DD948B00C38193 /* WalletBadgesTableViewCell.swift */; };
1E51678E2AE6934100FE66C3 /* WalletVouchersBannerTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E51678D2AE6934100FE66C3 /* WalletVouchersBannerTableViewCell.swift */; };
1E56DF732CC249B300F71882 /* MerchantTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E56DF722CC249B300F71882 /* MerchantTableViewCell.swift */; };
1E56DF752CC2620000F71882 /* PopupMerchantsFooterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E56DF742CC2620000F71882 /* PopupMerchantsFooterTableViewCell.swift */; };
1E64E8FD2B8DE457001BA46E /* WalletQuestionnaireBannerTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E64E8FC2B8DE457001BA46E /* WalletQuestionnaireBannerTableViewCell.swift */; };
1E64E8FF2B8DE487001BA46E /* WalletHistoryBannerTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E64E8FE2B8DE487001BA46E /* WalletHistoryBannerTableViewCell.swift */; };
1E64E9012B8DE4AC001BA46E /* WalletEmptyViewTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E64E9002B8DE4AC001BA46E /* WalletEmptyViewTableViewCell.swift */; };
......@@ -62,6 +64,7 @@
1EDCDFAC28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EDCDFAB28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift */; };
1EDD4F892AE937AA00A6B5A6 /* LoyaltyHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EDD4F882AE937AA00A6B5A6 /* LoyaltyHistoryViewController.swift */; };
1EE67DA32AE2AF2B0057C8CC /* UnifiedCouponsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE67DA22AE2AF2B0057C8CC /* UnifiedCouponsViewController.swift */; };
1EEC5C582CC15C4600CF3CAC /* PopupMerchantsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EEC5C572CC15C4600CF3CAC /* PopupMerchantsViewController.swift */; };
7630AD9A6242D60846D6750C /* Pods_SwiftWarplyFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */; };
A02F34052882B6E60086465F /* TelcoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A02F34042882B6E60086465F /* TelcoViewController.swift */; };
A04D31DE288FF670000E43B5 /* HistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A04D31DD288FF670000E43B5 /* HistoryViewController.swift */; };
......@@ -220,6 +223,8 @@
1E46B4C02BEBBDD800D5B488 /* WalletActiveCouponCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletActiveCouponCollectionViewCell.swift; sourceTree = "<group>"; };
1E479FB229DD948B00C38193 /* WalletBadgesTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletBadgesTableViewCell.swift; sourceTree = "<group>"; };
1E51678D2AE6934100FE66C3 /* WalletVouchersBannerTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletVouchersBannerTableViewCell.swift; sourceTree = "<group>"; };
1E56DF722CC249B300F71882 /* MerchantTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantTableViewCell.swift; sourceTree = "<group>"; };
1E56DF742CC2620000F71882 /* PopupMerchantsFooterTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopupMerchantsFooterTableViewCell.swift; sourceTree = "<group>"; };
1E64E8FC2B8DE457001BA46E /* WalletQuestionnaireBannerTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletQuestionnaireBannerTableViewCell.swift; sourceTree = "<group>"; };
1E64E8FE2B8DE487001BA46E /* WalletHistoryBannerTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletHistoryBannerTableViewCell.swift; sourceTree = "<group>"; };
1E64E9002B8DE4AC001BA46E /* WalletEmptyViewTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletEmptyViewTableViewCell.swift; sourceTree = "<group>"; };
......@@ -255,6 +260,7 @@
1EDCDFAB28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisMoreViewCell.swift; sourceTree = "<group>"; };
1EDD4F882AE937AA00A6B5A6 /* LoyaltyHistoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoyaltyHistoryViewController.swift; sourceTree = "<group>"; };
1EE67DA22AE2AF2B0057C8CC /* UnifiedCouponsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnifiedCouponsViewController.swift; sourceTree = "<group>"; };
1EEC5C572CC15C4600CF3CAC /* PopupMerchantsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopupMerchantsViewController.swift; sourceTree = "<group>"; };
A02F34042882B6E60086465F /* TelcoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TelcoViewController.swift; sourceTree = "<group>"; };
A04D31DD288FF670000E43B5 /* HistoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HistoryViewController.swift; sourceTree = "<group>"; };
A079366D2885D07700064122 /* AnalysisChildViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisChildViewController.swift; sourceTree = "<group>"; };
......@@ -567,6 +573,9 @@
1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */,
1EB5F4C728536FD60016F36E /* StepsViewController.swift */,
1E36E43C2CBFDD5100A60198 /* PopupInfoViewController.swift */,
1EEC5C572CC15C4600CF3CAC /* PopupMerchantsViewController.swift */,
1E56DF722CC249B300F71882 /* MerchantTableViewCell.swift */,
1E56DF742CC2620000F71882 /* PopupMerchantsFooterTableViewCell.swift */,
E6A77860282933E40045BBA8 /* MyApi.h */,
E6A778DC282933E60045BBA8 /* MyApi.m */,
E6A77862282933E50045BBA8 /* MyEmptyClass.swift */,
......@@ -993,6 +1002,7 @@
E6A77901282933E60045BBA8 /* WLBaseItem.m in Sources */,
1EE67DA32AE2AF2B0057C8CC /* UnifiedCouponsViewController.swift in Sources */,
1E74838D28378AF40042A589 /* CouponBarcodeViewController.swift in Sources */,
1E56DF732CC249B300F71882 /* MerchantTableViewCell.swift in Sources */,
1E479FB329DD948B00C38193 /* WalletBadgesTableViewCell.swift in Sources */,
1E151F1829DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift in Sources */,
E6A778F0282933E60045BBA8 /* WLNativeAdsCollectionMode.m in Sources */,
......@@ -1059,6 +1069,7 @@
E6A77947282933E70045BBA8 /* FMDatabaseQueue.m in Sources */,
E6A77922282933E60045BBA8 /* NSData+SSToolkitAdditions.m in Sources */,
1EA771AC290977CA0030924C /* CopyableLabel.swift in Sources */,
1E56DF752CC2620000F71882 /* PopupMerchantsFooterTableViewCell.swift in Sources */,
1EB236AB28816B680063777A /* ShareViewController.swift in Sources */,
E6A778E7282933E60045BBA8 /* DetailsViewController.swift in Sources */,
1EB5F4CA285370C90016F36E /* LoyaltyAnalysisViewController.swift in Sources */,
......@@ -1087,6 +1098,7 @@
A04D31DE288FF670000E43B5 /* HistoryViewController.swift in Sources */,
E6A7792A282933E70045BBA8 /* AFNetworkActivityIndicatorManager.m in Sources */,
E6A77914282933E60045BBA8 /* WLUserManager.m in Sources */,
1EEC5C582CC15C4600CF3CAC /* PopupMerchantsViewController.swift in Sources */,
1EB236AF28816CAC0063777A /* NumbersTableViewCell.swift in Sources */,
E6A7794F282933E70045BBA8 /* FMDatabasePool.m in Sources */,
1EB236AD28816C560063777A /* NumberPopupViewController.swift in Sources */,
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "30A67F8F-7993-41EC-813B-55466ABD0520"
type = "0"
version = "2.0">
</Bucket>
......@@ -640,7 +640,18 @@ import AVFoundation
@IBAction func redeemButtomAction(_ sender: Any) {
if (isSMCoupon == true) {
// TODO: Open popup
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
if let popupVC = storyboard.instantiateViewController(withIdentifier: "PopupMerchantsViewController") as? SwiftWarplyFramework.PopupMerchantsViewController {
popupVC.modalPresentationStyle = .overCurrentContext
popupVC.modalTransitionStyle = .crossDissolve
popupVC.coupon = coupon
// popupVC.headerText = "Βρες το προϊον στα supermarket"
// popupVC.buttonTitle = "Βρες το"
popupVC.buttonIcon = "shopping_cart"
// popupVC.footerText = "Η διαθεσιμότητα ενδέχεται να διαφέρει ανάλογα με την τοποθεσία."
self.present(popupVC, animated: true, completion: nil)
}
} else {
let couponSetData: swiftApi.CouponSetItemModel? = self.coupon?.couponset_data
......
{
"images" : [
{
"filename" : "shopping_cart.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "shopping_cart 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "shopping_cart 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
//
// MerchantTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/10/24.
//
import UIKit
// Define a protocol (if using delegation)
protocol MerchantTableViewCellDelegate: AnyObject {
func didTapButton(in cell: MerchantTableViewCell)
}
class MerchantTableViewCell: UITableViewCell {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var merchantImage: UIImageView!
@IBOutlet weak var buttonView: UIView!
@IBOutlet weak var buttonTitleLable: UILabel!
@IBOutlet weak var buttonIconImage: UIImageView!
@IBOutlet weak var actionButton: UIButton!
// Delegate variable
weak var delegate: MerchantTableViewCellDelegate?
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.merchantImage.image = UIImage() // UIImage(named: "loading")
UIImage.loadImageUsingCacheWithUrlString(url) { image in
// set the image only when we are still displaying the content for the image we finished downloading
if url == self.postImageURL {
self.merchantImage.image = image
}
}
}
else {
self.merchantImage.image = nil
}
}
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
mainView.backgroundColor = UIColor(rgb: 0xF2F2F3)
mainView.layer.cornerRadius = 20.0
buttonTitleLable.font = UIFont(name: "PeridotPE-SBold", size: 13)
buttonTitleLable.textColor = UIColor(rgb: 0xFFFFFF)
buttonView.backgroundColor = UIColor(rgb: 0x0EA600)
buttonView.layer.cornerRadius = 12.0
// Add action for button tap
actionButton.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
public override func layoutSubviews() {
super.layoutSubviews()
//set the values for top,left,bottom,right margins
let margins = UIEdgeInsets(top: 0, left: 0, bottom: 32, right: 0)
contentView.frame = contentView.frame.inset(by: margins)
}
func configureCell(merchant: swiftApi.MerchantModel, buttonTitle: String, iconImage: String?) {
self.postImageURL = merchant._img_preview
buttonTitleLable.text = buttonTitle
if let iconImage {
self.buttonIconImage.image = UIImage(named: iconImage)
self.buttonIconImage.isHidden = false
} else {
self.buttonIconImage.isHidden = true
}
}
@objc private func buttonTapped() {
// Notify the delegate when button is tapped
delegate?.didTapButton(in: self)
}
}
//
// PopupMerchantsFooterTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/10/24.
//
import UIKit
class PopupMerchantsFooterTableViewCell: UITableViewCell {
@IBOutlet weak var footerLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
footerLabel.font = UIFont(name: "PeridotPE-Regular", size: 13)
footerLabel.textColor = UIColor(rgb: 0x000000)
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func configureCell(title: String) {
footerLabel.text = title
}
}
//
// PopupSMMerchantsViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 17/10/24.
//
import UIKit
class PopupMerchantsViewController: UIViewController {
@IBOutlet weak var popupView: UIView!
@IBOutlet weak var headerLabel: UILabel!
@IBOutlet weak var closeButton: UIButton!
@IBOutlet weak var tableView: DynamicSizeTableView!
public var coupon: swiftApi.CouponItemModel?
public var headerText: String? = "Βρες το προϊον στα supermarket"
public var buttonTitle: String? = "Βρες το"
public var buttonIcon: String?
public var footerText: String? = "Η διαθεσιμότητα ενδέχεται να διαφέρει ανάλογα με την τοποθεσία."
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
tableView.contentInset.top = 75
popupView.clipsToBounds = true
popupView.layer.cornerRadius = 16
popupView.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, right corner radius
closeButton.setImage(UIImage(named: "ic_close_3.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
closeButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
// self.tableView.reloadData()
self.tableView.invalidateIntrinsicContentSize()
self.headerLabel.text = self.headerText
headerLabel.font = UIFont(name: "BTCosmo-Bold", size: 18)
headerLabel.textColor = UIColor(rgb: 0x000000)
}
// MARK: - UIButton Actions
@IBAction func closeButtonAction(_ sender: Any) {
}
}
// MARK: - TableView
extension PopupMerchantsViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
return self.merchantList.count
} else if (section == 1) {
return 1
} else {
return 0
}
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if (indexPath.section == 0) {
return 56.0 + 32.0
// return UITableViewAutomaticDimension
} else if (indexPath.section == 1) {
return 100.0
} else {
return 0.0
}
// return UITableViewAutomaticDimension
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if (indexPath.section == 0) {
let cell = tableView.dequeueReusableCell(withIdentifier: "MerchantTableViewCellId", for: indexPath) as! MerchantTableViewCell
cell.configureCell(merchant: merchantList[indexPath.row], buttonTitle: self.buttonTitle ?? "Βρες το", iconImage: buttonIcon)
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "PopupMerchantsFooterTableViewCellId", for: indexPath) as! PopupMerchantsFooterTableViewCell
cell.configureCell(title: self.footerText ?? "Η διαθεσιμότητα ενδέχεται να διαφέρει ανάλογα με την τοποθεσία.")
return cell
}
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// self.dismiss(animated: true, completion: {})
// TODO: DELETE LOGS
print(" didSelectRowAt Button tapped in row \(indexPath.row)")
// TODO: Open merchant url
// Logs
// let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data
// print("Coupon clicked: " + (coupons[indexPath.row].coupon ?? ""))
// print("Coupon Name clicked: " + (couponSetData?.name ?? ""))
// print("Coupon Description clicked: " + (couponSetData?.short_description ?? ""))
// print("Coupon Expiration clicked: " + (coupons[indexPath.row].expiration ?? ""))
}
public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return nil
}
public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 0.0
}
public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// return CGFloat.leastNormalMagnitude
return 0.0
}
public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return nil
}
}
// MARK: - MerchantTableViewCellDelegate
extension PopupMerchantsViewController: MerchantTableViewCellDelegate {
func didTapButton(in cell: MerchantTableViewCell) {
// Find the index path of the cell where the button was tapped
if let indexPath = tableView.indexPath(for: cell) {
// TODO: DELETE LOGS
print("Button tapped in row \(indexPath.row)")
print("Button tapped cell: \(cell)")
// Handle the button tap action here
}
}
}