mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Move app to a dedicated folder
This commit is contained in:
64
Telegram/Watch/Extension/TGNeoTextMessageViewModel.m
Normal file
64
Telegram/Watch/Extension/TGNeoTextMessageViewModel.m
Normal file
@@ -0,0 +1,64 @@
|
||||
#import "TGNeoTextMessageViewModel.h"
|
||||
|
||||
#import <WatchCommonWatch/WatchCommonWatch.h>
|
||||
|
||||
#import "TGNeoLabelViewModel.h"
|
||||
#import "TGMessageViewModel.h"
|
||||
|
||||
@interface TGNeoTextMessageViewModel ()
|
||||
{
|
||||
TGNeoLabelViewModel *_textModel;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TGNeoTextMessageViewModel
|
||||
|
||||
- (instancetype)initWithMessage:(TGBridgeMessage *)message type:(TGNeoMessageType)type users:(NSDictionary *)users context:(TGBridgeContext *)context
|
||||
{
|
||||
self = [super initWithMessage:message type:type users:users context:context];
|
||||
if (self != nil)
|
||||
{
|
||||
NSString *text = [message.text stringByReplacingOccurrencesOfString:@"/" withString:@"/\u2060"];
|
||||
CGFloat fontSize = [TGNeoBubbleMessageViewModel bodyTextFontSize];
|
||||
UIColor *textColor = [self normalColorForMessage:message type:type];
|
||||
|
||||
if (message.textCheckingResults.count > 0)
|
||||
{
|
||||
_textModel = [[TGNeoLabelViewModel alloc] initWithAttributedText:[TGMessageViewModel attributedTextForMessage:message fontSize:fontSize textColor:textColor]];
|
||||
}
|
||||
else
|
||||
{
|
||||
_textModel = [[TGNeoLabelViewModel alloc] initWithText:text font:[UIFont systemFontOfSize:fontSize] color:textColor attributes:nil];
|
||||
}
|
||||
|
||||
_textModel.multiline = true;
|
||||
|
||||
[self addSubmodel:_textModel];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CGSize)layoutWithContainerSize:(CGSize)containerSize
|
||||
{
|
||||
CGSize contentContainerSize = [self contentContainerSizeWithContainerSize:containerSize];
|
||||
|
||||
CGSize headerSize = [self layoutHeaderModelsWithContainerSize:contentContainerSize];
|
||||
CGFloat maxContentWidth = headerSize.width;
|
||||
CGFloat textTopOffset = headerSize.height;
|
||||
|
||||
CGSize textSize = [_textModel contentSizeWithContainerSize:contentContainerSize];
|
||||
_textModel.frame = CGRectMake(TGNeoBubbleMessageViewModelInsets.left, textTopOffset, textSize.width, textSize.height);
|
||||
|
||||
if (textSize.width > maxContentWidth)
|
||||
maxContentWidth = textSize.width;
|
||||
|
||||
CGSize contentSize = CGSizeZero;
|
||||
contentSize.width = maxContentWidth + TGNeoBubbleMessageViewModelInsets.left + TGNeoBubbleMessageViewModelInsets.right;
|
||||
contentSize.height = CGRectGetMaxY(_textModel.frame) + TGNeoBubbleMessageViewModelInsets.bottom;
|
||||
|
||||
[super layoutWithContainerSize:contentSize];
|
||||
|
||||
return contentSize;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user