CommentModels.swift 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import Foundation
  2. enum CommentWriterTab: String, CaseIterable, Identifiable {
  3. case compose
  4. case preview
  5. case variants
  6. var id: String { rawValue }
  7. var title: String {
  8. switch self {
  9. case .compose: "Compose"
  10. case .preview: "Preview"
  11. case .variants: "Variants"
  12. }
  13. }
  14. }
  15. enum CommentType: String, CaseIterable, Identifiable, Codable {
  16. case topLevel
  17. case reply
  18. var id: String { rawValue }
  19. var title: String {
  20. switch self {
  21. case .topLevel: "Top-Level"
  22. case .reply: "Reply"
  23. }
  24. }
  25. var subtitle: String {
  26. switch self {
  27. case .topLevel: "Comment on the post"
  28. case .reply: "Reply to a comment"
  29. }
  30. }
  31. var systemImage: String {
  32. switch self {
  33. case .topLevel: "text.bubble"
  34. case .reply: "arrowshape.turn.up.left.fill"
  35. }
  36. }
  37. }
  38. enum CommentIntent: String, CaseIterable, Identifiable, Codable {
  39. case addValue
  40. case agree
  41. case disagree
  42. case question
  43. case funny
  44. case empathetic
  45. case technical
  46. case summary
  47. var id: String { rawValue }
  48. var title: String {
  49. switch self {
  50. case .addValue: "Add Value"
  51. case .agree: "Agree"
  52. case .disagree: "Counter"
  53. case .question: "Question"
  54. case .funny: "Funny"
  55. case .empathetic: "Empathetic"
  56. case .technical: "Technical"
  57. case .summary: "TL;DR"
  58. }
  59. }
  60. var subtitle: String {
  61. switch self {
  62. case .addValue: "Share insight or tips"
  63. case .agree: "Support the post/comment"
  64. case .disagree: "Respectful counterpoint"
  65. case .question: "Ask for clarification"
  66. case .funny: "Witty or lighthearted"
  67. case .empathetic: "Personal & relatable"
  68. case .technical: "Detailed explanation"
  69. case .summary: "Concise recap"
  70. }
  71. }
  72. var systemImage: String {
  73. switch self {
  74. case .addValue: "lightbulb.fill"
  75. case .agree: "hand.thumbsup.fill"
  76. case .disagree: "arrow.left.arrow.right"
  77. case .question: "questionmark.circle.fill"
  78. case .funny: "face.smiling.fill"
  79. case .empathetic: "heart.fill"
  80. case .technical: "wrench.and.screwdriver.fill"
  81. case .summary: "text.alignleft"
  82. }
  83. }
  84. }
  85. enum CommentLength: String, CaseIterable, Identifiable, Codable {
  86. case short
  87. case medium
  88. case long
  89. var id: String { rawValue }
  90. var title: String {
  91. switch self {
  92. case .short: "Short"
  93. case .medium: "Medium"
  94. case .long: "Long"
  95. }
  96. }
  97. var subtitle: String {
  98. switch self {
  99. case .short: "1–2 sentences"
  100. case .medium: "1–2 paragraphs"
  101. case .long: "Detailed reply"
  102. }
  103. }
  104. var wordRange: String {
  105. switch self {
  106. case .short: "20–60 words"
  107. case .medium: "60–150 words"
  108. case .long: "150–300 words"
  109. }
  110. }
  111. }
  112. enum CommentVariantCount: Int, CaseIterable, Identifiable, Codable {
  113. case three = 3
  114. case five = 5
  115. var id: Int { rawValue }
  116. var label: String { "\(rawValue) variants" }
  117. }
  118. struct CommentDraft: Equatable {
  119. var commentType: CommentType = .topLevel
  120. var subreddit: String = ""
  121. var postTitle: String = ""
  122. var postBody: String = ""
  123. var postURL: String = ""
  124. var parentComment: String = ""
  125. var topic: String = ""
  126. var tone: PostTone = .casual
  127. var intent: CommentIntent = .addValue
  128. var length: CommentLength = .medium
  129. var body: String = ""
  130. var includeQuote: Bool = true
  131. var useMarkdown: Bool = true
  132. var variantCount: CommentVariantCount = .three
  133. }
  134. struct CommentVariant: Identifiable, Equatable {
  135. let id: UUID
  136. var body: String
  137. var score: Int
  138. var reasoning: String
  139. init(id: UUID = UUID(), body: String, score: Int, reasoning: String) {
  140. self.id = id
  141. self.body = body
  142. self.score = score
  143. self.reasoning = reasoning
  144. }
  145. }
  146. struct GeneratedComment: Equatable {
  147. var body: String
  148. var variants: [CommentVariant]
  149. }