|
@@ -19,19 +19,27 @@ class MediaEditCell: BaseCollectionViewCell {
|
|
|
@IBOutlet weak var titleLabel: UILabel!
|
|
|
@IBOutlet weak var timeLabel: UILabel!
|
|
|
@IBOutlet weak var sizeLabel: UILabel!
|
|
|
+ @IBOutlet weak var VideoAspectRatio: NSLayoutConstraint!
|
|
|
+ @IBOutlet weak var AudioAspectRatio: NSLayoutConstraint!
|
|
|
|
|
|
override var media: VLCMLObject? {
|
|
|
didSet {
|
|
|
- guard let media = media as? VLCMLMedia else {
|
|
|
- fatalError("needs to be of Type VLCMLMedia")
|
|
|
+ if let media = media as? VLCMLMedia {
|
|
|
+ updateForMedia(media: media)
|
|
|
+ } else if let artist = media as? VLCMLArtist {
|
|
|
+ updateForArtist(artist: artist)
|
|
|
+ } else if let album = media as? VLCMLAlbum {
|
|
|
+ updateForAlbum(album: album)
|
|
|
+ } else if let genre = media as? VLCMLGenre {
|
|
|
+ updateForGenre(genre: genre)
|
|
|
+ } else {
|
|
|
+ fatalError("needs to be of a supported Type")
|
|
|
}
|
|
|
- update(media:media)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
override func awakeFromNib() {
|
|
|
super.awakeFromNib()
|
|
|
- thumbnailImageView.layer.cornerRadius = 3
|
|
|
thumbnailImageView.clipsToBounds = true
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(themeDidChange), name: .VLCThemeDidChangeNotification, object: nil)
|
|
|
themeDidChange()
|
|
@@ -44,7 +52,10 @@ class MediaEditCell: BaseCollectionViewCell {
|
|
|
sizeLabel.textColor = PresentationTheme.current.colors.cellTextColor
|
|
|
}
|
|
|
|
|
|
- func update(media: VLCMLMedia) {
|
|
|
+ func updateForMedia(media: VLCMLMedia) {
|
|
|
+ thumbnailImageView.layer.cornerRadius = 3
|
|
|
+ AudioAspectRatio.isActive = false
|
|
|
+ VideoAspectRatio.isActive = true
|
|
|
titleLabel.text = media.title
|
|
|
timeLabel.text = media.mediaDuration()
|
|
|
sizeLabel.text = media.formatSize()
|
|
@@ -53,6 +64,25 @@ class MediaEditCell: BaseCollectionViewCell {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ func updateForArtist(artist: VLCMLArtist) {
|
|
|
+ //TODO: add size, number of tracks, thumbnail
|
|
|
+ titleLabel.text = artist.name
|
|
|
+ thumbnailImageView.layer.cornerRadius = thumbnailImageView.frame.size.height / 2
|
|
|
+ }
|
|
|
+
|
|
|
+ func updateForAlbum(album: VLCMLAlbum) {
|
|
|
+ titleLabel.text = album.title
|
|
|
+ timeLabel.text = album.albumArtist != nil ? album.albumArtist.name : ""
|
|
|
+ //TODO: add size, number of tracks, thumbnail
|
|
|
+ }
|
|
|
+
|
|
|
+ func updateForGenre(genre: VLCMLGenre) {
|
|
|
+ titleLabel.text = genre.name
|
|
|
+ timeLabel.text = genre.numberOfTracksString()
|
|
|
+ thumbnailImageView.layer.cornerRadius = thumbnailImageView.frame.size.height / 2
|
|
|
+ //TODO: add thumbnail
|
|
|
+ }
|
|
|
+
|
|
|
var isChecked: Bool = false {
|
|
|
didSet {
|
|
|
checkboxImageView.image = isChecked ? UIImage(named: "checkboxSelected") : UIImage(named: "checkboxEmpty")
|
|
@@ -66,5 +96,8 @@ class MediaEditCell: BaseCollectionViewCell {
|
|
|
sizeLabel.text = ""
|
|
|
thumbnailImageView.image = nil
|
|
|
isChecked = false
|
|
|
+ thumbnailImageView.layer.cornerRadius = 0
|
|
|
+ AudioAspectRatio.isActive = true
|
|
|
+ VideoAspectRatio.isActive = false
|
|
|
}
|
|
|
}
|