Manos Chorianopoulos

fix return popup at handleSharing

......@@ -3098,7 +3098,7 @@ public class swiftApi {
self.errorUsedDialog(controller, sharingData?._msg ?? "")
} else if (sharingData?._status_outer == 7) {
self.initialSharingDialog(controller, "Επιστροφή δώρου", sharingData?._msg ?? "", sharingId)
self.returnDialog(controller, "Επιστροφή δώρου", sharingData?._msg ?? "", sharingId)
}
}
} else { // status != 1
......@@ -3173,6 +3173,72 @@ public class swiftApi {
}
}
func returnDialog(_ controller: UIViewController, _ alertHeaderTitle: String, _ alertTitle: String, _ sharingId: String) -> Void {
let alert = UIAlertController(title: alertHeaderTitle, message: alertTitle, preferredStyle: .alert)
let cancelButton = UIAlertAction(title: "Άκυρο", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
})
// cancelButton.setValue(UIColor(rgb: 0xFC5757), forKey: "titleTextColor")
alert.addAction(cancelButton)
alert.addAction(UIAlertAction(title: "Ενεργοποίηση", style: .default, handler: { action in
switch action.style{
case .default:
self.cosmoteRetrieveSharingAsync(sharingId: sharingId, accept: true, retrieveSharingCallback)
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
controller.present(alert, animated: true, completion: nil)
func retrieveSharingCallback (_ sharingData: GenericResponseModel?) -> Void {
if (sharingData != nil) {
DispatchQueue.main.async {
if (sharingData?.getStatus == 1) {
self.acceptSharingDialog(controller)
swiftApi().getCouponsAsync(getCouponsCallback)
func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
if (couponsData != nil) {
DispatchQueue.main.async {
SwiftEventBus.post("coupons_fetched")
}
} else {
}
}
} else {
self.errorSharingDialog(controller)
}
}
} else {
self.errorSharingDialog(controller)
}
}
}
func acceptSharingDialog(_ controller: UIViewController) -> Void {
let alert = UIAlertController(title: "Συγχαρητήρια!", message: "Το δώρο σου ενεργοποιήθηκε επιτυχώς!", preferredStyle: .alert)
......