Showing
6 changed files
with
196 additions
and
2 deletions
| ... | @@ -14,6 +14,7 @@ | ... | @@ -14,6 +14,7 @@ |
| 14 | 1E108A9628A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E108A9128A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf */; }; | 14 | 1E108A9628A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E108A9128A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf */; }; |
| 15 | 1E2966EA2837A21D00F83FAC /* RSBarcodes_Swift in Frameworks */ = {isa = PBXBuildFile; productRef = 1E2966E92837A21D00F83FAC /* RSBarcodes_Swift */; }; | 15 | 1E2966EA2837A21D00F83FAC /* RSBarcodes_Swift in Frameworks */ = {isa = PBXBuildFile; productRef = 1E2966E92837A21D00F83FAC /* RSBarcodes_Swift */; }; |
| 16 | 1E74838D28378AF40042A589 /* CouponBarcodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */; }; | 16 | 1E74838D28378AF40042A589 /* CouponBarcodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */; }; |
| 17 | + 1E87A9EF28C2021200C79F90 /* ContextualViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E87A9EE28C2021200C79F90 /* ContextualViewController.swift */; }; | ||
| 17 | 1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */; }; | 18 | 1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */; }; |
| 18 | 1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */; }; | 19 | 1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */; }; |
| 19 | 1EB236AB28816B680063777A /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AA28816B680063777A /* ShareViewController.swift */; }; | 20 | 1EB236AB28816B680063777A /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AA28816B680063777A /* ShareViewController.swift */; }; |
| ... | @@ -169,6 +170,7 @@ | ... | @@ -169,6 +170,7 @@ |
| 169 | 1E108A9128A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = pf_square_sans_pro_bold.ttf; sourceTree = "<group>"; }; | 170 | 1E108A9128A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = pf_square_sans_pro_bold.ttf; sourceTree = "<group>"; }; |
| 170 | 1E108A9728A3FA9B0008B8E7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; | 171 | 1E108A9728A3FA9B0008B8E7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; |
| 171 | 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewController.swift; sourceTree = "<group>"; }; | 172 | 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewController.swift; sourceTree = "<group>"; }; |
| 173 | + 1E87A9EE28C2021200C79F90 /* ContextualViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContextualViewController.swift; sourceTree = "<group>"; }; | ||
| 172 | 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponsTableViewCell.swift; sourceTree = "<group>"; }; | 174 | 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponsTableViewCell.swift; sourceTree = "<group>"; }; |
| 173 | 1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxTableViewCell.swift; sourceTree = "<group>"; }; | 175 | 1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxTableViewCell.swift; sourceTree = "<group>"; }; |
| 174 | 1EB236AA28816B680063777A /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; }; | 176 | 1EB236AA28816B680063777A /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; }; |
| ... | @@ -449,6 +451,7 @@ | ... | @@ -449,6 +451,7 @@ |
| 449 | E6A77A35282BB4CB0045BBA8 /* MakeItAPresentViewController.swift */, | 451 | E6A77A35282BB4CB0045BBA8 /* MakeItAPresentViewController.swift */, |
| 450 | E6A7785A282933E40045BBA8 /* Helpers */, | 452 | E6A7785A282933E40045BBA8 /* Helpers */, |
| 451 | E6A77861282933E50045BBA8 /* Main.storyboard */, | 453 | E6A77861282933E50045BBA8 /* Main.storyboard */, |
| 454 | + 1E87A9EE28C2021200C79F90 /* ContextualViewController.swift */, | ||
| 452 | 1EB236AA28816B680063777A /* ShareViewController.swift */, | 455 | 1EB236AA28816B680063777A /* ShareViewController.swift */, |
| 453 | 1EB236AC28816C560063777A /* NumberPopupViewController.swift */, | 456 | 1EB236AC28816C560063777A /* NumberPopupViewController.swift */, |
| 454 | 1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */, | 457 | 1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */, |
| ... | @@ -874,6 +877,7 @@ | ... | @@ -874,6 +877,7 @@ |
| 874 | E6A778E2282933E60045BBA8 /* CouponsViewController.swift in Sources */, | 877 | E6A778E2282933E60045BBA8 /* CouponsViewController.swift in Sources */, |
| 875 | E6A77930282933E70045BBA8 /* UIImageView+AFNetworking.m in Sources */, | 878 | E6A77930282933E70045BBA8 /* UIImageView+AFNetworking.m in Sources */, |
| 876 | E6A77900282933E60045BBA8 /* WLInboxItemViewController.m in Sources */, | 879 | E6A77900282933E60045BBA8 /* WLInboxItemViewController.m in Sources */, |
| 880 | + 1E87A9EF28C2021200C79F90 /* ContextualViewController.swift in Sources */, | ||
| 877 | E6A7793E282933E70045BBA8 /* AFHTTPSessionManager.m in Sources */, | 881 | E6A7793E282933E70045BBA8 /* AFHTTPSessionManager.m in Sources */, |
| 878 | E6A77933282933E70045BBA8 /* UIButton+AFNetworking.m in Sources */, | 882 | E6A77933282933E70045BBA8 /* UIButton+AFNetworking.m in Sources */, |
| 879 | E6A77919282933E60045BBA8 /* Warply.m in Sources */, | 883 | E6A77919282933E60045BBA8 /* Warply.m in Sources */, | ... | ... |
No preview for this file type
| 1 | +// | ||
| 2 | +// ContextualViewController.swift | ||
| 3 | +// SwiftWarplyFramework | ||
| 4 | +// | ||
| 5 | +// Created by Manos Chorianopoulos on 2/9/22. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import UIKit | ||
| 9 | + | ||
| 10 | +@objc public class ContextualViewController: UIViewController, UIPopoverControllerDelegate { | ||
| 11 | + @IBOutlet weak var mainView: UIView! | ||
| 12 | + @IBOutlet weak var backgroundImage: UIImageView! | ||
| 13 | + @IBOutlet weak var scrollView: UIScrollView! | ||
| 14 | + @IBOutlet weak var scrollContentView: UIView! | ||
| 15 | + @IBOutlet weak var couponImage: UIImageView! | ||
| 16 | + @IBOutlet weak var couponImageHeight: NSLayoutConstraint! | ||
| 17 | + @IBOutlet weak var nameLabel: UILabel! | ||
| 18 | + @IBOutlet weak var descriptionLabel: UILabel! | ||
| 19 | + @IBOutlet weak var redeemButton: UIButton! | ||
| 20 | + | ||
| 21 | + public var ccms: swiftApi.LoyaltyContextualOfferModel? | ||
| 22 | + | ||
| 23 | + var selectedNumber: String = "" | ||
| 24 | + public var numbersList: Array<String> = [] | ||
| 25 | + | ||
| 26 | + let uiscreen: CGRect = UIScreen.main.bounds | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + public override func viewDidLoad() { | ||
| 30 | + super.viewDidLoad() | ||
| 31 | + | ||
| 32 | + self.hidesBottomBarWhenPushed = true | ||
| 33 | + | ||
| 34 | + // Do any additional setup after loading the view. | ||
| 35 | + getProfileRequest() | ||
| 36 | + | ||
| 37 | + setBackButton() | ||
| 38 | +// setNavigationTitle("") | ||
| 39 | + | ||
| 40 | + backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil) | ||
| 41 | + | ||
| 42 | + scrollView.clipsToBounds = true | ||
| 43 | + scrollView.layer.cornerRadius = 30 | ||
| 44 | + scrollView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius | ||
| 45 | + | ||
| 46 | + couponImage.load(link: ccms?._imageUrl ?? "", placeholder: UIImage(), cache: URLCache()) | ||
| 47 | + couponImage.contentMode = .scaleAspectFill | ||
| 48 | + couponImageHeight.constant = self.uiscreen.height * 0.25 | ||
| 49 | + | ||
| 50 | + nameLabel.text = ccms?._title ?? "" | ||
| 51 | + descriptionLabel.text = ccms?._subtitle ?? "" | ||
| 52 | + | ||
| 53 | + redeemButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16) | ||
| 54 | + redeemButton.setTitle("Ενεργοποίηση", for: .normal) | ||
| 55 | + redeemButton.setTitleColor(.white, for: .normal) | ||
| 56 | + redeemButton.backgroundColor = UIColor(red: 0.47, green: 0.75, blue: 0.08, alpha: 1.00) | ||
| 57 | + redeemButton.layer.cornerRadius = 12.0 | ||
| 58 | + | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + // MARK: - Functions | ||
| 62 | + func showConfirmDialog() -> Void { | ||
| 63 | + | ||
| 64 | + let alert = UIAlertController(title: "Ενεργοποίηση υπηρεσίας", message: "Θέλετε να γίνει ενεργοποίηση στο Κινητό μου;", preferredStyle: .alert) | ||
| 65 | + alert.addAction(UIAlertAction(title: "Ενεργοποίηση", style: .default, handler: { action in | ||
| 66 | + switch action.style{ | ||
| 67 | + case .default: | ||
| 68 | + self.submitOrderRequest() | ||
| 69 | + | ||
| 70 | + case .cancel: | ||
| 71 | + print("cancel") | ||
| 72 | + | ||
| 73 | + case .destructive: | ||
| 74 | + print("destructive") | ||
| 75 | + | ||
| 76 | + } | ||
| 77 | + })) | ||
| 78 | + alert.addAction(UIAlertAction(title: "Άκυρο", style: .default, handler: { action in | ||
| 79 | + switch action.style{ | ||
| 80 | + case .default: | ||
| 81 | + print("default") | ||
| 82 | + | ||
| 83 | + case .cancel: | ||
| 84 | + print("cancel") | ||
| 85 | + | ||
| 86 | + case .destructive: | ||
| 87 | + print("destructive") | ||
| 88 | + | ||
| 89 | + } | ||
| 90 | + })) | ||
| 91 | + self.present(alert, animated: true, completion: nil) | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void { | ||
| 95 | + | ||
| 96 | + let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert) | ||
| 97 | + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | ||
| 98 | + switch action.style{ | ||
| 99 | + case .default: | ||
| 100 | + print("default") | ||
| 101 | + | ||
| 102 | + case .cancel: | ||
| 103 | + print("cancel") | ||
| 104 | + | ||
| 105 | + case .destructive: | ||
| 106 | + print("destructive") | ||
| 107 | + | ||
| 108 | + } | ||
| 109 | + })) | ||
| 110 | + self.present(alert, animated: true, completion: nil) | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + | ||
| 114 | + // MARK: - API CALLS | ||
| 115 | + func getProfileRequest() { | ||
| 116 | + swiftApi().getProfileAsync(getProfileCallback) | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void { | ||
| 120 | + if (profileData != nil) { | ||
| 121 | + DispatchQueue.main.async { | ||
| 122 | + self.numbersList = profileData?._msisdnList ?? [] | ||
| 123 | + } | ||
| 124 | + } else { | ||
| 125 | + } | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + func submitOrderRequest() { | ||
| 129 | + swiftApi().submitOrderAsync(campaign_session_uuid: "", user_msisdn: self.selectedNumber, businessService: (ccms?._businessService ?? ""), offerName: (ccms?._offerName ?? ""), productType: (ccms?._productType ?? ""), provDuration: (ccms?._provDuration ?? ""), noOfRecurrance: (ccms?._noOfRecurrance ?? ""), price: (ccms?._price ?? ""), discount: (ccms?._discount ?? ""), voiceCategory: (ccms?._voiceCategory ?? ""), dataCategory: (ccms?._dataCategory ?? ""), minsValue: (ccms?._minsValue ?? ""), dataValue: (ccms?._dataValue ?? ""), provStepValueMins: (ccms?._provStepValueMins ?? ""), | ||
| 130 | + OfferAudienceLevel: (ccms?._offerAudienceLevel ?? ""), UACIOfferTrackingCode: (ccms?._uaciOfferTrackingCode ?? ""), OFFERCODE1: (ccms?._offerCode1 ?? ""), SCORE: (ccms?._score ?? ""), ZONE: (ccms?._zone ?? ""), WAVE: (ccms?._wave ?? ""), VALIDITY: (ccms?._validity ?? ""), TREATMENT_CODE: (ccms?._treatmentCode ?? ""), | ||
| 131 | + submitOrderCallback) | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + func submitOrderCallback (_ response: swiftApi.GenericResponseModel?) -> Void { | ||
| 135 | + if (response != nil) { | ||
| 136 | + DispatchQueue.main.async { | ||
| 137 | + if (response?.getStatus == 1) { | ||
| 138 | + self.showDialog("Το αίτημά σου ολοκληρώθηκε επιτυχώς!","Θα ενημερωθείς άμεσα για την ενεργοποίηση του πακέτου σου.") | ||
| 139 | + // self.postEventRequest() | ||
| 140 | + | ||
| 141 | + } else { | ||
| 142 | + self.showDialog("Αποτυχία","Κάτι πήγε στραβά") | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + } else { | ||
| 146 | + self.showDialog("Αποτυχία","Κάτι πήγε στραβά") | ||
| 147 | + } | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + // MARK: - Actions | ||
| 151 | + | ||
| 152 | + @IBAction func redeemButtomAction(_ sender: Any) { | ||
| 153 | + self.numbersPopupTapped(sender) | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | +} | ||
| 157 | + | ||
| 158 | +// MARK: NumbersPopup | ||
| 159 | +extension ContextualViewController: NumbersPopupDelegate { | ||
| 160 | + @objc func numbersPopupTapped(_ sender: Any) { | ||
| 161 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | ||
| 162 | + let pp = storyboard.instantiateViewController(withIdentifier: "NumberPopupViewController") as! SwiftWarplyFramework.NumberPopupViewController | ||
| 163 | + pp.InitWithController(controller: self, | ||
| 164 | + numbersList: self.numbersList, | ||
| 165 | + sender: sender, | ||
| 166 | + delegate: self) | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + func presentedPopup() { | ||
| 170 | +// Code for when popup is presented | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + func dismissedPopup() { | ||
| 174 | +// Code for when popup is dismissed | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + func optionSelected(_ option: String) { | ||
| 178 | +// Code for when option is selected | ||
| 179 | + self.selectedNumber = option | ||
| 180 | + DispatchQueue.main.async { | ||
| 181 | + self.showConfirmDialog() | ||
| 182 | + } | ||
| 183 | + } | ||
| 184 | +} |
| ... | @@ -160,7 +160,10 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -160,7 +160,10 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ |
| 160 | 160 | ||
| 161 | public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | 161 | public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
| 162 | if (campaigns[indexPath.row]._ccms != nil) { | 162 | if (campaigns[indexPath.row]._ccms != nil) { |
| 163 | - // TODO: open new screen with param campaigns[indexPath.row]._ccms | 163 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
| 164 | + let vc = storyboard.instantiateViewController(withIdentifier: "ContextualViewController") as! SwiftWarplyFramework.ContextualViewController | ||
| 165 | + vc.ccms = campaigns[indexPath.row]._ccms | ||
| 166 | + self.navigationController?.pushViewController(vc, animated: true) | ||
| 164 | 167 | ||
| 165 | } else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") { | 168 | } else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") { |
| 166 | let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() | 169 | let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() | ... | ... |
| ... | @@ -110,7 +110,10 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -110,7 +110,10 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ |
| 110 | 110 | ||
| 111 | public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | 111 | public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
| 112 | if (campaigns[indexPath.row]._ccms != nil) { | 112 | if (campaigns[indexPath.row]._ccms != nil) { |
| 113 | - // TODO: open new screen with param campaigns[indexPath.row]._ccms | 113 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
| 114 | + let vc = storyboard.instantiateViewController(withIdentifier: "ContextualViewController") as! SwiftWarplyFramework.ContextualViewController | ||
| 115 | + vc.ccms = campaigns[indexPath.row]._ccms | ||
| 116 | + self.navigationController?.pushViewController(vc, animated: true) | ||
| 114 | 117 | ||
| 115 | } else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") { | 118 | } else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") { |
| 116 | let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() | 119 | let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() | ... | ... |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment