Commit b33b222c authored by Carola Nitz's avatar Carola Nitz

VLCMediaSubcategoryViewController: move the chromecast and sortbutton to the...

VLCMediaSubcategoryViewController: move the chromecast and sortbutton to the audio and videoController
parent e7dc6290
......@@ -40,9 +40,11 @@ class VLCMediaSubcategoryViewController: BaseButtonBarPagerTabStripViewControlle
var services: Services
weak var mediaDelegate: VLCMediaViewControllerDelegate?
private var rendererButton: UIButton
init(services: Services) {
self.services = services
rendererButton = services.rendererDiscovererManager.setupRendererButton()
super.init(nibName: nil, bundle: nil)
}
......@@ -53,10 +55,34 @@ class VLCMediaSubcategoryViewController: BaseButtonBarPagerTabStripViewControlle
oldCell?.iconLabel.textColor = PresentationTheme.current.colors.cellDetailTextColor
newCell?.iconLabel.textColor = PresentationTheme.current.colors.orangeUI
}
setupNavigationBar()
super.viewDidLoad()
}
private func setupNavigationBar() {
if #available(iOS 11.0, *) {
navigationController?.navigationBar.prefersLargeTitles = false
}
super.viewDidLoad()
navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("SORT", comment: ""), style: .plain, target: self, action: #selector(sort))
navigationItem.rightBarButtonItem = 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) { action in
}
let sortBySizeAction = UIAlertAction(title: SortOption.size.localizedDescription, style: .default) { action in
}
let sortbyDateAction = UIAlertAction(title: SortOption.insertonDate.localizedDescription, style: .default) { action in
}
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 = UIColor.vlcOrangeTint()
present(sortOptionsAlertController, animated: true)
}
// MARK: - PagerTabStripDataSource
......@@ -71,13 +97,6 @@ class VLCMediaSubcategoryViewController: BaseButtonBarPagerTabStripViewControlle
override func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool) {
super.updateIndicator(for: viewController, fromIndex: fromIndex, toIndex: toIndex, withProgressPercentage: progressPercentage, indexWasChanged: indexWasChanged)
if indexWasChanged && toIndex >= 0 && toIndex < viewControllers.count {
let child = viewControllers[toIndex] as! IndicatorInfoProvider
UIView.performWithoutAnimation({ [weak self] in
guard let me = self else { return }
me.navigationItem.leftBarButtonItem?.title = child.indicatorInfo(for: me).title
})
}
}
}
......@@ -15,7 +15,6 @@ import Foundation
@objc public protocol VLCMediaViewControllerDelegate: class {
func mediaViewControllerDidSelectMediaObject(_ mediaViewController: VLCMediaViewController, mediaObject: NSManagedObject)
func mediaViewControllerDidSelectSort(_ mediaViewController: VLCMediaViewController)
}
public class VLCMediaViewController: UICollectionViewController, UISearchResultsUpdating, UISearchControllerDelegate, IndicatorInfoProvider {
......@@ -24,7 +23,6 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
private var searchController: UISearchController?
private let searchDataSource = VLCLibrarySearchDisplayDataSource()
private var mediaType: VLCMediaType
private var rendererButton: UIButton
public weak var delegate: VLCMediaViewControllerDelegate?
......@@ -50,7 +48,6 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
init(services: Services, type: VLCMediaType) {
self.services = services
mediaType = type
rendererButton = services.rendererDiscovererManager.setupRendererButton()
super.init(collectionViewLayout: UICollectionViewFlowLayout())
NotificationCenter.default.addObserver(self, selector: #selector(themeDidChange), name: .VLCThemeDidChangeNotification, object: nil)
......@@ -79,8 +76,6 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
super.viewDidLoad()
setupCollectionView()
setupSearchController()
setupNavigationBar()
setupRendererButton()
_ = (MLMediaLibrary.sharedMediaLibrary() as! MLMediaLibrary).libraryDidAppear()
}
......@@ -97,7 +92,6 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
@objc func themeDidChange() {
collectionView?.backgroundColor = PresentationTheme.current.colors.background
setNeedsStatusBarAppearanceUpdate()
}
func setupCollectionView() {
......@@ -134,10 +128,6 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
}
}
func setupNavigationBar() {
navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("SORT", comment: ""), style: .plain, target: self, action: #selector(sort))
}
func updateUIForContent() {
let isEmpty = collectionView?.numberOfItems(inSection: 0) == 0
......@@ -155,14 +145,6 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
// MARK: Renderer
private func setupRendererButton() {
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: rendererButton)
}
@objc func sort() {
delegate?.mediaViewControllerDidSelectSort(self)
}
public override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
collectionView?.collectionViewLayout.invalidateLayout()
}
......
......@@ -102,31 +102,9 @@ class VLCTabbarCooordinator: NSObject, VLCMediaViewControllerDelegate {
playMedia(media: mediaObject)
}
func mediaViewControllerDidSelectSort(_ VLCMediaViewController: VLCMediaViewController) {
showSortOptions()
}
func playMedia(media: NSManagedObject) {
//that should go into a Coordinator itself
let vpc = VLCPlaybackController.sharedInstance()
vpc?.playMediaLibraryObject(media)
}
func showSortOptions() {
// 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) { action in
}
let sortBySizeAction = UIAlertAction(title: SortOption.size.localizedDescription, style: .default) { action in
}
let sortbyDateAction = UIAlertAction(title: SortOption.insertonDate.localizedDescription, style: .default) { action in
}
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 = UIColor.vlcOrangeTint()
tabBarController.present(sortOptionsAlertController, animated: true)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment