| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- //
- // TUIMessageCellLayout.m
- // TXIMSDK_TUIKit_iOS
- //
- // Created by annidyfeng on 2019/5/21.
- // Copyright © 2023 Tencent. All rights reserved.
- //
- #import "TUIMessageCellLayout.h"
- #import <TIMCommon/TIMDefine.h>
- @implementation TUIMessageCellLayout
- - (instancetype)init:(BOOL)isIncomming {
- self = [super init];
- if (self) {
- self.avatarSize = CGSizeMake(40, 40);
- if (isIncomming) {
- self.avatarInsets = (UIEdgeInsets){
- .left = 8,
- .top = 3,
- .bottom = 1,
- };
- self.messageInsets = (UIEdgeInsets){
- .top = 3,
- .bottom = 17,
- .left = 8,
- };
- } else {
- self.avatarInsets = (UIEdgeInsets){
- .right = 8,
- .top = 3,
- .bottom = 1,
- };
- self.messageInsets = (UIEdgeInsets){
- .top = 3,
- .bottom = 17,
- .right = 8,
- };
- }
- }
- return self;
- }
- static TUIMessageCellLayout *gIncommingMessageLayout;
- + (TUIMessageCellLayout *)incommingMessageLayout {
- if (!gIncommingMessageLayout) {
- gIncommingMessageLayout = [[TUIMessageCellLayout alloc] init:YES];
- }
- return gIncommingMessageLayout;
- }
- static TUIMessageCellLayout *gOutgoingMessageLayout;
- + (TUIMessageCellLayout *)outgoingMessageLayout {
- if (!gOutgoingMessageLayout) {
- gOutgoingMessageLayout = [[TUIMessageCellLayout alloc] init:NO];
- }
- return gOutgoingMessageLayout;
- }
- #pragma Text CellLayout
- static TUIMessageCellLayout *gIncommingTextMessageLayout;
- + (TUIMessageCellLayout *)incommingTextMessageLayout {
- if (!gIncommingTextMessageLayout) {
- gIncommingTextMessageLayout = [[TUIMessageCellLayout alloc] init:YES];
- gIncommingTextMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 10.5, .bottom = 10.5, .left = 16, .right = 16};
- }
- return gIncommingTextMessageLayout;
- }
- static TUIMessageCellLayout *gOutgingTextMessageLayout;
- + (TUIMessageCellLayout *)outgoingTextMessageLayout {
- if (!gOutgingTextMessageLayout) {
- gOutgingTextMessageLayout = [[TUIMessageCellLayout alloc] init:NO];
- gOutgingTextMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 10.5, .bottom = 10.5, .left = 16, .right = 16};
- }
- return gOutgingTextMessageLayout;
- }
- #pragma Voice CellLayout
- static TUIMessageCellLayout *gIncommingVoiceMessageLayout;
- + (TUIMessageCellLayout *)incommingVoiceMessageLayout {
- if (!gIncommingVoiceMessageLayout) {
- gIncommingVoiceMessageLayout = [[TUIMessageCellLayout alloc] init:YES];
- gIncommingVoiceMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 12, .bottom = 12, .left = 16, .right = 16};
- }
- return gIncommingVoiceMessageLayout;
- }
- static TUIMessageCellLayout *gOutgingVoiceMessageLayout;
- + (TUIMessageCellLayout *)outgoingVoiceMessageLayout {
- if (!gOutgingVoiceMessageLayout) {
- gOutgingVoiceMessageLayout = [[TUIMessageCellLayout alloc] init:NO];
- gOutgingVoiceMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 14, .bottom = 20, .left = 22, .right = 20};
- }
- return gOutgingVoiceMessageLayout;
- }
- #pragma System CellLayout
- static TUIMessageCellLayout *gSystemMessageLayout;
- + (TUIMessageCellLayout *)systemMessageLayout {
- if (!gSystemMessageLayout) {
- gSystemMessageLayout = [[TUIMessageCellLayout alloc] init:YES];
- gSystemMessageLayout.messageInsets = (UIEdgeInsets){.top = 5, .bottom = 5};
- }
- return gSystemMessageLayout;
- }
- #pragma Image CellLayout
- static TUIMessageCellLayout *gIncommingImageMessageLayout;
- + (TUIMessageCellLayout *)incommingImageMessageLayout {
- if (!gIncommingImageMessageLayout) {
- gIncommingImageMessageLayout = [[TUIMessageCellLayout alloc] init:YES];
- gIncommingImageMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 0, .bottom = 0, .left = 0 ,.right = 0};
- }
- return gIncommingImageMessageLayout;
- }
- static TUIMessageCellLayout *gOutgoingImageMessageLayout;
- + (TUIMessageCellLayout *)outgoingImageMessageLayout {
- if (!gOutgoingImageMessageLayout) {
- gOutgoingImageMessageLayout = [[TUIMessageCellLayout alloc] init:NO];
- gOutgoingImageMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 0, .bottom = 0, .left = 0 ,.right = 0};
- }
- return gOutgoingImageMessageLayout;
- }
- #pragma Video CellLayout
- static TUIMessageCellLayout *gIncommingVideoMessageLayout;
- + (TUIMessageCellLayout *)incommingVideoMessageLayout {
- if (!gIncommingVideoMessageLayout) {
- gIncommingVideoMessageLayout = [[TUIMessageCellLayout alloc] init:YES];
- gIncommingVideoMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 0, .bottom = 0, .left = 0 ,.right = 0};
- }
- return gIncommingVideoMessageLayout;
- }
- static TUIMessageCellLayout *gOutgoingVideoMessageLayout;
- + (TUIMessageCellLayout *)outgoingVideoMessageLayout {
- if (!gOutgoingVideoMessageLayout) {
- gOutgoingVideoMessageLayout = [[TUIMessageCellLayout alloc] init:NO];
- gOutgoingVideoMessageLayout.bubbleInsets = (UIEdgeInsets){.top = 0, .bottom = 0, .left = 0 ,.right = 0};
- }
- return gOutgoingVideoMessageLayout;
- }
- @end
|