// // YOUPAILZGuardAttachment.m // TIANYAN // // Created by CY on 2021/4/13. // Copyright © 2021 leo. All rights reserved. // #import "YOUPAILZGuardAttachment.h" @implementation YOUPAILZGuardAttachment - (NSString *)encodeAttachment { NSDictionary *dict = @{ CMType : @(CustomOnGuard), CMData : @{ CMGuardName: self.guard_name?self.guard_name:@"", CMGuardUrl: self.guard_url ?self.guard_url:@"", CMGuardCount: self.guard_count ?[NSNumber numberWithInteger:self.guard_count]:@0, CMFrom: self.from_uid?[NSNumber numberWithInteger:self.from_uid]:@0, CMTo: self.to_uid?[NSNumber numberWithInteger:self.to_uid]:@0, CMLink_type: self.link_type?[NSNumber numberWithInteger:self.link_type]:@0, CMLink_url: self.link_url?self.link_url:@"", CMMd5String: self.md5_string?self.md5_string:@"", CMGiftSvga: self.gift_svga?self.gift_svga:@"", CMGiftType: self.gift_type?@(self.gift_type):@0, CMFromNickname: self.from_nickname?self.from_nickname:@"", CMFromAvatar: self.from_avatar?self.from_avatar:@"", CMToNickname: self.to_nickname?self.to_nickname:@"", CMToAvatar: self.to_avatar?self.to_avatar:@"", } }; NSData *data = [NSJSONSerialization dataWithJSONObject:dict options:0 error:nil]; NSString *content = nil; if (data) { content = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; } return content; } - (NSString *)cellContent:(NIMMessage *)message{ return @"YOUPAILZGuardContentView";//让礼物和贴图一样的形势发送 } - (CGSize)contentSize:(NIMMessageModel *)model cellWidth:(CGFloat)width{ NSString* giftStr = [NSString stringWithFormat:@"收%@",self.guard_name]; CGFloat nameWidth =[giftStr widthWithFont:LCFont(16) constrainedToHeight:48]; return CGSizeMake(20+nameWidth+60+50, 48); } - (UIEdgeInsets)contentViewInsets:(NIMMessage *)message { return UIEdgeInsetsZero; // CGFloat bubblePaddingForImage = 3.f; // CGFloat bubbleArrowWidthForImage = 5.f; // if (message.isOutgoingMsg) { // return UIEdgeInsetsMake(bubblePaddingForImage,bubblePaddingForImage,bubblePaddingForImage,bubblePaddingForImage + bubbleArrowWidthForImage); // }else{ // return UIEdgeInsetsMake(bubblePaddingForImage,bubblePaddingForImage + bubbleArrowWidthForImage, bubblePaddingForImage,bubblePaddingForImage); // } } @end