Manos Chorianopoulos

add spinners

......@@ -31,6 +31,7 @@ import SwiftEventBus
let uiscreen: CGRect = UIScreen.main.bounds
let spinner = SpinnerViewController()
public override func viewDidLoad() {
super.viewDidLoad()
......@@ -122,6 +123,26 @@ import SwiftEventBus
// MARK: - Functions
func showSpinner() {
// add the spinner view controller
// addChild(spinner)
// spinner.view.frame = view.frame
// view.addSubview(spinner.view)
// spinner.didMove(toParent: self)
addChild(spinner)
spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
self.view.addSubview(spinner.view)
spinner.didMove(toParent: self)
}
func hideSpinner() {
// remove the spinner view controller
spinner.willMove(toParent: nil)
spinner.view.removeFromSuperview()
spinner.removeFromParent()
}
func toggleTerms() {
if (termsVisible) {
termsTextView.isHidden = false
......@@ -269,9 +290,11 @@ import SwiftEventBus
}
func submitOrderRequest() {
self.showSpinner()
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 ?? ""),
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 ?? ""), ccms_session_id: (ccms?._sessionId ?? ""), notificationMessage: (ccms?._notificationMessage ?? ""),
submitOrderCallback, failureCallback: {errorCode in
self.hideSpinner()
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
......@@ -284,6 +307,7 @@ import SwiftEventBus
}
func submitOrderCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
self.hideSpinner()
if (response != nil) {
DispatchQueue.main.async {
if (response?.getStatus == 1) {
......
......@@ -32,6 +32,8 @@ import SwiftEventBus
var selectedNumber: String = ""
var numbersList: Array<String> = []
let spinner = SpinnerViewController()
public override func viewDidLoad() {
super.viewDidLoad()
......@@ -154,6 +156,26 @@ import SwiftEventBus
}
// MARK: - Functions
func showSpinner() {
// add the spinner view controller
// addChild(spinner)
// spinner.view.frame = view.frame
// view.addSubview(spinner.view)
// spinner.didMove(toParent: self)
addChild(spinner)
spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
self.view.addSubview(spinner.view)
spinner.didMove(toParent: self)
}
func hideSpinner() {
// remove the spinner view controller
spinner.willMove(toParent: nil)
spinner.view.removeFromSuperview()
spinner.removeFromParent()
}
func showSendDialog() -> Void {
let alert = UIAlertController(title: "Δώρισέ το", message: "Είσαι σίγουρος /-ή ότι θέλεις να κάνεις δώρο το κουπόνι σου;", preferredStyle: .alert)
......@@ -274,12 +296,15 @@ import SwiftEventBus
}
func cosmoteCouponSharingRequest() {
self.showSpinner()
swiftApi().cosmoteCouponSharingAsync(coupon: coupon?.coupon ?? "", sender: selectedNumber, receiver: numberTextField.text ?? "", couponSharingCallback, failureCallback: {errorCode in
self.hideSpinner()
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
})
}
func couponSharingCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
self.hideSpinner()
if (response != nil) {
DispatchQueue.main.async {
if (response?.getStatus == 1) {
......
......@@ -38,6 +38,8 @@ import SwiftEventBus
var moreVisible: Bool = false;
let spinner = SpinnerViewController()
public override func viewDidLoad() {
super.viewDidLoad()
......@@ -139,6 +141,26 @@ import SwiftEventBus
}
// MARK: - Functions
func showSpinner() {
// add the spinner view controller
// addChild(spinner)
// spinner.view.frame = view.frame
// view.addSubview(spinner.view)
// spinner.didMove(toParent: self)
addChild(spinner)
spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
self.view.addSubview(spinner.view)
spinner.didMove(toParent: self)
}
func hideSpinner() {
// remove the spinner view controller
spinner.willMove(toParent: nil)
spinner.view.removeFromSuperview()
spinner.removeFromParent()
}
func toggleMore() {
if (moreVisible) {
moreTextView.isHidden = false
......@@ -226,9 +248,11 @@ import SwiftEventBus
}
func submitOrderRequest() {
showSpinner()
swiftApi().submitOrderAsync(campaign_session_uuid: (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 ?? ""),
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 ?? ""), ccms_session_id: (ccms?._sessionId ?? ""), notificationMessage: (ccms?._notificationMessage ?? ""),
submitOrderCallback, failureCallback: {errorCode in
self.hideSpinner()
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
......@@ -241,6 +265,7 @@ import SwiftEventBus
}
func submitOrderCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
self.hideSpinner()
if (response != nil) {
DispatchQueue.main.async {
if (response?.getStatus == 1) {
......
......@@ -27,6 +27,8 @@ import SwiftEventBus
public var coupon: swiftApi.UnifiedCouponModel?
public var isFromWallet: Bool? = false
let spinner = SpinnerViewController()
public override func viewDidLoad() {
super.viewDidLoad()
......@@ -57,6 +59,26 @@ import SwiftEventBus
// MARK: - Functions
func showSpinner() {
// add the spinner view controller
// addChild(spinner)
// spinner.view.frame = view.frame
// view.addSubview(spinner.view)
// spinner.didMove(toParent: self)
addChild(spinner)
spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
self.view.addSubview(spinner.view)
spinner.didMove(toParent: self)
}
func hideSpinner() {
// remove the spinner view controller
spinner.willMove(toParent: nil)
spinner.view.removeFromSuperview()
spinner.removeFromParent()
}
func showConfirmDialog() -> Void {
let alert = UIAlertController(title: "Ακύρωση Κουπονιού", message: "Είσαι σίγουρος ότι θέλεις να ακυρώσεις το κουπόνι σου;", preferredStyle: .alert)
......@@ -116,6 +138,7 @@ import SwiftEventBus
}
func cancelUnifiedCouponRequest () -> Void {
self.showSpinner()
var tranIdFound = "";
for coupon in self.coupon?._coupons ?? [] {
if ((coupon.transaction_uuid != nil) && coupon.transaction_uuid != "") {
......@@ -125,11 +148,16 @@ import SwiftEventBus
}
if (tranIdFound != "") {
swiftApi().cancelUnifiedCouponAsync(transactionId: tranIdFound, self.cancelUnifiedCouponCallback, failureCallback: { errorCode in })
swiftApi().cancelUnifiedCouponAsync(transactionId: tranIdFound, self.cancelUnifiedCouponCallback, failureCallback: { errorCode in
self.hideSpinner()
})
} else {
self.hideSpinner()
}
}
func cancelUnifiedCouponCallback (_ responseData: swiftApi.GenericResponseModel?) -> Void {
self.hideSpinner()
if (responseData != nil) {
DispatchQueue.main.async {
if (responseData?.getStatus == 1) {
......
......@@ -29,6 +29,8 @@ import SwiftEventBus
// Track the selection state
var isSelectAllActive: Bool = false
let spinner = SpinnerViewController()
public override func viewDidLoad() {
super.viewDidLoad()
......@@ -141,6 +143,26 @@ import SwiftEventBus
}
// MARK: - Functions
func showSpinner() {
// add the spinner view controller
// addChild(spinner)
// spinner.view.frame = view.frame
// view.addSubview(spinner.view)
// spinner.didMove(toParent: self)
addChild(spinner)
spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
self.view.addSubview(spinner.view)
spinner.didMove(toParent: self)
}
func hideSpinner() {
// remove the spinner view controller
spinner.willMove(toParent: nil)
spinner.view.removeFromSuperview()
spinner.removeFromParent()
}
// Button action for "select all"
@objc func selectAllTapped() {
// Toggle the selection state
......@@ -267,9 +289,10 @@ import SwiftEventBus
@IBAction func submitButtonAction(_ sender: Any) {
// let smCouponsString = self.smCouponsSelected.map { $0.coupon ?? "" }.joined(separator: ",")
// swiftApi().logTrackersEvent("click", ("UnifySMCoupons:" + (smCouponsString)))
self.showSpinner()
let smCouponCodes = self.smCouponsSelected.map { $0.coupon ?? "" }
swiftApi().createUnifiedCouponAsync(couponCodes: smCouponCodes) { responseData in
self.hideSpinner()
if (responseData != nil) {
DispatchQueue.main.async {
if (responseData?.getStatus == 1) {
......@@ -285,6 +308,7 @@ import SwiftEventBus
}
}
} failureCallback: { errorCode in
self.hideSpinner()
self.showFailureDialog()
}
......