JXTransferCell.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. //
  2. // JXTransferCell.m
  3. // shiku_im
  4. //
  5. // Created by 1 on 2019/3/1.
  6. // Copyright © 2019年 Reese. All rights reserved.
  7. //
  8. #import "JXTransferCell.h"
  9. @interface JXTransferCell ()
  10. @property (nonatomic, strong) UIImageView *headImageView;
  11. @property (nonatomic, strong) UILabel *nameLabel;
  12. @property (nonatomic, strong) UILabel *title;
  13. @property (nonatomic, strong) UILabel *moneyLabel;
  14. @end
  15. @implementation JXTransferCell
  16. - (void)awakeFromNib {
  17. [super awakeFromNib];
  18. // Initialization code
  19. }
  20. -(void)creatUI{
  21. self.bubbleBg.custom_acceptEventInterval = 1.0;
  22. _imageBackground =[[JXImageView alloc]initWithFrame:CGRectZero];
  23. [_imageBackground setBackgroundColor:[UIColor clearColor]];
  24. _imageBackground.layer.cornerRadius = 6;
  25. _imageBackground.image = [UIImage imageNamed:@"transfer_back_icon"];
  26. _imageBackground.layer.masksToBounds = YES;
  27. _imageBackground.contentMode = UIViewContentModeScaleAspectFill;
  28. [self.bubbleBg addSubview:_imageBackground];
  29. _headImageView = [[UIImageView alloc]init];
  30. _headImageView.frame = CGRectMake(15,20, 40, 40);
  31. _headImageView.image = [UIImage imageNamed:@"ic_transfer_money"];
  32. _headImageView.userInteractionEnabled = NO;
  33. [_imageBackground addSubview:_headImageView];
  34. _moneyLabel = [[UILabel alloc]init];
  35. _moneyLabel.frame = CGRectMake(CGRectGetMaxX(_headImageView.frame) + 15,20, 180, 15);
  36. _moneyLabel.font = g_factory.font15;
  37. _moneyLabel.textColor = [UIColor whiteColor];
  38. _moneyLabel.numberOfLines = 0;
  39. _moneyLabel.userInteractionEnabled = NO;
  40. [_imageBackground addSubview:_moneyLabel];
  41. _nameLabel = [[UILabel alloc]init];
  42. _nameLabel.frame = CGRectMake(CGRectGetMaxX(_headImageView.frame) + 15,CGRectGetMaxY(_moneyLabel.frame)+5, 180, 14);
  43. _nameLabel.font = g_factory.font14;
  44. _nameLabel.textColor = [UIColor whiteColor];
  45. _nameLabel.numberOfLines = 0;
  46. _nameLabel.userInteractionEnabled = NO;
  47. [_imageBackground addSubview:_nameLabel];
  48. // _title = [[UILabel alloc] initWithFrame:CGRectMake(15, 10, 200, 30)];
  49. // _title.text = Localized(@"JX_Transfer");
  50. // _title.font = SYSFONT(14.0);
  51. // _title.textColor = [UIColor whiteColor];
  52. // [_imageBackground addSubview:_title];
  53. }
  54. -(void)setCellData{
  55. [super setCellData];
  56. int n = imageItemHeight;
  57. if(self.msg.isMySend)
  58. {
  59. self.bubbleBg.frame=CGRectMake(CGRectGetMinX(self.headImage.frame)- kChatCellMaxWidth - CHAT_WIDTH_ICON, INSETS, kChatCellMaxWidth, n+INSETS -4);
  60. _imageBackground.frame = self.bubbleBg.bounds;
  61. }
  62. else
  63. {
  64. self.bubbleBg.frame=CGRectMake(CGRectGetMaxX(self.headImage.frame) + CHAT_WIDTH_ICON, INSETS2(self.msg.isGroup), kChatCellMaxWidth, n+INSETS -4);
  65. _imageBackground.frame = self.bubbleBg.bounds;
  66. }
  67. _title.frame = CGRectMake(15, _imageBackground.frame.size.height - 30, 200, 30);
  68. if (self.msg.isShowTime) {
  69. CGRect frame = self.bubbleBg.frame;
  70. frame.origin.y = self.bubbleBg.frame.origin.y + 40;
  71. self.bubbleBg.frame = frame;
  72. }
  73. [self setMaskLayer:_imageBackground];
  74. JXUserObject *user = [[JXUserObject alloc] init];
  75. user = [user getUserById:self.msg.toUserId];
  76. _nameLabel.text = self.msg.fileName.length > 0 ? self.msg.fileName : self.msg.isMySend ? [NSString stringWithFormat:@"%@%@",Localized(@"JX_TransferTo"),user.remarkName.length > 0 ? user.remarkName : user.userNickname] : Localized(@"JX_TransferToYou");
  77. _moneyLabel.text = [NSString stringWithFormat:@"¥%@",self.msg.content];
  78. if ([self.msg.fileSize intValue] == 2) {
  79. _imageBackground.alpha = 0.5;
  80. }else {
  81. _imageBackground.alpha = 1;
  82. }
  83. }
  84. -(void)didTouch:(UIButton*)button{
  85. self.msg.index = self.indexNum;
  86. [g_notify postNotificationName:kcellTransferDidTouchNotifaction object:self.msg];
  87. }
  88. + (float)getChatCellHeight:(JXMessageObject *)msg {
  89. if ([g_App.isShowRedPacket intValue] == 1){
  90. if ([msg.chatMsgHeight floatValue] > 1) {
  91. return [msg.chatMsgHeight floatValue];
  92. }
  93. float n = 0;
  94. if (msg.isGroup && !msg.isMySend) {
  95. if (msg.isShowTime) {
  96. n = JX_SCREEN_WIDTH/3 + 10 + 40;
  97. }else {
  98. n = JX_SCREEN_WIDTH/3 + 10;
  99. }
  100. n += GROUP_CHAT_INSET;
  101. }else {
  102. if (msg.isShowTime) {
  103. n = JX_SCREEN_WIDTH/3 + 40;
  104. }else {
  105. n = JX_SCREEN_WIDTH/3;
  106. }
  107. }
  108. msg.chatMsgHeight = [NSString stringWithFormat:@"%f",n];
  109. if (!msg.isNotUpdateHeight) {
  110. [msg updateChatMsgHeight];
  111. }
  112. return n;
  113. }else{
  114. msg.chatMsgHeight = [NSString stringWithFormat:@"0"];
  115. if (!msg.isNotUpdateHeight) {
  116. [msg updateChatMsgHeight];
  117. }
  118. return 0;
  119. }
  120. }
  121. @end