TUIEvaluationCellData.m 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // TUIEvaluationCellData.m
  3. // TUIChat
  4. //
  5. // Created by xia on 2022/6/10.
  6. // Copyright © 2023 Tencent. All rights reserved.
  7. //
  8. #import "TUIEvaluationCellData.h"
  9. @implementation TUIEvaluationCellData
  10. + (TUIMessageCellData *)getCellData:(V2TIMMessage *)message {
  11. NSDictionary *param = [NSJSONSerialization JSONObjectWithData:message.customElem.data options:NSJSONReadingAllowFragments error:nil];
  12. if (param == nil) {
  13. return nil;
  14. }
  15. TUIEvaluationCellData *cellData = [[TUIEvaluationCellData alloc] initWithDirection:message.isSelf ? MsgDirectionOutgoing : MsgDirectionIncoming];
  16. cellData.innerMessage = message;
  17. cellData.desc = message.customElem.desc;
  18. cellData.score = [param[@"score"] integerValue];
  19. cellData.comment = param[@"comment"];
  20. return cellData;
  21. }
  22. + (NSString *)getDisplayString:(V2TIMMessage *)message {
  23. return message.customElem.desc;
  24. }
  25. - (CGSize)contentSize {
  26. CGRect rect = [self.comment boundingRectWithSize:CGSizeMake(215, MAXFLOAT)
  27. options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
  28. attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]}
  29. context:nil];
  30. CGSize size = CGSizeMake(245, ceilf(rect.size.height));
  31. size.height += self.comment.length > 0 ? 88 : 50;
  32. return size;
  33. }
  34. @end