123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- //
- // FKProActivityThemeCell.m
- // FirstLink
- //
- // Created by ascii on 2016/11/11.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKProActivityThemeCell.h"
- #import "FKProDetailViewModel.h"
- #import <SDWebImage/SDWebImageDownloader.h>
- #import "FLImageHelper.h"
- #import "SchemaManager.h"
- @interface FKProActivityThemeCell ()
- @property (nonatomic, strong) UIImageView *themeImgView;
- @property (nonatomic, strong) NSString *targetUrl;
- @end
- @implementation FKProActivityThemeCell
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- [self.contentView addSubview:self.themeImgView];
- [self.themeImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self.contentView);
- }];
- }
- return self;
- }
- #pragma mark -
- - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath {
- if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
- FKProDetailViewModel *detailModel = (FKProDetailViewModel*)viewModel;
-
- NSString *imageUrl = detailModel.dataItem.themeItem.photoURL;
- self.targetUrl = detailModel.dataItem.themeItem.targetURL;
-
- if (imageUrl.length > 0) {
- [self.themeImgView setImageWithURL:imageUrl placeholderImage:nil width:UISCREENWIDTH height:[FKProActivityBaseCell height]];
- }
- }
- }
- -(void)clickThemeImageView {
- if (self.targetUrl.length > 0) {
- [[SchemaManager sharedManager] parserURL:[NSURL URLWithString:self.targetUrl] shouldCache:NO];
- }
- }
- #pragma mark - Property
- - (UIImageView *)themeImgView {
- if (!_themeImgView) {
- _themeImgView = [UIImageView new];
- _themeImgView.userInteractionEnabled = YES;
- [_themeImgView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickThemeImageView)]];
- }
- return _themeImgView;
- }
- @end
|