Commit 23fef486 authored by Carola Nitz's avatar Carola Nitz

AudioCollectionviewCell: add basic AudioCell for Audiocontent

return MovieCell for all other cells where we don't have yet a designated cell
parent 4269d8f7
/*****************************************************************************
* AudioCollectionViewCell.swift
* VLC for iOS
*****************************************************************************
* Copyright (c) 2018 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Carola Nitz <nitz.carola # googlemail.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
import Foundation
class AudioCollectionViewCell: BaseCollectionViewCell {
@IBOutlet weak var thumbnailView: UIImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var descriptionLabel: UILabel!
@IBOutlet weak var newLabel: UILabel!
override var media: VLCMLObject? {
didSet {
guard let albumTrack = media as? VLCMLMedia else {
fatalError("needs to be of Type VLCMLMovie")
}
update(audiotrack:albumTrack)
}
}
override func awakeFromNib() {
super.awakeFromNib()
newLabel.text = NSLocalizedString("NEW", comment: "")
newLabel.textColor = PresentationTheme.current.colors.orangeUI
NotificationCenter.default.addObserver(self, selector: #selector(themeDidChange), name: .VLCThemeDidChangeNotification, object: nil)
themeDidChange()
thumbnailView.layer.cornerRadius = thumbnailView.frame.size.width / 2.0
}
@objc fileprivate func themeDidChange() {
backgroundColor = PresentationTheme.current.colors.background
titleLabel?.textColor = PresentationTheme.current.colors.cellTextColor
descriptionLabel?.textColor = PresentationTheme.current.colors.cellDetailTextColor
}
func update(audiotrack: VLCMLMedia) {
titleLabel.text = audiotrack.title
descriptionLabel.text = audiotrack.mediaDuration()
if audiotrack.isThumbnailGenerated() {
thumbnailView.image = UIImage(contentsOfFile: audiotrack.thumbnail.absoluteString)
}
newLabel.isHidden = !audiotrack.isNew()
}
override func prepareForReuse() {
super.prepareForReuse()
titleLabel.text = ""
descriptionLabel.text = ""
thumbnailView.image = nil
newLabel.isHidden = true
}
}
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" 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="Safe area layout guides" 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"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="OaX-w0-CLr" userLabel="Audio Collection View Cell" customClass="AudioCollectionViewCell" customModule="VLC" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="480" height="80"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO">
<rect key="frame" x="0.0" y="0.0" width="480" height="80"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" alignment="center" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="jwA-4O-tgL">
<rect key="frame" x="0.0" y="0.0" width="480" height="80"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="DpW-xo-rll" userLabel="Thumbnail">
<rect key="frame" x="0.0" y="12" width="56" height="56"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" secondItem="DpW-xo-rll" secondAttribute="height" multiplier="1:1" id="K1w-Z8-Rbn"/>
<constraint firstAttribute="width" constant="56" id="vgz-Bg-lit"/>
</constraints>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="4" translatesAutoresizingMaskIntoConstraints="NO" id="HHK-jR-WLx">
<rect key="frame" x="64" y="12" width="416" height="56.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="new" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Klo-Bq-5nI" userLabel="NewLabel">
<rect key="frame" x="0.0" y="0.0" width="416" height="12"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="10"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Zkn-vN-SN4" userLabel="Titlelabel">
<rect key="frame" x="0.0" y="16" width="416" height="20.5"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5N8-js-t0W" userLabel="descriptionLabel">
<rect key="frame" x="0.0" y="40.5" width="416" height="16"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="13"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
</subviews>
</stackView>
</subviews>
</view>
<constraints>
<constraint firstItem="jwA-4O-tgL" firstAttribute="leading" secondItem="L0K-f1-QjV" secondAttribute="leading" id="IBs-dW-Lj7"/>
<constraint firstItem="jwA-4O-tgL" firstAttribute="top" secondItem="L0K-f1-QjV" secondAttribute="top" id="TTE-Hs-KZ8"/>
<constraint firstItem="L0K-f1-QjV" firstAttribute="trailing" secondItem="jwA-4O-tgL" secondAttribute="trailing" id="VMU-O4-8og"/>
<constraint firstItem="L0K-f1-QjV" firstAttribute="bottom" secondItem="jwA-4O-tgL" secondAttribute="bottom" id="tHN-ES-0Mv"/>
</constraints>
<viewLayoutGuide key="safeArea" id="L0K-f1-QjV"/>
<size key="customSize" width="480" height="213"/>
<connections>
<outlet property="descriptionLabel" destination="5N8-js-t0W" id="8YA-5P-R6q"/>
<outlet property="newLabel" destination="Klo-Bq-5nI" id="8jr-y0-SoR"/>
<outlet property="thumbnailView" destination="DpW-xo-rll" id="U2i-pe-qCM"/>
<outlet property="titleLabel" destination="Zkn-vN-SN4" id="H77-N8-sRM"/>
</connections>
<point key="canvasLocation" x="110" y="-53.5"/>
</collectionViewCell>
</objects>
</document>
......@@ -23,7 +23,8 @@ class MovieCollectionViewCell: BaseCollectionViewCell {
override var media: VLCMLObject? {
didSet {
guard let movie = media as? VLCMLMedia else {
fatalError("needs to be of Type VLCMLMovie")
//Todo: fatalerror here once all celltypes are there and this is not abused for others anymore
return
}
update(movie:movie)
}
......
......@@ -16,6 +16,8 @@ class AlbumModel: MLBaseModel {
var files = [VLCMLAlbum]()
var cellType: BaseCollectionViewCell.Type { return MovieCollectionViewCell.self }
var medialibrary: VLCMediaLibraryManager
var indicatorName: String = NSLocalizedString("ALBUMS", comment: "")
......
......@@ -16,6 +16,8 @@ class ArtistModel: MLBaseModel {
var files = [VLCMLArtist]()
var cellType: BaseCollectionViewCell.Type { return MovieCollectionViewCell.self }
var medialibrary: VLCMediaLibraryManager
var indicatorName: String = NSLocalizedString("ARTISTS", comment: "")
......
......@@ -16,6 +16,8 @@ class AudioModel: MediaModel {
var files = [VLCMLMedia]()
var cellType: BaseCollectionViewCell.Type { return AudioCollectionViewCell.self }
var medialibrary: VLCMediaLibraryManager
var indicatorName: String = NSLocalizedString("SONGS", comment: "")
......
......@@ -16,6 +16,8 @@ class GenreModel: MLBaseModel {
var files = [VLCMLGenre]()
var cellType: BaseCollectionViewCell.Type { return MovieCollectionViewCell.self }
var medialibrary: VLCMediaLibraryManager
var indicatorName: String = NSLocalizedString("GENRES", comment: "")
......
......@@ -45,9 +45,6 @@ protocol MLBaseModel: AnyObject, MediaLibraryBaseModel {
}
extension MLBaseModel {
var cellType: BaseCollectionViewCell.Type {
return MovieCollectionViewCell.self
}
var anyfiles: [VLCMLObject] {
return files
......
......@@ -16,6 +16,8 @@ class PlaylistModel: MLBaseModel {
var files = [VLCMLPlaylist]()
var cellType: BaseCollectionViewCell.Type { return MovieCollectionViewCell.self }
var medialibrary: VLCMediaLibraryManager
var indicatorName: String = NSLocalizedString("PLAYLISTS", comment: "")
......
......@@ -16,6 +16,8 @@ class ShowEpisodeModel: MLBaseModel {
var files = [VLCMLMedia]()
var cellType: BaseCollectionViewCell.Type { return MovieCollectionViewCell.self }
var medialibrary: VLCMediaLibraryManager
var indicatorName: String = NSLocalizedString("EPISODES", comment: "")
......
......@@ -10,12 +10,15 @@
*****************************************************************************/
class VideoModel: MediaModel {
typealias MLType = VLCMLMedia
var updateView: (() -> Void)?
var files = [VLCMLMedia]()
var cellType: BaseCollectionViewCell.Type { return MovieCollectionViewCell.self }
var medialibrary: VLCMediaLibraryManager
var indicatorName: String = NSLocalizedString("MOVIES", comment: "")
......
......@@ -194,13 +194,13 @@ class VLCMediaCategoryViewController: UICollectionViewController, UICollectionVi
assertionFailure("you forgot to register the cell or the cell is not a subclass of BaseCollectionViewCell")
return UICollectionViewCell()
}
guard let media = category.anyfiles[indexPath.row] as? VLCMLMedia else {
assertionFailure("The contained file in the category doesn't conform to VLCMLMedia")
return mediaCell
let mediaObject = category.anyfiles[indexPath.row]
if let media = mediaObject as? VLCMLMedia {
assert(media.mainFile() != nil, "The mainfile is nil")
mediaCell.media = media.mainFile() != nil ? media : nil
} else {
mediaCell.media = mediaObject
}
assert(media.mainFile() != nil, "The mainfile is nil")
mediaCell.media = media.mainFile() != nil ? media : nil
return mediaCell
}
......
......@@ -35,6 +35,8 @@
417E68B91F321EFF00DB9BB2 /* VLCActivityViewControllerVendor.m in Sources */ = {isa = PBXBuildFile; fileRef = 417E68B81F321EFF00DB9BB2 /* VLCActivityViewControllerVendor.m */; };
4181087A2142894A0046A931 /* PlayingExternallyView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 418108792142894A0046A931 /* PlayingExternallyView.xib */; };
4184AA151A5492070063DF5A /* VLCCloudStorageController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4184AA141A5492070063DF5A /* VLCCloudStorageController.m */; };
41884A4E214BE0C800D2C6B4 /* AudioCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 41884A4D214BE0C800D2C6B4 /* AudioCollectionViewCell.xib */; };
41884A50214BE0D800D2C6B4 /* AudioCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41884A4F214BE0D800D2C6B4 /* AudioCollectionViewCell.swift */; };
418B144720179C00000447AA /* MediaCategoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 418B144620179C00000447AA /* MediaCategoryViewController.swift */; };
418B144D20179C75000447AA /* VLCTabBarCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 418B144C20179C74000447AA /* VLCTabBarCoordinator.swift */; };
418B145020179CB9000447AA /* LayoutAnchorContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 418B144F20179CB9000447AA /* LayoutAnchorContainer.swift */; };
......@@ -532,6 +534,8 @@
418108792142894A0046A931 /* PlayingExternallyView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = PlayingExternallyView.xib; path = Resources/PlayingExternallyView.xib; sourceTree = "<group>"; };
4184AA131A5492070063DF5A /* VLCCloudStorageController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCCloudStorageController.h; path = Sources/VLCCloudStorageController.h; sourceTree = SOURCE_ROOT; };
4184AA141A5492070063DF5A /* VLCCloudStorageController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCCloudStorageController.m; path = Sources/VLCCloudStorageController.m; sourceTree = SOURCE_ROOT; };
41884A4D214BE0C800D2C6B4 /* AudioCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AudioCollectionViewCell.xib; sourceTree = "<group>"; };
41884A4F214BE0D800D2C6B4 /* AudioCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioCollectionViewCell.swift; sourceTree = "<group>"; };
418B144620179C00000447AA /* MediaCategoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MediaCategoryViewController.swift; path = Sources/MediaCategories/MediaCategoryViewController.swift; sourceTree = SOURCE_ROOT; };
418B144C20179C74000447AA /* VLCTabBarCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = VLCTabBarCoordinator.swift; path = Sources/VLCTabBarCoordinator.swift; sourceTree = SOURCE_ROOT; };
418B144F20179CB9000447AA /* LayoutAnchorContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LayoutAnchorContainer.swift; path = Sources/LayoutAnchorContainer.swift; sourceTree = "<group>"; };
......@@ -561,9 +565,9 @@
41E6BECC207E64E900E158BA /* RemoteNetworkCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteNetworkCell.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; name = BaseCollectionViewCell.swift; path = Sources/BaseCollectionViewCell.swift; sourceTree = "<group>"; };
41EC28E42136DD41004BCF0F /* MovieCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MovieCollectionViewCell.swift; path = SharedSources/MovieCollectionViewCell.swift; sourceTree = "<group>"; };
41EC28E82136DE46004BCF0F /* MovieCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = MovieCollectionViewCell.xib; path = Sources/MovieCollectionViewCell.xib; sourceTree = "<group>"; };
41EC28E22136D905004BCF0F /* BaseCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseCollectionViewCell.swift; sourceTree = "<group>"; };
41EC28E42136DD41004BCF0F /* MovieCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieCollectionViewCell.swift; sourceTree = "<group>"; };
41EC28E82136DE46004BCF0F /* MovieCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MovieCollectionViewCell.xib; sourceTree = "<group>"; };
41F5C0761F41ED55005EB9CB /* VLCLibrarySearchDisplayDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VLCLibrarySearchDisplayDataSource.h; path = Sources/VLCLibrarySearchDisplayDataSource.h; sourceTree = SOURCE_ROOT; };
41F5C0771F41ED55005EB9CB /* VLCLibrarySearchDisplayDataSource.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = VLCLibrarySearchDisplayDataSource.m; path = Sources/VLCLibrarySearchDisplayDataSource.m; sourceTree = SOURCE_ROOT; };
41F9BC7A1F4F20E400268461 /* VLCTrackSelectorView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VLCTrackSelectorView.h; path = Sources/VLCTrackSelectorView.h; sourceTree = SOURCE_ROOT; };
......@@ -1254,6 +1258,18 @@
path = "VLC-iOS-Tests";
sourceTree = "<group>";
};
41884A4C214BE09D00D2C6B4 /* MediaCategoryCells */ = {
isa = PBXGroup;
children = (
41EC28E22136D905004BCF0F /* BaseCollectionViewCell.swift */,
41EC28E42136DD41004BCF0F /* MovieCollectionViewCell.swift */,
41EC28E82136DE46004BCF0F /* MovieCollectionViewCell.xib */,
41884A4F214BE0D800D2C6B4 /* AudioCollectionViewCell.swift */,
41884A4D214BE0C800D2C6B4 /* AudioCollectionViewCell.xib */,
);
path = MediaCategoryCells;
sourceTree = "<group>";
};
41B0BC871F73ED7D0063BA26 /* VLC-iOS-UITests */ = {
isa = PBXGroup;
children = (
......@@ -1521,6 +1537,7 @@
7D5F7AB81752658E006CCCFA /* Everything Playlist */ = {
isa = PBXGroup;
children = (
41884A4C214BE09D00D2C6B4 /* MediaCategoryCells */,
8DE1879821060D0B00A091D2 /* MediaCategories */,
8DE1877F2105DA2B00A091D2 /* MediaViewControllers */,
418B145820179E50000447AA /* VLCDragAndDropManager.swift */,
......@@ -1534,9 +1551,6 @@
41701545209B36E800802E44 /* VLCPagingViewController.swift */,
41D7DD0420C1853E00AD94F6 /* ButtonBarView.swift */,
41D7DD2620C3060300AD94F6 /* PagerStripViewController.swift */,
41EC28E22136D905004BCF0F /* BaseCollectionViewCell.swift */,
41EC28E42136DD41004BCF0F /* MovieCollectionViewCell.swift */,
41EC28E82136DE46004BCF0F /* MovieCollectionViewCell.xib */,
);
name = "Everything Playlist";
sourceTree = "<group>";
......@@ -2803,6 +2817,7 @@
7D27EC2B19DF310300EF0370 /* VLCFirstStepsSecondPageViewController~ipad.xib in Resources */,
417CDA241A48D1F300D9ACE7 /* VLCCloudServicesTableViewController.xib in Resources */,
7D9870671A3E03D5009CF27D /* papasscode_failed_bg@2x.png in Resources */,
41884A4E214BE0C800D2C6B4 /* AudioCollectionViewCell.xib in Resources */,
7DDFF4251BDFD23300913BD1 /* VLCCone512x512.png in Resources */,
7DF04F4F1961F2B8004A5429 /* web-open-fixed.png in Resources */,
7DBBF19A183AB4300009A339 /* VLCCloudStorageTableViewCell~ipad.xib in Resources */,
......@@ -3179,6 +3194,7 @@
DD3EFF331BDEBCE500B68579 /* VLCLocalNetworkServiceBrowserMediaDiscoverer.m in Sources */,
7DE56C1A1AD93F9100E8CA00 /* VLCPlaybackController.m in Sources */,
4152F1621FEF19BD00F1908B /* KeychainCoordinator.swift in Sources */,
41884A50214BE0D800D2C6B4 /* AudioCollectionViewCell.swift in Sources */,
DD7110F01AF38B2B00854776 /* MLMediaLibrary+playlist.m in Sources */,
7D5CAA891A4AD763003F2CBC /* VLCTrackSelectorTableViewCell.m in Sources */,
7D63C19018774B1700BD5256 /* VLCFirstStepsSecondPageViewController.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