浏览代码

fix title sort button text #1246

marinofaggiana 4 年之前
父节点
当前提交
d1864cc3d1
共有 2 个文件被更改,包括 19 次插入4 次删除
  1. 2 1
      iOSClient/Main/CCMain.m
  2. 17 3
      iOSClient/Main/Menu/CCMain+Menu.swift

+ 2 - 1
iOSClient/Main/CCMain.m

@@ -160,7 +160,6 @@
     heightSearchBar = self.viewRichWorkspace.topView.frame.size.height;
 
     [self.sortButton setTitleColor:NCBrandColor.sharedInstance.brand forState:UIControlStateNormal];
-    [self.sortButton setTitle: [NSString stringWithFormat:@"Sorted by %@ ", [CCUtility getOrderSettings]] forState:UIControlStateNormal];
     [self.sortButton addTarget:self action:@selector(toggleReMainMenu) forControlEvents:UIControlEventTouchUpInside];
     
     heightRichWorkspace = UIScreen.mainScreen.bounds.size.height / 4 + heightSearchBar;
@@ -738,6 +737,8 @@
             }
         }
     }
+    
+    [self SetSortButtonText];
 }
 
 - (UIImage *)getImageLogoHome

+ 17 - 3
iOSClient/Main/Menu/CCMain+Menu.swift

@@ -41,6 +41,20 @@ extension CCMain {
 
         viewController.present(menuPanelController, animated: true, completion: nil)
     }
+    
+    @objc func SetSortButtonText() {
+        
+        let orderSettings = CCUtility.getOrderSettings()
+        
+        if orderSettings == "fileName" {
+            self.sortButton.setTitle((CCUtility.getAscendingSettings() ? NSLocalizedString("_order_by_name_a_z_", comment: "") : NSLocalizedString("_order_by_name_z_a_", comment: "")), for: .normal)
+        } else if orderSettings == "date" {
+            self.sortButton.setTitle((CCUtility.getAscendingSettings() ? NSLocalizedString("_order_by_date_less_recent_", comment: "") : NSLocalizedString("_order_by_date_more_recent_", comment: "")), for: .normal)
+        } else if orderSettings == "size" {
+            self.sortButton.setTitle((CCUtility.getAscendingSettings() ? NSLocalizedString("_order_by_size_largest_", comment: "") : NSLocalizedString("_order_by_size_smallest_", comment: "")), for: .normal)
+        }
+    }
+    
 
     private func initSortMenu() -> [NCMenuAction] {
         var actions = [NCMenuAction]()
@@ -59,7 +73,7 @@ extension CCMain {
                     } else {
                         CCUtility.setOrderSettings("fileName")
                     }
-                    self.sortButton.setTitle((CCUtility.getAscendingSettings() ? NSLocalizedString("_order_by_name_a_z_", comment: "") : NSLocalizedString("_order_by_name_z_a_", comment: "")) + " ▽", for: .normal)
+                    self.SetSortButtonText()
                     NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_clearDateReadDataSource), object: nil)
                 }
             )
@@ -79,7 +93,7 @@ extension CCMain {
                     } else {
                         CCUtility.setOrderSettings("date")
                     }
-                    self.sortButton.setTitle((CCUtility.getAscendingSettings() ? NSLocalizedString("_order_by_date_less_recent_", comment: "") : NSLocalizedString("_order_by_date_more_recent_", comment: "")) + " ▽", for: .normal)
+                    self.SetSortButtonText()
                     NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_clearDateReadDataSource), object: nil)
                 }
             )
@@ -99,7 +113,7 @@ extension CCMain {
                     } else {
                         CCUtility.setOrderSettings("size")
                     }
-                    self.sortButton.setTitle((CCUtility.getAscendingSettings() ? NSLocalizedString("_order_by_size_largest_", comment: "") : NSLocalizedString("_order_by_size_smallest_", comment: "")) + " ▽", for: .normal)
+                    self.SetSortButtonText()
                     NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_clearDateReadDataSource), object: nil)
                 }
             )