MessageDetailsViewController.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2013-2020 Threema GmbH
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU Affero General Public License, version 3,
  11. // as published by the Free Software Foundation.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU Affero General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Affero General Public License
  19. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. #import "MessageDetailsViewController.h"
  21. #import "BaseMessage.h"
  22. #import "BrandingUtils.h"
  23. #import "NSString+Hex.h"
  24. @interface MessageDetailsViewController ()
  25. @end
  26. @implementation MessageDetailsViewController
  27. - (void)viewWillAppear:(BOOL)animated {
  28. [super viewWillAppear:animated];
  29. self.messageIdLabel.text = [NSString stringWithHexData:self.message.id];
  30. if (!self.message.isOwn.boolValue) {
  31. self.sendDateLabel.text = [DateFormatter shortStyleDateTime:self.message.remoteSentDate];
  32. self.deliveredDateLabel.text = [DateFormatter shortStyleDateTime:self.message.deliveryDate];
  33. if (self.message.readDate != nil)
  34. self.readDateLabel.text = [DateFormatter shortStyleDateTime:self.message.readDate];
  35. else
  36. self.readDateLabel.text = @"";
  37. self.ackDateLabel.text = @"";
  38. } else {
  39. self.sendDateLabel.text = [DateFormatter shortStyleDateTime:self.message.date];
  40. if (self.message.deliveryDate != nil)
  41. self.deliveredDateLabel.text = [DateFormatter shortStyleDateTime:self.message.deliveryDate];
  42. else
  43. self.deliveredDateLabel.text = @"";
  44. if (self.message.readDate != nil)
  45. self.readDateLabel.text = [DateFormatter shortStyleDateTime:self.message.readDate];
  46. else
  47. self.readDateLabel.text = @"";
  48. if (self.message.userackDate != nil)
  49. self.ackDateLabel.text = [DateFormatter shortStyleDateTime:self.message.userackDate];
  50. else
  51. self.ackDateLabel.text = @"";
  52. }
  53. }
  54. - (void)tableView:(UITableView *)tableView willDisplayCell:(nonnull UITableViewCell *)cell forRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
  55. [super tableView:tableView willDisplayCell:cell forRowAtIndexPath:indexPath];
  56. if (!self.message.isOwn.boolValue) {
  57. if (self.message.remoteSentDate != nil && indexPath.row == 0)
  58. cell.hidden = NO;
  59. else if (self.message.deliveryDate != nil && indexPath.row == 1)
  60. cell.hidden = NO;
  61. else if (self.message.readDate != nil && indexPath.row == 2)
  62. cell.hidden = NO;
  63. else if (indexPath.row == 4)
  64. cell.hidden = NO;
  65. else
  66. cell.hidden = YES;
  67. } else {
  68. if (self.message.date == nil && indexPath.row == 0)
  69. cell.hidden = YES;
  70. else if (self.message.deliveryDate == nil && indexPath.row == 1)
  71. cell.hidden = YES;
  72. else if (self.message.readDate == nil && indexPath.row == 2)
  73. cell.hidden = YES;
  74. else if (self.message.userackDate == nil && indexPath.row == 3)
  75. cell.hidden = YES;
  76. else
  77. cell.hidden = NO;
  78. }
  79. }
  80. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  81. if (!self.message.isOwn.boolValue) {
  82. if (self.message.remoteSentDate != nil && indexPath.row == 0)
  83. return UITableViewAutomaticDimension;
  84. else if (self.message.deliveryDate != nil && indexPath.row == 1)
  85. return UITableViewAutomaticDimension;
  86. else if (self.message.readDate != nil && indexPath.row == 2)
  87. return UITableViewAutomaticDimension;
  88. else if (indexPath.row == 4)
  89. return UITableViewAutomaticDimension;
  90. else
  91. return 0;
  92. } else {
  93. if (self.message.date == nil && indexPath.row == 0)
  94. return 0;
  95. if (self.message.deliveryDate == nil && indexPath.row == 1)
  96. return 0;
  97. if (self.message.readDate == nil && indexPath.row == 2)
  98. return 0;
  99. if (self.message.userackDate == nil && indexPath.row == 3)
  100. return 0;
  101. }
  102. return UITableViewAutomaticDimension;
  103. }
  104. @end