Эх сурвалжийг харах

Add refresh control

Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Milen Pivchev 1 жил өмнө
parent
commit
1f764d035e

+ 3 - 0
iOSClient/Notification/NCNotification.storyboard

@@ -159,6 +159,9 @@
                         </connections>
                     </tableView>
                     <navigationItem key="navigationItem" id="bV4-Hy-bmE"/>
+                    <refreshControl key="refreshControl" opaque="NO" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" id="JwZ-Sr-qEU">
+                        <autoresizingMask key="autoresizingMask"/>
+                    </refreshControl>
                 </tableViewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="I7i-N5-tEB" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>

+ 4 - 2
iOSClient/Notification/NCNotification.swift

@@ -34,7 +34,6 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
     var emptyDataSet: NCEmptyDataSet?
     var isReloadDataSourceNetworkInProgress: Bool = false
 
-
     // MARK: - View Life Cycle
 
     override func viewDidLoad() {
@@ -48,6 +47,8 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
         tableView.estimatedRowHeight = 50.0
         tableView.backgroundColor = .systemBackground
 
+        refreshControl?.addTarget(self, action: #selector(getNetwokingNotification), for: .valueChanged)
+
         // Empty
         let offset = (self.navigationController?.navigationBar.bounds.height ?? 0) - 20
         emptyDataSet = NCEmptyDataSet(view: tableView, offset: -offset, delegate: self)
@@ -294,7 +295,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
 
     // MARK: - Load notification networking
 
-    func getNetwokingNotification() {
+   @objc func getNetwokingNotification() {
 
         isReloadDataSourceNetworkInProgress = true
         self.tableView.reloadData()
@@ -309,6 +310,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
                     }
                     self.notifications.append(notification as! NKNotifications)
                 }
+                self.refreshControl?.endRefreshing()
                 self.isReloadDataSourceNetworkInProgress = false
                 self.tableView.reloadData()
             }