38 lines
1.1 KiB
Objective-C
38 lines
1.1 KiB
Objective-C
//
|
|
// MessageGiftModel.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2023/1/30.
|
|
//
|
|
|
|
#import "MessageGiftModel.h"
|
|
#import "GiftReceiveInfoModel.h"
|
|
#import "NSObject+MJExtension.h"
|
|
#import "XPGiftStorage.h"
|
|
#import "AttachmentModel.h"
|
|
@implementation MessageGiftModel
|
|
|
|
- (instancetype)initWithMessage:(NIMMessage *)message {
|
|
if (self = [super initWithMessage:message]) {
|
|
self.messageType = SessionMessageType_Custom;
|
|
self.contentSize = CGSizeMake(185 + MESSAGE_PADDING * 2, 80);
|
|
self.height = (CONTENT_PADDING_V_TOTAL + 80 + MESSAGE_PADDING * 2);
|
|
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
|
AttachmentModel * attach = (AttachmentModel *)obj.attachment;
|
|
GiftReceiveInfoModel *info = [GiftReceiveInfoModel modelWithDictionary:attach.data];
|
|
GiftInfoModel *giftInfo1 = info.gift == nil ? info.giftInfo : info.gift;
|
|
if (giftInfo1 == nil) {
|
|
giftInfo1 = [[XPGiftStorage shareStorage] findGiftInfo:info.giftId];
|
|
}
|
|
self.giftNum = info.giftNum;
|
|
self.giftInfo = giftInfo1;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (NSString *)cellContent:(MessageBaseModel *)model {
|
|
return @"MessageContentGiftView";
|
|
}
|
|
|
|
@end
|