1
0
mirror of https://github.com/danog/Telegram.git synced 2024-12-03 09:57:46 +01:00
Telegram/Telegraph/TGDisclosureActionCollectionItem.m
2016-02-25 01:03:51 +01:00

64 lines
1.3 KiB
Objective-C

#import "TGDisclosureActionCollectionItem.h"
#import "TGDisclosureActionCollectionItemView.h"
@implementation TGDisclosureActionCollectionItem
- (instancetype)initWithTitle:(NSString *)title action:(SEL)action
{
self = [super init];
if (self != nil)
{
_title = title;
_action = action;
}
return self;
}
- (Class)itemViewClass
{
return [TGDisclosureActionCollectionItemView class];
}
- (CGSize)itemSizeForContainerSize:(CGSize)containerSize
{
return CGSizeMake(containerSize.width, 44);
}
- (void)itemSelected:(id)actionTarget
{
if (_action != NULL && [actionTarget respondsToSelector:_action])
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[actionTarget performSelector:_action];
#pragma clang diagnostic pop
}
}
- (void)bindView:(TGDisclosureActionCollectionItemView *)view
{
[super bindView:view];
[view setTitle:_title];
[view setIcon:_icon];
}
- (void)setTitle:(NSString *)title
{
_title = title;
if (self.view != nil)
[(TGDisclosureActionCollectionItemView *)self.view setTitle:title];
}
- (void)setIcon:(UIImage *)icon
{
_icon = icon;
if (self.view != nil)
[(TGDisclosureActionCollectionItemView *)self.view setIcon:icon];
}
@end