Commit 6397c5f6 authored by Mike JS. Choi's avatar Mike JS. Choi Committed by Carola Nitz

EmptyView: Adjust view for devices and theme

Adapt EmptyView to theme
Add adaptive layout to empty view
Collapse navigation bar for empty view
parent 252bed6c
<?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">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="Stack View standard spacing" minToolsVersion="9.0"/>
<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="VLCEmptyLibraryView">
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<view contentMode="scaleAspectFit" preservesSuperviewLayoutMargins="YES" id="112" customClass="VLCEmptyLibraryView">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<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="247.33333333333337" width="128" height="128"/>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="18" translatesAutoresizingMaskIntoConstraints="NO" id="141-gp-zTI" userLabel="Empty View">
<rect key="frame" x="24.5" y="153" width="326" height="381"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="VLCCone512x512.png" translatesAutoresizingMaskIntoConstraints="NO" id="115">
<rect key="frame" x="90" y="0.0" width="146" height="146"/>
<constraints>
<constraint firstAttribute="width" relation="lessThanOrEqual" constant="250" id="51y-b0-uDd"/>
<constraint firstAttribute="width" secondItem="115" secondAttribute="height" multiplier="1:1" id="cc7-4o-L1f"/>
</constraints>
</imageView>
<stackView opaque="NO" contentMode="scaleAspectFit" axis="vertical" distribution="fillEqually" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="hAg-Nw-10g" userLabel="Descriptions">
<rect key="frame" x="0.0" y="164" width="326" height="217"/>
<subviews>
<label opaque="NO" 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="78.5" y="0.0" width="169" height="67"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" 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="19" y="75" width="288.5" height="67"/>
<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="14"/>
<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="117" y="150" width="92" height="67"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<state key="normal" title="Learn More">
<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>
</stackView>
</subviews>
<constraints>
<constraint firstAttribute="width" constant="128" id="SFf-AC-Ub8"/>
<constraint firstAttribute="height" constant="128" id="m2Z-Tl-hAc"/>
<constraint firstItem="115" firstAttribute="width" secondItem="hAg-Nw-10g" secondAttribute="width" multiplier="0.45" id="HnH-ba-fHc"/>
</constraints>
</imageView>
<label opaque="NO" 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="395.66666666666669" width="169" height="20.666666666666686"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<activityIndicatorView hidden="YES" contentMode="scaleToFill" hidesWhenStopped="YES" style="whiteLarge" translatesAutoresizingMaskIntoConstraints="NO" id="122">
<rect key="frame" x="169" y="387.66666666666669" width="37" height="37"/>
</activityIndicatorView>
<label opaque="NO" 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="38" y="425.66666666666669" width="298.33333333333331" height="89.666666666666686"/>
<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="15"/>
<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="523.33333333333337" width="126" height="34"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="126" id="ISw-i5-3Bn"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<state key="normal" title="Learn More">
<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>
<viewLayoutGuide key="safeArea" id="whM-Tb-M9o"/>
<variation key="heightClass=compact" axis="horizontal"/>
</stackView>
</subviews>
<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"/>
<constraint firstItem="122" firstAttribute="centerX" secondItem="112" secondAttribute="centerX" id="1r4-45-cEq"/>
<constraint firstItem="A78-83-MhQ" firstAttribute="centerX" secondItem="112" secondAttribute="centerX" id="Dys-fq-utf"/>
<constraint firstItem="114" firstAttribute="centerX" secondItem="112" secondAttribute="centerX" id="I5K-I4-TIq"/>
<constraint firstItem="vqV-xO-9Ez" firstAttribute="centerY" secondItem="112" secondAttribute="centerY" id="ISD-nk-qjn"/>
<constraint firstItem="vqV-xO-9Ez" firstAttribute="centerX" secondItem="112" secondAttribute="centerX" id="IrI-hi-XZK"/>
<constraint firstItem="115" firstAttribute="centerX" secondItem="112" secondAttribute="centerX" id="SvE-9Q-MUz"/>
<constraint firstItem="122" firstAttribute="centerY" secondItem="112" secondAttribute="centerY" id="cDx-tE-VwH"/>
<constraint firstItem="A78-83-MhQ" firstAttribute="top" secondItem="vqV-xO-9Ez" secondAttribute="bottom" constant="8.5" id="fSe-v5-qdy"/>
<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"/>
<constraint firstItem="141-gp-zTI" firstAttribute="centerX" secondItem="1mU-bI-aIo" secondAttribute="centerX" id="Cdl-do-lNd"/>
<constraint firstItem="141-gp-zTI" firstAttribute="centerY" secondItem="1mU-bI-aIo" secondAttribute="centerY" id="ZrH-Xy-Fzq"/>
<constraint firstItem="141-gp-zTI" firstAttribute="height" secondItem="1mU-bI-aIo" secondAttribute="height" multiplier="0.55" priority="749" id="kIp-QD-bah"/>
<constraint firstItem="1mU-bI-aIo" firstAttribute="width" relation="greaterThanOrEqual" secondItem="141-gp-zTI" secondAttribute="width" multiplier="1.15" id="u8v-1a-vO0"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="0iO-j4-F4t"/>
<exclude reference="ISD-nk-qjn"/>
</mask>
</variation>
<viewLayoutGuide key="safeArea" id="1mU-bI-aIo"/>
<connections>
<outlet property="activityIndicator" destination="122" id="123"/>
<outlet property="emptyLibraryLabel" destination="114" id="119"/>
<outlet property="emptyLibraryLongDescriptionLabel" destination="vqV-xO-9Ez" id="Grj-83-sAj"/>
<outlet property="learnMoreButton" destination="A78-83-MhQ" id="z6i-rn-FZx"/>
</connections>
<point key="canvasLocation" x="368.5" y="66"/>
<point key="canvasLocation" x="43" y="153"/>
</view>
</objects>
<resources>
<image name="VLCCone512x512" width="512" height="512"/>
<image name="VLCCone512x512.png" width="512" height="512"/>
</resources>
</document>
......@@ -39,7 +39,6 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
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
}()
......@@ -63,7 +62,7 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
@objc func reloadData() {
collectionView?.reloadData()
displayEmptyViewIfNeeded()
updateUIForEmptyView()
}
@available(*, unavailable)
......@@ -126,20 +125,29 @@ public class VLCMediaViewController: UICollectionViewController, UISearchResults
backgroundview.clipsToBounds = true
}
}
if #available(iOS 11.0, *) {
navigationItem.searchController = searchController
} else {
navigationItem.titleView = searchController?.searchBar
searchController?.hidesNavigationBarDuringPresentation = false
}
}
func setupNavigationBar() {
navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("SORT", comment: ""), style: .plain, target: self, action: #selector(sort))
}
func updateUIForEmptyView() {
let isEmpty = collectionView?.numberOfItems(inSection: 0) == 0
func displayEmptyViewIfNeeded() {
collectionView?.backgroundView = collectionView?.numberOfItems(inSection: 0) == 0 ? emptyView : nil
if isEmpty {
collectionView?.setContentOffset(.zero, animated: false)
collectionView?.backgroundView = emptyView
edgesForExtendedLayout = []
} else {
collectionView?.backgroundView = nil
edgesForExtendedLayout = .all
}
if #available(iOS 11.0, *) {
navigationItem.searchController = isEmpty ? nil :searchController
} else {
navigationItem.titleView = isEmpty ? nil : searchController?.searchBar
}
}
// MARK: Renderer
......
......@@ -16,7 +16,6 @@
@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;
......
......@@ -13,6 +13,7 @@
#import <Foundation/Foundation.h>
#import "VLCEmptyLibraryView.h"
#import "VLCFirstStepsViewController.h"
#import "VLC_iOS-Swift.h"
@implementation VLCEmptyLibraryView
......@@ -21,6 +22,12 @@
_emptyLibraryLabel.text = NSLocalizedString(@"EMPTY_LIBRARY", nil);
_emptyLibraryLongDescriptionLabel.text = NSLocalizedString(@"EMPTY_LIBRARY_LONG", nil);
[_learnMoreButton setTitle:NSLocalizedString(@"BUTTON_LEARN_MORE", nil) forState:UIControlStateNormal];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(themeDidChange)
name:kVLCThemeDidChangeNotification
object:nil];
[self themeDidChange];
[super awakeFromNib];
}
......@@ -32,4 +39,10 @@
[self.window.rootViewController presentViewController:navCon animated:YES completion:nil];
}
- (void)themeDidChange
{
_emptyLibraryLabel.textColor = PresentationTheme.current.colors.cellTextColor;
_emptyLibraryLongDescriptionLabel.textColor = PresentationTheme.current.colors.lightTextColor;
}
@end
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