You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

675 lines
26 KiB

6 years ago
  1. //
  2. // CommentsViewController.swift
  3. // GMERemittance
  4. //
  5. // Created by Fm-user on 1/16/18.
  6. // Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import UIKit
  9. //import ReadMoreTextView
  10. class CommentsViewController: UIViewController {
  11. private var activityIndicator: UIActivityIndicatorView = UIActivityIndicatorView()
  12. var socialfeedviewmodel: SocialFeedViewModel?
  13. var tappedIndex: Int?
  14. var feedIdFromNotification: String?
  15. var tappedCommentIndex: Int! //To keep track of comment that will be selected to edit or delete
  16. var commentInputText: String!
  17. var fromNotification: Int?
  18. private var checkDialog = 0
  19. @IBOutlet weak var commentButton: UIButton!
  20. @IBOutlet weak var contentView: UIView!
  21. @IBOutlet weak var tableViewComments: UITableView!{
  22. didSet {
  23. tableViewComments.estimatedRowHeight = 100
  24. tableViewComments.rowHeight = UITableViewAutomaticDimension
  25. }
  26. }
  27. @IBOutlet weak var imageViewUserImageComment: UIImageView!
  28. @IBOutlet weak var viewCommentEdit: UIView!
  29. @IBOutlet weak var textFieldAddComment: UITextField!
  30. @IBOutlet weak var buttomConstraint: NSLayoutConstraint!
  31. private var movement: CGFloat = 0.0
  32. private var expandedCells = Set<Int>()
  33. private var cell:CommentsTableViewCell?
  34. private var comments:String?
  35. private var feed: SocialFeed!
  36. private var newCommentsWillBeAppended: Bool = false
  37. private var arrayIndexPath = [IndexPath] ()
  38. @IBOutlet weak var imageViewUserBottom: UIImageView!
  39. @IBOutlet weak var labelInitialBottom: UILabel!
  40. override func viewWillAppear(_ animated: Bool) {
  41. guard socialfeedviewmodel != nil else {
  42. return
  43. }
  44. setUpNetworkListener()
  45. setUpListener()
  46. setUpAnotherLoginListener(genericviewmodel: socialfeedviewmodel!)
  47. self.tableViewComments.reloadSections(NSIndexSet(index: 1) as IndexSet, with: .none)
  48. if tappedCommentIndex != nil {
  49. self.tableViewComments.scrollToRow(at: IndexPath(row: tappedCommentIndex!, section:
  50. 1), at: UITableViewScrollPosition.bottom, animated: true)
  51. }
  52. }
  53. override func viewWillDisappear(_ animated: Bool) {
  54. // socialfeedviewmodel?.resetCommentsArray()
  55. }
  56. override func viewDidLoad() {
  57. super.viewDidLoad()
  58. guard socialfeedviewmodel != nil else {
  59. return
  60. }
  61. socialfeedviewmodel?.socialFeedConnectionTimeOut.value = nil
  62. /**
  63. connection timeout
  64. */
  65. socialfeedviewmodel?.socialFeedConnectionTimeOut.bind { [unowned self] in
  66. guard $0 != nil else {
  67. return
  68. }
  69. self.enableUserInteractions()
  70. self.dismissActivityIndicator(activityIndicator: self.activityIndicator)
  71. if self.fromNotification != 0{
  72. if self.fromNotification != 0{
  73. if self.checkDialog == 0{
  74. self.checkDialog = self.checkDialog+1
  75. self.popUpMessage(value: 20)
  76. }
  77. }
  78. }
  79. }
  80. socialfeedviewmodel?.resetCommentsArray()
  81. if tappedIndex != nil {
  82. setUpNavBar(id: 5, title: "")
  83. feed = socialfeedviewmodel!.getSocialFeedAt(index: tappedIndex!)
  84. disableUserInteractions()
  85. showActivityIndicator(activityIndicator: activityIndicator)
  86. socialfeedviewmodel!.fetchAllCommentsFor(feedId: feed.id, loadMore: false)
  87. } else if feedIdFromNotification != nil {
  88. setUpNavBar(id: 300, title: "Comments")
  89. if !Reachability.isConnectedToNetwork() {
  90. commentButton.isUserInteractionEnabled = false
  91. self.popUpMessage(value: 15)
  92. } else {
  93. disableUserInteractions()
  94. showActivityIndicator(activityIndicator: self.activityIndicator)
  95. socialfeedviewmodel!.fetchFeedWithId(feedId: feedIdFromNotification!)
  96. }
  97. }
  98. textFieldAddComment.delegate = self
  99. NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
  100. NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
  101. let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(clearKeyboard))
  102. view.addGestureRecognizer(tap)
  103. self.tableViewComments.tableFooterView = UIView()
  104. labelInitialBottom.isHidden = false
  105. labelInitialBottom.backgroundColor = UIColor(hex: 0x2e3192)
  106. labelInitialBottom.layer.cornerRadius = labelInitialBottom.frame.height / 2
  107. labelInitialBottom.text = getFirstName().prefix(1).uppercased()
  108. let userDpString = UserDefaults.standard.object(forKey: "com.gmeremit.dpUrl") as? String
  109. if let userDpUrl = URL(string: userDpString!) {
  110. imageViewUserBottom.isHidden = false
  111. imageViewUserBottom.sd_setImage(with: userDpUrl, placeholderImage: nil, options: [.progressiveDownload,.scaleDownLargeImages], completed: nil)
  112. imageViewUserBottom.layer.cornerRadius = imageViewUserBottom.frame.height/2
  113. labelInitialBottom.isHidden = true
  114. }
  115. }
  116. func setUpNetworkListener() {
  117. socialfeedviewmodel!.internetConnection.value = nil
  118. socialfeedviewmodel!.internetConnection.bind { [unowned self] in
  119. guard $0 != nil else {
  120. return
  121. }
  122. print("%%%%%%%%%%%")
  123. self.enableUserInteractions()
  124. self.dismissActivityIndicator(activityIndicator: self.activityIndicator)
  125. self.popUpMessage(value: 15)
  126. }
  127. }
  128. func setUpListener() {
  129. socialfeedviewmodel!.socialFeedsRxValue.bind { [weak self] in
  130. guard $0 != nil else {
  131. return
  132. }
  133. self?.enableUserInteractions()
  134. if self?.activityIndicator != nil {
  135. if (self?.activityIndicator)!.isAnimating {
  136. self?.dismissActivityIndicator(activityIndicator: (self?.activityIndicator)!)
  137. }
  138. }
  139. guard $0 != 0 else {
  140. if self?.checkDialog == 0{
  141. self?.checkDialog = (self?.checkDialog)!+1
  142. //self?.popUpMessageError(value: 19, message: (self?.socialfeedviewmodel!.getErrorMessage())!)
  143. }
  144. self?.socialfeedviewmodel!.socialFeedsRxValue.value = nil
  145. self?.commentButton.isUserInteractionEnabled = false
  146. self?.textFieldAddComment.isUserInteractionEnabled = false
  147. return
  148. }
  149. switch $0 {
  150. case socialWallCode.likeUnlikePost.rawValue?:
  151. if self?.tappedIndex != nil {
  152. self?.socialfeedviewmodel!.updateSocialFeedArrayLikeNumber(atIndex: (self?.tappedIndex)!)
  153. } else {
  154. self?.socialfeedviewmodel!.updateParticularFeedWithUpdatedLikeNumber()
  155. }
  156. self?.tableViewComments.reloadSections(NSIndexSet(index: 0) as IndexSet, with: .none)
  157. case socialWallCode.fetchComments.rawValue?:
  158. // self?.tableViewComments.reloadSections(NSIndexSet(index: 1) as IndexSet, with: .none)
  159. // self?.tableViewComments.reloadSections(NSIndexSet(index: 2) as IndexSet, with: .none)
  160. let count = self?.socialfeedviewmodel!.getCommentsCount()
  161. if count! > 0 {
  162. if (self?.newCommentsWillBeAppended)! {
  163. self?.arrayIndexPath.removeAll()
  164. self?.tableViewComments.beginUpdates()
  165. let currentCount = self?.socialfeedviewmodel!.getCurrentlyFetchedCommentCount()
  166. for i in 0...(self?.socialfeedviewmodel!.getCurrentlyFetchedCommentCount())!-1 {
  167. self?.arrayIndexPath.append(IndexPath.init(row: count! - currentCount! + i, section: 1))
  168. }
  169. self?.tableViewComments.insertRows(at: (self?.arrayIndexPath)!, with: .automatic)
  170. self?.tableViewComments.endUpdates()
  171. } else {
  172. self?.tableViewComments.reloadSections(NSIndexSet(index: 1) as IndexSet, with: .none)
  173. self?.tableViewComments.reloadSections(NSIndexSet(index: 2) as IndexSet, with: .none)
  174. }
  175. }
  176. case socialWallCode.deleteComment.rawValue?:
  177. self?.socialfeedviewmodel!.removeComment(atIndex: (self?.tappedCommentIndex)!)
  178. if self?.tappedIndex != nil {
  179. self?.socialfeedviewmodel!.updateSocialFeedArrayCommentNumber(atIndex: (self?.tappedIndex)!, increase: false)
  180. } else {
  181. self?.socialfeedviewmodel!.updateParticularFeedWithDecreasedCommentNumber()
  182. }
  183. self?.tableViewComments.deleteRows(at: [IndexPath(item: (self?.tappedCommentIndex)!, section: 1)], with: .automatic)
  184. self?.tableViewComments.reloadSections(NSIndexSet(index: 0) as IndexSet, with: .none)
  185. case socialWallCode.createUpdateComment.rawValue?:
  186. if self?.tappedIndex != nil {
  187. self?.socialfeedviewmodel!.updateSocialFeedArrayCommentNumber(atIndex: (self?.tappedIndex)!, increase: true)
  188. } else {
  189. self?.socialfeedviewmodel!.updateParticularFeedWithIncreasedCommentNumber()
  190. }
  191. self?.textFieldAddComment.text = ""
  192. self?.tableViewComments.beginUpdates()
  193. self?.tableViewComments.insertRows(at: [IndexPath.init(row: 0, section: 1)], with: .automatic)
  194. self?.tableViewComments.endUpdates()
  195. self?.tableViewComments.reloadSections(NSIndexSet(index: 0) as IndexSet, with: .none)
  196. self?.tableViewComments.scrollToRow(at: IndexPath(row: 0, section:
  197. 1), at: UITableViewScrollPosition.bottom, animated: true)
  198. case socialWallCode.fetchParticularPost.rawValue?:
  199. self?.feed = self?.socialfeedviewmodel!.getParticularFeed()
  200. self?.tableViewComments.reloadData()
  201. self?.socialfeedviewmodel!.fetchAllCommentsFor(feedId: (self?.feed.id)!, loadMore: false)
  202. default:
  203. return
  204. }
  205. self?.socialfeedviewmodel!.socialFeedsRxValue.value = nil
  206. }
  207. }
  208. @objc func keyboardWillShow(notification: NSNotification) {
  209. let userInfo = notification.userInfo
  210. var keyboardFrame:CGRect = (userInfo![UIKeyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
  211. keyboardFrame = self.view.convert(keyboardFrame, from: nil)
  212. movement = (keyboardFrame.size.height)
  213. UIView.animate(withDuration: 0.3, animations: {
  214. self.viewCommentEdit.frame = self.viewCommentEdit.frame.offsetBy(dx: 0, dy: self.movement * -1.0)
  215. // self.tableViewComments.frame = self.tableViewComments.frame.offsetBy(dx: 0, dy: self.movement * -1.0)
  216. self.tableViewComments.contentInset = UIEdgeInsetsMake(0.0, 0.0, self.movement, 0.0)
  217. })
  218. }
  219. @objc func keyboardWillHide(notification: NSNotification){
  220. UIView.animate(withDuration: 0.3, animations: {
  221. self.viewCommentEdit.frame = self.viewCommentEdit.frame.offsetBy(dx: 0, dy: self.movement)
  222. // self.tableViewComments.frame = self.tableViewComments.frame.offsetBy(dx: 0, dy: self.movement)
  223. self.tableViewComments.contentInset = UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0)
  224. })
  225. }
  226. @IBAction func commentAddButton(_ sender: Any) {
  227. disableUserInteractions()
  228. showActivityIndicator(activityIndicator: activityIndicator)
  229. textFieldAddComment.resignFirstResponder()
  230. socialfeedviewmodel!.createCommentFor(feedId: feed.id)
  231. }
  232. @objc func clearKeyboard() {
  233. textFieldAddComment?.resignFirstResponder()
  234. }
  235. override func didReceiveMemoryWarning() {
  236. super.didReceiveMemoryWarning()
  237. }
  238. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  239. switch segue.identifier {
  240. case "editComment"?:
  241. let editCommentViewController = segue.destination as! EditCommentViewController
  242. editCommentViewController.commentIndex = tappedCommentIndex
  243. editCommentViewController.socialfeedviewmodel = socialfeedviewmodel!
  244. if tappedIndex != nil {
  245. editCommentViewController.feedIndex = tappedIndex!
  246. }
  247. case "showLikedByFromComments"?:
  248. let likedByViewController = segue.destination as! LikesViewController
  249. likedByViewController.socialfeedviewmodel = socialfeedviewmodel
  250. if tappedIndex != nil {
  251. likedByViewController.tappedIndex = tappedIndex
  252. }
  253. default:
  254. return
  255. }
  256. }
  257. }
  258. extension CommentsViewController: UITextFieldDelegate {
  259. func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
  260. commentInputText = (textField.text! as NSString).replacingCharacters(in: range, with: string)
  261. socialfeedviewmodel?.updateCommentText(text: commentInputText)
  262. return true
  263. }
  264. }
  265. extension CommentsViewController: UITableViewDelegate, UITableViewDataSource {
  266. func numberOfSections(in tableView: UITableView) -> Int {
  267. return 3
  268. }
  269. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  270. switch section {
  271. case 0:
  272. if feed != nil {
  273. return 1
  274. }
  275. return 0
  276. case 1:
  277. if (socialfeedviewmodel?.getAllComments().count)! > 0{
  278. return socialfeedviewmodel!.getAllComments().count
  279. }
  280. return 0
  281. case 2:
  282. return 1
  283. default:
  284. return 0
  285. }
  286. }
  287. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  288. switch indexPath.section {
  289. case 0:
  290. cell = tableView.dequeueReusableCell(withIdentifier: "statusCell", for: indexPath) as? CommentsTableViewCell
  291. cell!.imageViewUser.layer.cornerRadius = cell!.imageViewUser.frame.height / 2
  292. /* To show changes in comment number and likes when likes/comments are updated*/
  293. if tappedIndex != nil {
  294. feed = socialfeedviewmodel!.getSocialFeedAt(index: tappedIndex!)
  295. } else {
  296. feed = socialfeedviewmodel!.getParticularFeed()
  297. }
  298. cell?.labelInitialTop.isHidden = false
  299. cell?.labelInitialTop.backgroundColor = UIColor(hex: 0x2e3192)
  300. cell?.labelInitialTop.layer.cornerRadius = cell!.labelInitialTop.frame.height / 2
  301. cell?.labelInitialTop.text = feed.firstName.prefix(1).uppercased()
  302. if let userDpString = feed.userDpUrl {
  303. if let userDpUrl = URL(string: userDpString) {
  304. cell?.imageViewUser.isHidden = false
  305. cell?.imageViewUser.sd_setImage(with: userDpUrl, placeholderImage: #imageLiteral(resourceName: "gme-logo"), options: [.progressiveDownload,.scaleDownLargeImages], completed: nil)
  306. cell?.labelInitialTop.isHidden = true
  307. }
  308. }
  309. cell?.labelUserName.text = socialfeedviewmodel!.getFullName(feed: feed)
  310. cell?.labelTimeAgo.text = feed.agoDate
  311. if let feedText = feed.feedText {
  312. cell?.labelFeedContent.text = feedText
  313. }
  314. if let feedImageString = feed.feedImage {
  315. if let feedImageUrl = URL(string: feedImageString) {
  316. cell?.imageViewFeed.sd_setImage(with: feedImageUrl, placeholderImage: #imageLiteral(resourceName: "gme-logo"), options: [.progressiveDownload,.scaleDownLargeImages], completed: nil)
  317. cell?.imageHeightConstraint.constant = view.frame.width
  318. }
  319. } else {
  320. cell?.imageHeightConstraint.constant = 0
  321. }
  322. if feed.liked {
  323. cell?.buttonLikeStatus.setImage(UIImage(named:"ic_heartfull"), for: UIControlState.normal)
  324. }
  325. else {
  326. cell?.buttonLikeStatus.setImage(UIImage(named:"ic_heart"), for: UIControlState.normal)
  327. }
  328. cell?.buttonLikeStatus?.addTarget(self, action: #selector(toggleLike(_:)), for: .touchUpInside)
  329. //Display total number of LIKES
  330. if feed.totalLike > 1 {
  331. cell?.buttonLikes.setTitle("\(feed.totalLike) Likes", for:UIControlState.normal)
  332. }
  333. else {
  334. cell?.buttonLikes.setTitle("\(feed.totalLike) Like", for:UIControlState.normal)
  335. }
  336. if feed.totalLike > 0 {
  337. cell?.buttonLikes?.addTarget(self, action: #selector(showLikes(_:)), for: .touchUpInside)
  338. }
  339. if feed.totalComment > 1 {
  340. cell?.buttonComments.setTitle(" \(feed.totalComment) Comments", for:UIControlState.normal)
  341. }
  342. else {
  343. cell?.buttonComments.setTitle(" \(feed.totalComment) Comment", for:UIControlState.normal)
  344. }
  345. return cell!
  346. case 1:
  347. cell = tableView.dequeueReusableCell(withIdentifier: "commentCell", for: indexPath) as? CommentsTableViewCell
  348. let comment = socialfeedviewmodel!.getCommentAt(index: indexPath.row)
  349. cell!.labelName.text = comment.userName
  350. cell!.labelComment.text = comment.userComment
  351. cell!.labelTime.text = comment.agoDate
  352. cell!.imageViewComment.layer.cornerRadius = cell!.imageViewComment.frame.height / 2
  353. cell!.labelUserNameInitial.isHidden = false
  354. cell!.labelUserNameInitial.backgroundColor = UIColor(hex: 0x2e3192)
  355. cell!.labelUserNameInitial.layer.cornerRadius = cell!.labelUserNameInitial.frame.height / 2
  356. cell!.labelUserNameInitial.text = comment.userName.prefix(1).uppercased()
  357. if let userDpString = comment.userDpUrl {
  358. if let userDpUrl = URL(string: userDpString) {
  359. cell!.imageViewComment.isHidden = false
  360. cell!.imageViewComment.sd_setImage(with: userDpUrl, placeholderImage: nil, options: [.progressiveDownload,.scaleDownLargeImages], completed: nil)
  361. }
  362. cell!.labelUserNameInitial.isHidden = true
  363. }
  364. // if let userimageUrl = socialfeedviewmodel!.getCommentAt(index: indexPath.row).userDpUrl {
  365. // cell?.imageViewComment.sd_setImage(with: URL(string: userimageUrl), placeholderImage: #imageLiteral(resourceName: "gme-logo"), options: [.progressiveDownload,.scaleDownLargeImages], completed: nil)
  366. // }
  367. return cell!
  368. case 2:
  369. cell = (tableView.dequeueReusableCell(withIdentifier: "loadMoreCell", for: indexPath) as! CommentsTableViewCell)
  370. cell!.buttonLoadMore.addTarget(self, action: #selector(loadMore(_:)), for: .touchUpInside)
  371. if !socialfeedviewmodel!.commentsRemaining() {
  372. cell!.buttonLoadMore.isHidden = true
  373. } else {
  374. cell!.buttonLoadMore.isHidden = false
  375. }
  376. return cell!
  377. default:
  378. return cell!
  379. }
  380. }
  381. @objc func loadMore(_ sender: TableViewCell) {
  382. disableUserInteractions()
  383. showActivityIndicator(activityIndicator: activityIndicator)
  384. newCommentsWillBeAppended = true
  385. socialfeedviewmodel!.fetchAllCommentsFor(feedId: feed.id, loadMore: true)
  386. }
  387. @objc func showLikes(_ sender: CommentsTableViewCell) {
  388. textFieldAddComment.resignFirstResponder()
  389. guard Reachability.isConnectedToNetwork() else {
  390. self.popUpMessage(value: 15)
  391. return
  392. }
  393. self.performSegue(withIdentifier: "showLikedByFromComments", sender: nil)
  394. }
  395. /* LIKE OR DISLIKE A POST WHEN TAPPPED */
  396. @objc func toggleLike(_ sender: TableViewCell) {
  397. if tappedIndex != nil {
  398. // feed = socialfeedviewmodel?.getSocialFeedAt(index: tappedIndex!)
  399. socialfeedviewmodel!.likeDislikePost(feedId: feed.id, liked: feed.liked)
  400. } else {
  401. // feed = socialfeedviewmodel?.getParticularFeed()
  402. socialfeedviewmodel!.likeDislikePost(feedId: feed.id, liked: feed.liked)
  403. }
  404. }
  405. func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
  406. switch indexPath.section {
  407. case 1:
  408. let delete = UITableViewRowAction(style: .destructive, title: "Delete") { (action, indexPath) in
  409. let alert = UIAlertController(title: "Are you sure you want to delete?",
  410. message: "",
  411. preferredStyle: .alert)
  412. let cancelAction = UIAlertAction(title: "No", style: .destructive) { (action) -> Void in
  413. alert.dismiss(animated: true, completion: nil)
  414. }
  415. let deleteAction = UIAlertAction(title: "Yes", style: .destructive) { (action) -> Void in
  416. alert.dismiss(animated: true, completion: nil)
  417. let feedId = self.feed.id //self.socialfeedviewmodel!.getSocialFeedAt(index: self.tappedIndex!).id
  418. let commentId = self.socialfeedviewmodel!.getCommentAt(index: indexPath.row).commentId
  419. self.tappedCommentIndex = indexPath.row
  420. self.disableUserInteractions()
  421. self.showActivityIndicator(activityIndicator: self.activityIndicator)
  422. self.socialfeedviewmodel!.removeComment(feedId: feedId, commentId: commentId!)
  423. }
  424. alert.addAction(cancelAction)
  425. alert.addAction(deleteAction)
  426. self.present(alert, animated: true, completion: nil)
  427. }
  428. let edit = UITableViewRowAction(style: .normal, title: "Edit") { (action, indexPath) in
  429. self.tappedCommentIndex = indexPath.row
  430. self.performSegue(withIdentifier: "editComment", sender: nil)
  431. }
  432. let cancel = UITableViewRowAction(style: .normal, title: "Cancel") {_,_ in
  433. }
  434. if tappedIndex != nil {
  435. if socialfeedviewmodel!.postBelongsToMe(postIndex: tappedIndex!) {
  436. if socialfeedviewmodel!.commentBelongsToMe(commentIndex: indexPath.row) {
  437. return [edit, delete]
  438. } else {
  439. return [delete, cancel]
  440. }
  441. } else if socialfeedviewmodel!.commentBelongsToMe(commentIndex: indexPath.row) {
  442. return [edit, delete]
  443. }
  444. } else {
  445. if socialfeedviewmodel!.particularPostBelongsToMe() {
  446. if socialfeedviewmodel!.commentBelongsToMe(commentIndex: indexPath.row) {
  447. return [edit, delete]
  448. } else {
  449. return [delete, cancel]
  450. }
  451. } else if socialfeedviewmodel!.commentBelongsToMe(commentIndex: indexPath.row) {
  452. return [edit, delete]
  453. }
  454. }
  455. default:
  456. return []
  457. }
  458. return []
  459. }
  460. // private func tableView(_ tableView: UITableView, willDisplay cell: CommentsTableViewCell, forRowAt indexPath: IndexPath) {
  461. //
  462. // switch indexPath.section {
  463. // case 1:
  464. // let readMoreTextView = cell.contentView.viewWithTag(1) as? ReadMoreTextView
  465. // readMoreTextView?.onSizeChange = { [unowned tableView, unowned self] r in
  466. // let point = tableView.convert(r.bounds.origin, from: r)
  467. // guard let indexPath = tableView.indexPathForRow(at: point) else { return }
  468. // if r.shouldTrim {
  469. // self.expandedCells.remove(indexPath.row)
  470. // } else {
  471. // self.expandedCells.insert(indexPath.row)
  472. // }
  473. // self.tableViewComments.reloadData()
  474. // }
  475. // default:
  476. // break
  477. // }
  478. //
  479. // }
  480. // func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  481. //
  482. // switch indexPath.section {
  483. // case 0:
  484. // print("section")
  485. // case 1:
  486. // print("coment")
  487. // let cell = tableView.cellForRow(at: indexPath)!
  488. // let readMoreTextView = cell.contentView.viewWithTag(1) as? ReadMoreTextView
  489. // readMoreTextView?.shouldTrim = !(readMoreTextView?.shouldTrim)!
  490. // default: break
  491. // }
  492. //
  493. // }
  494. }