Files
GLEGram-iOS/Telegram/Watch/Extension/TGNeoTextMessageViewModel.m
Leeksov 4647310322 GLEGram 12.5 — Initial public release
Based on Swiftgram 12.5 (Telegram iOS 12.5).
All GLEGram features ported and organized in GLEGram/ folder.

Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass,
Font Replacement, Fake Profile, Chat Export, Plugin System, and more.

See CHANGELOG_12.5.md for full details.
2026-04-06 09:48:12 +03:00

65 lines
2.3 KiB
Objective-C

#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