|
@@ -39,45 +39,11 @@ class VLCMediaViewController: VLCPagingViewController<VLCLabelCell> {
|
|
|
navigationController?.navigationBar.prefersLargeTitles = false
|
|
|
}
|
|
|
navigationController?.navigationBar.isTranslucent = false
|
|
|
- sortButton = UIBarButtonItem(title: NSLocalizedString("SORT", comment: ""), style: .plain, target: self, action: #selector(sort))
|
|
|
- navigationItem.leftBarButtonItem = sortButton
|
|
|
navigationItem.rightBarButtonItems = [editButtonItem, UIBarButtonItem(customView: rendererButton)]
|
|
|
- }
|
|
|
-
|
|
|
- @objc func sort() {
|
|
|
- // This should be in a subclass
|
|
|
- let sortOptionsAlertController = UIAlertController(title: NSLocalizedString("SORT_BY", comment: ""), message: nil, preferredStyle: .actionSheet)
|
|
|
- let sortByNameAction = UIAlertAction(title: SortOption.alphabetically.localizedDescription, style: .default) {
|
|
|
- [weak self] action in
|
|
|
- // call medialibrary
|
|
|
- if let index = self?.currentIndex {
|
|
|
- let currentViewController = self?.viewControllers[index] as? VLCMediaCategoryViewController
|
|
|
- currentViewController?.sortByFileName()
|
|
|
- }
|
|
|
- }
|
|
|
- let sortBySizeAction = UIAlertAction(title: SortOption.size.localizedDescription, style: .default) {
|
|
|
- [weak self] action in
|
|
|
- if let index = self?.currentIndex {
|
|
|
- let currentViewController = self?.viewControllers[index] as? VLCMediaCategoryViewController
|
|
|
- currentViewController?.sortBySize()
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- let sortbyDateAction = UIAlertAction(title: SortOption.insertonDate.localizedDescription, style: .default) {
|
|
|
- [weak self] action in
|
|
|
- if let index = self?.currentIndex {
|
|
|
- let currentViewController = self?.viewControllers[index] as? VLCMediaCategoryViewController
|
|
|
- currentViewController?.sortByDate()
|
|
|
- }
|
|
|
- }
|
|
|
- let cancelAction = UIAlertAction(title: NSLocalizedString("CANCEL", comment: ""), style: .cancel, handler: nil)
|
|
|
- sortOptionsAlertController.addAction(sortByNameAction)
|
|
|
- sortOptionsAlertController.addAction(sortbyDateAction)
|
|
|
- sortOptionsAlertController.addAction(sortBySizeAction)
|
|
|
- sortOptionsAlertController.addAction(cancelAction)
|
|
|
- sortOptionsAlertController.view.tintColor = .vlcOrangeTint
|
|
|
- sortOptionsAlertController.popoverPresentationController?.sourceView = self.view
|
|
|
- present(sortOptionsAlertController, animated: true)
|
|
|
+ navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("SORT", comment: ""),
|
|
|
+ style: .plain,
|
|
|
+ target: self,
|
|
|
+ action: #selector(handleSort))
|
|
|
}
|
|
|
|
|
|
// MARK: - PagerTabStripDataSource
|
|
@@ -105,4 +71,13 @@ class VLCMediaViewController: VLCPagingViewController<VLCLabelCell> {
|
|
|
navigationItem.leftBarButtonItem = editing ? nil : sortButton
|
|
|
viewControllers[currentIndex].setEditing(editing, animated: animated)
|
|
|
}
|
|
|
+
|
|
|
+ // Hack to send to the child vc the sort event
|
|
|
+ override func handleSort() {
|
|
|
+ viewControllers[currentIndex].handleSort()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+extension UIViewController {
|
|
|
+ @objc func handleSort() {}
|
|
|
}
|