CollectionModel.swift 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. var sortModel: SortModel
  11. typealias MLType = VLCMLMedia // could be anything
  12. required init(medialibrary: MediaLibraryService) {
  13. preconditionFailure("")
  14. }
  15. required init(mediaService: MediaLibraryService, mediaCollection: MediaCollectionModel) {
  16. self.medialibrary = mediaService
  17. files = mediaCollection.files()
  18. sortModel = mediaCollection.sortModel() ?? SortModel([.default])
  19. }
  20. func append(_ item: VLCMLMedia) {
  21. files.append(item)
  22. }
  23. var medialibrary: MediaLibraryService
  24. var updateView: (() -> Void)?
  25. var files = [VLCMLMedia]()
  26. var cellType: BaseCollectionViewCell.Type { return AudioCollectionViewCell.self } //TODO: this approach will not work here because playlists can contain audio or videocells
  27. var indicatorName: String = NSLocalizedString("Collections", comment: "")
  28. func delete(_ items: [VLCMLObject]) {
  29. assertionFailure("still needs implementation")
  30. }
  31. func createPlaylist(_ name: String, _ fileIndexes: Set<IndexPath>?) {
  32. assertionFailure("still needs implementation")
  33. }
  34. }
  35. // MARK: - Edit
  36. extension CollectionModel: EditableMLModel {
  37. func editCellType() -> BaseCollectionViewCell.Type {
  38. return MediaEditCell.self
  39. }
  40. }