123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- /*****************************************************************************
- * MediaViewController.swift
- * VLC for iOS
- *****************************************************************************
- * Copyright (c) 2018 VideoLAN. All rights reserved.
- * $Id$
- *
- * Authors: Carola Nitz <caro # videolan.org>
- *
- * Refer to the COPYING file of the official project for license.
- *****************************************************************************/
- import UIKit
- class VLCMediaViewController: VLCPagingViewController<VLCLabelCell> {
- var services: Services
- private var rendererButton: UIButton
- private var sortButton: UIBarButtonItem?
- init(services: Services) {
- self.services = services
- rendererButton = services.rendererDiscovererManager.setupRendererButton()
- super.init(nibName: nil, bundle: nil)
- }
- override func viewDidLoad() {
- changeCurrentIndexProgressive = { (oldCell: VLCLabelCell?, newCell: VLCLabelCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) in
- guard changeCurrentIndex == true else { return }
- 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
- }
- navigationController?.navigationBar.isTranslucent = false
- navigationItem.rightBarButtonItems = [editButtonItem, UIBarButtonItem(customView: rendererButton)]
- navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("SORT", comment: ""),
- style: .plain,
- target: self,
- action: #selector(handleSort))
- }
- // MARK: - PagerTabStripDataSource
- override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
- fatalError("this should only be used as subclass")
- }
- override func configure(cell: VLCLabelCell, for indicatorInfo: IndicatorInfo) {
- cell.iconLabel.text = indicatorInfo.title
- }
- 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)
- }
- override var preferredStatusBarStyle: UIStatusBarStyle {
- return PresentationTheme.current.colors.statusBarStyle
- }
- override func setEditing(_ editing: Bool, animated: Bool) {
- super.setEditing(editing, animated: animated)
- scrollingEnabled(!editing)
- 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() {}
- }
|