Showing
2 changed files
with
67 additions
and
1 deletions
No preview for this file type
... | @@ -3098,7 +3098,7 @@ public class swiftApi { | ... | @@ -3098,7 +3098,7 @@ public class swiftApi { |
3098 | self.errorUsedDialog(controller, sharingData?._msg ?? "") | 3098 | self.errorUsedDialog(controller, sharingData?._msg ?? "") |
3099 | 3099 | ||
3100 | } else if (sharingData?._status_outer == 7) { | 3100 | } else if (sharingData?._status_outer == 7) { |
3101 | - self.initialSharingDialog(controller, "Επιστροφή δώρου", sharingData?._msg ?? "", sharingId) | 3101 | + self.returnDialog(controller, "Επιστροφή δώρου", sharingData?._msg ?? "", sharingId) |
3102 | } | 3102 | } |
3103 | } | 3103 | } |
3104 | } else { // status != 1 | 3104 | } else { // status != 1 |
... | @@ -3173,6 +3173,72 @@ public class swiftApi { | ... | @@ -3173,6 +3173,72 @@ public class swiftApi { |
3173 | } | 3173 | } |
3174 | } | 3174 | } |
3175 | 3175 | ||
3176 | + func returnDialog(_ controller: UIViewController, _ alertHeaderTitle: String, _ alertTitle: String, _ sharingId: String) -> Void { | ||
3177 | + | ||
3178 | + let alert = UIAlertController(title: alertHeaderTitle, message: alertTitle, preferredStyle: .alert) | ||
3179 | + | ||
3180 | + let cancelButton = UIAlertAction(title: "Άκυρο", style: .default, handler: { action in | ||
3181 | + switch action.style{ | ||
3182 | + case .default: | ||
3183 | + print("default") | ||
3184 | + | ||
3185 | + case .cancel: | ||
3186 | + print("cancel") | ||
3187 | + | ||
3188 | + case .destructive: | ||
3189 | + print("destructive") | ||
3190 | + | ||
3191 | + } | ||
3192 | + }) | ||
3193 | + // cancelButton.setValue(UIColor(rgb: 0xFC5757), forKey: "titleTextColor") | ||
3194 | + alert.addAction(cancelButton) | ||
3195 | + | ||
3196 | + alert.addAction(UIAlertAction(title: "Ενεργοποίηση", style: .default, handler: { action in | ||
3197 | + switch action.style{ | ||
3198 | + case .default: | ||
3199 | + self.cosmoteRetrieveSharingAsync(sharingId: sharingId, accept: true, retrieveSharingCallback) | ||
3200 | + | ||
3201 | + case .cancel: | ||
3202 | + print("cancel") | ||
3203 | + | ||
3204 | + case .destructive: | ||
3205 | + print("destructive") | ||
3206 | + | ||
3207 | + } | ||
3208 | + })) | ||
3209 | + | ||
3210 | + controller.present(alert, animated: true, completion: nil) | ||
3211 | + | ||
3212 | + | ||
3213 | + func retrieveSharingCallback (_ sharingData: GenericResponseModel?) -> Void { | ||
3214 | + if (sharingData != nil) { | ||
3215 | + DispatchQueue.main.async { | ||
3216 | + | ||
3217 | + if (sharingData?.getStatus == 1) { | ||
3218 | + self.acceptSharingDialog(controller) | ||
3219 | + | ||
3220 | + swiftApi().getCouponsAsync(getCouponsCallback) | ||
3221 | + | ||
3222 | + func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void { | ||
3223 | + if (couponsData != nil) { | ||
3224 | + DispatchQueue.main.async { | ||
3225 | + SwiftEventBus.post("coupons_fetched") | ||
3226 | + } | ||
3227 | + } else { | ||
3228 | + } | ||
3229 | + } | ||
3230 | + | ||
3231 | + } else { | ||
3232 | + self.errorSharingDialog(controller) | ||
3233 | + } | ||
3234 | + | ||
3235 | + } | ||
3236 | + } else { | ||
3237 | + self.errorSharingDialog(controller) | ||
3238 | + } | ||
3239 | + } | ||
3240 | + } | ||
3241 | + | ||
3176 | func acceptSharingDialog(_ controller: UIViewController) -> Void { | 3242 | func acceptSharingDialog(_ controller: UIViewController) -> Void { |
3177 | 3243 | ||
3178 | let alert = UIAlertController(title: "Συγχαρητήρια!", message: "Το δώρο σου ενεργοποιήθηκε επιτυχώς!", preferredStyle: .alert) | 3244 | let alert = UIAlertController(title: "Συγχαρητήρια!", message: "Το δώρο σου ενεργοποιήθηκε επιτυχώς!", preferredStyle: .alert) | ... | ... |
-
Please register or login to post a comment