2015-10-01 18:19:52 +02:00
|
|
|
#import "TGUserHandleRowController.h"
|
|
|
|
#import "TGUserHandle.h"
|
|
|
|
|
|
|
|
NSString *const TGUserHandleRowIdentifier = @"TGUserHandleRow";
|
|
|
|
|
|
|
|
@implementation TGUserHandleRowController
|
|
|
|
|
|
|
|
- (void)updateWithUserHandle:(TGUserHandle *)userHandle
|
|
|
|
{
|
2016-02-25 01:03:51 +01:00
|
|
|
bool useRegularFont = (userHandle.handleType == TGUserHandleTypeDescription);
|
2015-10-01 18:19:52 +02:00
|
|
|
|
|
|
|
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
|