CollectionModel.swift 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. }
  32. // MARK: - Edit
  33. extension CollectionModel: EditableMLModel {
  34. func editCellType() -> BaseCollectionViewCell.Type {
  35. return MediaEditCell.self
  36. }
  37. }