Просмотр исходного кода

ask before blocking/unblocking contacts

B. Petersen 5 лет назад
Родитель
Сommit
5d4cd709a1
1 измененных файлов с 17 добавлено и 2 удалено
  1. 17 2
      deltachat-ios/Controller/ContactDetailViewController.swift

+ 17 - 2
deltachat-ios/Controller/ContactDetailViewController.swift

@@ -144,8 +144,23 @@ class ContactDetailViewController: UITableViewController {
     }
 
     private func toggleBlockContact() {
-        contact.isBlocked ? contact.unblock() : contact.block()
-        updateBlockContactCell()
+        if contact.isBlocked {
+            let alert = UIAlertController(title: String.localized("ask_unblock_contact"), message: nil, preferredStyle: .actionSheet)
+            alert.addAction(UIAlertAction(title: String.localized("menu_unblock_contact"), style: .default, handler: { _ in
+                self.contact.unblock()
+                self.updateBlockContactCell()
+            }))
+            alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
+            present(alert, animated: true, completion: nil)
+        } else {
+            let alert = UIAlertController(title: String.localized("ask_block_contact"), message: nil, preferredStyle: .actionSheet)
+            alert.addAction(UIAlertAction(title: String.localized("menu_block_contact"), style: .destructive, handler: { _ in
+                self.contact.block()
+                self.updateBlockContactCell()
+            }))
+            alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
+            present(alert, animated: true, completion: nil)
+        }
     }
 
     private func updateBlockContactCell() {