Explorar o código

PlaylistViewController: remove separate video and audio playlists and add playlist tab

Carola Nitz %!s(int64=6) %!d(string=hai) anos
pai
achega
849de38122

+ 1 - 3
Resources/en.lproj/Localizable.strings

@@ -307,10 +307,8 @@
 // MediaViewController Swipable Header
 "ALBUMS" = "Albums";
 "ARTISTS" = "Artists";
-"AUDIO_PLAYLISTS" = "Playlists";
 "EPISODES" = "Episodes";
 "GENRES" = "Genres";
 "MOVIES" = "Movies";
 "SONGS" = "Songs";
-"VIDEOS" = "Videos";
-"VIDEO_PLAYLISTS" = "Playlists";
+"PLAYLISTS" = "Playlists";

+ 1 - 11
Sources/MediaCategories/MediaCategory.swift

@@ -30,7 +30,7 @@ class VLCShowEpisodeCategoryViewController: VLCMediaCategoryViewController {
     }
 }
 
-class VLCVideoPlaylistCategoryViewController: VLCMediaCategoryViewController {
+class VLCPlaylistCategoryViewController: VLCMediaCategoryViewController {
     init(_ services: Services) {
         let model = PlaylistModel(medialibrary: services.medialibraryManager)
         super.init(services: services, category: model)
@@ -79,13 +79,3 @@ class VLCAlbumCategoryViewController: VLCMediaCategoryViewController {
         }
     }
 }
-
-class VLCAudioPlaylistCategoryViewController: VLCMediaCategoryViewController {
-    init(_ services: Services) {
-        let model = PlaylistModel(medialibrary: services.medialibraryManager)
-        super.init(services: services, category: model)
-        category.updateView = { [weak self] in
-            self?.reloadData()
-        }
-    }
-}

+ 0 - 1
Sources/MediaViewControllers/AudioViewController.swift

@@ -31,7 +31,6 @@ class VLCAudioViewController: VLCMediaViewController {
             VLCGenreCategoryViewController(services),
             VLCArtistCategoryViewController(services),
             VLCAlbumCategoryViewController(services),
-            VLCAudioPlaylistCategoryViewController(services)
         ]
     }
 }

+ 33 - 0
Sources/MediaViewControllers/PlaylistViewController.swift

@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * VLCPlaylistViewController.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.
+ *****************************************************************************/
+
+class VLCPlaylistViewController: VLCMediaViewController {
+    override init(services: Services) {
+        super.init(services: services)
+        setupUI()
+    }
+
+    private func setupUI() {
+        title = NSLocalizedString("PLAYLISTS", comment: "")
+        tabBarItem = UITabBarItem(
+            title: NSLocalizedString("PLAYLISTS", comment: ""),
+            image: UIImage(named: "TVShowsIcon"),
+            selectedImage: UIImage(named: "TVShowsIcon"))
+        tabBarItem.accessibilityIdentifier = VLCAccessibilityIdentifier.playlist
+    }
+
+    override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
+        return [
+            VLCPlaylistCategoryViewController(services)
+        ]
+    }
+}

+ 0 - 1
Sources/MediaViewControllers/VideoViewController.swift

@@ -29,7 +29,6 @@ class VLCVideoViewController: VLCMediaViewController {
         return [
             VLCMovieCategoryViewController(services),
             VLCShowEpisodeCategoryViewController(services),
-            VLCVideoPlaylistCategoryViewController(services)
         ]
     }
 }

+ 0 - 1
Sources/PagerStripViewController.swift

@@ -58,7 +58,6 @@ class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
         containerView = UIScrollView(frame: CGRect(x: 0, y: 0, width: view.bounds.width, height: view.bounds.height))
 
         containerView.translatesAutoresizingMaskIntoConstraints = false
-        containerView.alwaysBounceHorizontal = true
         containerView.scrollsToTop = false
         containerView.delegate = self
         containerView.showsVerticalScrollIndicator = false

+ 2 - 2
Sources/VLCEditController.swift

@@ -111,7 +111,7 @@ extension VLCEditController: VLCEditControllerDataSource {
 extension VLCEditController: VLCEditToolbarDelegate {
     func createPlaylist() {
         if let model = category as? PlaylistModel {
-            let alertInfo = TextFieldAlertInfo(alertTitle: NSLocalizedString("VIDEO_PLAYLISTS", comment: ""),
+            let alertInfo = TextFieldAlertInfo(alertTitle: NSLocalizedString("PLAYLISTS", comment: ""),
                 placeHolder: "NEW_PLAYLIST")
 
             presentTextFieldAlert(with: alertInfo, completionHandler: {
@@ -120,7 +120,7 @@ extension VLCEditController: VLCEditToolbarDelegate {
                 })
 
         } else if let model = category as? VideoModel {
-            let alertInfo = TextFieldAlertInfo(alertTitle: NSLocalizedString("VIDEO_PLAYLISTS", comment: ""),
+            let alertInfo = TextFieldAlertInfo(alertTitle: NSLocalizedString("PLAYLISTS", comment: ""),
                                                placeHolder: "NEW_PLAYLIST")
 
             presentTextFieldAlert(with: alertInfo, completionHandler: {

+ 2 - 2
Sources/VLCPagingViewController.swift

@@ -45,7 +45,7 @@ class VLCPagingViewController<ButtonBarCellType: UICollectionViewCell>: PagerTab
     var changeCurrentIndexProgressive: ((_ oldCell: ButtonBarCellType?, _ newCell: ButtonBarCellType?, _ progressPercentage: CGFloat, _ changeCurrentIndex: Bool, _ animated: Bool) -> Void)?
 
     var buttonBarView: ButtonBarView!
-    let buttonbarViewHeight: CGFloat = 45.0
+    var buttonbarViewHeight: CGFloat = 45.0
     lazy private var cachedCellWidths: [CGFloat]? = { [unowned self] in
         return self.calculateWidths()
         }()
@@ -64,7 +64,7 @@ class VLCPagingViewController<ButtonBarCellType: UICollectionViewCell>: PagerTab
 
     override func viewDidLoad() {
         super.viewDidLoad()
-
+        buttonbarViewHeight = viewControllers.count == 1 ? 0 : 45
         let flowLayout = UICollectionViewFlowLayout()
         flowLayout.scrollDirection = .horizontal
         buttonBarView = ButtonBarView(frame: .zero, collectionViewLayout: flowLayout)

+ 1 - 0
Sources/VLCTabBarCoordinator.swift

@@ -47,6 +47,7 @@ class VLCTabBarCoordinator: NSObject {
         let controllers = [
             VLCVideoViewController(services: services),
             VLCAudioViewController(services: services),
+            VLCPlaylistViewController(services: services),
             VLCServerListViewController(nibName: nil, bundle: nil),
             VLCSettingsController()
         ]

+ 1 - 0
VLC-iOS-UITests/Helpers/VLCAccessibilityIdentifier.swift

@@ -15,6 +15,7 @@ import Foundation
     static let video = "video"
     static let audio = "audio"
     @objc static let localNetwork = "localNetwork"
+    static let playlist = "playlist"
     @objc static let settings = "settings"
     static let cloud = "cloud"
     static let stream = "stream"

+ 5 - 0
VLC-iOS-UITests/VLCTestMenu.swift

@@ -41,6 +41,11 @@ class VLCTestMenu: XCTestCase {
         XCTAssertNotNil(app.navigationBars[VLCAccessibilityIdentifier.video])
     }
 
+    func testNavigationToPlaylistTab() {
+        helper.tapTabBarItem(VLCAccessibilityIdentifier.playlist)
+        XCTAssertNotNil(app.navigationBars[VLCAccessibilityIdentifier.playlist])
+    }
+
     func testNavigationToSettingsTab() {
         helper.tapTabBarItem(VLCAccessibilityIdentifier.settings)
         XCTAssertNotNil(app.navigationBars[VLCAccessibilityIdentifier.settings])

+ 4 - 0
VLC.xcodeproj/project.pbxproj

@@ -65,6 +65,7 @@
 		41E6BECD207E64E900E158BA /* RemoteNetworkCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41E6BECC207E64E900E158BA /* RemoteNetworkCell.swift */; };
 		41EA74C120C02DFC001E5D57 /* VLCDropboxController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3784AA183A9906009EE944 /* VLCDropboxController.m */; };
 		41EA74C320C02F8E001E5D57 /* VLCBoxController.m in Sources */ = {isa = PBXBuildFile; fileRef = 41CD69591A29D72600E60BCE /* VLCBoxController.m */; };
+		41EB6634216147DD00FDC38B /* PlaylistViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41EB6633216147DD00FDC38B /* PlaylistViewController.swift */; };
 		41EB91D71F7BE6F500821AA5 /* VLCRemoteControlService.m in Sources */ = {isa = PBXBuildFile; fileRef = 417D7F5F1F7BA26200DDF36A /* VLCRemoteControlService.m */; };
 		41EB91DD1F7BFF8500821AA5 /* VLCMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 41EB91DC1F7BFF8400821AA5 /* VLCMetadata.m */; };
 		41EB91DE1F7BFF8500821AA5 /* VLCMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 41EB91DC1F7BFF8400821AA5 /* VLCMetadata.m */; };
@@ -526,6 +527,7 @@
 		41D7DD2620C3060300AD94F6 /* PagerStripViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PagerStripViewController.swift; path = Sources/PagerStripViewController.swift; sourceTree = "<group>"; };
 		41DFC6C52100BAAF00EEC9E3 /* VLCDocumentClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = VLCDocumentClass.swift; path = Sources/VLCDocumentClass.swift; sourceTree = "<group>"; };
 		41E6BECC207E64E900E158BA /* RemoteNetworkCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteNetworkCell.swift; sourceTree = "<group>"; };
+		41EB6633216147DD00FDC38B /* PlaylistViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaylistViewController.swift; sourceTree = "<group>"; };
 		41EB91DB1F7BFF8400821AA5 /* VLCMetadata.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCMetadata.h; sourceTree = "<group>"; };
 		41EB91DC1F7BFF8400821AA5 /* VLCMetadata.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCMetadata.m; sourceTree = "<group>"; };
 		41EC28E22136D905004BCF0F /* BaseCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseCollectionViewCell.swift; sourceTree = "<group>"; };
@@ -1878,6 +1880,7 @@
 				8DE187822105DB2E00A091D2 /* AudioViewController.swift */,
 				4170152B209A1D3600802E44 /* MediaViewController.swift */,
 				8DE187802105DAB100A091D2 /* VideoViewController.swift */,
+				41EB6633216147DD00FDC38B /* PlaylistViewController.swift */,
 			);
 			name = MediaViewControllers;
 			path = Sources/MediaViewControllers;
@@ -2982,6 +2985,7 @@
 				7D30F3C3183AB24C00FFC021 /* VLCHTTPFileDownloader.m in Sources */,
 				41273A3C1A955C4100A2EF77 /* VLCMigrationViewController.m in Sources */,
 				4144156A20ECD2620078EC37 /* VLCSectionTableHeaderView.swift in Sources */,
+				41EB6634216147DD00FDC38B /* PlaylistViewController.swift in Sources */,
 				7D30F3C4183AB24C00FFC021 /* VLCHTTPUploaderController.m in Sources */,
 				7D30F3C7183AB26F00FFC021 /* VLCOpenNetworkStreamViewController.m in Sources */,
 				41E6BECD207E64E900E158BA /* RemoteNetworkCell.swift in Sources */,