Prechádzať zdrojové kódy

MediaCategoryViewController: Set the title in the navbar for the selected collection

(fixes #474)
Carola Nitz 6 rokov pred
rodič
commit
b0bf89b92f

+ 4 - 0
SharedSources/MediaLibraryModel/AlbumModel.swift

@@ -74,4 +74,8 @@ extension VLCMLAlbum: MediaCollectionModel {
     func files() -> [VLCMLMedia]? {
         return tracks
     }
+
+    func title() -> String? {
+        return title
+    }
 }

+ 4 - 0
SharedSources/MediaLibraryModel/ArtistModel.swift

@@ -74,6 +74,10 @@ extension VLCMLArtist: MediaCollectionModel {
     func files() -> [VLCMLMedia]? {
         return tracks()
     }
+
+    func title() -> String? {
+        return name
+    }
 }
 
 extension VLCMLArtist {

+ 4 - 0
SharedSources/MediaLibraryModel/GenreModel.swift

@@ -86,4 +86,8 @@ extension VLCMLGenre: MediaCollectionModel {
     func files() -> [VLCMLMedia]? {
         return tracks()
     }
+
+    func title() -> String? {
+        return name
+    }
 }

+ 1 - 0
SharedSources/MediaLibraryModel/MediaLibraryBaseModel.swift

@@ -73,4 +73,5 @@ protocol EditableMLModel {
 protocol MediaCollectionModel {
     func files() -> [VLCMLMedia]?
     func sortModel() -> SortModel?
+    func title() -> String?
 }

+ 4 - 0
SharedSources/MediaLibraryModel/PlaylistModel.swift

@@ -111,4 +111,8 @@ extension VLCMLPlaylist: MediaCollectionModel {
     func files() -> [VLCMLMedia]? {
         return media
     }
+
+    func title() -> String? {
+        return name
+    }
 }

+ 3 - 0
Sources/MediaCategories/MediaCategoryViewController.swift

@@ -76,6 +76,9 @@ class VLCMediaCategoryViewController: UICollectionViewController, UICollectionVi
         self.model = model
         self.rendererButton = services.rendererDiscovererManager.setupRendererButton()
         super.init(collectionViewLayout: UICollectionViewFlowLayout())
+        if let collection = model as? CollectionModel {
+            title = collection.mediaCollection.title()
+        }
         NotificationCenter.default.addObserver(self, selector: #selector(themeDidChange), name: .VLCThemeDidChangeNotification, object: nil)
         navigationItem.rightBarButtonItems = [editButtonItem, UIBarButtonItem(customView: rendererButton)]
     }