|
24 | 24 | case thread |
25 | 25 | case share |
26 | 26 | case sticker |
| 27 | + case reaction |
27 | 28 | } |
28 | 29 |
|
29 | 30 | protocol RowPresentable { |
|
46 | 47 | func didSharePressed() |
47 | 48 | func didForwardPressed() |
48 | 49 | func didStickerPressed() |
| 50 | + func didReactionPressed() |
49 | 51 | } |
50 | 52 |
|
51 | 53 |
|
|
87 | 89 | } |
88 | 90 | let actionsCell = UINib.init(nibName: "ActionsCell", bundle: UIKitSettings.bundle) |
89 | 91 | self.tableView.register(actionsCell, forCellReuseIdentifier: "actionsCell") |
| 92 | + |
| 93 | + let addReactionCell = UINib.init(nibName: "AddReactionsCell", bundle: UIKitSettings.bundle) |
| 94 | + self.tableView.register(addReactionCell, forCellReuseIdentifier: "addReactionsCell") |
90 | 95 | } |
91 | 96 |
|
92 | 97 | // MARK: - UITableViewDataSource |
|
96 | 101 | } |
97 | 102 |
|
98 | 103 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
99 | | - |
100 | | - guard let cell = tableView.dequeueReusableCell(withIdentifier: "actionsCell", for: indexPath) as? ActionsCell |
101 | | - else { return UITableViewCell() } |
102 | | - |
| 104 | + |
| 105 | + let staticCell = UITableViewCell() |
103 | 106 | if let currentActions = actions { |
104 | 107 | switch currentActions[indexPath.row] { |
105 | 108 | case .takeAPhoto: |
| 109 | + if let cell = tableView.dequeueReusableCell(withIdentifier: "actionsCell", for: indexPath) as? ActionsCell { |
106 | 110 | cell.name.text = "Take a Photo" |
107 | 111 | cell.icon.image = UIImage(named: ".png", in: UIKitSettings.bundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) |
108 | 112 | cell.fullScreenSwitch.isHidden = true |
109 | 113 | cell.badgeCountSwitch.isHidden = true |
| 114 | + return cell |
| 115 | + } |
110 | 116 | case .photoAndVideoLibrary: |
| 117 | + if let cell = tableView.dequeueReusableCell(withIdentifier: "actionsCell", for: indexPath) as? ActionsCell { |
111 | 118 | cell.name.text = "Photo & Video Library" |
112 | 119 | cell.icon.image = UIImage(named: ".png", in: UIKitSettings.bundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) |
113 | 120 | cell.fullScreenSwitch.isHidden = true |
114 | 121 | cell.badgeCountSwitch.isHidden = true |
| 122 | + return cell |
| 123 | + } |
115 | 124 | case .document: |
| 125 | + if let cell = tableView.dequeueReusableCell(withIdentifier: "actionsCell", for: indexPath) as? ActionsCell { |
116 | 126 | cell.name.text = "Document" |
117 | 127 | cell.icon.image = UIImage(named: ".png", in: UIKitSettings.bundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) |
118 | 128 | cell.fullScreenSwitch.isHidden = true |
119 | 129 | cell.badgeCountSwitch.isHidden = true |
| 130 | + return cell |
| 131 | + } |
120 | 132 | case .shareLocation: |
| 133 | + if let cell = tableView.dequeueReusableCell(withIdentifier: "actionsCell", for: indexPath) as? ActionsCell { |
121 | 134 | cell.name.text = "Share Location" |
122 | 135 | cell.icon.image = UIImage(named: ".png", in: UIKitSettings.bundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) |
123 | 136 | cell.fullScreenSwitch.isHidden = true |
124 | 137 | cell.badgeCountSwitch.isHidden = true |
| 138 | + return cell |
| 139 | + } |
125 | 140 | case .edit: |
| 141 | + if let cell = tableView.dequeueReusableCell(withIdentifier: "actionsCell", for: indexPath) as? ActionsCell { |
126 | 142 | cell.name.text = "Edit Message" |
127 | 143 | if #available(iOS 13.0, *) { |
128 | 144 | cell.name.textColor = .label |
|
132 | 148 | cell.icon.image = UIImage(named: ".png", in: UIKitSettings.bundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) |
133 | 149 | cell.fullScreenSwitch.isHidden = true |
134 | 150 | cell.badgeCountSwitch.isHidden = true |
| 151 | + return cell |
| 152 | + } |
135 | 153 | case .delete: |
| 154 | + if let cell = tableView.dequeueReusableCell(withIdentifier: "actionsCell", for: indexPath) as? ActionsCell { |
136 | 155 | cell.name.text = "Delete Message" |
137 | 156 | if #available(iOS 13.0, *) { |
138 | 157 | cell.name.textColor = .label |
|
143 | 162 | cell.icon.tintColor = #colorLiteral(red: 0.9254902005, green: 0.2352941185, blue: 0.1019607857, alpha: 1) |
144 | 163 | cell.fullScreenSwitch.isHidden = true |
145 | 164 | cell.badgeCountSwitch.isHidden = true |
| 165 | + return cell |
| 166 | + } |
146 | 167 | case .reply: |
| 168 | + if let cell = tableView.dequeueReusableCell(withIdentifier: "actionsCell", for: indexPath) as? ActionsCell { |
147 | 169 | cell.name.text = "Reply Message" |
| 170 | + cell.icon.image = UIImage(named: "reply1.png", in: UIKitSettings.bundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) |
148 | 171 | if #available(iOS 13.0, *) { |
| 172 | + cell.icon.tintColor = .label |
149 | 173 | cell.name.textColor = .label |
150 | 174 | }else{ |
| 175 | + cell.icon.tintColor = .black |
151 | 176 | cell.name.textColor = .black |
152 | 177 | } |
153 | | - cell.icon.image = UIImage(named: ".png", in: UIKitSettings.bundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) |
154 | 178 | cell.fullScreenSwitch.isHidden = true |
155 | 179 | cell.badgeCountSwitch.isHidden = true |
| 180 | + return cell |
| 181 | + } |
156 | 182 | case .forward: |
| 183 | + if let cell = tableView.dequeueReusableCell(withIdentifier: "actionsCell", for: indexPath) as? ActionsCell { |
157 | 184 | cell.name.text = "Forward Message" |
158 | 185 | if #available(iOS 13.0, *) { |
159 | 186 | cell.name.textColor = .label |
160 | 187 | }else{ |
161 | 188 | cell.name.textColor = .black |
162 | 189 | } |
163 | 190 | cell.icon.image = UIImage(named: ".png", in: UIKitSettings.bundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) |
| 191 | + if #available(iOS 13.0, *) { |
| 192 | + cell.icon.tintColor = .label |
| 193 | + cell.name.textColor = .label |
| 194 | + }else{ |
| 195 | + cell.icon.tintColor = .black |
| 196 | + cell.name.textColor = .black |
| 197 | + } |
164 | 198 | cell.fullScreenSwitch.isHidden = true |
165 | 199 | cell.badgeCountSwitch.isHidden = true |
| 200 | + return cell |
| 201 | + } |
166 | 202 | case .thread: |
| 203 | + if let cell = tableView.dequeueReusableCell(withIdentifier: "actionsCell", for: indexPath) as? ActionsCell { |
167 | 204 | cell.name.text = "Start Thread" |
168 | 205 | cell.icon.image = UIImage(named: ".png", in: UIKitSettings.bundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) |
169 | 206 | if #available(iOS 13.0, *) { |
|
173 | 210 | } |
174 | 211 | cell.fullScreenSwitch.isHidden = true |
175 | 212 | cell.badgeCountSwitch.isHidden = true |
176 | | - |
| 213 | + return cell |
| 214 | + } |
177 | 215 | case .share: |
| 216 | + if let cell = tableView.dequeueReusableCell(withIdentifier: "actionsCell", for: indexPath) as? ActionsCell { |
178 | 217 | cell.icon.image = UIImage(named: ".png", in: UIKitSettings.bundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) |
179 | 218 | cell.name.text = "Share Message" |
180 | 219 | if #available(iOS 13.0, *) { |
|
184 | 223 | } |
185 | 224 | cell.fullScreenSwitch.isHidden = true |
186 | 225 | cell.badgeCountSwitch.isHidden = true |
| 226 | + return cell |
| 227 | + } |
187 | 228 | case .messageInfo: |
| 229 | + if let cell = tableView.dequeueReusableCell(withIdentifier: "actionsCell", for: indexPath) as? ActionsCell { |
188 | 230 | cell.icon.image = UIImage(named: ".png", in: UIKitSettings.bundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) |
189 | 231 | cell.name.text = "Message Information" |
190 | 232 | if #available(iOS 13.0, *) { |
|
194 | 236 | } |
195 | 237 | cell.fullScreenSwitch.isHidden = true |
196 | 238 | cell.badgeCountSwitch.isHidden = true |
| 239 | + return cell |
| 240 | + } |
197 | 241 | case .copy: |
| 242 | + if let cell = tableView.dequeueReusableCell(withIdentifier: "actionsCell", for: indexPath) as? ActionsCell { |
198 | 243 | cell.name.text = "Copy Message" |
199 | 244 | cell.icon.image = UIImage(named: ".png", in: UIKitSettings.bundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) |
200 | 245 | cell.fullScreenSwitch.isHidden = true |
201 | 246 | cell.badgeCountSwitch.isHidden = true |
| 247 | + return cell |
| 248 | + } |
202 | 249 | case .createAPoll: |
| 250 | + if let cell = tableView.dequeueReusableCell(withIdentifier: "actionsCell", for: indexPath) as? ActionsCell { |
203 | 251 | cell.name.text = "Create a Poll" |
204 | 252 | cell.icon.image = UIImage(named: ".png", in: UIKitSettings.bundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) |
205 | 253 | cell.fullScreenSwitch.isHidden = true |
206 | 254 | cell.badgeCountSwitch.isHidden = true |
| 255 | + return cell |
| 256 | + } |
207 | 257 | case .sticker: |
| 258 | + if let cell = tableView.dequeueReusableCell(withIdentifier: "actionsCell", for: indexPath) as? ActionsCell { |
208 | 259 | cell.name.text = "Send Sticker" |
209 | 260 | cell.icon.image = UIImage(named: "sticker1.png", in: UIKitSettings.bundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) |
210 | 261 | cell.fullScreenSwitch.isHidden = true |
211 | 262 | cell.badgeCountSwitch.isHidden = true |
| 263 | + return cell |
| 264 | + } |
| 265 | + case .reaction: |
| 266 | + if let cell = tableView.dequeueReusableCell(withIdentifier: "addReactionsCell", for: indexPath) as? AddReactionsCell { |
| 267 | + return cell |
| 268 | + } |
212 | 269 | } |
213 | 270 | } |
214 | | - return cell |
| 271 | + return staticCell |
215 | 272 | } |
216 | 273 |
|
217 | 274 | override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |
218 | | - return 55.0 |
| 275 | + if UIKitSettings.messageReaction == .enabled { |
| 276 | + if indexPath.row == 0 { |
| 277 | + return 65.0 |
| 278 | + }else{ |
| 279 | + return 55.0 |
| 280 | + } |
| 281 | + }else{ |
| 282 | + return 55.0 |
| 283 | + } |
219 | 284 | } |
220 | 285 |
|
221 | 286 | // MARK: - UITableViewDelegate |
|
283 | 348 | self.dismiss(animated: true) { |
284 | 349 | MessageActions.actionsDelegate?.didStickerPressed() |
285 | 350 | } |
| 351 | + case .reaction: |
| 352 | + self.dismiss(animated: true) { |
| 353 | + MessageActions.actionsDelegate?.didReactionPressed() |
| 354 | + } |
286 | 355 | } |
287 | 356 | } |
288 | 357 | } |
|
0 commit comments