瀏覽代碼

allow to reconsider the destination for forwarding, similar to Android

cyberta 5 年之前
父節點
當前提交
f5727236ab
共有 2 個文件被更改,包括 24 次插入10 次删除
  1. 24 7
      deltachat-ios/Controller/ChatListController.swift
  2. 0 3
      deltachat-ios/Controller/ChatViewController.swift

+ 24 - 7
deltachat-ios/Controller/ChatListController.swift

@@ -21,6 +21,11 @@ class ChatListController: UIViewController {
 
     private var newButton: UIBarButtonItem!
 
+    lazy var cancelButton: UIBarButtonItem = {
+        let button = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(cancelButtonPressed))
+        return button
+    }()
+
     init(dcContext: DcContext, showArchive: Bool) {
         self.dcContext = dcContext
         self.showArchive = showArchive
@@ -34,13 +39,7 @@ class ChatListController: UIViewController {
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         getChatList()
-
-        if RelayHelper.sharedInstance.isForwarding() {
-            title = String.localized("forward_to")
-        } else {
-            title = showArchive ? String.localized("chat_archived_chats_title") :
-                String.localized("pref_chats")
-        }
+        updateTitle()
 
     }
 
@@ -101,6 +100,11 @@ class ChatListController: UIViewController {
         coordinator?.showNewChatController()
     }
 
+    @objc func cancelButtonPressed() {
+        RelayHelper.sharedInstance.cancel()
+        updateTitle()
+    }
+
     private func getNumberOfArchivedChats() -> Int {
         let chatList = dcContext.getChatlist(flags: DC_GCL_ARCHIVED_ONLY, queryString: nil, queryId: 0)
         return chatList.length
@@ -114,6 +118,19 @@ class ChatListController: UIViewController {
         chatList = dcContext.getChatlist(flags: gclFlags, queryString: nil, queryId: 0)
         chatTable.reloadData()
     }
+
+    private func updateTitle() {
+        if RelayHelper.sharedInstance.isForwarding() {
+            title = String.localized("forward_to")
+            if !showArchive {
+                navigationItem.setLeftBarButton(cancelButton, animated: true)
+            }
+        } else {
+            title = showArchive ? String.localized("chat_archived_chats_title") :
+                String.localized("pref_chats")
+            navigationItem.setLeftBarButton(nil, animated: true)
+        }
+    }
 }
 
 extension ChatListController: UITableViewDataSource, UITableViewDelegate {

+ 0 - 3
deltachat-ios/Controller/ChatViewController.swift

@@ -505,9 +505,6 @@ class ChatViewController: MessagesViewController {
                           actionTitle: String.localized("menu_forward"),
                           actionHandler: { _ in
                             RelayHelper.sharedInstance.forward(to: self.chatId)
-                            self.dismiss(animated: true, completion: nil)},
-                          cancelHandler: { _ in
-                            RelayHelper.sharedInstance.cancel()
                             self.dismiss(animated: true, completion: nil)})
     }
 }