Commit 6c1b9099 authored by Mike JS. Choi's avatar Mike JS. Choi Committed by Carola Nitz

[UI] Include empty view for media controllers

Note this uses pre-existing VLCEmptyLibraryView Objective-C code
parent 7b360847
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="9058" systemVersion="15B30a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina5_9" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<development version="6000" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9048"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="center" id="112" customClass="EmptyLibraryView">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<view contentMode="center" id="112" customClass="VLCEmptyLibraryView">
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="VLCCone512x512" translatesAutoresizingMaskIntoConstraints="NO" id="115">
<rect key="frame" x="123" y="175" width="128" height="128"/>
<animations/>
<rect key="frame" x="123" y="247.33333333333337" width="128" height="128"/>
<constraints>
<constraint firstAttribute="width" constant="128" id="SFf-AC-Ub8"/>
<constraint firstAttribute="height" constant="128" id="m2Z-Tl-hAc"/>
</constraints>
</imageView>
<label clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Empty Media Library" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="114">
<rect key="frame" x="103" y="323.5" width="169" height="20.5"/>
<animations/>
<color key="backgroundColor" red="0.1215686275" green="0.1215686275" blue="0.1215686275" alpha="1" colorSpace="calibratedRGB"/>
<rect key="frame" x="103" y="395.66666666666669" width="169" height="20.666666666666686"/>
<color key="backgroundColor" red="0.1215686275" green="0.1215686275" blue="0.1215686275" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<activityIndicatorView hidden="YES" contentMode="scaleToFill" hidesWhenStopped="YES" style="whiteLarge" translatesAutoresizingMaskIntoConstraints="NO" id="122">
<rect key="frame" x="169" y="315" width="37" height="37"/>
<animations/>
<rect key="frame" x="169" y="387.66666666666669" width="37" height="37"/>
</activityIndicatorView>
<label clipsSubviews="YES" userInteractionEnabled="NO" contentMode="center" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="300" translatesAutoresizingMaskIntoConstraints="NO" id="vqV-xO-9Ez">
<rect key="frame" x="37" y="353.5" width="300" height="101.5"/>
<animations/>
<color key="backgroundColor" red="0.1215686275" green="0.1215686275" blue="0.1215686275" alpha="1" colorSpace="calibratedRGB"/>
<rect key="frame" x="37" y="425.66666666666669" width="300" height="101.66666666666669"/>
<color key="backgroundColor" red="0.1215686275" green="0.1215686275" blue="0.1215686275" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<string key="text">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.</string>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="0.71999999999999997" alpha="1" colorSpace="calibratedWhite"/>
<color key="textColor" red="0.72000002861022949" green="0.72000002861022949" blue="0.72000002861022949" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="A78-83-MhQ">
<rect key="frame" x="124" y="463" width="126" height="42"/>
<animations/>
<rect key="frame" x="124" y="535.33333333333337" width="126" height="42"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="126" id="ISw-i5-3Bn"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<state key="normal" title="Learn More">
<color key="titleColor" red="0.0" green="0.37647058820000001" blue="0.99607843139999996" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleColor" red="0.0" green="0.37647058820000001" blue="0.99607843139999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="learnMore:" destination="112" eventType="touchUpInside" id="TQf-Oo-oTD"/>
</connections>
</button>
</subviews>
<animations/>
<color key="backgroundColor" white="0.12" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.11999999731779099" green="0.11999999731779099" blue="0.11999999731779099" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="114" firstAttribute="centerY" secondItem="112" secondAttribute="centerY" id="098-OL-ugD"/>
<constraint firstItem="115" firstAttribute="top" secondItem="112" secondAttribute="top" constant="100" id="0iO-j4-F4t"/>
......@@ -73,7 +70,7 @@
<constraint firstItem="114" firstAttribute="top" secondItem="115" secondAttribute="bottom" constant="20" id="pbA-T9-jI3"/>
<constraint firstItem="vqV-xO-9Ez" firstAttribute="top" secondItem="114" secondAttribute="bottom" constant="9.5" id="w3w-k2-PUH"/>
</constraints>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina47"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<variation key="default">
<mask key="constraints">
<exclude reference="0iO-j4-F4t"/>
......
......@@ -6,6 +6,7 @@
* $Id$
*
* Authors: Carola Nitz <nitz.carola # gmail.com>
* Mike JS. Choi <mkchoi212 # icloud.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
......@@ -27,7 +28,10 @@ public class MediaDataSourceAndDelegate: NSObject, UICollectionViewDataSource, U
}
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return Int(services.mediaDataSource.numberOfFiles())
let numItems = Int(services.mediaDataSource.numberOfFiles())
let hasMedia = numItems > 0
collectionView.backgroundView?.isHidden = hasMedia
return numItems
}
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
......
......@@ -6,6 +6,7 @@
* $Id$
*
* Authors: Carola Nitz <nitz.carola # gmail.com>
* Mike JS. Choi <mkchoi212 # icloud.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
......@@ -30,6 +31,14 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
dragAndDropManager.delegate = services.mediaDataSource
return dragAndDropManager
}()
lazy var emptyView: VLCEmptyLibraryView = {
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)") }
emptyView.frame = view.bounds
return emptyView
}()
public convenience init(services: Services) {
self.init(collectionViewLayout: UICollectionViewFlowLayout())
......@@ -76,12 +85,13 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
override public func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
displayEmptyViewIfNeeded()
services.mediaDataSource.updateContents(forSelection: nil)
services.mediaDataSource.addAllFolders()
services.mediaDataSource.addRemainingFiles()
collectionView?.reloadData()
}
func setupSearchController() {
searchController = UISearchController(searchResultsController: nil)
searchController?.searchResultsUpdater = self
......@@ -105,6 +115,10 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
func setupNavigationBar() {
navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("SORT", comment: ""), style: .plain, target: self, action: #selector(sort))
}
func displayEmptyViewIfNeeded() {
collectionView?.backgroundView = collectionView?.numberOfItems(inSection: 0) == 0 ? emptyView : nil
}
@objc func sort() {
delegate?.mediaViewControllerDidSelectSort(self)
......
/*****************************************************************************
* VLCEmptyLibraryView.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2018 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Mike JS. Choi <mkchoi212 # icloud.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import <UIKit/UIKit.h>
@interface VLCEmptyLibraryView: UIView
@property (nonatomic, strong) IBOutlet UILabel *emptyLibraryLabel;
@property (nonatomic, strong) IBOutlet UILabel *emptyLibraryLongDescriptionLabel;
@property (nonatomic, strong) IBOutlet UIActivityIndicatorView *activityIndicator;
@property (nonatomic, strong) IBOutlet UIButton *learnMoreButton;
- (IBAction)learnMore:(id)sender;
@end
/*****************************************************************************
* VLCEmptyLibraryView.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2018 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Mike JS. Choi <mkchoi212 # icloud.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import <Foundation/Foundation.h>
#import "VLCEmptyLibraryView.h"
#import "VLCFirstStepsViewController.h"
@implementation VLCEmptyLibraryView
- (void)awakeFromNib
{
_emptyLibraryLabel.text = NSLocalizedString(@"EMPTY_LIBRARY", nil);
_emptyLibraryLongDescriptionLabel.text = NSLocalizedString(@"EMPTY_LIBRARY_LONG", nil);
[_learnMoreButton setTitle:NSLocalizedString(@"BUTTON_LEARN_MORE", nil) forState:UIControlStateNormal];
[super awakeFromNib];
}
- (IBAction)learnMore:(id)sender
{
UIViewController *firstStepsVC = [[VLCFirstStepsViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:firstStepsVC];
navCon.modalPresentationStyle = UIModalPresentationFormSheet;
[self.window.rootViewController presentViewController:navCon animated:YES completion:nil];
}
@end
......@@ -7,6 +7,7 @@
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
* Gleb Pinigin <gpinigin # gmail.com>
* Mike JS. Choi <mkchoi212 # icloud.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
......@@ -17,26 +18,12 @@
#import "MLMediaLibrary+playlist.h"
@class EmptyLibraryView;
@interface VLCLibraryViewController : UIViewController <UITabBarDelegate, UIPopoverControllerDelegate>
- (IBAction)leftButtonAction:(id)sender;
- (void)updateViewContents;
- (void)removeMediaObject:(id)mediaObject updateDatabase:(BOOL)updateDB;
- (void)setLibraryMode:(VLCLibraryMode)mode;
@end
@interface EmptyLibraryView: UIView
@property (nonatomic, strong) IBOutlet UILabel *emptyLibraryLabel;
@property (nonatomic, strong) IBOutlet UILabel *emptyLibraryLongDescriptionLabel;
@property (nonatomic, strong) IBOutlet UIActivityIndicatorView *activityIndicator;
@property (nonatomic, strong) IBOutlet UIButton *learnMoreButton;
- (IBAction)learnMore:(id)sender;
@end
......@@ -10,6 +10,7 @@
* Tamas Timar <ttimar.vlc # gmail.com>
* Carola Nitz <nitz.carola # gmail.com>
* Tobias Conradi <videolan # tobias-conradi.de>
* Mike JS. Choi <mkchoi212 # icloud.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
......@@ -20,7 +21,7 @@
#import "VLCActivityViewControllerVendor.h"
#import "VLCAppDelegate.h"
#import "VLCBugreporter.h"
#import "VLCFirstStepsViewController.h"
#import "VLCEmptyLibraryView.h"
#import "VLCFolderCollectionViewFlowLayout.h"
#import "VLCMediaDataSource.h"
#import "VLCLibrarySearchDisplayDataSource.h"
......@@ -37,18 +38,6 @@
static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutorial?";
static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
@implementation EmptyLibraryView
- (IBAction)learnMore:(id)sender
{
UIViewController *firstStepsVC = [[VLCFirstStepsViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:firstStepsVC];
navCon.modalPresentationStyle = UIModalPresentationFormSheet;
[self.window.rootViewController presentViewController:navCon animated:YES completion:nil];
}
@end
@interface VLCLibraryViewController () <VLCFolderCollectionViewDelegateFlowLayout, LXReorderableCollectionViewDataSource, LXReorderableCollectionViewDelegateFlowLayout, UITableViewDataSource, UITableViewDelegate, MLMediaLibrary, VLCMediaListDelegate, UISearchResultsUpdating, UISearchControllerDelegate> {
VLCLibraryMode _libraryMode;
VLCLibraryMode _previousLibraryMode;
......@@ -79,7 +68,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
@property (nonatomic, strong) UIBarButtonItem *displayModeBarButtonItem;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) EmptyLibraryView *emptyLibraryView;
@property (nonatomic, strong) VLCEmptyLibraryView *emptyLibraryView;
@end
......
......@@ -8,6 +8,7 @@
#import "VLCCloudServicesTableViewController.h"
#import "VLCConstants.h"
#import "VLCDownloadViewController.h"
#import "VLCEmptyLibraryView.h"
#import "VLCLibrarySearchDisplayDataSource.h"
#import "VLCMediaDataSource.h"
#import "VLCOpenNetworkStreamViewController.h"
......
......@@ -253,6 +253,7 @@
CAD925792075536300F88496 /* Screenshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAD925782075536300F88496 /* Screenshot.swift */; };
CAD925812075613200F88496 /* SnapshotHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAD925802075613100F88496 /* SnapshotHelper.swift */; };
CAF76D9520709CDE00E2AD7B /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A79246C6170F11DF0036AAF2 /* Localizable.strings */; };
CADFAD08207D128200103F33 /* VLCEmptyLibraryView.m in Sources */ = {isa = PBXBuildFile; fileRef = CADFAD07207D128200103F33 /* VLCEmptyLibraryView.m */; };
CC1BBC461704938300A20CBF /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CC1BBC451704938300A20CBF /* libiconv.dylib */; };
CC1BBC4C1704939B00A20CBF /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CC1BBC4B1704939B00A20CBF /* libsqlite3.dylib */; };
CC1BBC4E170493A300A20CBF /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CC1BBC4D170493A300A20CBF /* libbz2.dylib */; };
......@@ -962,6 +963,8 @@
CAF76D8F20709C4100E2AD7B /* VLCiOSTestMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VLCiOSTestMenu.swift; sourceTree = "<group>"; };
CAF76D9120709C7000E2AD7B /* VLCiOSTestVideoCodecs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VLCiOSTestVideoCodecs.swift; sourceTree = "<group>"; };
CAF76D9320709C9500E2AD7B /* XCUIElement+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCUIElement+Helpers.swift"; sourceTree = "<group>"; };
CADFAD06207D128200103F33 /* VLCEmptyLibraryView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCEmptyLibraryView.h; path = Sources/VLCEmptyLibraryView.h; sourceTree = "<group>"; };
CADFAD07207D128200103F33 /* VLCEmptyLibraryView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCEmptyLibraryView.m; path = Sources/VLCEmptyLibraryView.m; sourceTree = "<group>"; };
CC1BBC451704938300A20CBF /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = usr/lib/libiconv.dylib; sourceTree = SDKROOT; };
CC1BBC471704938B00A20CBF /* libstdc++.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libstdc++.dylib"; path = "usr/lib/libstdc++.dylib"; sourceTree = SDKROOT; };
CC1BBC491704939300A20CBF /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
......@@ -1532,6 +1535,8 @@
7D378496183A98D1009EE944 /* VLCPlaylistTableViewCell.m */,
7D378497183A98D1009EE944 /* VLCLibraryViewController.h */,
7D378498183A98D1009EE944 /* VLCLibraryViewController.m */,
CADFAD06207D128200103F33 /* VLCEmptyLibraryView.h */,
CADFAD07207D128200103F33 /* VLCEmptyLibraryView.m */,
8F91EC77195CEC7900F5BCBA /* VLCOpenInActivity.h */,
8F91EC78195CEC7900F5BCBA /* VLCOpenInActivity.m */,
41F5C0761F41ED55005EB9CB /* VLCLibrarySearchDisplayDataSource.h */,
......@@ -3214,6 +3219,7 @@
7D3784A1183A98EB009EE944 /* VLCBugreporter.m in Sources */,
7D3784A6183A98F5009EE944 /* VLCAboutViewController.m in Sources */,
7D3784A7183A98F5009EE944 /* VLCSettingsController.m in Sources */,
CADFAD08207D128200103F33 /* VLCEmptyLibraryView.m in Sources */,
7DC19AE41868C8EC00810BF7 /* VLCFirstStepsFirstPageViewController.m in Sources */,
7D3784AD183A9906009EE944 /* VLCDropboxController.m in Sources */,
7D3784AE183A9906009EE944 /* VLCDropboxTableViewController.m in Sources */,
......
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