SortModel.swift 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*****************************************************************************
  2. * SortModel.swift
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2018 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Carola Nitz <nitz.carola # gmail.com>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. struct SortModel {
  13. var currentSort: VLCMLSortingCriteria
  14. var desc: Bool
  15. var sortingCriteria: [VLCMLSortingCriteria]
  16. init(_ criteria: [VLCMLSortingCriteria]) {
  17. sortingCriteria = criteria
  18. currentSort = .default
  19. desc = false
  20. }
  21. }
  22. // MARK: - VLCMLSortingCriteria extension
  23. extension VLCMLSortingCriteria: CustomStringConvertible {
  24. init(value: UInt) {
  25. guard let sortingCriteria = VLCMLSortingCriteria(rawValue: value) else {
  26. assertionFailure("VLCMLSortingCriteria: Unable to init with the given value: \(value)")
  27. self = .default
  28. return
  29. }
  30. self = sortingCriteria
  31. }
  32. public var description: String {
  33. switch self {
  34. case .alpha:
  35. return NSLocalizedString("ALPHA", comment: "")
  36. case .duration:
  37. return NSLocalizedString("DURATION", comment: "")
  38. case .insertionDate:
  39. return NSLocalizedString("INSERTION_DATE", comment: "")
  40. case .lastModificationDate:
  41. return NSLocalizedString("LAST_MODIFICATION_DATE", comment: "")
  42. case .releaseDate:
  43. return NSLocalizedString("RELEASE_DATE", comment: "")
  44. case .fileSize:
  45. return NSLocalizedString("FILE_SIZE", comment: "")
  46. case .artist:
  47. return NSLocalizedString("ARTIST", comment: "")
  48. case .playCount:
  49. return NSLocalizedString("PLAY_COUNT", comment: "")
  50. case .album:
  51. return NSLocalizedString("ALBUM", comment: "")
  52. case .filename:
  53. return NSLocalizedString("FILENAME", comment: "")
  54. case .trackNumber:
  55. return NSLocalizedString("TRACK_NUMBER", comment: "")
  56. default:
  57. return NSLocalizedString("DEFAULT", comment: "")
  58. }
  59. }
  60. }