Commit be21473bac94274b3b954847c24b916c9c9456cf

Authored by yanglingyu
1 parent 5608678a

添加交互0.4.4

CNLiveVideoClassifyKit.podspec
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 8
9 Pod::Spec.new do |s| 9 Pod::Spec.new do |s|
10 s.name = 'CNLiveVideoClassifyKit' 10 s.name = 'CNLiveVideoClassifyKit'
11 - s.version = '0.4.3' 11 + s.version = '0.4.4'
12 s.summary = '视讯头部一二级菜单组件' 12 s.summary = '视讯头部一二级菜单组件'
13 13
14 # This description is used to generate tags and improve search results. 14 # This description is used to generate tags and improve search results.
CNLiveVideoClassifyKit/Classes/Manager/CNLiveClassifyJumpBridge.h
@@ -60,6 +60,13 @@ NS_ASSUME_NONNULL_BEGIN @@ -60,6 +60,13 @@ NS_ASSUME_NONNULL_BEGIN
60 /// 展示登录窗口 60 /// 展示登录窗口
61 /// @param loginPrepositionUrl 为appdelegate属性赋值字符串 61 /// @param loginPrepositionUrl 为appdelegate属性赋值字符串
62 + (void)showLoginViewWithString:(NSString *)loginPrepositionUrl; 62 + (void)showLoginViewWithString:(NSString *)loginPrepositionUrl;
  63 +/// 打开用户个人视频页
  64 +/// @param params 传递参数
  65 ++ (void)openPersonMessage:(NSDictionary *)params;
  66 +/// 打开视频播放页面
  67 +/// @param currentIndex 当前选中
  68 +/// @param dataList 视频数组
  69 ++ (void)openVideoPlayerVCWithCurrentIndex:(NSString *)currentIndex dataList:(NSArray *)dataList;
63 @end 70 @end
64 71
65 NS_ASSUME_NONNULL_END 72 NS_ASSUME_NONNULL_END
CNLiveVideoClassifyKit/Classes/Manager/CNLiveClassifyJumpBridge.m
@@ -72,4 +72,10 @@ @@ -72,4 +72,10 @@
72 + (void)showLoginViewWithString:(NSString *)loginPrepositionUrl{ 72 + (void)showLoginViewWithString:(NSString *)loginPrepositionUrl{
73 [[CNLiveClassifyJumpBridge shareInstance].protocol showLoginViewWithString:loginPrepositionUrl]; 73 [[CNLiveClassifyJumpBridge shareInstance].protocol showLoginViewWithString:loginPrepositionUrl];
74 } 74 }
  75 ++ (void)openPersonMessage:(NSDictionary *)params{
  76 + [[CNLiveClassifyJumpBridge shareInstance].protocol openPersonMessage:params];
  77 +}
  78 ++ (void)openVideoPlayerVCWithCurrentIndex:(NSString *)currentIndex dataList:(NSArray *)dataList{
  79 + [[CNLiveClassifyJumpBridge shareInstance].protocol openVideoPlayerVCWithCurrentIndex:currentIndex dataList:dataList];
  80 +}
75 @end 81 @end
CNLiveVideoClassifyKit/Classes/Manager/CNLiveListManager.h
@@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN @@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
12 @interface CNLiveListManager : NSObject 12 @interface CNLiveListManager : NSObject
13 @property (nonatomic, copy) void (^scrollViewDidScrollBlock)(BOOL isUp); 13 @property (nonatomic, copy) void (^scrollViewDidScrollBlock)(BOOL isUp);
14 @property (nonatomic, assign) BOOL isHiddenFirst; 14 @property (nonatomic, assign) BOOL isHiddenFirst;
  15 +@property (nonatomic, strong)NSDictionary *personMessage;
15 16
16 +(instancetype)shareListManager; 17 +(instancetype)shareListManager;
17 //第一分类是否隐藏:yes为隐藏 18 //第一分类是否隐藏:yes为隐藏
@@ -20,6 +21,9 @@ NS_ASSUME_NONNULL_BEGIN @@ -20,6 +21,9 @@ NS_ASSUME_NONNULL_BEGIN
20 + (CNCategoryBaseViewController *)CNCategoryBaseViewController; 21 + (CNCategoryBaseViewController *)CNCategoryBaseViewController;
21 /// 跳转目击者搜索页 22 /// 跳转目击者搜索页
22 + (void)pushWitnessSearchVC; 23 + (void)pushWitnessSearchVC;
  24 +/// 用户信息变动,修改关注状态
  25 +/// @param jsonStr 返回参数
  26 ++ (void)personMessageChange:(NSString *)jsonStr;
23 @end 27 @end
24 28
25 NS_ASSUME_NONNULL_END 29 NS_ASSUME_NONNULL_END
CNLiveVideoClassifyKit/Classes/Manager/CNLiveListManager.m
@@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
8 #import "CNLiveListManager.h" 8 #import "CNLiveListManager.h"
9 #import "CNLiveClassifySegmentController.h" 9 #import "CNLiveClassifySegmentController.h"
10 #import "CNWitnessSearchViewController.h" 10 #import "CNWitnessSearchViewController.h"
  11 +#import "CNWitnessSearchModel.h"
11 12
12 @interface CNLiveListManager() 13 @interface CNLiveListManager()
13 { 14 {
@@ -49,4 +50,8 @@ @@ -49,4 +50,8 @@
49 _isHiddenFirst = isHiddenFirst; 50 _isHiddenFirst = isHiddenFirst;
50 !self.scrollViewDidScrollBlock ?: self.scrollViewDidScrollBlock(isHiddenFirst); 51 !self.scrollViewDidScrollBlock ?: self.scrollViewDidScrollBlock(isHiddenFirst);
51 } 52 }
  53 ++ (void)personMessageChange:(NSString *)jsonStr
  54 +{
  55 + [CNLiveListManager shareListManager].personMessage = [jsonStr mj_keyValues];
  56 +}
52 @end 57 @end
CNLiveVideoClassifyKit/Classes/Manager/CNLiveVideoClassifyProtocol.h
@@ -101,6 +101,14 @@ NS_ASSUME_NONNULL_BEGIN @@ -101,6 +101,14 @@ NS_ASSUME_NONNULL_BEGIN
101 /// @param shopType 按着后台给的传 101 /// @param shopType 按着后台给的传
102 /// @param currentVC 当前控制器 102 /// @param currentVC 当前控制器
103 -(void)skipType:(nonnull NSString*)type to:(nonnull NSString*)to shopType:(nonnull NSString*)shopType currentVC:(nonnull UIViewController*)currentVC; 103 -(void)skipType:(nonnull NSString*)type to:(nonnull NSString*)to shopType:(nonnull NSString*)shopType currentVC:(nonnull UIViewController*)currentVC;
  104 +
  105 +/// 打开用户个人视频页
  106 +/// @param params 传递参数
  107 +- (void)openPersonMessage:(NSDictionary *)params;
  108 +/// 打开视频播放页面
  109 +/// @param currentIndex 当前选中
  110 +/// @param dataList 视频数组
  111 +- (void)openVideoPlayerVCWithCurrentIndex:(NSString *)currentIndex dataList:(NSArray *)dataList;
104 @end 112 @end
105 113
106 NS_ASSUME_NONNULL_END 114 NS_ASSUME_NONNULL_END
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessSearchPersonCell.h
@@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN @@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
12 12
13 @interface CNWitnessSearchPersonCell : UICollectionViewCell 13 @interface CNWitnessSearchPersonCell : UICollectionViewCell
14 @property (nonatomic, strong)CNPersonMessageModel *model; 14 @property (nonatomic, strong)CNPersonMessageModel *model;
  15 +@property (nonatomic, strong)void (^selectPersonBlock)(NSDictionary *dic);
15 @end 16 @end
16 17
17 NS_ASSUME_NONNULL_END 18 NS_ASSUME_NONNULL_END
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessSearchPersonCell.m
@@ -96,6 +96,14 @@ @@ -96,6 +96,14 @@
96 CAShapeLayer *maskLayer = [CAShapeLayer layer]; 96 CAShapeLayer *maskLayer = [CAShapeLayer layer];
97 maskLayer.path = path.CGPath; 97 maskLayer.path = path.CGPath;
98 _logoImage.layer.mask = maskLayer; 98 _logoImage.layer.mask = maskLayer;
  99 + _logoImage.userInteractionEnabled = YES;
  100 + weakself
  101 + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
  102 + if (weakSelf.selectPersonBlock) {
  103 + weakSelf.selectPersonBlock([weakSelf.model mj_keyValues]);
  104 + }
  105 + }];
  106 + [_logoImage addGestureRecognizer:tap];
99 } 107 }
100 return _logoImage; 108 return _logoImage;
101 } 109 }
CNLiveVideoClassifyKit/Classes/SearchView/ViewController/CNWitnessSearchDetailController.m
@@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
11 #import "CNWitnessSearchPersonCell.h" 11 #import "CNWitnessSearchPersonCell.h"
12 #import "CNWitnessSearchModel.h" 12 #import "CNWitnessSearchModel.h"
13 #import "CNCollectionViewLayout.h" 13 #import "CNCollectionViewLayout.h"
  14 +#import "CNLiveListManager.h"
14 15
15 static NSString *const CNWitnessSearchVideoCellID = @"CNWitnessSearchVideoCell"; 16 static NSString *const CNWitnessSearchVideoCellID = @"CNWitnessSearchVideoCell";
16 static NSString *const CNWitnessSearchPersonCellID = @"CNWitnessSearchPersonCell"; 17 static NSString *const CNWitnessSearchPersonCellID = @"CNWitnessSearchPersonCell";
@@ -20,6 +21,8 @@ static NSString *const CNWitnessSearchPersonCellID = @"CNWitnessSearchPersonCell @@ -20,6 +21,8 @@ static NSString *const CNWitnessSearchPersonCellID = @"CNWitnessSearchPersonCell
20 @property (nonatomic, assign)NSInteger page;//请求页数 21 @property (nonatomic, assign)NSInteger page;//请求页数
21 @property (nonatomic, strong)NSString *ts; 22 @property (nonatomic, strong)NSString *ts;
22 @property (nonatomic, strong)NSMutableArray *dataSource; 23 @property (nonatomic, strong)NSMutableArray *dataSource;
  24 +@property (nonatomic, strong)NSMutableArray *personIDArray;
  25 +@property (nonatomic, strong)NSMutableArray *videoIDArray;
23 @end 26 @end
24 27
25 @implementation CNWitnessSearchDetailController 28 @implementation CNWitnessSearchDetailController
@@ -57,10 +60,28 @@ static NSString *const CNWitnessSearchPersonCellID = @"CNWitnessSearchPersonCell @@ -57,10 +60,28 @@ static NSString *const CNWitnessSearchPersonCellID = @"CNWitnessSearchPersonCell
57 } 60 }
58 [self.emptyView removeFromSuperview]; 61 [self.emptyView removeFromSuperview];
59 [self.dataSource addObjectsFromArray:dataArray]; 62 [self.dataSource addObjectsFromArray:dataArray];
  63 + if (weakSelf.type == CNWitnessSearchDetailTypeVideo) {
  64 + [dataArray enumerateObjectsUsingBlock:^(CNWitnessSearchDetailModel *model, NSUInteger idx, BOOL * _Nonnull stop) {
  65 + [weakSelf.videoIDArray addObject:model.pid];
  66 + }];
  67 + }else{
  68 + [dataArray enumerateObjectsUsingBlock:^(CNPersonMessageModel *model, NSUInteger idx, BOOL * _Nonnull stop) {
  69 + [weakSelf.personIDArray addObject:model.id];
  70 + }];
  71 + }
  72 +
60 [self.collectionView reloadData]; 73 [self.collectionView reloadData];
61 }]; 74 }];
62 } 75 }
63 - 76 +- (void)dealloc
  77 +{
  78 + if (self.type == CNWitnessSearchDetailTypeVideo) {
  79 + [[NSNotificationCenter defaultCenter] removeObserver:self];
  80 + }else{
  81 + [[CNLiveListManager shareListManager] removeObserver:self forKeyPath:@"personMessage"];
  82 + }
  83 +
  84 +}
64 - (instancetype)initWithPageType:(CNWitnessSearchDetailType)type 85 - (instancetype)initWithPageType:(CNWitnessSearchDetailType)type
65 { 86 {
66 if (self = [super init]) { 87 if (self = [super init]) {
@@ -81,6 +102,12 @@ static NSString *const CNWitnessSearchPersonCellID = @"CNWitnessSearchPersonCell @@ -81,6 +102,12 @@ static NSString *const CNWitnessSearchPersonCellID = @"CNWitnessSearchPersonCell
81 pan.delegate = self; 102 pan.delegate = self;
82 [self.view addGestureRecognizer:pan]; 103 [self.view addGestureRecognizer:pan];
83 } 104 }
  105 + if (self.type == CNWitnessSearchDetailTypeVideo) {
  106 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoChangeWithParam:) name:@"WjjWitnessLikeStatusNotification" object:nil];
  107 + }else{
  108 + [[CNLiveListManager shareListManager] addObserver:self forKeyPath:@"personMessage" options:NSKeyValueObservingOptionNew context:NULL];
  109 + }
  110 +
84 } 111 }
85 - (void)panGestureEvent:(UIPanGestureRecognizer *)gesture{ 112 - (void)panGestureEvent:(UIPanGestureRecognizer *)gesture{
86 if (self.panGestureBlock) { 113 if (self.panGestureBlock) {
@@ -90,11 +117,42 @@ static NSString *const CNWitnessSearchPersonCellID = @"CNWitnessSearchPersonCell @@ -90,11 +117,42 @@ static NSString *const CNWitnessSearchPersonCellID = @"CNWitnessSearchPersonCell
90 - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{ 117 - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
91 return YES; 118 return YES;
92 } 119 }
  120 +#pragma KVO||Notification
  121 +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context{
  122 + if ([keyPath isEqualToString:@"personMessage"]) {
  123 + NSDictionary *dic = change[NSKeyValueChangeNewKey];
  124 + CNPersonMessageModel *model = [CNPersonMessageModel mj_objectWithKeyValues:dic];
  125 + if ([self.personIDArray containsObject:model.id]) {
  126 + NSInteger index = [self.personIDArray indexOfObject:model.id];
  127 + [self.dataSource replaceObjectAtIndex:index withObject:model];
  128 + [self.collectionView reloadItemsAtIndexPaths:@[[NSIndexPath indexPathForItem:index inSection:0]]];
  129 + }
  130 + }
  131 +}
  132 +- (void)videoChangeWithParam:(NSNotification *)noti{
  133 + NSString *pid = [noti.userInfo objectForKey:@"contentId"];
  134 + if ([self.videoIDArray containsObject:pid]) {
  135 + NSInteger index = [self.videoIDArray indexOfObject:pid];
  136 + NSString *selected = [noti.userInfo objectForKey:@"selected"];
  137 + NSString *likesNumber = [noti.userInfo objectForKey:@"likesNum"];
  138 + CNWitnessSearchDetailModel *model = self.dataSource[index];
  139 + model.tool.liked = [selected isEqualToString:@"true"];
  140 + model.tool.likesNum = likesNumber.integerValue;
  141 + [self.collectionView reloadItemsAtIndexPaths:@[[NSIndexPath indexPathForItem:index inSection:0]]];
  142 + }
  143 +}
93 #pragma mark - UIGestureRecognizerDelegate 144 #pragma mark - UIGestureRecognizerDelegate
94 145
95 -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{ 146 -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
96 [self.view endEditing:YES]; 147 [self.view endEditing:YES];
97 } 148 }
  149 +#pragma mark - UICollectionViewDelegate
  150 +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  151 + if (self.type == CNWitnessSearchDetailTypeVideo) {
  152 + NSArray *dicArray = [NSDictionary mj_keyValuesArrayWithObjectArray:self.dataSource];
  153 + [CNLiveClassifyJumpBridge openVideoPlayerVCWithCurrentIndex:[NSString stringWithFormat:@"%ld",indexPath.row] dataList:dicArray.copy];
  154 + }
  155 +}
98 #pragma mark - UICollectionViewDataSource 156 #pragma mark - UICollectionViewDataSource
99 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ 157 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
100 return self.dataSource.count; 158 return self.dataSource.count;
@@ -107,9 +165,16 @@ static NSString *const CNWitnessSearchPersonCellID = @&quot;CNWitnessSearchPersonCell @@ -107,9 +165,16 @@ static NSString *const CNWitnessSearchPersonCellID = @&quot;CNWitnessSearchPersonCell
107 }else{ 165 }else{
108 CNWitnessSearchPersonCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNWitnessSearchPersonCellID forIndexPath:indexPath]; 166 CNWitnessSearchPersonCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNWitnessSearchPersonCellID forIndexPath:indexPath];
109 cell.model = self.dataSource[indexPath.row]; 167 cell.model = self.dataSource[indexPath.row];
  168 + weakself
  169 + cell.selectPersonBlock = ^(NSDictionary * _Nonnull dic) {
  170 + [weakSelf openPersonMessage:dic];
  171 + };
110 return cell; 172 return cell;
111 } 173 }
112 } 174 }
  175 +- (void)openPersonMessage:(NSDictionary *)param{
  176 + [CNLiveClassifyJumpBridge openPersonMessage:param];
  177 +}
113 #pragma mark - CNWaterFallLayoutDelegate 178 #pragma mark - CNWaterFallLayoutDelegate
114 //通过代理得到每个item 的一个高度 179 //通过代理得到每个item 的一个高度
115 - (CGFloat)collectionViewLayout:(CNCollectionViewLayout*)layout heightAtIndexPath:(NSIndexPath*)indexPath{ 180 - (CGFloat)collectionViewLayout:(CNCollectionViewLayout*)layout heightAtIndexPath:(NSIndexPath*)indexPath{
@@ -131,6 +196,12 @@ static NSString *const CNWitnessSearchPersonCellID = @&quot;CNWitnessSearchPersonCell @@ -131,6 +196,12 @@ static NSString *const CNWitnessSearchPersonCellID = @&quot;CNWitnessSearchPersonCell
131 if (![_searchStr isEqualToString:searchStr]) { 196 if (![_searchStr isEqualToString:searchStr]) {
132 _searchStr = searchStr; 197 _searchStr = searchStr;
133 [self.dataSource removeAllObjects]; 198 [self.dataSource removeAllObjects];
  199 + if (self.type == CNWitnessSearchDetailTypeVideo) {
  200 + [self.videoIDArray removeAllObjects];
  201 + }else{
  202 + [self.personIDArray removeAllObjects];
  203 + }
  204 +
134 [self.collectionView reloadData]; 205 [self.collectionView reloadData];
135 self.page = 1; 206 self.page = 1;
136 [self requestData]; 207 [self requestData];
@@ -170,10 +241,6 @@ static NSString *const CNWitnessSearchPersonCellID = @&quot;CNWitnessSearchPersonCell @@ -170,10 +241,6 @@ static NSString *const CNWitnessSearchPersonCellID = @&quot;CNWitnessSearchPersonCell
170 weakSelf.page ++; 241 weakSelf.page ++;
171 [weakSelf requestData]; 242 [weakSelf requestData];
172 }]; 243 }];
173 -// UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {  
174 -// [weakSelf.view endEditing:YES];  
175 -// }];  
176 -// [_collectionView addGestureRecognizer:pan];  
177 } 244 }
178 return _collectionView; 245 return _collectionView;
179 } 246 }
@@ -184,6 +251,18 @@ static NSString *const CNWitnessSearchPersonCellID = @&quot;CNWitnessSearchPersonCell @@ -184,6 +251,18 @@ static NSString *const CNWitnessSearchPersonCellID = @&quot;CNWitnessSearchPersonCell
184 } 251 }
185 return _dataSource; 252 return _dataSource;
186 } 253 }
  254 +- (NSMutableArray *)personIDArray{
  255 + if (!_personIDArray) {
  256 + _personIDArray = [NSMutableArray array];
  257 + }
  258 + return _personIDArray;
  259 +}
  260 +- (NSMutableArray *)videoIDArray{
  261 + if (!_videoIDArray) {
  262 + _videoIDArray = [NSMutableArray array];
  263 + }
  264 + return _videoIDArray;
  265 +}
187 #pragma mark - JXCategoryListContentViewDelegate 266 #pragma mark - JXCategoryListContentViewDelegate
188 - (UIView *)listView{ 267 - (UIView *)listView{
189 return self.view; 268 return self.view;
Example/CNLiveVideoClassifyKit/CNLiveClassifyKitImpl.m
@@ -95,6 +95,16 @@ @@ -95,6 +95,16 @@
95 - (void)skipType:(nonnull NSString *)type to:(nonnull NSString *)to shopType:(nonnull NSString *)shopType currentVC:(nonnull UIViewController *)currentVC { 95 - (void)skipType:(nonnull NSString *)type to:(nonnull NSString *)to shopType:(nonnull NSString *)shopType currentVC:(nonnull UIViewController *)currentVC {
96 96
97 } 97 }
98 - 98 +/// 打开用户个人视频页
  99 +/// @param params 传递参数
  100 +- (void)openPersonMessage:(NSDictionary *)params{
  101 +
  102 +}
  103 +/// 打开视频播放页面
  104 +/// @param currentIndex 当前选中
  105 +/// @param dataList 视频数组
  106 +- (void)openVideoPlayerVCWithCurrentIndex:(NSString *)currentIndex dataList:(NSArray *)dataList{
  107 +
  108 +}
99 109
100 @end 110 @end