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

coding

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 жил өмнө
parent
commit
b539904acb

+ 1 - 0
iOSClient/Data/NCDataSource.swift

@@ -350,6 +350,7 @@ class NCMetadataForSection: NSObject {
     var shares: [tableShare]
     var localFiles: [tableLocalFile]
     var searchResult: NCCSearchResult?
+    var unifiedSearchInProgress: Bool = false
 
     private var sort : String
     private var ascending: Bool

+ 13 - 0
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -895,7 +895,15 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     func tapButtonSection(_ sender: Any, metadataForSection: NCMetadataForSection?) {
 
         if let metadataForSection = metadataForSection, let searchResult = metadataForSection.searchResult, let cursor = searchResult.cursor, let term = literalSearch {
+
+            metadataForSection.unifiedSearchInProgress = true
+            self.collectionView?.reloadData()
+
             NCNetworking.shared.unifiedSearchFilesProvider(urlBase: appDelegate, id: searchResult.id, term: term, limit: 5, cursor: cursor) { searchResult, metadatas, errorCode, ErrorDescription in
+
+                metadataForSection.unifiedSearchInProgress = false
+                self.collectionView?.reloadData()
+
                 guard let searchResult = searchResult, let metadatas = metadatas else {
                     return
                 }
@@ -1800,6 +1808,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             let section = indexPath.section
             let metadataForSection = self.dataSource.getMetadataForSection(indexPath.section)
             let isPaginated = metadataForSection?.searchResult?.isPaginated ?? false
+            let unifiedSearchInProgress = metadataForSection?.unifiedSearchInProgress ?? false
 
             footer.delegate = self
             footer.metadataForSection = metadataForSection
@@ -1808,6 +1817,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             footer.setButtonText(NSLocalizedString("_show_more_results_", comment: ""))
             footer.separatorIsHidden(true)
             footer.buttonIsHidden(true)
+            footer.hideActivityIndicatorSection()
 
             if isSearching {
                 if sections > 1 && section != sections - 1 {
@@ -1816,6 +1826,9 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 if isSearching && isPaginated {
                     footer.buttonIsHidden(false)
                 }
+                if unifiedSearchInProgress {
+                    footer.showActivityIndicatorSection()
+                }
             } else {
                 if sections == 1 || section == sections - 1 {
                     let info = dataSource.getFooterInformation()

+ 6 - 0
iOSClient/Main/Section Header Footer/NCSectionFooter.xib

@@ -29,6 +29,9 @@
                         <action selector="touchUpInsideButton:" destination="Vin-9E-7nW" eventType="touchUpInside" id="XSh-0v-WHJ"/>
                     </connections>
                 </button>
+                <activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" style="medium" translatesAutoresizingMaskIntoConstraints="NO" id="qWG-SR-Qly">
+                    <rect key="frame" x="177.5" y="5" width="20" height="20"/>
+                </activityIndicatorView>
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="s2m-yO-4x0" userLabel="separator">
                     <rect key="frame" x="10" y="30" width="365" height="1"/>
                     <color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -46,10 +49,12 @@
             </subviews>
             <viewLayoutGuide key="safeArea" id="EFn-SN-cxu"/>
             <constraints>
+                <constraint firstItem="qWG-SR-Qly" firstAttribute="centerX" secondItem="EFn-SN-cxu" secondAttribute="centerX" id="18M-RP-YIn"/>
                 <constraint firstItem="EFn-SN-cxu" firstAttribute="trailing" secondItem="TK1-KX-Qe0" secondAttribute="trailing" constant="10" id="PoY-CD-99O"/>
                 <constraint firstAttribute="trailing" secondItem="gzy-cT-Gjn" secondAttribute="trailing" constant="10" id="QzY-ac-CRO"/>
                 <constraint firstItem="EFn-SN-cxu" firstAttribute="leading" secondItem="s2m-yO-4x0" secondAttribute="leading" constant="-10" id="ai4-Qy-YWi"/>
                 <constraint firstItem="gzy-cT-Gjn" firstAttribute="centerY" secondItem="Vin-9E-7nW" secondAttribute="centerY" id="avP-sX-JB5"/>
+                <constraint firstItem="qWG-SR-Qly" firstAttribute="centerY" secondItem="TK1-KX-Qe0" secondAttribute="centerY" id="baS-g9-E8a"/>
                 <constraint firstItem="EFn-SN-cxu" firstAttribute="trailing" secondItem="s2m-yO-4x0" secondAttribute="trailing" id="dWj-wQ-cfb"/>
                 <constraint firstItem="TK1-KX-Qe0" firstAttribute="bottom" secondItem="s2m-yO-4x0" secondAttribute="bottom" constant="-1" id="ekM-Ii-N58"/>
                 <constraint firstItem="gzy-cT-Gjn" firstAttribute="leading" secondItem="Vin-9E-7nW" secondAttribute="leading" constant="10" id="hZz-MT-pHg"/>
@@ -57,6 +62,7 @@
                 <constraint firstItem="TK1-KX-Qe0" firstAttribute="leading" secondItem="EFn-SN-cxu" secondAttribute="leading" constant="10" id="xqA-FX-AlG"/>
             </constraints>
             <connections>
+                <outlet property="activityIndicatorSection" destination="qWG-SR-Qly" id="t9x-qH-lxP"/>
                 <outlet property="buttonSection" destination="TK1-KX-Qe0" id="Y2u-vO-1c4"/>
                 <outlet property="buttonSectionHeightConstraint" destination="Qvv-k4-hfY" id="kif-9a-gD8"/>
                 <outlet property="labelSection" destination="gzy-cT-Gjn" id="hhG-DH-GJc"/>

+ 17 - 0
iOSClient/Main/Section Header Footer/NCSectionHeaderFooter.swift

@@ -318,6 +318,7 @@ class NCSectionHeader: UICollectionReusableView {
 class NCSectionFooter: UICollectionReusableView, NCSectionFooterDelegate {
 
     @IBOutlet weak var buttonSection: UIButton!
+    @IBOutlet weak var activityIndicatorSection: UIActivityIndicatorView!
     @IBOutlet weak var labelSection: UILabel!
     @IBOutlet weak var separator: UIView!
     @IBOutlet weak var separatorHeightConstraint: NSLayoutConstraint!
@@ -337,6 +338,7 @@ class NCSectionFooter: UICollectionReusableView, NCSectionFooterDelegate {
         separatorHeightConstraint.constant = 0.5
 
         buttonIsHidden(true)
+        activityIndicatorSection.isHidden = true
     }
 
     func setTitleLabel(directories: Int, files: Int, size: Int64) {
@@ -390,6 +392,21 @@ class NCSectionFooter: UICollectionReusableView, NCSectionFooterDelegate {
         }
     }
 
+    func showActivityIndicatorSection() {
+
+        buttonSection.isHidden = true
+        buttonSectionHeightConstraint.constant = NCGlobal.shared.heightFooterButton
+
+        activityIndicatorSection.isHidden = false
+        activityIndicatorSection.startAnimating()
+    }
+
+    func hideActivityIndicatorSection() {
+
+        activityIndicatorSection.stopAnimating()
+        activityIndicatorSection.isHidden = true
+    }
+
     // MARK: - Action
 
     @IBAction func touchUpInsideButton(_ sender: Any) {