Commit f9503bf1b9944d93e103cfd0f63412bd5627aaec

Authored by zhangxiaowen
1 parent bbf0d3a0

no message

CNLiveCollectionModule.podspec
... ... @@ -92,4 +92,7 @@ TODO: 网家家-我的模块.
92 92 #
93 93 s.dependency 'CNLiveCustomUI'
94 94  
  95 + s.dependency 'CNLiveCommonCategory'
  96 + s.dependency 'CNLiveBaseKit'
  97 +
95 98 end
... ...
CNLiveCollectionModule/Classes/Controller/CNLiveCollectionController.m
... ... @@ -35,8 +35,6 @@
35 35 @end
36 36  
37 37 @implementation CNLiveCollectionController
38   -static const NSInteger margin = 20;
39   -static const CGFloat timeValue = 1.5;
40 38 #pragma mark - 数据
41 39 - (void)loadData{
42 40 NSDictionary *params = @{
... ... @@ -48,6 +46,9 @@ static const CGFloat timeValue = 1.5;
48 46 [CNLiveNetworking setAllowRequestDefaultArgument:YES];
49 47 [QMUITips showLoadingInView:self.view];
50 48 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:CNDarenCollectListDataSourceUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  49 + if(_pageNo == 1 && self.data.count > 0){
  50 + [self.data removeAllObjects];
  51 + }
51 52 [QMUITips hideAllTipsInView:self.view];
52 53 [self hideEmptyView];
53 54  
... ... @@ -103,7 +104,6 @@ static const CGFloat timeValue = 1.5;
103 104  
104 105 - (void)viewDidLoad {
105 106 [super viewDidLoad];
106   - self.view.backgroundColor = [UIColor blackColor];
107 107 if (@available(iOS 11, *)) {
108 108 }
109 109 else {
... ... @@ -136,11 +136,10 @@ static const CGFloat timeValue = 1.5;
136 136 }
137 137 }
138 138  
139   -#pragma mark - 代理
140 139 #pragma mark - UITableViewDelegate
141 140 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
142   -// CNLiveCollectionModel *model = self.data[indexPath.row];
143   - return 120.0;
  141 + CNLiveCollectionModel *model = self.data[indexPath.row];
  142 + return model.height;
144 143 }
145 144  
146 145 #pragma mark - UITableViewDataSource
... ... @@ -244,9 +243,11 @@ static const CGFloat timeValue = 1.5;
244 243 [self loadData];
245 244  
246 245 }];
247   - _tableView.mj_footer = [CNLiveRrfreshFooter footerWithRefreshingBlock:^{
  246 + CNLiveRrfreshFooter *footer = [CNLiveRrfreshFooter footerWithRefreshingBlock:^{
248 247 [self loadMoreData];
249 248 }];
  249 + footer.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
  250 + _tableView.mj_footer = footer;
250 251 }
251 252 return _tableView;
252 253 }
... ...
CNLiveCollectionModule/Classes/Model/CNLiveCollectionModel.h
... ... @@ -16,7 +16,7 @@ typedef NS_ENUM(NSInteger, CNLiveCollectionCellType) {
16 16 CNLiveCollectionCellVideo = 3,
17 17 };
18 18  
19   -@interface CNLiveIcon
  19 +@interface CNLiveIcon : NSObject
20 20  
21 21 @property (nonatomic, copy) NSString *userId;
22 22 @property (nonatomic, copy) NSString *nickName;
... ... @@ -50,6 +50,14 @@ typedef NS_ENUM(NSInteger, CNLiveCollectionCellType) {
50 50  
51 51 @property (nonatomic, copy) NSMutableAttributedString *attributedString;
52 52  
  53 +
  54 +@property (nonatomic, copy) NSURL *imageUrl;
  55 +@property (nonatomic, copy) NSMutableAttributedString *title;
  56 +@property (nonatomic, copy) NSString *nameTime;
  57 +
  58 +@property (nonatomic, assign) CGFloat height;
  59 +
  60 +
53 61 @end
54 62  
55 63 NS_ASSUME_NONNULL_END
... ...
CNLiveCollectionModule/Classes/Model/CNLiveCollectionModel.m
... ... @@ -7,14 +7,57 @@
7 7 //
8 8  
9 9 #import "CNLiveCollectionModel.h"
  10 +#import "CNLiveBaseKit.h"
  11 +#import "CNLiveCommonCategory.h"
10 12  
11 13 @implementation CNLiveCollectionModel
12   -//static const NSInteger margin = 10;
13 14  
14   -//+ (NSDictionary *)mj_objectClassInArray{
15   -// return @{
16   -// @"icon" : @"CNLiveIcon"
17   -// };
18   -//}
  15 ++ (NSDictionary *)mj_objectClassInArray{
  16 + return @{
  17 + @"icon" : @"CNLiveIcon"
  18 + };
  19 +}
  20 +
  21 +- (void)setUpAttributedString{
  22 + NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
  23 + style.alignment = NSTextAlignmentLeft;
  24 + style.lineBreakMode = NSLineBreakByTruncatingTail;
  25 + NSDictionary *attributes = @{ NSFontAttributeName:UIFontCNMake(17), NSParagraphStyleAttributeName:style};
  26 +
  27 +// NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithAttributedString:[CNTools replaceQQemojiWithCustomText:self.text ? self.text : @""]];
  28 +// [str setAttributes:attributes];
  29 +
  30 +// YYTextContainer *textContainer = [YYTextContainer containerWithSize:CGSizeMake(MainScreenWidth() -(100*RATIO+50), CGFLOAT_MAX)];
  31 +// YYTextLayout *textLayout = [YYTextLayout layoutWithContainer:textContainer text:str];
  32 +// _attributedString = str;
  33 +}
  34 +- (CGFloat)height{
  35 + if ([self.type isEqualToString:@"1"]||[self.type isEqualToString:@"2"]||[self.type isEqualToString:@"3"]||[self.type isEqualToString:@"4"]) {
  36 + return 180;
  37 + }
  38 + return 80;
  39 +}
  40 +
  41 +- (NSMutableAttributedString *)title{
  42 + return nil;
  43 +}
  44 +
  45 +- (NSString *)nameTime{
  46 + NSString *str = [NSString stringWithFormat:@"%ld",self.time];
  47 + NSTimeInterval time = ceil([str doubleValue] / 1000);
  48 + NSDate *detaildate = [NSDate dateWithTimeIntervalSince1970:time];
  49 + NSString *timeString = [detaildate shortTimeTextOfDate];
  50 +
  51 + return self.icon == nil ? [NSString stringWithFormat:@"%@",timeString]:[NSString stringWithFormat:@"%@ %@",self.icon.nickName,timeString];
  52 +}
  53 +
  54 +- (NSURL *)imageUrl{
  55 + return [NSURL URLWithString:(self.imagePath&&![self.imagePath isEqualToString:@""])?self.imagePath:self.videoImg];
  56 +}
  57 +
  58 +@end
  59 +
  60 +
  61 +@implementation CNLiveIcon
19 62  
20 63 @end
... ...
CNLiveCollectionModule/Classes/View/CNLiveCollectionCell.m
... ... @@ -10,15 +10,17 @@
10 10 #import <Masonry/Masonry.h>
11 11 #import <SDWebImage/SDWebImage.h>
12 12 #import "QMUIKit.h"
  13 +#import "CNLiveCategory.h"
  14 +#import "CNLiveBaseKit.h"
13 15  
14 16 #import "CNLiveCollectionModel.h"
15 17  
16 18 @interface CNLiveCollectionCell()
17   -
  19 +@property (nonatomic, strong) UIView *bgView;
18 20 @property (nonatomic, strong) UIImageView *leftImage;
19 21 @property (nonatomic, strong) UILabel *titleLabel;
20 22 @property (nonatomic, strong) UILabel *timeLabel;
21   -@property (nonatomic, strong) UILabel *contentLabel;
  23 +@property (nonatomic, strong) UIButton *playerBtn;
22 24  
23 25 @end
24 26  
... ... @@ -29,51 +31,57 @@ static const NSInteger margin = 10;
29 31 - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
30 32 self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
31 33 if (self) {
32   - self.contentView.backgroundColor = [UIColor whiteColor];
  34 + self.contentView.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
33 35 [self setupUI];
34   -
35 36 }
36 37 return self;
37 38 }
38 39  
39 40 #pragma mark - UI
40 41 - (void)setupUI{
  42 + [self.contentView addSubview:self.bgView];
41 43 [self.contentView addSubview:self.leftImage];
42 44 [self.contentView addSubview:self.titleLabel];
43 45 [self.contentView addSubview:self.timeLabel];
44   - [self.contentView addSubview:self.contentLabel];
  46 + [self.contentView addSubview:self.playerBtn];
45 47  
46 48 }
47 49 - (void)layoutSubviews{
48 50 [super layoutSubviews];
49   - [_leftImage mas_makeConstraints:^(MASConstraintMaker *make) {
  51 + [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
50 52 make.top.equalTo(self.contentView.mas_top).with.offset(margin);
51   - make.left.equalTo(self.contentView.mas_left).with.offset(margin*3/4.0);
52   - make.width.offset(30);
53   - make.height.offset(30);
  53 + make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-0);
  54 + make.left.equalTo(self.contentView.mas_left).with.offset(margin);
  55 + make.right.equalTo(self.contentView.mas_right).with.offset(-margin);
54 56  
55 57 }];
  58 + [_leftImage mas_makeConstraints:^(MASConstraintMaker *make) {
  59 + make.top.equalTo(_bgView.mas_top).with.offset(margin);
  60 + make.left.equalTo(_bgView.mas_left).with.offset(margin);
  61 + make.width.offset(120);
  62 + make.height.offset(130);
  63 + }];
56 64  
57 65 [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
58   - make.top.equalTo(self.contentView.mas_top).with.offset(margin/2.0);
59   - make.left.equalTo(_leftImage.mas_right).with.offset(margin*3/4.0);
60   - make.right.equalTo(_leftImage.mas_left).with.offset(-margin*3/4.0);
61   - make.height.offset(20);
62   -
  66 + make.top.equalTo(_leftImage.mas_top);
  67 + make.left.equalTo(_leftImage.mas_right).with.offset(margin);
  68 + make.right.equalTo(self.contentView.mas_right).with.offset(-margin);
  69 + make.bottom.equalTo(_leftImage.mas_bottom).with.offset(0);
  70 +
63 71 }];
64   -
  72 +
65 73 [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
66   - make.top.equalTo(_titleLabel.mas_bottom).with.offset(margin/2.0);
67   - make.left.equalTo(_leftImage.mas_right).with.offset(margin*3/4.0);
68   - make.height.offset(10);
69   -
  74 + make.top.equalTo(_leftImage.mas_bottom).with.offset(0);
  75 + make.left.equalTo(self.leftImage.mas_left);
  76 + make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-0);
  77 + make.right.equalTo(self.leftImage.mas_right);
  78 +
70 79 }];
71 80  
72   - [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
73   - make.top.equalTo(_titleLabel.mas_bottom).with.offset(margin/2.0);
74   - make.left.equalTo(_timeLabel.mas_right).with.offset(margin*3/4.0);
75   - make.height.offset(10);
76   -
  81 + [_playerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  82 + make.centerX.equalTo(_leftImage.mas_centerX);
  83 + make.centerY.equalTo(_leftImage.mas_centerY);
  84 + make.width.height.offset(50);
77 85 }];
78 86  
79 87 }
... ... @@ -81,7 +89,11 @@ static const NSInteger margin = 10;
81 89 #pragma mark - Data
82 90 - (void)setModel:(CNLiveCollectionModel *)model{
83 91 _model = model;
84   - [_leftImage sd_setImageWithURL:[NSURL URLWithString:model.imagePath] placeholderImage:nil];
  92 + [_leftImage sd_setImageWithURL:model.imageUrl placeholderImage:nil];
  93 +
  94 + _timeLabel.text = model.nameTime;
  95 +
  96 + _playerBtn.hidden = [model.videoId isEqualToString:@""];
85 97  
86 98 }
87 99 - (void)awakeFromNib {
... ... @@ -95,7 +107,23 @@ static const NSInteger margin = 10;
95 107 // Configure the view for the selected state
96 108 }
97 109  
98   -#pragma mark - Lazy loading
  110 +#pragma mark - 响应方法
  111 +- (void)playerDidClicked:(UIButton *)btn{
  112 +
  113 +}
  114 +
  115 +#pragma mark - 懒加载
  116 +- (UIView *)bgView {
  117 + if (!_bgView) {
  118 + _bgView = [[UIView alloc] init];
  119 + _bgView.layer.cornerRadius = 5;
  120 + _bgView.layer.masksToBounds = YES;
  121 + _bgView.exclusiveTouch = YES;
  122 + _bgView.backgroundColor = [UIColor whiteColor];
  123 + _bgView.userInteractionEnabled = YES;
  124 + }
  125 + return _bgView;
  126 +}
99 127 - (UIImageView *)leftImage{
100 128 if (!_leftImage) {
101 129 _leftImage = [[UIImageView alloc] init];
... ... @@ -108,7 +136,7 @@ static const NSInteger margin = 10;
108 136 if(_titleLabel == nil){
109 137 _titleLabel = [[UILabel alloc] init];
110 138 _titleLabel.textColor = [UIColor colorWithRed:40/255.0 green:40/255.0 blue:40/255.0 alpha:1.0];
111   - _titleLabel.font = UIFontMake(16);
  139 + _titleLabel.font = UIFontCNMake(16);
112 140 _titleLabel.userInteractionEnabled = YES;
113 141  
114 142 }
... ... @@ -119,23 +147,22 @@ static const NSInteger margin = 10;
119 147 if(_timeLabel == nil){
120 148 _timeLabel = [[UILabel alloc] init];
121 149 _timeLabel.textColor = [UIColor colorWithRed:155/255.0 green:155/255.0 blue:155/255.0 alpha:1.0];
122   - _timeLabel.font = UIFontMake(12);
  150 + _timeLabel.font = UIFontCNMake(13);
123 151 _timeLabel.userInteractionEnabled = YES;
124 152  
125 153 }
126 154 return _timeLabel;
127 155  
128 156 }
129   -- (UILabel *)contentLabel{
130   - if(_contentLabel == nil){
131   - _contentLabel = [[UILabel alloc] init];
132   - _contentLabel.textColor = [UIColor colorWithRed:155/255.0 green:155/255.0 blue:155/255.0 alpha:1.0];
133   - _contentLabel.font = UIFontMake(12);
134   - _contentLabel.userInteractionEnabled = YES;
135   -
  157 +- (UIButton *)playerBtn {
  158 + if (!_playerBtn) {
  159 + _playerBtn= [UIButton buttonWithType:UIButtonTypeCustom];
  160 + _playerBtn.adjustsImageWhenHighlighted = NO;
  161 + UIImage *image = [self getImageWithImageName:@"collection_back_black_b" bundleName:@"CNLiveCollectionModule" targetClass:[self class]];
  162 + [_playerBtn setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
  163 + [_playerBtn addTarget:self action:@selector(playerDidClicked:) forControlEvents:UIControlEventTouchUpInside];
136 164 }
137   - return _contentLabel;
138   -
  165 + return _playerBtn;
139 166 }
140 167  
141 168 @end
... ...
Example/CNLiveCollectionModule.xcodeproj/project.pbxproj
... ... @@ -351,6 +351,7 @@
351 351 "${BUILT_PRODUCTS_DIR}/CNLiveBeeHive/CNLiveBeeHive.framework",
352 352 "${BUILT_PRODUCTS_DIR}/CNLiveCategory/CNLiveCategory.framework",
353 353 "${BUILT_PRODUCTS_DIR}/CNLiveCollectionModule/CNLiveCollectionModule.framework",
  354 + "${BUILT_PRODUCTS_DIR}/CNLiveCommonCategory/CNLiveCommonCategory.framework",
354 355 "${BUILT_PRODUCTS_DIR}/CNLiveCommonClass/CNLiveCommonClass.framework",
355 356 "${BUILT_PRODUCTS_DIR}/CNLiveCustomUI/CNLiveCustomUI.framework",
356 357 "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework",
... ... @@ -372,6 +373,7 @@
372 373 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBeeHive.framework",
373 374 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCategory.framework",
374 375 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCollectionModule.framework",
  376 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonCategory.framework",
375 377 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonClass.framework",
376 378 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCustomUI.framework",
377 379 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework",
... ...