TUIMessageCellLayout.m 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. //
  2. // TUIMessageCellLayout.m
  3. // TXIMSDK_TUIKit_iOS
  4. //
  5. // Created by annidyfeng on 2019/5/21.
  6. // Copyright © 2023 Tencent. All rights reserved.
  7. //
  8. #import "TUIMessageCellLayout.h"
  9. #import <TIMCommon/TIMDefine.h>
  10. @implementation TUIMessageCellLayout
  11. - (instancetype)init:(BOOL)isIncomming {
  12. self = [super init];
  13. if (self) {
  14. self.avatarSize = CGSizeMake(40, 40);
  15. if (isIncomming) {
  16. self.avatarInsets = (UIEdgeInsets){
  17. .left = 8,
  18. .top = 3,
  19. .bottom = 1,
  20. };
  21. self.messageInsets = (UIEdgeInsets){
  22. .top = 3,
  23. .bottom = 17,
  24. .left = 8,
  25. };
  26. } else {
  27. self.avatarInsets = (UIEdgeInsets){
  28. .right = 8,
  29. .top = 3,
  30. .bottom = 1,
  31. };
  32. self.messageInsets = (UIEdgeInsets){
  33. .top = 3,
  34. .bottom = 17,
  35. .right = 8,
  36. };
  37. }
  38. }
  39. return self;
  40. }
  41. static TUIMessageCellLayout *gIncommingMessageLayout;
  42. + (TUIMessageCellLayout *)incommingMessageLayout {
  43. if (!gIncommingMessageLayout) {
  44. gIncommingMessageLayout = [[TUIMessageCellLayout alloc] init:YES];
  45. }
  46. return gIncommingMessageLayout;
  47. }
  48. static TUIMessageCellLayout *gOutgoingMessageLayout;
  49. + (TUIMessageCellLayout *)outgoingMessageLayout {
  50. if (!gOutgoingMessageLayout) {
  51. gOutgoingMessageLayout = [[TUIMessageCellLayout alloc] init:NO];
  52. }
  53. return gOutgoingMessageLayout;
  54. }
  55. #pragma Text CellLayout
  56. static TUIMessageCellLayout *gIncommingTextMessageLayout;
  57. + (TUIMessageCellLayout *)incommingTextMessageLayout {
  58. if (!gIncommingTextMessageLayout) {
  59. gIncommingTextMessageLayout = [[TUIMessageCellLayout alloc] init:YES];
  60. gIncommingTextMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 10.5, .bottom = 10.5, .left = 16, .right = 16};
  61. }
  62. return gIncommingTextMessageLayout;
  63. }
  64. static TUIMessageCellLayout *gOutgingTextMessageLayout;
  65. + (TUIMessageCellLayout *)outgoingTextMessageLayout {
  66. if (!gOutgingTextMessageLayout) {
  67. gOutgingTextMessageLayout = [[TUIMessageCellLayout alloc] init:NO];
  68. gOutgingTextMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 10.5, .bottom = 10.5, .left = 16, .right = 16};
  69. }
  70. return gOutgingTextMessageLayout;
  71. }
  72. #pragma Voice CellLayout
  73. static TUIMessageCellLayout *gIncommingVoiceMessageLayout;
  74. + (TUIMessageCellLayout *)incommingVoiceMessageLayout {
  75. if (!gIncommingVoiceMessageLayout) {
  76. gIncommingVoiceMessageLayout = [[TUIMessageCellLayout alloc] init:YES];
  77. gIncommingVoiceMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 12, .bottom = 12, .left = 16, .right = 16};
  78. }
  79. return gIncommingVoiceMessageLayout;
  80. }
  81. static TUIMessageCellLayout *gOutgingVoiceMessageLayout;
  82. + (TUIMessageCellLayout *)outgoingVoiceMessageLayout {
  83. if (!gOutgingVoiceMessageLayout) {
  84. gOutgingVoiceMessageLayout = [[TUIMessageCellLayout alloc] init:NO];
  85. gOutgingVoiceMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 14, .bottom = 20, .left = 22, .right = 20};
  86. }
  87. return gOutgingVoiceMessageLayout;
  88. }
  89. #pragma System CellLayout
  90. static TUIMessageCellLayout *gSystemMessageLayout;
  91. + (TUIMessageCellLayout *)systemMessageLayout {
  92. if (!gSystemMessageLayout) {
  93. gSystemMessageLayout = [[TUIMessageCellLayout alloc] init:YES];
  94. gSystemMessageLayout.messageInsets = (UIEdgeInsets){.top = 5, .bottom = 5};
  95. }
  96. return gSystemMessageLayout;
  97. }
  98. #pragma Image CellLayout
  99. static TUIMessageCellLayout *gIncommingImageMessageLayout;
  100. + (TUIMessageCellLayout *)incommingImageMessageLayout {
  101. if (!gIncommingImageMessageLayout) {
  102. gIncommingImageMessageLayout = [[TUIMessageCellLayout alloc] init:YES];
  103. gIncommingImageMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 0, .bottom = 0, .left = 0 ,.right = 0};
  104. }
  105. return gIncommingImageMessageLayout;
  106. }
  107. static TUIMessageCellLayout *gOutgoingImageMessageLayout;
  108. + (TUIMessageCellLayout *)outgoingImageMessageLayout {
  109. if (!gOutgoingImageMessageLayout) {
  110. gOutgoingImageMessageLayout = [[TUIMessageCellLayout alloc] init:NO];
  111. gOutgoingImageMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 0, .bottom = 0, .left = 0 ,.right = 0};
  112. }
  113. return gOutgoingImageMessageLayout;
  114. }
  115. #pragma Video CellLayout
  116. static TUIMessageCellLayout *gIncommingVideoMessageLayout;
  117. + (TUIMessageCellLayout *)incommingVideoMessageLayout {
  118. if (!gIncommingVideoMessageLayout) {
  119. gIncommingVideoMessageLayout = [[TUIMessageCellLayout alloc] init:YES];
  120. gIncommingVideoMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 0, .bottom = 0, .left = 0 ,.right = 0};
  121. }
  122. return gIncommingVideoMessageLayout;
  123. }
  124. static TUIMessageCellLayout *gOutgoingVideoMessageLayout;
  125. + (TUIMessageCellLayout *)outgoingVideoMessageLayout {
  126. if (!gOutgoingVideoMessageLayout) {
  127. gOutgoingVideoMessageLayout = [[TUIMessageCellLayout alloc] init:NO];
  128. gOutgoingVideoMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 0, .bottom = 0, .left = 0 ,.right = 0};
  129. }
  130. return gOutgoingVideoMessageLayout;
  131. }
  132. @end