Presentr+Equatable.swift 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // Presentr+Equatable.swift
  3. // Presentr
  4. //
  5. // Created by Daniel Lozano on 7/6/16.
  6. // Copyright © 2016 danielozano. All rights reserved.
  7. //
  8. import Foundation
  9. extension PresentationType: Equatable { }
  10. public func == (lhs: PresentationType, rhs: PresentationType) -> Bool {
  11. switch (lhs, rhs) {
  12. case (let .custom(lhsWidth, lhsHeight, lhsCenter), let .custom(rhsWidth, rhsHeight, rhsCenter)):
  13. return lhsWidth == rhsWidth && lhsHeight == rhsHeight && lhsCenter == rhsCenter
  14. case (.alert, .alert):
  15. return true
  16. case (.popup, .popup):
  17. return true
  18. case (.topHalf, .topHalf):
  19. return true
  20. case (.bottomHalf, .bottomHalf):
  21. return true
  22. case (.dynamic, .dynamic):
  23. return true
  24. default:
  25. return false
  26. }
  27. }
  28. extension ModalSize: Equatable { }
  29. public func == (lhs: ModalSize, rhs: ModalSize) -> Bool {
  30. switch (lhs, rhs) {
  31. case (let .custom(lhsSize), let .custom(rhsSize)):
  32. return lhsSize == rhsSize
  33. case (.default, .default):
  34. return true
  35. case (.half, .half):
  36. return true
  37. case (.full, .full):
  38. return true
  39. default:
  40. return false
  41. }
  42. }
  43. extension ModalCenterPosition: Equatable { }
  44. public func == (lhs: ModalCenterPosition, rhs: ModalCenterPosition) -> Bool {
  45. switch (lhs, rhs) {
  46. case (let .custom(lhsCenterPoint), let .custom(rhsCenterPoint)):
  47. return lhsCenterPoint.x == rhsCenterPoint.x && lhsCenterPoint.y == rhsCenterPoint.y
  48. case (.center, .center):
  49. return true
  50. case (.topCenter, .topCenter):
  51. return true
  52. case (.bottomCenter, .bottomCenter):
  53. return true
  54. default:
  55. return false
  56. }
  57. }