Showing
1 changed file
with
53 additions
and
30 deletions
... | @@ -1619,13 +1619,6 @@ public class swiftApi { | ... | @@ -1619,13 +1619,6 @@ public class swiftApi { |
1619 | self.errorSharingDialog(controller) | 1619 | self.errorSharingDialog(controller) |
1620 | } | 1620 | } |
1621 | } | 1621 | } |
1622 | - | ||
1623 | -// initialSharingDialog(controller, alertTitle, "") | ||
1624 | -// acceptSharingDialog(controller) | ||
1625 | -// rejectSharingDialog(controller, "") | ||
1626 | -// returnSharingDialog(controller, alertTitle) | ||
1627 | -// errorSharingDialog(controller) | ||
1628 | - | ||
1629 | } | 1622 | } |
1630 | 1623 | ||
1631 | func initialSharingDialog(_ controller: UIViewController, _ alertTitle: String, _ sharingId: String) -> Void { | 1624 | func initialSharingDialog(_ controller: UIViewController, _ alertTitle: String, _ sharingId: String) -> Void { |
... | @@ -1634,32 +1627,43 @@ public class swiftApi { | ... | @@ -1634,32 +1627,43 @@ public class swiftApi { |
1634 | alert.addAction(UIAlertAction(title: "Ενεργοποίηση", style: .default, handler: { action in | 1627 | alert.addAction(UIAlertAction(title: "Ενεργοποίηση", style: .default, handler: { action in |
1635 | switch action.style{ | 1628 | switch action.style{ |
1636 | case .default: | 1629 | case .default: |
1637 | - // TODO: add cosmoteRetrieveSharing request | 1630 | + self.cosmoteRetrieveSharingAsync(sharingId: sharingId, accept: true, retrieveSharingCallback) |
1638 | - print("default 1") | ||
1639 | 1631 | ||
1640 | case .cancel: | 1632 | case .cancel: |
1641 | - print("cancel 1") | ||
1642 | 1633 | ||
1643 | case .destructive: | 1634 | case .destructive: |
1644 | - print("destructive 1") | ||
1645 | 1635 | ||
1646 | } | 1636 | } |
1647 | })) | 1637 | })) |
1648 | alert.addAction(UIAlertAction(title: "Απόρριψη", style: .default, handler: { action in | 1638 | alert.addAction(UIAlertAction(title: "Απόρριψη", style: .default, handler: { action in |
1649 | switch action.style{ | 1639 | switch action.style{ |
1650 | case .default: | 1640 | case .default: |
1651 | - self.rejectSharingDialog(controller, "") | 1641 | + self.rejectSharingDialog(controller, sharingId) |
1652 | - print("default 2") | ||
1653 | 1642 | ||
1654 | case .cancel: | 1643 | case .cancel: |
1655 | - print("cancel 2") | ||
1656 | 1644 | ||
1657 | case .destructive: | 1645 | case .destructive: |
1658 | - print("destructive 2") | ||
1659 | 1646 | ||
1660 | } | 1647 | } |
1661 | })) | 1648 | })) |
1662 | controller.present(alert, animated: true, completion: nil) | 1649 | controller.present(alert, animated: true, completion: nil) |
1650 | + | ||
1651 | + | ||
1652 | + func retrieveSharingCallback (_ sharingData: GenericResponseModel?) -> Void { | ||
1653 | + if (sharingData != nil) { | ||
1654 | + DispatchQueue.main.async { | ||
1655 | + | ||
1656 | + if (sharingData?.getStatus == 1) { | ||
1657 | + self.acceptSharingDialog(controller) | ||
1658 | + } else { | ||
1659 | + self.errorSharingDialog(controller) | ||
1660 | + } | ||
1661 | + | ||
1662 | + } | ||
1663 | + } else { | ||
1664 | + self.errorSharingDialog(controller) | ||
1665 | + } | ||
1666 | + } | ||
1663 | } | 1667 | } |
1664 | 1668 | ||
1665 | func acceptSharingDialog(_ controller: UIViewController) -> Void { | 1669 | func acceptSharingDialog(_ controller: UIViewController) -> Void { |
... | @@ -1668,13 +1672,10 @@ public class swiftApi { | ... | @@ -1668,13 +1672,10 @@ public class swiftApi { |
1668 | alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | 1672 | alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in |
1669 | switch action.style{ | 1673 | switch action.style{ |
1670 | case .default: | 1674 | case .default: |
1671 | - print("default 1") | ||
1672 | 1675 | ||
1673 | case .cancel: | 1676 | case .cancel: |
1674 | - print("cancel 1") | ||
1675 | 1677 | ||
1676 | case .destructive: | 1678 | case .destructive: |
1677 | - print("destructive 1") | ||
1678 | 1679 | ||
1679 | } | 1680 | } |
1680 | })) | 1681 | })) |
... | @@ -1687,30 +1688,42 @@ public class swiftApi { | ... | @@ -1687,30 +1688,42 @@ public class swiftApi { |
1687 | alert.addAction(UIAlertAction(title: "Απόρριψη", style: .default, handler: { action in | 1688 | alert.addAction(UIAlertAction(title: "Απόρριψη", style: .default, handler: { action in |
1688 | switch action.style{ | 1689 | switch action.style{ |
1689 | case .default: | 1690 | case .default: |
1690 | - print("default 1") | 1691 | + self.cosmoteRetrieveSharingAsync(sharingId: sharingId, accept: false, retrieveSharingCallback) |
1691 | 1692 | ||
1692 | case .cancel: | 1693 | case .cancel: |
1693 | - print("cancel 1") | ||
1694 | 1694 | ||
1695 | case .destructive: | 1695 | case .destructive: |
1696 | - print("destructive 1") | ||
1697 | 1696 | ||
1698 | } | 1697 | } |
1699 | })) | 1698 | })) |
1700 | alert.addAction(UIAlertAction(title: "Άκυρο", style: .default, handler: { action in | 1699 | alert.addAction(UIAlertAction(title: "Άκυρο", style: .default, handler: { action in |
1701 | switch action.style{ | 1700 | switch action.style{ |
1702 | case .default: | 1701 | case .default: |
1703 | - print("default 2") | ||
1704 | 1702 | ||
1705 | case .cancel: | 1703 | case .cancel: |
1706 | - print("cancel 2") | ||
1707 | 1704 | ||
1708 | case .destructive: | 1705 | case .destructive: |
1709 | - print("destructive 2") | ||
1710 | 1706 | ||
1711 | } | 1707 | } |
1712 | })) | 1708 | })) |
1713 | controller.present(alert, animated: true, completion: nil) | 1709 | controller.present(alert, animated: true, completion: nil) |
1710 | + | ||
1711 | + | ||
1712 | + func retrieveSharingCallback (_ sharingData: GenericResponseModel?) -> Void { | ||
1713 | + if (sharingData != nil) { | ||
1714 | + DispatchQueue.main.async { | ||
1715 | + | ||
1716 | + if (sharingData?.getStatus == 1) { | ||
1717 | + self.returnSharingSuccessDialog(controller) | ||
1718 | + } else { | ||
1719 | + self.errorSharingDialog(controller) | ||
1720 | + } | ||
1721 | + | ||
1722 | + } | ||
1723 | + } else { | ||
1724 | + self.errorSharingDialog(controller) | ||
1725 | + } | ||
1726 | + } | ||
1714 | } | 1727 | } |
1715 | 1728 | ||
1716 | func returnSharingDialog(_ controller: UIViewController, _ alertTitle: String) -> Void { | 1729 | func returnSharingDialog(_ controller: UIViewController, _ alertTitle: String) -> Void { |
... | @@ -1719,13 +1732,10 @@ public class swiftApi { | ... | @@ -1719,13 +1732,10 @@ public class swiftApi { |
1719 | alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | 1732 | alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in |
1720 | switch action.style{ | 1733 | switch action.style{ |
1721 | case .default: | 1734 | case .default: |
1722 | - print("default 1") | ||
1723 | 1735 | ||
1724 | case .cancel: | 1736 | case .cancel: |
1725 | - print("cancel 1") | ||
1726 | 1737 | ||
1727 | case .destructive: | 1738 | case .destructive: |
1728 | - print("destructive 1") | ||
1729 | 1739 | ||
1730 | } | 1740 | } |
1731 | })) | 1741 | })) |
... | @@ -1738,13 +1748,26 @@ public class swiftApi { | ... | @@ -1738,13 +1748,26 @@ public class swiftApi { |
1738 | alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | 1748 | alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in |
1739 | switch action.style{ | 1749 | switch action.style{ |
1740 | case .default: | 1750 | case .default: |
1741 | - print("default 1") | ||
1742 | 1751 | ||
1743 | case .cancel: | 1752 | case .cancel: |
1744 | - print("cancel 1") | ||
1745 | 1753 | ||
1746 | case .destructive: | 1754 | case .destructive: |
1747 | - print("destructive 1") | 1755 | + |
1756 | + } | ||
1757 | + })) | ||
1758 | + controller.present(alert, animated: true, completion: nil) | ||
1759 | + } | ||
1760 | + | ||
1761 | + func returnSharingSuccessDialog(_ controller: UIViewController) -> Void { | ||
1762 | + | ||
1763 | + let alert = UIAlertController(title: "Απόρριψη δώρου", message: "Το δώρο απορρίφθηκε", preferredStyle: .alert) | ||
1764 | + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | ||
1765 | + switch action.style{ | ||
1766 | + case .default: | ||
1767 | + | ||
1768 | + case .cancel: | ||
1769 | + | ||
1770 | + case .destructive: | ||
1748 | 1771 | ||
1749 | } | 1772 | } |
1750 | })) | 1773 | })) | ... | ... |
-
Please register or login to post a comment