Selaa lähdekoodia

scroll chatlist up when opened for forwarding

B. Petersen 5 vuotta sitten
vanhempi
commit
22d9bd59df

+ 5 - 0
deltachat-ios/Controller/ChatListController.swift

@@ -41,6 +41,11 @@ class ChatListController: UIViewController {
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         getChatList()
+
+        if RelayHelper.sharedInstance.isForwarding() {
+            chatTable.scrollToTop()
+        }
+
         updateTitle()
 
         let nc = NotificationCenter.default

+ 13 - 0
deltachat-ios/Extensions/Extensions.swift

@@ -71,3 +71,16 @@ extension UIAlertController.Style {
         }
     }
 }
+
+extension UITableView {
+    func scrollToTop() {
+        let numberOfSections = self.numberOfSections
+        if numberOfSections > 0 {
+            let numberOfRows = self.numberOfRows(inSection: 0)
+            if numberOfRows > 0 {
+                let indexPath = IndexPath(row: 0, section: 0)
+                self.scrollToRow(at: indexPath, at: UITableView.ScrollPosition.top, animated: false)
+            }
+        }
+    }
+}