Manos Chorianopoulos

add spinner at CouponVC

......@@ -24,6 +24,7 @@
1EB236AF28816CAC0063777A /* NumbersTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */; };
1EB5F4C828536FD60016F36E /* StepsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB5F4C728536FD60016F36E /* StepsViewController.swift */; };
1EB5F4CA285370C90016F36E /* LoyaltyAnalysisViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */; };
1EBC75432922829D004FBE75 /* SpinnerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBC75422922829D004FBE75 /* SpinnerViewController.swift */; };
1EBE97212865EE460080EFF7 /* MFYInboxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBE97202865EE460080EFF7 /* MFYInboxTableViewCell.swift */; };
1EBF5F072840E13F00B8B17F /* SwiftEventBus in Frameworks */ = {isa = PBXBuildFile; productRef = 1EBF5F062840E13F00B8B17F /* SwiftEventBus */; };
1ECA079128D9E3BA00D2BDE0 /* CSMButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECA079028D9E3BA00D2BDE0 /* CSMButton.swift */; };
......@@ -187,6 +188,7 @@
1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumbersTableViewCell.swift; sourceTree = "<group>"; };
1EB5F4C728536FD60016F36E /* StepsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepsViewController.swift; sourceTree = "<group>"; };
1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoyaltyAnalysisViewController.swift; sourceTree = "<group>"; };
1EBC75422922829D004FBE75 /* SpinnerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpinnerViewController.swift; sourceTree = "<group>"; };
1EBE97202865EE460080EFF7 /* MFYInboxTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFYInboxTableViewCell.swift; sourceTree = "<group>"; };
1ECA079028D9E3BA00D2BDE0 /* CSMButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CSMButton.swift; sourceTree = "<group>"; };
1ECA079228D9E53F00D2BDE0 /* MapsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapsViewController.swift; sourceTree = "<group>"; };
......@@ -444,6 +446,7 @@
E6A77850282933340045BBA8 /* SwiftWarplyFramework */ = {
isa = PBXGroup;
children = (
1EBC75422922829D004FBE75 /* SpinnerViewController.swift */,
1ECA079028D9E3BA00D2BDE0 /* CSMButton.swift */,
1E108A9728A3FA9B0008B8E7 /* Info.plist */,
1E108A8B28A3F8FF0008B8E7 /* Resources */,
......@@ -927,6 +930,7 @@
A07936702885D95600064122 /* AnalysisItemViewCell.swift in Sources */,
E6A77956282933E70045BBA8 /* GiftsViewController.swift in Sources */,
1ECA079728D9E66200D2BDE0 /* MerchantAnnotation.swift in Sources */,
1EBC75432922829D004FBE75 /* SpinnerViewController.swift in Sources */,
E6A778F1282933E60045BBA8 /* WLNativeAdTableViewCell.m in Sources */,
E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */,
E6A77938282933E70045BBA8 /* AFImageDownloader.m in Sources */,
......
......@@ -33,6 +33,8 @@ import SwiftEventBus
public var couponset: swiftApi.CouponSetItemModel?
public var campaign: swiftApi.CampaignItemModel?
let spinner = SpinnerViewController()
public override func viewDidLoad() {
super.viewDidLoad()
......@@ -160,7 +162,24 @@ import SwiftEventBus
}
}
func showSpinner() {
// add the spinner view controller
addChild(spinner)
spinner.view.frame = view.frame
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 redeemCouponSetRequest(uuid: String, communication_uuid: String) {
showSpinner()
if (ccms == nil) {
swiftApi().redeemCouponSetAsync(uuid: uuid, communication_uuid: communication_uuid, redeemCouponSetCallback)
} else {
......@@ -170,6 +189,8 @@ import SwiftEventBus
}
func redeemCouponSetCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
hideSpinner()
if (response != nil) {
DispatchQueue.main.async {
if (response?.getStatus == 1) {
......
//
// SpinnerViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 14/11/22.
//
import UIKit
@objc public class SpinnerViewController: UIViewController {
var spinner = UIActivityIndicatorView()
public override func loadView() {
if #available(iOS 13.0, *) {
spinner = UIActivityIndicatorView(style: .large)
spinner.color = .white
} else {
spinner = UIActivityIndicatorView(style: .whiteLarge)
}
view = UIView()
view.backgroundColor = UIColor(white: 0, alpha: 0.7)
spinner.translatesAutoresizingMaskIntoConstraints = false
spinner.startAnimating()
view.addSubview(spinner)
spinner.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
spinner.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
}
public override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}