Selaa lähdekoodia

fix activity layout

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 vuotta sitten
vanhempi
commit
85629e5b41

+ 5 - 3
iOSClient/Activity/NCActivity.swift

@@ -120,6 +120,7 @@ class NCActivity: UIViewController, NCSharePagingContent {
     @objc func initialize() {
         loadDataSource()
         fetchAll(isInitial: true)
+        view.setNeedsLayout()
     }
 
     func makeTableFooterView() -> UIView {
@@ -350,9 +351,10 @@ extension NCActivity {
         guard !isFetchingActivity else { return }
         self.isFetchingActivity = true
 
-        let height = self.tabBarController?.tabBar.frame.size.height ?? 0
-        NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false, bottom: height + 50, style: .gray)
-
+        if let height = self.tabBarController?.tabBar.frame.height {
+            NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false, bottom: -height-20, style: .gray)
+        }
+        
         let dispatchGroup = DispatchGroup()
         loadComments(disptachGroup: dispatchGroup)
 

+ 3 - 2
iOSClient/Media/NCMedia.swift

@@ -523,8 +523,9 @@ extension NCMedia {
             greaterDate = Calendar.current.date(byAdding: .day, value: value, to: lessDate)!
         }
 
-        let height = self.tabBarController?.tabBar.frame.size.height ?? 0
-        NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false, bottom: height + 50, style: .gray)
+        if let height = self.tabBarController?.tabBar.frame.height {
+            NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false, bottom: -height-20, style: .gray)
+        }
 
         NCCommunication.shared.searchMedia(path: mediaPath, lessDate: lessDate, greaterDate: greaterDate, elementDate: "d:getlastmodified/", limit: limit, showHiddenFiles: CCUtility.getShowHiddenFiles(), timeout: 300) { account, files, errorCode, errorDescription in
 

+ 1 - 1
iOSClient/Settings/CCAdvanced.m

@@ -416,7 +416,7 @@
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_delete_cache_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_yes_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-        [[NCUtility shared] startActivityIndicatorWithBackgroundView:nil blurEffect:true bottom:0 style: UIActivityIndicatorViewStyleWhiteLarge];
+        [[NCUtility shared] startActivityIndicatorWithBackgroundView:nil blurEffect:true bottom:0 top:0 style: UIActivityIndicatorViewStyleWhiteLarge];
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
             [self clearCache];
         });

+ 14 - 6
iOSClient/Utility/NCUtility.swift

@@ -708,7 +708,7 @@ class NCUtility: NSObject {
 
     // MARK: -
 
-    @objc func startActivityIndicator(backgroundView: UIView?, blurEffect: Bool, bottom: CGFloat = 0, style: UIActivityIndicatorView.Style = .whiteLarge) {
+    @objc func startActivityIndicator(backgroundView: UIView?, blurEffect: Bool, bottom: CGFloat = 0, top: CGFloat = 0, style: UIActivityIndicatorView.Style = .whiteLarge) {
 
         if self.activityIndicator != nil {
             stopActivityIndicator()
@@ -772,14 +772,22 @@ class NCUtility: NSObject {
             guard let viewBackgroundActivityIndicator = self.viewBackgroundActivityIndicator else { return }
             viewBackgroundActivityIndicator.addSubview(viewActivityIndicator)
 
-            var verticalConstant: CGFloat = 0
-            if bottom > 0 {
-                verticalConstant = (viewBackgroundActivityIndicator.frame.size.height / 2) - bottom
+            if bottom < 0 {
+                NSLayoutConstraint.activate([
+                    viewActivityIndicator.bottomAnchor.constraint(equalTo: viewBackgroundActivityIndicator.bottomAnchor, constant: bottom)
+                ])
+            } else if top > 0 {
+                NSLayoutConstraint.activate([
+                    viewActivityIndicator.topAnchor.constraint(equalTo: viewBackgroundActivityIndicator.topAnchor, constant: top)
+                ])
+            } else {
+                NSLayoutConstraint.activate([
+                    viewActivityIndicator.centerYAnchor.constraint(equalTo: viewBackgroundActivityIndicator.centerYAnchor)
+                ])
             }
 
             NSLayoutConstraint.activate([
-                viewActivityIndicator.centerXAnchor.constraint(equalTo: viewBackgroundActivityIndicator.centerXAnchor),
-                viewActivityIndicator.centerYAnchor.constraint(equalTo: viewBackgroundActivityIndicator.centerYAnchor, constant: verticalConstant)
+                viewActivityIndicator.centerXAnchor.constraint(equalTo: viewBackgroundActivityIndicator.centerXAnchor)
             ])
 
             activityIndicator.startAnimating()

+ 3 - 1
iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift

@@ -276,7 +276,9 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
               fileName == self.metadata.fileName
         else { return }
 
-        NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false, style: .gray)
+        if let height = self.navigationController?.navigationBar.frame.height {
+            NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false, top: height+50 , style: .gray)
+        }
     }
 
     @objc func uploadedFile(_ notification: NSNotification) {