Jelajahi Sumber

VLCEmptyLibraryView: Adapt content for different model types

Closes #665
Soomin Lee 5 tahun lalu
induk
melakukan
7f14dfb4c3

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

@@ -177,6 +177,9 @@
 "EMPTY_LIBRARY" = "Empty Media Library";
 "EMPTY_LIBRARY_LONG" = "For playback, you can stream media from a server on your local network, from the cloud or synchronize media to your device using iTunes, WiFi Upload or Cloud services.";
 
+"EMPTY_PLAYLIST" = "Empty playlist";
+"EMPTY_PLAYLIST_DESCRIPTION" = "Add media while editing in the respective categories.";
+
 "PLAYBACK_SCRUB_HELP" = "Slide your finger down to adjust the scrubbing rate.";
 "PLAYBACK_SCRUB_HIGH" = "High-Speed Scrubbing";
 "PLAYBACK_SCRUB_HALF" = "Half-Speed Scrubbing";

+ 7 - 0
Sources/MediaCategories/MediaCategoryViewController.swift

@@ -69,6 +69,13 @@ class MediaCategoryViewController: UICollectionViewController, UICollectionViewD
         let name = String(describing: VLCEmptyLibraryView.self)
         let nib = Bundle.main.loadNibNamed(name, owner: self, options: nil)
         guard let emptyView = nib?.first as? VLCEmptyLibraryView else { fatalError("Can't find nib for \(name)") }
+
+        // Check if it is inside a playlist
+        if let collectionModel = model as? CollectionModel,
+            collectionModel.mediaCollection is VLCMLPlaylist {
+            emptyView.contentType = .playlist
+        }
+
         return emptyView
     }()
 

+ 9 - 0
Sources/VLCEmptyLibraryView.h

@@ -12,11 +12,20 @@
 
 #import <UIKit/UIKit.h>
 
+typedef NS_ENUM (NSUInteger, VLCEmptyLibraryViewContentType)
+{
+    VLCEmptyLibraryViewContentTypeVideo,
+    VLCEmptyLibraryViewContentTypeAudio,
+    VLCEmptyLibraryViewContentTypePlaylist
+};
+
 @interface VLCEmptyLibraryView: UIView
 
 @property (nonatomic, strong) IBOutlet UILabel *emptyLibraryLabel;
 @property (nonatomic, strong) IBOutlet UILabel *emptyLibraryLongDescriptionLabel;
 @property (nonatomic, strong) IBOutlet UIButton *learnMoreButton;
+@property (nonatomic, strong) IBOutlet UIImageView *iconView;
+@property (nonatomic) VLCEmptyLibraryViewContentType contentType;
 
 - (IBAction)learnMore:(id)sender;
 

+ 25 - 0
Sources/VLCEmptyLibraryView.m

@@ -45,4 +45,29 @@
     _emptyLibraryLongDescriptionLabel.textColor = PresentationTheme.current.colors.lightTextColor;
 }
 
+- (void)setContentType:(VLCEmptyLibraryViewContentType)contentType
+{
+    _contentType = contentType;
+
+    NSString *title;
+    NSString *description;
+
+    switch (contentType) {
+        case VLCEmptyLibraryViewContentTypeVideo:
+        case VLCEmptyLibraryViewContentTypeAudio:
+            title = NSLocalizedString(@"EMPTY_LIBRARY", nil);
+            description = NSLocalizedString(@"EMPTY_LIBRARY_LONG", nil);
+            _learnMoreButton.hidden = NO;
+            break;
+        case VLCEmptyLibraryViewContentTypePlaylist:
+            title = NSLocalizedString(@"EMPTY_PLAYLIST", nil);
+            description = NSLocalizedString(@"EMPTY_PLAYLIST_DESCRIPTION",
+                                            nil);
+            _learnMoreButton.hidden = YES;
+            break;
+    }
+    _emptyLibraryLabel.text = title;
+    _emptyLibraryLongDescriptionLabel.text = description;
+}
+
 @end