You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
3.1 KiB

2 years ago
//
// XHMessageBubbleFactory.m
// MessageDisplayExample
//
// Created by HUAJIE-1 on 14-4-25.
// Copyright (c) 2014年 曾宪华 开发团队(http://iyilunba.com ) 本人QQ:543413507 本人QQ群142557668. All rights reserved.
//
#import "XHMessageBubbleFactory.h"
#import "XHMacro.h"
#import "XHConfigurationHelper.h"
#import "myHelper.h"
@implementation XHMessageBubbleFactory
+ (UIImage *)bubbleImageViewForType:(XHBubbleMessageType)type
style:(XHBubbleImageViewStyle)style
meidaType:(XHBubbleMessageMediaType)mediaType {
NSString *messageTypeString = @"chat_";
// switch (style) {
// case XHBubbleImageViewStyleWeChat:
// // 类似微信的
// messageTypeString = @"weChatBubble";
// break;
// default:
// break;
// }
switch (type) {
case XHBubbleMessageTypeSending:
// 发送
messageTypeString = [messageTypeString stringByAppendingString:@"发送对话框"];
break;
case XHBubbleMessageTypeReceiving:
// 接收
messageTypeString = [messageTypeString stringByAppendingString:@"接收对话框"];
break;
default:
break;
}
// switch (mediaType) {
// case XHBubbleMessageMediaTypePhoto:
// case XHBubbleMessageMediaTypeVideo:
// messageTypeString = [messageTypeString stringByAppendingString:@"_Solid"];
// break;
// case XHBubbleMessageMediaTypeText:
// case XHBubbleMessageMediaTypeVoice:
// messageTypeString = [messageTypeString stringByAppendingString:@"_Solid"];
// break;
// default:
// break;
// }
if (type == XHBubbleMessageTypeReceiving) {
NSString *receivingSolidImageName = [[XHConfigurationHelper appearance].messageTableStyle objectForKey:kXHMessageTableReceivingSolidImageNameKey];
if (receivingSolidImageName) {
messageTypeString = receivingSolidImageName;
}
} else {
NSString *sendingSolidImageName = [[XHConfigurationHelper appearance].messageTableStyle objectForKey:kXHMessageTableSendingSolidImageNameKey];
if (sendingSolidImageName) {
messageTypeString = sendingSolidImageName;
}
}
UIImage *bublleImage = [myHelper getImageWithName:messageTypeString];
UIEdgeInsets bubbleImageEdgeInsets = [self bubbleImageEdgeInsetsWithStyle:style type:type];
UIImage *edgeBubbleImage = XH_STRETCH_IMAGE(bublleImage, bubbleImageEdgeInsets);
return edgeBubbleImage;
}
+ (UIEdgeInsets)bubbleImageEdgeInsetsWithStyle:(XHBubbleImageViewStyle)style
type:(XHBubbleMessageType)type
{
UIEdgeInsets edgeInsets;
// switch (style) {
// case XHBubbleImageViewStyleWeChat:
// // 类似微信的
// break;
// default:
// break;
// }
if (type == XHBubbleMessageTypeSending) {
edgeInsets = UIEdgeInsetsMake(30, 5, 10, 20);
}else{
edgeInsets = UIEdgeInsetsMake(30, 8, 10, 12);
}
return edgeInsets;
}
@end