Manos Chorianopoulos

update handleSharing

......@@ -1619,13 +1619,6 @@ public class swiftApi {
self.errorSharingDialog(controller)
}
}
// initialSharingDialog(controller, alertTitle, "")
// acceptSharingDialog(controller)
// rejectSharingDialog(controller, "")
// returnSharingDialog(controller, alertTitle)
// errorSharingDialog(controller)
}
func initialSharingDialog(_ controller: UIViewController, _ alertTitle: String, _ sharingId: String) -> Void {
......@@ -1634,32 +1627,43 @@ public class swiftApi {
alert.addAction(UIAlertAction(title: "Ενεργοποίηση", style: .default, handler: { action in
switch action.style{
case .default:
// TODO: add cosmoteRetrieveSharing request
print("default 1")
self.cosmoteRetrieveSharingAsync(sharingId: sharingId, accept: true, retrieveSharingCallback)
case .cancel:
print("cancel 1")
case .destructive:
print("destructive 1")
}
}))
alert.addAction(UIAlertAction(title: "Απόρριψη", style: .default, handler: { action in
switch action.style{
case .default:
self.rejectSharingDialog(controller, "")
print("default 2")
self.rejectSharingDialog(controller, sharingId)
case .cancel:
print("cancel 2")
case .destructive:
print("destructive 2")
}
}))
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)
} else {
self.errorSharingDialog(controller)
}
}
} else {
self.errorSharingDialog(controller)
}
}
}
func acceptSharingDialog(_ controller: UIViewController) -> Void {
......@@ -1668,13 +1672,10 @@ public class swiftApi {
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default 1")
case .cancel:
print("cancel 1")
case .destructive:
print("destructive 1")
}
}))
......@@ -1687,30 +1688,42 @@ public class swiftApi {
alert.addAction(UIAlertAction(title: "Απόρριψη", style: .default, handler: { action in
switch action.style{
case .default:
print("default 1")
self.cosmoteRetrieveSharingAsync(sharingId: sharingId, accept: false, retrieveSharingCallback)
case .cancel:
print("cancel 1")
case .destructive:
print("destructive 1")
}
}))
alert.addAction(UIAlertAction(title: "Άκυρο", style: .default, handler: { action in
switch action.style{
case .default:
print("default 2")
case .cancel:
print("cancel 2")
case .destructive:
print("destructive 2")
}
}))
controller.present(alert, animated: true, completion: nil)
func retrieveSharingCallback (_ sharingData: GenericResponseModel?) -> Void {
if (sharingData != nil) {
DispatchQueue.main.async {
if (sharingData?.getStatus == 1) {
self.returnSharingSuccessDialog(controller)
} else {
self.errorSharingDialog(controller)
}
}
} else {
self.errorSharingDialog(controller)
}
}
}
func returnSharingDialog(_ controller: UIViewController, _ alertTitle: String) -> Void {
......@@ -1719,13 +1732,10 @@ public class swiftApi {
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default 1")
case .cancel:
print("cancel 1")
case .destructive:
print("destructive 1")
}
}))
......@@ -1738,13 +1748,26 @@ public class swiftApi {
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default 1")
case .cancel:
print("cancel 1")
case .destructive:
print("destructive 1")
}
}))
controller.present(alert, animated: true, completion: nil)
}
func returnSharingSuccessDialog(_ controller: UIViewController) -> Void {
let alert = UIAlertController(title: "Απόρριψη δώρου", message: "Το δώρο απορρίφθηκε", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
case .cancel:
case .destructive:
}
}))
......