No Description

FKProActivityInProgressCell.m 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // FKProActivityInProgressCell.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 2016/11/11.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKProActivityInProgressCell.h"
  9. #import "FKProDetailViewModel.h"
  10. #import "FLStringHelper.h"
  11. @implementation FKProActivityInProgressCell
  12. /*
  13. // Only override drawRect: if you perform custom drawing.
  14. // An empty implementation adversely affects performance during animation.
  15. - (void)drawRect:(CGRect)rect {
  16. // Drawing code
  17. }
  18. */
  19. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  20. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  21. if (self) {
  22. [self addAllSubviews];
  23. }
  24. return self;
  25. }
  26. - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath {
  27. if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
  28. FKProDetailViewModel *detailModel = (FKProDetailViewModel*)viewModel;
  29. [self.leftIconView sd_setImageWithURL:[NSURL URLWithString:detailModel.dataItem.promotionItem.iconURL]];
  30. self.titleLabel.text = @"限时活动抢购中";
  31. self.countDownView.descLabel.text = @"距结束时间:";
  32. NSTimeInterval serverTime = [FLStringHelper timeIntervalFromString:detailModel.dataItem.serverTime];
  33. NSTimeInterval endTime = [FLStringHelper timeIntervalFromString:detailModel.dataItem.promotionItem.endTime];
  34. [self.countDownView startWithTimeInterval:(endTime - serverTime)];
  35. }
  36. }
  37. #pragma mark - Layout
  38. - (void)addAllSubviews {
  39. [self.contentView addSubview:self.leftIconView];
  40. [self.leftIconView mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.left.top.bottom.equalTo(self.contentView);
  42. make.width.mas_equalTo(60);
  43. }];
  44. [self.contentView addSubview:self.countDownView];
  45. [self.countDownView mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.right.top.bottom.equalTo(self.contentView);
  47. make.width.mas_equalTo([FKProActivityBaseCell countDownViewWidth]);
  48. }];
  49. [self.contentView addSubview:self.titleLabel];
  50. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.left.equalTo(self.leftIconView.mas_right).offset(4);
  52. make.right.equalTo(self.countDownView.mas_left).offset(-12);
  53. make.centerY.equalTo(self.contentView);
  54. }];
  55. }
  56. #pragma mark - Property
  57. @end