Browse Source

normalize

marinofaggiana 4 years ago
parent
commit
91d7f53d02

+ 4 - 5
iOSClient/Main/Account Request/NCAccountRequest.swift

@@ -53,7 +53,7 @@ class NCAccountRequest: UIViewController {
         NotificationCenter.default.addObserver(self, selector: #selector(startTimer), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidBecomeActive), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
         
-        changeTheming()
+        changeTheming()        
     }
     
     override func viewWillAppear(_ animated: Bool) {
@@ -122,9 +122,8 @@ extension NCAccountRequest: UITableViewDelegate {
             NCManageDatabase.shared.setAccountActive(account.account)
             dismiss(animated: true) {
                 self.appDelegate.settingAccount(account.account, urlBase: account.urlBase, user: account.user, userId: account.userId, password: CCUtility.getPassword(account.account))
-                self.appDelegate.initializeMain()
-                self.appDelegate.activeViewController?.viewWillAppear(true)
-                self.appDelegate.activeViewController?.viewDidAppear(true)
+                
+                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
             }
         } else {
             dismiss(animated: true)
@@ -170,7 +169,7 @@ extension NCAccountRequest: UITableViewDataSource {
         avatarImage?.image = avatar
         accountLabel?.text = account.user + " " + (URL(string: account.urlBase)?.host ?? "")
         if account.active {
-            activeImage?.image = UIImage(named: "check")!.imageColor(NCBrandColor.shared.brandText)
+            activeImage?.image = UIImage(named: "check")!.imageColor(NCBrandColor.shared.textView)
         } else {
             activeImage?.image = nil
         }

+ 9 - 0
iOSClient/Media/NCMedia.swift

@@ -93,6 +93,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
         emptyDataSet = NCEmptyDataSet.init(view: collectionView, offset: 0, delegate: self)
       
         // Notification
+        NotificationCenter.default.addObserver(self, selector: #selector(initializeMain), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitializeMain), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(deleteFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterDeleteFile), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(moveFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterMoveFile), object: nil)
@@ -148,6 +149,14 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
     
     //MARK: - Notification
     
+    @objc func initializeMain() {
+        
+        self.reloadDataSourceWithCompletion { (_) in
+            self.timerSearchNewMedia?.invalidate()
+            self.timerSearchNewMedia = Timer.scheduledTimer(timeInterval: self.timeIntervalSearchNewMedia, target: self, selector: #selector(self.searchNewMediaTimer), userInfo: nil, repeats: false)
+        }
+    }
+    
     @objc func applicationWillEnterForeground() {
         if self.view.window != nil {
             self.viewDidAppear(false)

+ 51 - 51
iOSClient/More/NCMore.swift

@@ -60,7 +60,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         labelQuotaExternalSite.addGestureRecognizer(tapQuota)
 
         // Notification
-        NotificationCenter.default.addObserver(self, selector: #selector(changeUserProfile), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeUserProfile), object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(initializeMain), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitializeMain), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
         
         changeTheming()
@@ -71,6 +71,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         appDelegate.activeViewController = self
         
         var item = NCCommunicationExternalSite()
+        var quota: String = ""
 
         // Clear
         functionMenu.removeAll()
@@ -156,8 +157,34 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
             labelQuotaExternalSite.text = item.name
         }
         
-        changeUserProfile()
+        // Display Name user & Quota
+
+        if let tabAccount = NCManageDatabase.shared.getAccountActive() {
+      
+            self.tabAccount = tabAccount
+
+            if (tabAccount.quotaRelative > 0) {
+                progressQuota.progress = Float(tabAccount.quotaRelative) / 100
+            } else {
+                progressQuota.progress = 0
+            }
 
+            switch tabAccount.quotaTotal {
+            case -1:
+                quota = "0"
+            case -2:
+                quota = NSLocalizedString("_quota_space_unknown_", comment: "")
+            case -3:
+                quota = NSLocalizedString("_quota_space_unlimited_", comment: "")
+            default:
+                quota = CCUtility.transformedSize(tabAccount.quotaTotal)
+            }
+
+            let quotaUsed: String = CCUtility.transformedSize(tabAccount.quotaUsed)
+
+            labelQuota.text = String.localizedStringWithFormat(NSLocalizedString("_quota_using_", comment: ""), quotaUsed, quota)
+        }
+        
         // ITEM : External
         if NCBrandOptions.shared.disable_more_external_site == false {
             if let externalSites = NCManageDatabase.shared.getAllExternalSites(account: appDelegate.account) {
@@ -195,42 +222,36 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         tableView.separatorColor = NCBrandColor.shared.separator
         tableView.reloadData()
     }
+    
+    @objc func initializeMain() {
+        viewWillAppear(true)
+    }
 
-    @objc func changeUserProfile() {
-        // Display Name user & Quota
-        var quota: String = ""
-
-        guard let tabAccount = NCManageDatabase.shared.getAccountActive() else {
-            return
-        }
-        self.tabAccount = tabAccount
+    // MARK: - Action
 
-        if (tabAccount.quotaRelative > 0) {
-            progressQuota.progress = Float(tabAccount.quotaRelative) / 100
-        } else {
-            progressQuota.progress = 0
-        }
+    @objc func tapLabelQuotaExternalSite() {
 
-        switch tabAccount.quotaTotal {
-        case -1:
-            quota = "0"
-        case -2:
-            quota = NSLocalizedString("_quota_space_unknown_", comment: "")
-        case -3:
-            quota = NSLocalizedString("_quota_space_unlimited_", comment: "")
-        default:
-            quota = CCUtility.transformedSize(tabAccount.quotaTotal)
-        }
+        if (quotaMenu.count > 0) {
 
-        let quotaUsed: String = CCUtility.transformedSize(tabAccount.quotaUsed)
+            let item = quotaMenu[0]
+            let browserWebVC = UIStoryboard(name: "NCBrowserWeb", bundle: nil).instantiateInitialViewController() as! NCBrowserWeb
+            browserWebVC.urlBase = item.url
+            browserWebVC.isHiddenButtonExit = true
 
-        labelQuota.text = String.localizedStringWithFormat(NSLocalizedString("_quota_using_", comment: ""), quotaUsed, quota)
-        
-        DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
-            self.tableView.reloadData()
+            self.navigationController?.pushViewController(browserWebVC, animated: true)
+            self.navigationController?.navigationBar.isHidden = false
         }
     }
 
+    @objc func tapImageLogoManageAccount() {
+
+        let controller = CCManageAccount.init()
+
+        self.navigationController?.pushViewController(controller, animated: true)
+    }
+    
+    // MARK: -
+    
     func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
         if indexPath.section == 0 {
             return 100
@@ -427,27 +448,6 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
             self.present(alertController, animated: true, completion: nil)
         }
     }
-
-    @objc func tapLabelQuotaExternalSite() {
-
-        if (quotaMenu.count > 0) {
-
-            let item = quotaMenu[0]
-            let browserWebVC = UIStoryboard(name: "NCBrowserWeb", bundle: nil).instantiateInitialViewController() as! NCBrowserWeb
-            browserWebVC.urlBase = item.url
-            browserWebVC.isHiddenButtonExit = true
-
-            self.navigationController?.pushViewController(browserWebVC, animated: true)
-            self.navigationController?.navigationBar.isHidden = false
-        }
-    }
-
-    @objc func tapImageLogoManageAccount() {
-
-        let controller = CCManageAccount.init()
-
-        self.navigationController?.pushViewController(controller, animated: true)
-    }
 }
 
 class CCCellMore: UITableViewCell {

+ 0 - 1
iOSClient/NCGlobal.swift

@@ -237,7 +237,6 @@ class NCGlobal: NSObject {
 
     @objc let notificationCenterInitializeMain                  = "initializeMain"
     @objc let notificationCenterChangeTheming                   = "changeTheming"
-    let notificationCenterChangeUserProfile                     = "changeUserProfile"
     let notificationCenterRichdocumentGrabFocus                 = "richdocumentGrabFocus"
     let notificationCenterReloadDataNCShare                     = "reloadDataNCShare"
     let notificationCenterCloseRichWorkspaceWebView             = "closeRichWorkspaceWebView"

+ 0 - 2
iOSClient/Networking/NCService.swift

@@ -92,8 +92,6 @@ class NCService: NSObject {
                         }
                     }
                           
-                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterChangeUserProfile)
-                                        
                     self.requestServerCapabilities()
                 }