Browse Source

MediaViewController: Use icon for sortButton

(closes #423)
Soomin Lee 6 years ago
parent
commit
50aad2efa4

+ 2 - 0
Resources/en.lproj/Localizable.strings

@@ -341,6 +341,8 @@
 
 
 // Sort
 // Sort
 
 
+"BUTTON_SORT" = "Sort";
+"BUTTON_SORT_HINT" = "Display sort action sheet";
 "HEADER_TITLE_SORT" = "Sort by";
 "HEADER_TITLE_SORT" = "Sort by";
 
 
 // VLCMediaLibraryKit - Sorting Criteria
 // VLCMediaLibraryKit - Sorting Criteria

+ 20 - 11
Sources/MediaViewControllers/MediaViewController.swift

@@ -16,7 +16,16 @@ class VLCMediaViewController: VLCPagingViewController<VLCLabelCell>, MediaCatego
 
 
     var services: Services
     var services: Services
     private var rendererButton: UIButton
     private var rendererButton: UIButton
-    private var sortButton: UIBarButtonItem?
+    private lazy var sortButton: UIBarButtonItem = {
+        var sortButton = UIBarButtonItem(image: UIImage(named: "sort"),
+                                     style: .plain, target: self,
+                                     action: #selector(handleSort))
+        sortButton.tintColor = PresentationTheme.current.colors.orangeUI
+        sortButton.accessibilityLabel = NSLocalizedString("BUTTON_SORT", comment: "")
+        sortButton.accessibilityHint = NSLocalizedString("BUTTON_SORT_HINT", comment: "")
+        return sortButton
+    }()
+
     private lazy var editButton: UIBarButtonItem = {
     private lazy var editButton: UIBarButtonItem = {
         var editButton = UIBarButtonItem(image: UIImage(named: "edit"),
         var editButton = UIBarButtonItem(image: UIImage(named: "edit"),
                                      style: .plain, target: self,
                                      style: .plain, target: self,
@@ -33,10 +42,6 @@ class VLCMediaViewController: VLCPagingViewController<VLCLabelCell>, MediaCatego
         self.services = services
         self.services = services
         rendererButton = services.rendererDiscovererManager.setupRendererButton()
         rendererButton = services.rendererDiscovererManager.setupRendererButton()
         super.init(nibName: nil, bundle: nil)
         super.init(nibName: nil, bundle: nil)
-        sortButton = UIBarButtonItem(title: NSLocalizedString("SORT", comment: ""),
-                                     style: .plain,
-                                     target: self,
-                                     action: #selector(handleSort))
         rigthBarButtons = [editButton, UIBarButtonItem(customView: rendererButton)]
         rigthBarButtons = [editButton, UIBarButtonItem(customView: rendererButton)]
     }
     }
 
 
@@ -99,12 +104,6 @@ class VLCMediaViewController: VLCPagingViewController<VLCLabelCell>, MediaCatego
     override var preferredStatusBarStyle: UIStatusBarStyle {
     override var preferredStatusBarStyle: UIStatusBarStyle {
         return PresentationTheme.current.colors.statusBarStyle
         return PresentationTheme.current.colors.statusBarStyle
     }
     }
-
-    @objc func handleSort() {
-        if let mediaCategoryViewController = viewControllers[currentIndex] as? VLCMediaCategoryViewController {
-            mediaCategoryViewController.handleSort()
-        }
-    }
 }
 }
 
 
 // MARK: - Edit
 // MARK: - Edit
@@ -122,3 +121,13 @@ extension VLCMediaViewController {
         viewControllers[currentIndex].setEditing(editing, animated: animated)
         viewControllers[currentIndex].setEditing(editing, animated: animated)
     }
     }
 }
 }
+
+// MARK: - Sort
+
+extension VLCMediaViewController {
+    @objc func handleSort() {
+        if let mediaCategoryViewController = viewControllers[currentIndex] as? VLCMediaCategoryViewController {
+            mediaCategoryViewController.handleSort()
+        }
+    }
+}

+ 6 - 0
vlc-ios/Images.xcassets/MediaController/Sort/Contents.json

@@ -0,0 +1,6 @@
+{
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

+ 26 - 0
vlc-ios/Images.xcassets/MediaController/Sort/sort.imageset/Contents.json

@@ -0,0 +1,26 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "sort.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "sort@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "sort@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  },
+  "properties" : {
+    "template-rendering-intent" : "template"
+  }
+}

BIN
vlc-ios/Images.xcassets/MediaController/Sort/sort.imageset/sort.png


BIN
vlc-ios/Images.xcassets/MediaController/Sort/sort.imageset/sort@2x.png


BIN
vlc-ios/Images.xcassets/MediaController/Sort/sort.imageset/sort@3x.png