1
0
mirror of https://github.com/danog/Telegram.git synced 2024-12-04 02:17:51 +01:00
Telegram/Watch/Extension/TGUserHandleRowController.m
2016-02-25 01:03:51 +01:00

48 lines
1.4 KiB
Objective-C

#import "TGUserHandleRowController.h"
#import "TGUserHandle.h"
NSString *const TGUserHandleRowIdentifier = @"TGUserHandleRow";
@implementation TGUserHandleRowController
- (void)updateWithUserHandle:(TGUserHandle *)userHandle
{
bool useRegularFont = (userHandle.handleType == TGUserHandleTypeDescription);
NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init];
attributes[NSFontAttributeName] = useRegularFont ? [UIFont systemFontOfSize:16.0f weight:UIFontWeightRegular] : [UIFont systemFontOfSize:16.0f weight:UIFontWeightMedium];
attributes[NSForegroundColorAttributeName] = [UIColor whiteColor];
if (useRegularFont)
{
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.hyphenationFactor = 1.0f;
attributes[NSParagraphStyleAttributeName] = paragraphStyle;
}
NSString *handle = userHandle.handle;
if (handle == nil)
handle = @"";
self.handleLabel.attributedText = [[NSAttributedString alloc] initWithString:handle attributes:attributes];
self.typeLabel.text = userHandle.type;
}
+ (NSString *)identifier
{
return TGUserHandleRowIdentifier;
}
@end
NSString *const TGUserHandleActiveRowIdentifier = @"TGUserHandleActiveRow";
@implementation TGUserHandleActiveRowController
+ (NSString *)identifier
{
return TGUserHandleActiveRowIdentifier;
}
@end