ReportItem.swift 916 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // ReportItem.swift
  3. // Mastodon
  4. //
  5. // Created by MainasuK on 2022-1-27.
  6. //
  7. import Foundation
  8. import CoreDataStack
  9. enum ReportItem: Hashable {
  10. case header(context: HeaderContext)
  11. case status(record: ManagedObjectRecord<Status>)
  12. case comment(context: CommentContext)
  13. case result(record: ManagedObjectRecord<MastodonUser>)
  14. case bottomLoader
  15. }
  16. extension ReportItem {
  17. struct HeaderContext: Hashable {
  18. let primaryLabelText: String
  19. let secondaryLabelText: String
  20. }
  21. class CommentContext: Hashable {
  22. let id = UUID()
  23. @Published var comment: String = ""
  24. static func == (
  25. lhs: ReportItem.CommentContext,
  26. rhs: ReportItem.CommentContext
  27. ) -> Bool {
  28. lhs.comment == rhs.comment
  29. }
  30. func hash(into hasher: inout Hasher) {
  31. hasher.combine(id)
  32. }
  33. }
  34. }