CollectionModel.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // CollectionModel.swift
  3. // VLC-iOS
  4. //
  5. // Created by Carola Nitz on 08.03.19.
  6. // Copyright © 2019 VideoLAN. All rights reserved.
  7. //
  8. import Foundation
  9. class CollectionModel: MLBaseModel {
  10. typealias MLType = VLCMLMedia // could be anything
  11. required init(medialibrary: MediaLibraryService) {
  12. preconditionFailure("")
  13. }
  14. required init(mediaService: MediaLibraryService, mediaCollection: MediaCollectionModel) {
  15. self.medialibrary = mediaService
  16. files = mediaCollection.files()
  17. }
  18. func append(_ item: VLCMLMedia) {
  19. files.append(item)
  20. }
  21. var medialibrary: MediaLibraryService
  22. var updateView: (() -> Void)?
  23. var files = [VLCMLMedia]()
  24. var cellType: BaseCollectionViewCell.Type { return AudioCollectionViewCell.self } //TODO: this approach will not work here because playlists can contain audio or videocells
  25. var indicatorName: String = NSLocalizedString("Collections", comment: "")
  26. func delete(_ items: [VLCMLObject]) {
  27. assertionFailure("still needs implementation")
  28. }
  29. }
  30. // MARK: - Edit
  31. extension CollectionModel: EditableMLModel {
  32. func editCellType() -> BaseCollectionViewCell.Type {
  33. return MediaEditCell.self
  34. }
  35. }