CollectionModel.swift 1.4 KB

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