Commit 5608678ae1c1e315634978cb4143a12b348e04ea

Authored by yanglingyu
1 parent 527c8588

目击者搜索功能完成

Showing 50 changed files with 2061 additions and 14 deletions
CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/backBlack@2x.png 0 → 100644

804 Bytes

CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/backBlack@3x.png 0 → 100644

1.31 KB

CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/witness_history_delete@2x.png 0 → 100644

809 Bytes

CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/witness_history_delete@3x.png 0 → 100644

1.62 KB

CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/witness_search@2x.png 0 → 100644

1.17 KB

CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/witness_search@3x.png 0 → 100644

1.85 KB

CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/witness_search_like@2x.png 0 → 100644

993 Bytes

CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/witness_search_like@3x.png 0 → 100644

1.54 KB

CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/witness_search_play@2x.png 0 → 100644

1.81 KB

CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/witness_search_play@3x.png 0 → 100644

2.92 KB

CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/witness_search_unLike@2x.png 0 → 100644

1.32 KB

CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/witness_search_unLike@3x.png 0 → 100644

2.11 KB

CNLiveVideoClassifyKit/Classes/ClassifyCategory/Manager/CNLiveClassifyJumpBridge.h renamed to CNLiveVideoClassifyKit/Classes/Manager/CNLiveClassifyJumpBridge.h
CNLiveVideoClassifyKit/Classes/ClassifyCategory/Manager/CNLiveClassifyJumpBridge.m renamed to CNLiveVideoClassifyKit/Classes/Manager/CNLiveClassifyJumpBridge.m
CNLiveVideoClassifyKit/Classes/ClassifyCategory/Manager/CNLiveListManager.h renamed to CNLiveVideoClassifyKit/Classes/Manager/CNLiveListManager.h
... ... @@ -18,6 +18,8 @@ NS_ASSUME_NONNULL_BEGIN
18 18 - (void)firstHeaderUp:(BOOL)isUp;
19 19 //创建分类控制器
20 20 + (CNCategoryBaseViewController *)CNCategoryBaseViewController;
  21 +/// 跳转目击者搜索页
  22 ++ (void)pushWitnessSearchVC;
21 23 @end
22 24  
23 25 NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/ClassifyCategory/Manager/CNLiveListManager.m renamed to CNLiveVideoClassifyKit/Classes/Manager/CNLiveListManager.m
... ... @@ -7,6 +7,7 @@
7 7  
8 8 #import "CNLiveListManager.h"
9 9 #import "CNLiveClassifySegmentController.h"
  10 +#import "CNWitnessSearchViewController.h"
10 11  
11 12 @interface CNLiveListManager()
12 13 {
... ... @@ -29,6 +30,10 @@
29 30 {
30 31 return [[CNLiveClassifySegmentController alloc] init];
31 32 }
  33 ++ (void)pushWitnessSearchVC{
  34 + CNWitnessSearchViewController *vc = [CNWitnessSearchViewController new];
  35 + [[BaseAppDelegate sharedAppDelegate] pushViewController:vc];
  36 +}
32 37 - (void)firstHeaderUp:(BOOL)isUp
33 38 {
34 39 if (isUp&& !self.isHiddenFirst) {
... ...
CNLiveVideoClassifyKit/Classes/ClassifyCategory/Manager/CNLiveVideoClassifyProtocol.h renamed to CNLiveVideoClassifyKit/Classes/Manager/CNLiveVideoClassifyProtocol.h
CNLiveVideoClassifyKit/Classes/ClassifyCategory/Manager/CNWebRedirectHandle.h renamed to CNLiveVideoClassifyKit/Classes/Manager/CNWebRedirectHandle.h
CNLiveVideoClassifyKit/Classes/ClassifyCategory/Manager/CNWebRedirectHandle.m renamed to CNLiveVideoClassifyKit/Classes/Manager/CNWebRedirectHandle.m
CNLiveVideoClassifyKit/Classes/SearchView/Model/CNWitnessSearchModel.h 0 → 100644
  1 +//
  2 +// CNWitnessSearchModel.h
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/16.
  6 +//
  7 +
  8 +#import <Foundation/Foundation.h>
  9 +
  10 +NS_ASSUME_NONNULL_BEGIN
  11 +
  12 +@interface CNWitnessSearchModel : NSObject
  13 +@property (nonatomic, copy)NSString *title;
  14 +@property (nonatomic, strong)NSArray <NSString *>* list;
  15 +@end
  16 +
  17 +@interface CNWitnessHotModel : NSObject
  18 +@property (nonatomic, assign)NSInteger score;
  19 +@property (nonatomic, copy)NSString *value;
  20 +@end
  21 +@interface CNPersonMessageModel : NSObject
  22 +/// 头像
  23 +@property (nonatomic, copy)NSString *face;
  24 +@property (nonatomic, copy)NSString *id;
  25 +@property (nonatomic, copy)NSString *name;
  26 +@property (nonatomic, copy)NSString *type;
  27 +@property (nonatomic, copy)NSString *desc;
  28 +@property (nonatomic, assign)BOOL focused;
  29 +@property (nonatomic, strong)NSDictionary *vip;
  30 +@property (nonatomic, assign)NSInteger fansNum;
  31 +@property (nonatomic, assign)NSInteger focusNum;
  32 +@end
  33 +@interface CNToolMessageModel : NSObject
  34 +@property (nonatomic, assign)NSInteger commentsNum;
  35 +@property (nonatomic, strong)NSArray * commentList;
  36 +@property (nonatomic, copy)NSString *collectioned;
  37 +@property (nonatomic, strong)NSArray * likeList;
  38 +@property (nonatomic, assign)BOOL liked;
  39 +@property (nonatomic, assign)NSInteger likesNum;
  40 +@property (nonatomic, assign)NSInteger voteNum;
  41 +@property (nonatomic, assign)NSInteger shareNum;
  42 +@property (nonatomic, assign)NSInteger playNum;
  43 +@property (nonatomic, assign)NSInteger collectionNum;
  44 +@property (nonatomic, copy)NSString *sort;
  45 +@property (nonatomic, copy)NSString *voted;
  46 +@end
  47 +@interface CNWitnessSearchDetailModel : NSObject
  48 +@property (nonatomic, copy)NSString *title;
  49 +@property (nonatomic, copy)NSString *subTitle;
  50 +@property (nonatomic, copy)NSString *poster;
  51 +@property (nonatomic, copy)NSString *model;
  52 +@property (nonatomic, copy)NSString *thirdUrl;
  53 +@property (nonatomic, copy)NSString *colours;
  54 +@property (nonatomic, copy)NSString *address;
  55 +@property (nonatomic, copy)NSString *contentId;
  56 +@property (nonatomic, copy)NSString *source;
  57 +@property (nonatomic, copy)NSString *pid;
  58 +@property (nonatomic, copy)NSString *witnessId;
  59 +@property (nonatomic, copy)NSString *videoUrl;
  60 +@property (nonatomic, copy)NSString *duration;
  61 +@property (nonatomic, copy)NSString *number;
  62 +@property (nonatomic, copy)NSString *goods;
  63 +@property (nonatomic, strong)CNPersonMessageModel *icon;
  64 +@property (nonatomic, assign)NSInteger time;
  65 +@property (nonatomic, copy)NSString *tagId;
  66 +@property (nonatomic, copy)NSString *tagName;
  67 +@property (nonatomic, strong)CNToolMessageModel *tool;
  68 +@property (nonatomic, copy)NSString *activityEndTime;
  69 +@property (nonatomic, copy)NSString *h5Url;
  70 +@property (nonatomic, copy)NSString *shareUrl;
  71 +@property (nonatomic, copy)NSString *album;
  72 +/// 是否横屏
  73 +@property (nonatomic, assign)NSInteger isHorizontalScreen;
  74 +@property (nonatomic, assign)NSInteger videoShowType;
  75 +@end
  76 +
  77 +NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/SearchView/Model/CNWitnessSearchModel.m 0 → 100644
  1 +//
  2 +// CNWitnessSearchModel.m
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/16.
  6 +//
  7 +
  8 +#import "CNWitnessSearchModel.h"
  9 +
  10 +@implementation CNWitnessSearchModel
  11 +
  12 +@end
  13 +
  14 +@implementation CNWitnessHotModel
  15 +
  16 +@end
  17 +@implementation CNPersonMessageModel
  18 +
  19 +@end
  20 +@implementation CNToolMessageModel
  21 +
  22 +@end
  23 +@implementation CNWitnessSearchDetailModel
  24 +
  25 +@end
... ...
CNLiveVideoClassifyKit/Classes/SearchView/Present/CNWitnessSearchPresent.h 0 → 100644
  1 +//
  2 +// CNWitnessSearchPresent.h
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/16.
  6 +//
  7 +
  8 +#import <Foundation/Foundation.h>
  9 +
  10 +
  11 +@interface CNWitnessSearchPresent : NSObject
  12 +/// 搜索热词
  13 +/// @param response 返回
  14 ++ (void)requestHotListResponse:(void (^)(NSArray *hots, NSString *errorString))response;
  15 +
  16 +/// 存储搜索历史
  17 +/// @param data 数据
  18 ++ (void)saveSearchHistories:(NSMutableArray *)data;
  19 +
  20 +/// 读取存储数据
  21 ++ (NSMutableArray *)readSearchHistories;
  22 +
  23 +/// 数据整合
  24 +/// @param hots 热搜
  25 +/// @param isShowAll 是否展示全部历史搜索
  26 +/// @param histories 历史搜索
  27 ++ (NSArray *)dealHots:(NSArray *)hots isShowAll:(BOOL)isShowAll allHistories:(NSArray *)histories;
  28 +/// UGC视频搜索结果
  29 +/// @param ts 最后一条数据时间戳
  30 +/// @param keyword 搜索关键词
  31 +/// @param page 页数
  32 +/// @param responseBlock 返回
  33 ++ (void)requestSearchVideoListWithTS:(NSString *)ts searchType:(NSInteger)searchType keyword:(NSString *)keyword page:(NSInteger)page responseBlock:(void (^)(NSArray *dataArray ,BOOL isLastPage, NSString *error))responseBlock;
  34 +/// 视频点赞
  35 +/// @param pid 未知
  36 +/// @param contentSid 未知
  37 +/// @param support @“0”取消赞 “1”点赞
  38 +/// @param contentTag 未知
  39 +/// @param responseBlock 返回
  40 ++ (void)requestWitnessLikeMomentWithPid:(NSString *)pid ContentSid:(NSString *)contentSid support:(NSString *)support contentTag:(NSString *)contentTag responseBlock:(void (^)(BOOL succeed))responseBlock;
  41 +/// 对显示的用户进行关注
  42 +/// @param isFocus 是否关注
  43 +/// @param toSid 显示sid
  44 +/// @param responseBlock 完成回调
  45 ++(void)requestContentGetContentHeaderFocusType:(BOOL)isFocus ToSid:(NSString *)toSid responseBlock:(void (^)(BOOL succeed))responseBlock;
  46 +@end
  47 +
  48 +
... ...
CNLiveVideoClassifyKit/Classes/SearchView/Present/CNWitnessSearchPresent.m 0 → 100644
  1 +//
  2 +// CNWitnessSearchPresent.m
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/16.
  6 +//
  7 +
  8 +#import "CNWitnessSearchPresent.h"
  9 +#import "CNWitnessSearchModel.h"
  10 +
  11 +@implementation CNWitnessSearchPresent
  12 ++ (void)requestHotListResponse:(void (^)(NSArray * _Nonnull, NSString * _Nonnull))response{
  13 + [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  14 + [CNLiveNetworking setupShowDataResult:YES];
  15 + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:cn_API_Classify(@"/ugcApi/getHotList") Param:@{} CacheType:CNLiveNetworkCacheTypeCacheNetwork CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  16 + NSMutableArray *listArr = [NSMutableArray array];
  17 + if (responseObject && [responseObject isKindOfClass:[NSArray class]]) {
  18 + NSArray *modelArray = [CNWitnessHotModel mj_objectArrayWithKeyValuesArray:responseObject];
  19 + for (CNWitnessHotModel *model in modelArray) {
  20 + [listArr addObject:model.value];
  21 + }
  22 + }
  23 + if (response) {
  24 + response(listArr.copy, error.localizedDescription);
  25 + }
  26 + }];
  27 +}
  28 ++ (void)saveSearchHistories:(NSMutableArray *)data
  29 +{
  30 + NSString *Path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
  31 + NSString *filePath = [Path stringByAppendingPathComponent:@"WitnessSearchHistories.data"];
  32 + [NSKeyedArchiver archiveRootObject:data toFile:filePath];
  33 +}
  34 ++ (NSMutableArray *)readSearchHistories{
  35 + NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
  36 + NSString *filePath = [path stringByAppendingPathComponent:@"WitnessSearchHistories.data"];
  37 + //解档
  38 + NSMutableArray *data = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
  39 + return data;
  40 +}
  41 ++ (NSArray *)dealHots:(NSArray *)hots isShowAll:(BOOL)isShowAll allHistories:(NSArray *)histories{
  42 + if (!isShowAll&&histories.count >2) {
  43 + histories = [histories subarrayWithRange:NSMakeRange(0, 2)];
  44 + }
  45 + NSArray *dataArray = @[
  46 + @{
  47 + @"title":@"",
  48 + @"list":histories
  49 + },
  50 + @{
  51 + @"title":@"热门搜索",
  52 + @"list":hots?hots:@[]
  53 + }
  54 + ];
  55 + NSArray *modelArray = [CNWitnessSearchModel mj_objectArrayWithKeyValuesArray:dataArray];
  56 + return modelArray;
  57 +}
  58 +
  59 ++ (void)requestSearchVideoListWithTS:(NSString *)ts searchType:(NSInteger)searchType keyword:(NSString *)keyword page:(NSInteger)page responseBlock:(void (^)(NSArray *, BOOL, NSString *))responseBlock{
  60 + NSDictionary *params = @{
  61 + @"ts":ts?ts:@"",
  62 + @"userId":CNUserShareModelUid,
  63 + @"keyword":keyword?keyword:@"",
  64 + @"searchType":@(searchType),
  65 + @"type":@"1",
  66 + @"page":@(page),
  67 + @"pageSize":@(10)
  68 + };
  69 + [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  70 + [CNLiveNetworking setupShowDataResult:YES];
  71 + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:cn_API_Classify(@"/ugcApi/ugcVideoList") Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  72 + BOOL lastPage = NO;
  73 + NSArray *dataArr = nil;
  74 + if (responseObject&& [responseObject isKindOfClass:[NSDictionary class]]) {
  75 + NSArray *array = responseObject[@"list"];
  76 + if (array &&[array isKindOfClass:[NSArray class]]) {
  77 + if (array.count == 0) {
  78 + lastPage = YES;
  79 + }else{
  80 + if (searchType == 1) {
  81 + dataArr = [CNWitnessSearchDetailModel mj_objectArrayWithKeyValuesArray:array];
  82 + }else{
  83 + dataArr = [CNPersonMessageModel mj_objectArrayWithKeyValuesArray:array];
  84 + }
  85 +
  86 + }
  87 + }
  88 + }
  89 + if (responseBlock) {
  90 + responseBlock(dataArr,lastPage ,error.localizedDescription);
  91 + }
  92 + }];
  93 +
  94 +}
  95 ++ (void)requestWitnessLikeMomentWithPid:(NSString *)pid ContentSid:(NSString *)contentSid support:(NSString *)support contentTag:(NSString *)contentTag responseBlock:(void (^)(BOOL ))responseBlock{
  96 + NSDictionary *params = @{@"contentId":pid?pid:@"",
  97 + @"appId":AppId,
  98 + @"sid":CNLiveStringIsEmpty(CNUserShareModel.uid)? @"":CNUserShareModel.uid,
  99 + @"contentTag":contentTag?contentTag:@"",
  100 + @"contentSid":contentSid?contentSid:@"",
  101 + @"support":support,
  102 + @"isRank":@"false"
  103 + };
  104 + [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  105 + [CNLiveNetworking setupShowDataResult:NO];
  106 +
  107 + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNGetWitnessFavoriteMomentUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  108 + if (!error) {
  109 + if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
  110 + NSString *errorCode = [NSString stringWithFormat:@"%@",responseObject[@"errorCode"]];
  111 + NSString *errorMessage = responseObject[@"errorMessage"];
  112 + if ([errorCode isEqualToString:@"0"]) {
  113 + !responseBlock?:responseBlock(YES);
  114 + }else {
  115 + [QMUITips showWithText:errorMessage inView:AppKeyWindow hideAfterDelay:1.5f];
  116 + !responseBlock?:responseBlock(NO);;
  117 + }
  118 + }else{
  119 + [QMUITips showWithText:error.localizedDescription inView:AppKeyWindow hideAfterDelay:1.5f];
  120 + !responseBlock?:responseBlock(NO);;
  121 + }
  122 +
  123 + }else{
  124 + !responseBlock?:responseBlock(NO);;
  125 + }
  126 +
  127 + }];
  128 +
  129 +}
  130 +/// 对显示的用户进行关注
  131 +/// @param isFocus 是否关注
  132 +/// @param toSid 显示sid
  133 +/// @param responseBlock 完成回调
  134 ++(void)requestContentGetContentHeaderFocusType:(BOOL)isFocus ToSid:(NSString *)toSid responseBlock:(void (^)(BOOL ))responseBlock
  135 +{
  136 + NSDictionary * dict = @{
  137 + @"toSid":toSid,
  138 + @"type":isFocus?@"focus":@"cancelFollow"
  139 + };
  140 + [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  141 + [CNLiveNetworking setupShowDataResult:NO];
  142 + [CNLiveNetworking setupShowResult:YES];
  143 + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNGetWitnessFollowsContent Param:dict CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  144 + if (!error) {
  145 + if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
  146 + NSString *errorCode = [NSString stringWithFormat:@"%@",responseObject[@"errorCode"]];
  147 + NSString *errorMessage = responseObject[@"errorMessage"];
  148 + if ([errorCode isEqualToString:@"0"]) {
  149 + !responseBlock?:responseBlock(YES);
  150 + }else {
  151 + [QMUITips showWithText:errorMessage inView:AppKeyWindow hideAfterDelay:1.5f];
  152 + !responseBlock?:responseBlock(NO);;
  153 + }
  154 + }else{
  155 + [QMUITips showWithText:error.localizedDescription inView:AppKeyWindow hideAfterDelay:1.5f];
  156 + !responseBlock?:responseBlock(NO);;
  157 + }
  158 +
  159 + }else{
  160 + !responseBlock?:responseBlock(NO);;
  161 + }
  162 + }];
  163 +}
  164 +
  165 +@end
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNCollectionViewLayout.h 0 → 100644
  1 +//
  2 +// CNCollectionViewLayout.h
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/17.
  6 +//
  7 +
  8 +#import <UIKit/UIKit.h>
  9 +
  10 +@protocol CNWaterFallLayoutDelegate;
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNCollectionViewLayout : UICollectionViewLayout
  14 +@property(nonatomic,assign)int colCount;//列数
  15 +@property(nonatomic,assign)CGFloat colSpace;//列间距
  16 +@property(nonatomic,assign)CGFloat lineSpace;//行间距
  17 +@property(nonatomic,assign)UIEdgeInsets sectionInsets;
  18 +@property(nonatomic,weak) id <CNWaterFallLayoutDelegate> delegate;
  19 +
  20 +@end
  21 +
  22 +NS_ASSUME_NONNULL_END
  23 +@protocol CNWaterFallLayoutDelegate <NSObject>
  24 +
  25 +@required
  26 +//通过代理得到每个item 的一个高度
  27 +- (CGFloat)collectionViewLayout:(CNCollectionViewLayout *_Nonnull)layout heightAtIndexPath:(NSIndexPath*_Nonnull)indexPath;
  28 +
  29 +@end
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNCollectionViewLayout.m 0 → 100644
  1 +//
  2 +// CNCollectionViewLayout.m
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/17.
  6 +//
  7 +
  8 +#import "CNCollectionViewLayout.h"
  9 +
  10 +@interface CNCollectionViewLayout ()
  11 +
  12 +@property (nonatomic, strong)NSMutableDictionary *maxDic;//储存列的长度
  13 +
  14 +@end
  15 +
  16 +@implementation CNCollectionViewLayout
  17 +
  18 +- (instancetype)init{
  19 + if (self = [super init]) {
  20 + self.maxDic = [NSMutableDictionary dictionary];
  21 + }
  22 + return self;
  23 +}
  24 +- (void)prepareLayout{
  25 + [super prepareLayout];
  26 +}
  27 +/**
  28 + * 决定collectionview能滑动的范围
  29 + */
  30 +- (CGSize)collectionViewContentSize{
  31 + __block NSString *maxCol = @"0";
  32 + //找到最长的列
  33 + [self.maxDic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
  34 + if ([obj floatValue] > [self.maxDic[maxCol] floatValue]) {
  35 + maxCol = key;
  36 + }
  37 + }];
  38 + CGFloat maxY = [self.maxDic[maxCol] floatValue]+self.lineSpace;
  39 + return CGSizeMake(0, maxY) ;
  40 +}
  41 +/**
  42 + * 布局layout
  43 + */
  44 +- (nullable NSArray<__kindof UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect{
  45 + for (int i = 0; i < self.colCount; i ++) {
  46 + NSString *key = [NSString stringWithFormat:@"%d",i];
  47 + self.maxDic[key] = @0;
  48 + }
  49 +
  50 + NSMutableArray *arr = [NSMutableArray array];
  51 + int count = (int)[self.collectionView numberOfItemsInSection:0];
  52 +
  53 + for (int i = 0 ; i < count ; i ++) {
  54 + UICollectionViewLayoutAttributes *att = [self layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];
  55 + [arr addObject:att];
  56 + }
  57 +
  58 + return arr;
  59 +}
  60 +/**
  61 + 决定了每个item的位置,大小
  62 + */
  63 +- (nullable UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath{
  64 + __block NSString *minCol = @"0";
  65 + [self.maxDic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
  66 + if ([obj floatValue] < [self.maxDic[minCol] floatValue] ) {
  67 + minCol = key;
  68 + }
  69 + }];
  70 + int col = [minCol intValue];
  71 + CGFloat nowY = [self.maxDic[minCol] floatValue];//当前列的y值
  72 +
  73 + CGFloat itemW = (self.collectionView.frame.size.width - self.sectionInsets.left - self.sectionInsets.right - self.colSpace*(self.colCount - 1))/(self.colCount);
  74 + CGFloat itemH = 0 ;
  75 + if ([self.delegate respondsToSelector:@selector(collectionViewLayout:heightAtIndexPath:)]) {
  76 + itemH = [self.delegate collectionViewLayout:self heightAtIndexPath:indexPath];
  77 + }
  78 + CGFloat x = self.sectionInsets.left + (itemW + self.colSpace) * col;
  79 + CGFloat space = 0 ;
  80 +
  81 + if (indexPath.row < self.colCount) {//第一行的时候y值
  82 + space = self.sectionInsets.top;
  83 + }else {
  84 + space = self.lineSpace;
  85 + }
  86 + CGFloat y = nowY + space;
  87 +
  88 + self.maxDic[minCol] = @(y + itemH);//更新此列的y值
  89 +
  90 + UICollectionViewLayoutAttributes *attributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
  91 + attributes.frame = CGRectMake(x, y, itemW, itemH);
  92 +
  93 + return attributes;
  94 +}
  95 +@end
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessSearchCell.h 0 → 100644
  1 +//
  2 +// CNWitnessSearchCell.h
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/16.
  6 +//
  7 +
  8 +#import <UIKit/UIKit.h>
  9 +
  10 +NS_ASSUME_NONNULL_BEGIN
  11 +
  12 +@interface CNWitnessSearchCell : UICollectionViewCell
  13 +@property (nonatomic, copy)void (^deleteBlock)(NSString *str);
  14 +/// 赋值
  15 +/// @param str 字符串
  16 +/// @param section 当前section
  17 +- (void)setString:(NSString *)str section:(NSInteger)section;
  18 +@end
  19 +
  20 +NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessSearchCell.m 0 → 100644
  1 +//
  2 +// CNWitnessSearchCell.m
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/16.
  6 +//
  7 +
  8 +#import "CNWitnessSearchCell.h"
  9 +@interface CNWitnessSearchCell()
  10 +@property (nonatomic, strong)UILabel *textLabel;
  11 +@property (nonatomic, strong)UIView *lineView;
  12 +@property (nonatomic, strong)UIButton *delectBtn;
  13 +@end
  14 +
  15 +@implementation CNWitnessSearchCell
  16 +- (instancetype)initWithFrame:(CGRect)frame
  17 +{
  18 + if (self = [super initWithFrame:frame]) {
  19 + [self.contentView addSubview:self.textLabel];
  20 + [self.contentView addSubview:self.lineView];
  21 + [self.contentView addSubview:self.delectBtn];
  22 + [self.textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  23 + make.centerY.left.equalTo(self);
  24 + make.right.equalTo(self.delectBtn.mas_left);
  25 + }];
  26 + [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  27 + make.right.bottom.left.equalTo(self);
  28 + make.height.mas_equalTo(0.5);
  29 + }];
  30 + [self.delectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  31 + make.right.centerY.equalTo(self);
  32 + make.width.height.mas_equalTo(11.5);
  33 + }];
  34 + }
  35 + return self;
  36 +}
  37 +- (void)deleteBtnClick{
  38 + if (self.deleteBlock) {
  39 + self.deleteBlock(self.textLabel.text);
  40 + }
  41 +}
  42 +- (void)setString:(NSString *)str section:(NSInteger)section{
  43 + self.textLabel.text = str;
  44 + if (section == 0) {
  45 + self.lineView.hidden = NO;
  46 + self.delectBtn.hidden = NO;
  47 + }else{
  48 + self.lineView.hidden = YES;
  49 + self.delectBtn.hidden = YES;
  50 + }
  51 +}
  52 +#pragma mark - Getting
  53 +- (UILabel *)textLabel
  54 +{
  55 + if (!_textLabel) {
  56 + _textLabel = [[UILabel alloc] init];
  57 + _textLabel.font = UIFontMake(14);
  58 + _textLabel.textColor = UIColorHex(#333333);
  59 + _textLabel.textAlignment = NSTextAlignmentLeft;
  60 + }
  61 + return _textLabel;
  62 +}
  63 +- (UIView *)lineView{
  64 + if (!_lineView) {
  65 + _lineView = [[UIView alloc] init];
  66 + _lineView.backgroundColor = UIColorHex(#F2F2F2);
  67 + }
  68 + return _lineView;
  69 +}
  70 +- (UIButton *)delectBtn{
  71 + if (!_delectBtn) {
  72 + _delectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  73 + _delectBtn.touchAreaInsets = UIEdgeInsetsMake(-5, -5, -5, -5);
  74 + [_delectBtn setImage:[UIImage loadBundleImage:@"witness_history_delete"] forState:UIControlStateNormal];
  75 + [_delectBtn addTarget:self action:@selector(deleteBtnClick) forControlEvents:UIControlEventTouchUpInside];
  76 + }
  77 + return _delectBtn;
  78 +}
  79 +@end
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessSearchFooterView.h 0 → 100644
  1 +//
  2 +// CNWitnessSearchFooterView.h
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/16.
  6 +//
  7 +
  8 +#import <UIKit/UIKit.h>
  9 +
  10 +NS_ASSUME_NONNULL_BEGIN
  11 +
  12 +@interface CNWitnessSearchFooterView : UICollectionReusableView
  13 +@property (nonatomic, assign)BOOL isallShow;
  14 +@property (nonatomic, copy)void (^organizaBtnBlock)(NSInteger index);
  15 +@end
  16 +
  17 +NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessSearchFooterView.m 0 → 100644
  1 +//
  2 +// CNWitnessSearchFooterView.m
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/16.
  6 +//
  7 +
  8 +#import "CNWitnessSearchFooterView.h"
  9 +@interface CNWitnessSearchFooterView ()
  10 +@property (nonatomic, strong)UIButton *organizeHistoryBtn;
  11 +@end
  12 +
  13 +@implementation CNWitnessSearchFooterView
  14 +-(instancetype)initWithFrame:(CGRect)frame{
  15 + if (self = [super initWithFrame:frame]) {
  16 + self.backgroundColor = UIColorWhite;
  17 + [self addSubview:self.organizeHistoryBtn];
  18 + [self.organizeHistoryBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  19 + make.left.equalTo(self).offset(15);
  20 + make.right.equalTo(self).offset(-15);
  21 + make.centerY.equalTo(self);
  22 + make.height.mas_equalTo(39);
  23 + }];
  24 + }
  25 + return self;
  26 +}
  27 +- (void)organizeHistoryBtnAction:(UIButton *)sender
  28 +{
  29 + if (self.organizaBtnBlock) {
  30 + self.organizaBtnBlock(sender.tag - 1001);
  31 + }
  32 +}
  33 +#pragma mark - Setting
  34 +- (void)setIsallShow:(BOOL)isallShow
  35 +{
  36 + _isallShow = isallShow;
  37 + if (isallShow) {
  38 + self.organizeHistoryBtn.tag = 1002;
  39 + [self.organizeHistoryBtn setTitle:@"清除全部搜索记录" forState:UIControlStateNormal];
  40 + }else{
  41 + self.organizeHistoryBtn.tag = 1001;
  42 + [self.organizeHistoryBtn setTitle:@"全部搜索记录" forState:UIControlStateNormal];
  43 + }
  44 +}
  45 +#pragma mark - Getting
  46 +- (UIButton *)organizeHistoryBtn
  47 +{
  48 + if (!_organizeHistoryBtn) {
  49 + _organizeHistoryBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  50 + _organizeHistoryBtn.titleLabel.font = UIFontMake(14);
  51 + [_organizeHistoryBtn setTitleColor:UIColorHex(#F5A623) forState:UIControlStateNormal];
  52 + _organizeHistoryBtn.backgroundColor = RGBA(245, 166, 35, 0.06);
  53 + [_organizeHistoryBtn addTarget:self action:@selector(organizeHistoryBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  54 + UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, kScreenWidth - 30, 39) cornerRadius:6];
  55 + CAShapeLayer *maskLayer = [CAShapeLayer layer];
  56 + maskLayer.path = path.CGPath;
  57 + _organizeHistoryBtn.layer.mask = maskLayer;
  58 + }
  59 + return _organizeHistoryBtn;
  60 +}
  61 +@end
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessSearchHeaderView.h 0 → 100644
  1 +//
  2 +// CNWitnessSearchHeaderView.h
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/16.
  6 +//
  7 +
  8 +#import <UIKit/UIKit.h>
  9 +
  10 +NS_ASSUME_NONNULL_BEGIN
  11 +
  12 +@interface CNWitnessSearchHeaderView : UICollectionReusableView
  13 +@property (nonatomic, strong)NSString *titleStr;
  14 +@end
  15 +
  16 +NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessSearchHeaderView.m 0 → 100644
  1 +//
  2 +// CNWitnessSearchHeaderView.m
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/16.
  6 +//
  7 +
  8 +#import "CNWitnessSearchHeaderView.h"
  9 +
  10 +@interface CNWitnessSearchHeaderView ()
  11 +@property (nonatomic, strong)UILabel *titleLabel;
  12 +@end
  13 +
  14 +@implementation CNWitnessSearchHeaderView
  15 +- (instancetype)initWithFrame:(CGRect)frame
  16 +{
  17 + if (self = [super initWithFrame:frame]) {
  18 + [self addSubview:self.titleLabel];
  19 + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  20 + make.left.equalTo(self).offset(15);
  21 + make.centerY.equalTo(self);
  22 + }];
  23 + }
  24 + return self;
  25 +}
  26 +- (void)setTitleStr:(NSString *)titleStr{
  27 + _titleLabel.text = titleStr;
  28 + self.titleLabel.text = titleStr;
  29 +}
  30 +- (UILabel *)titleLabel{
  31 + if (!_titleLabel) {
  32 + _titleLabel = [[UILabel alloc] init];
  33 + _titleLabel.textColor = UIColorHex(#333333);
  34 + _titleLabel.font = UIFontMake(16);
  35 + _titleLabel.textAlignment = NSTextAlignmentLeft;
  36 + }
  37 + return _titleLabel;
  38 +}
  39 +@end
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessSearchPersonCell.h 0 → 100644
  1 +//
  2 +// CNWitnessSearchPersonCell.h
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/17.
  6 +//
  7 +
  8 +#import <UIKit/UIKit.h>
  9 +@class CNPersonMessageModel;
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNWitnessSearchPersonCell : UICollectionViewCell
  14 +@property (nonatomic, strong)CNPersonMessageModel *model;
  15 +@end
  16 +
  17 +NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessSearchPersonCell.m 0 → 100644
  1 +//
  2 +// CNWitnessSearchPersonCell.m
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/17.
  6 +//
  7 +
  8 +#import "CNWitnessSearchPersonCell.h"
  9 +#import "CNWitnessSearchModel.h"
  10 +#import "CNWitnessSearchPresent.h"
  11 +
  12 +@interface CNWitnessSearchPersonCell ()
  13 +@property (nonatomic, strong)UIImageView *logoImage;
  14 +@property (nonatomic, strong)UILabel *nameLabel;
  15 +@property (nonatomic, strong)UILabel *fansNumLabel;
  16 +@property (nonatomic, strong)QMUIButton *focusedBtn;
  17 +@property (nonatomic, strong)UIView *lineView;
  18 +@end
  19 +
  20 +@implementation CNWitnessSearchPersonCell
  21 +- (instancetype)initWithFrame:(CGRect)frame{
  22 + if (self = [super initWithFrame:frame]) {
  23 + [self.contentView addSubview:self.logoImage];
  24 + [self.contentView addSubview:self.nameLabel];
  25 + [self.contentView addSubview:self.fansNumLabel];
  26 + [self.contentView addSubview:self.focusedBtn];
  27 + [self.contentView addSubview:self.lineView];
  28 + [self.logoImage mas_makeConstraints:^(MASConstraintMaker *make) {
  29 + make.left.equalTo(self);
  30 + make.centerY.equalTo(self);
  31 + make.width.height.mas_equalTo(50);
  32 + }];
  33 + [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  34 + make.top.equalTo(self.logoImage).offset(4);
  35 + make.left.equalTo(self.logoImage.mas_right).offset(15);
  36 + }];
  37 + [self.fansNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  38 + make.top.equalTo(self.nameLabel.mas_bottom).offset(5);
  39 + make.left.equalTo(self.logoImage.mas_right).offset(15);
  40 + }];
  41 + [self.focusedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  42 + make.right.equalTo(self).offset(-3);
  43 + make.centerY.equalTo(self);
  44 + make.width.mas_equalTo(70);
  45 + make.height.mas_equalTo(26);
  46 + }];
  47 + [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  48 + make.left.bottom.right.equalTo(self);
  49 + make.height.mas_equalTo(0.5);
  50 + }];
  51 + }
  52 + return self;
  53 +}
  54 +- (void)focusedBtnClick:(QMUIButton *)sender{
  55 + weakself
  56 + [QMUITips showLoadingInView:self.contentView];
  57 + [CNWitnessSearchPresent requestContentGetContentHeaderFocusType:!sender.selected ToSid:_model.id responseBlock:^(BOOL succeed) {
  58 + [QMUITips hideAllTips];
  59 + if (succeed) {
  60 + if (sender.selected) {
  61 + sender.selected = NO;
  62 + weakSelf.model.fansNum --;
  63 + self.focusedBtn.layer.borderWidth = 0;
  64 + }else{
  65 + sender.selected = YES;
  66 + weakSelf.model.fansNum ++;
  67 + self.focusedBtn.layer.borderWidth = 0.5;
  68 + }
  69 + weakSelf.model.focused = sender.selected;
  70 + weakSelf.fansNumLabel.text = [NSString stringWithFormat:@"粉丝%ld",weakSelf.model.fansNum];
  71 + }
  72 + }];
  73 +}
  74 +#pragma mark - Setting
  75 +- (void)setModel:(CNPersonMessageModel *)model
  76 +{
  77 + _model = model;
  78 + [self.logoImage sd_setImageWithURL:[NSURL URLWithString:model.face] placeholderImage:[UIImage loadBundleImage:@"default _icon_bg"]];
  79 + self.nameLabel.text = model.name;
  80 + self.fansNumLabel.text = [NSString stringWithFormat:@"粉丝%ld",model.fansNum];
  81 + self.focusedBtn.selected = model.focused;
  82 + if (model.focused) {
  83 + self.focusedBtn.layer.borderWidth = 0.5;
  84 + }else{
  85 + self.focusedBtn.layer.borderWidth = 0;
  86 + }
  87 + self.focusedBtn.hidden = [CNUserShareModelUid isEqualToString:model.id];
  88 +}
  89 +#pragma mark - Getting
  90 +- (UIImageView *)logoImage
  91 +{
  92 + if (!_logoImage) {
  93 + _logoImage = [[UIImageView alloc] init];
  94 + _logoImage.contentMode = UIViewContentModeScaleAspectFill;
  95 + UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 50, 50) cornerRadius:25];
  96 + CAShapeLayer *maskLayer = [CAShapeLayer layer];
  97 + maskLayer.path = path.CGPath;
  98 + _logoImage.layer.mask = maskLayer;
  99 + }
  100 + return _logoImage;
  101 +}
  102 +- (UILabel *)nameLabel
  103 +{
  104 + if (!_nameLabel) {
  105 + _nameLabel = [[UILabel alloc] init];
  106 + _nameLabel.textColor = UIColorHex(#333333);
  107 + _nameLabel.font = UIFontMake(15);
  108 + _nameLabel.textAlignment = NSTextAlignmentLeft;
  109 + }
  110 + return _nameLabel;
  111 +}
  112 +- (UILabel *)fansNumLabel
  113 +{
  114 + if (!_fansNumLabel) {
  115 + _fansNumLabel = [[UILabel alloc] init];
  116 + _fansNumLabel.textColor = UIColorHex(#999999);
  117 + _fansNumLabel.font = UIFontMake(12);
  118 + _fansNumLabel.textAlignment = NSTextAlignmentLeft;
  119 + }
  120 + return _fansNumLabel;
  121 +}
  122 +- (QMUIButton *)focusedBtn
  123 +{
  124 + if (!_focusedBtn) {
  125 + _focusedBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
  126 + [_focusedBtn setTitle:@"+ 关注" forState:UIControlStateNormal];
  127 + [_focusedBtn setTitleColor:UIColorWhite forState:UIControlStateNormal];
  128 + [_focusedBtn setBackgroundImage:[UIImage imageWithColor:UIColorHex(#F5A623)] forState:UIControlStateNormal];
  129 + [_focusedBtn setTitle:@"已关注" forState:UIControlStateSelected];
  130 + [_focusedBtn setTitleColor:UIColorHex(#999999) forState:UIControlStateSelected];
  131 + [_focusedBtn setBackgroundImage:[UIImage imageWithColor:UIColorWhite] forState:UIControlStateSelected];
  132 + _focusedBtn.titleLabel.font = UIFontMake(13);
  133 + _focusedBtn.spacingBetweenImageAndTitle = 5;
  134 + _focusedBtn.layer.cornerRadius = 14.5;
  135 + _focusedBtn.clipsToBounds = YES;
  136 +// _likeBtn.touchAreaInsets = UIEdgeInsetsMake(-5, -5, -5, -5);
  137 + [_focusedBtn addTarget:self action:@selector(focusedBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  138 + }
  139 + return _focusedBtn;
  140 +}
  141 +- (UIView *)lineView{
  142 + if (!_lineView) {
  143 + _lineView = [[UIView alloc] init];
  144 + _lineView.backgroundColor = UIColorHex(#F2F2F2);
  145 + }
  146 + return _lineView;
  147 +}
  148 +@end
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessSearchVideoCell.h 0 → 100644
  1 +//
  2 +// CNWitnessSearchVideoCell.h
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/17.
  6 +//
  7 +
  8 +#import <UIKit/UIKit.h>
  9 +@class CNWitnessSearchDetailModel;
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNWitnessSearchVideoCell : UICollectionViewCell
  14 +@property (nonatomic, strong)CNWitnessSearchDetailModel *model;
  15 +@end
  16 +
  17 +NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessSearchVideoCell.m 0 → 100644
  1 +//
  2 +// CNWitnessSearchVideoCell.m
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/17.
  6 +//
  7 +
  8 +#import "CNWitnessSearchVideoCell.h"
  9 +#import "CNWitnessSearchModel.h"
  10 +#import "CNWitnessSearchPresent.h"
  11 +
  12 +@interface CNWitnessSearchVideoCell ()
  13 +@property (nonatomic, strong)UIView *bgView;
  14 +@property (nonatomic, strong)UIImageView *videoImage;
  15 +@property (nonatomic, strong)UIImageView *playImage;
  16 +@property (nonatomic, strong)UILabel *titleLabel;
  17 +@property (nonatomic, strong)UIImageView *logoImage;
  18 +@property (nonatomic, strong)UILabel *nameLabel;
  19 +@property (nonatomic, strong)QMUIButton *likeBtn;
  20 +@end
  21 +
  22 +@implementation CNWitnessSearchVideoCell
  23 +- (instancetype)initWithFrame:(CGRect)frame{
  24 + if (self = [super initWithFrame:frame]) {
  25 + [self.contentView addSubview:self.bgView];
  26 + [self.bgView addSubview:self.videoImage];
  27 + [self.videoImage addSubview:self.playImage];
  28 + [self.bgView addSubview:self.titleLabel];
  29 + [self.bgView addSubview:self.logoImage];
  30 + [self.bgView addSubview:self.nameLabel];
  31 + [self.bgView addSubview:self.likeBtn];
  32 + [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  33 + make.top.bottom.left.right.equalTo(self.contentView);
  34 + }];
  35 + [self.videoImage mas_makeConstraints:^(MASConstraintMaker *make) {
  36 + make.top.left.right.equalTo(self.contentView);
  37 + make.height.mas_equalTo(242);
  38 + }];
  39 + [self.playImage mas_makeConstraints:^(MASConstraintMaker *make) {
  40 + make.top.equalTo(self.contentView).offset(9);
  41 + make.right.equalTo(self.contentView).offset(-9);
  42 + make.width.height.mas_equalTo(21);
  43 + }];
  44 + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  45 + make.left.equalTo(self.contentView).offset(10);
  46 + make.right.equalTo(self.contentView).offset(-10);
  47 + make.top.equalTo(self.videoImage.mas_bottom).offset(9);
  48 + }];
  49 + [self.logoImage mas_makeConstraints:^(MASConstraintMaker *make) {
  50 + make.bottom.equalTo(self.contentView).offset(-10);
  51 + make.left.equalTo(self.contentView).offset(10);
  52 + make.width.height.mas_equalTo(21);
  53 + }];
  54 + [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  55 + make.centerY.equalTo(self.logoImage);
  56 + make.left.equalTo(self.logoImage.mas_right).offset(5);
  57 + make.right.equalTo(self.likeBtn.mas_left).offset(-5);
  58 + }];
  59 + [self.likeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  60 + make.right.equalTo(self.contentView).offset(-10);
  61 + make.centerY.equalTo(self.logoImage);
  62 + }];
  63 + }
  64 + return self;
  65 +}
  66 +#pragma mark - Action
  67 +- (void)likeBtnClick:(QMUIButton *)sender{
  68 + [QMUITips showLoadingInView:self.contentView];
  69 + weakself
  70 + [CNWitnessSearchPresent requestWitnessLikeMomentWithPid:self.model.pid ContentSid:self.model.icon.id support:sender.selected?@"0":@"1" contentTag:self.model.tagName responseBlock:^(BOOL succeed) {
  71 +
  72 + [QMUITips hideAllTips];
  73 + if (succeed) {
  74 + if (sender.selected) {
  75 + sender.selected = NO;
  76 + weakSelf.model.tool.likesNum --;
  77 + }else{
  78 + sender.selected = YES;
  79 + weakSelf.model.tool.likesNum ++;
  80 + }
  81 + weakSelf.model.tool.liked = sender.selected;
  82 + [self.likeBtn setTitle:[NSString stringWithFormat:@"%ld",weakSelf.model.tool.likesNum] forState:UIControlStateNormal];
  83 + [self.likeBtn setTitle:[NSString stringWithFormat:@"%ld",weakSelf.model.tool.likesNum] forState:UIControlStateSelected];
  84 + }
  85 + }];
  86 +}
  87 +#pragma mark - Setting
  88 +- (void)setModel:(CNWitnessSearchDetailModel *)model{
  89 + _model = model;
  90 + if (model.isHorizontalScreen == 1) {
  91 + [self.videoImage mas_updateConstraints:^(MASConstraintMaker *make) {
  92 + make.height.mas_equalTo(121);
  93 + }];
  94 + }else{
  95 + [self.videoImage mas_updateConstraints:^(MASConstraintMaker *make) {
  96 + make.height.mas_equalTo(242);
  97 + }];
  98 + }
  99 + [self.videoImage sd_setImageWithURL:[NSURL URLWithString:model.poster] placeholderImage:[UIImage loadBundleImage:@"moren"]];
  100 + self.titleLabel.text = model.title;
  101 + [self.logoImage sd_setImageWithURL:[NSURL URLWithString:model.icon.face] placeholderImage:[UIImage loadBundleImage:@"default _icon_bg"]];
  102 + self.nameLabel.text = model.icon.name;
  103 + [self.likeBtn setTitle:[NSString stringWithFormat:@"%ld",model.tool.likesNum] forState:UIControlStateNormal];
  104 + [self.likeBtn setTitle:[NSString stringWithFormat:@"%ld",model.tool.likesNum] forState:UIControlStateSelected];
  105 + self.likeBtn.selected = _model.tool.liked;
  106 + [self.likeBtn sizeToFit];
  107 +}
  108 +#pragma mark - Getting
  109 +- (UIView *)bgView{
  110 + if (!_bgView) {
  111 + _bgView = [[UIView alloc] init];
  112 + _bgView.backgroundColor = UIColorWhite;
  113 + _bgView.layer.cornerRadius = 8;
  114 + _bgView.clipsToBounds = YES;
  115 + }
  116 + return _bgView;
  117 +}
  118 +- (UIImageView *)videoImage{
  119 + if (!_videoImage) {
  120 + _videoImage = [[UIImageView alloc] init];
  121 + _videoImage.layer.cornerRadius = 8;
  122 + _videoImage.clipsToBounds = YES;
  123 + _videoImage.contentMode = UIViewContentModeScaleAspectFill;
  124 + }
  125 + return _videoImage;
  126 +}
  127 +- (UIImageView *)playImage {
  128 + if (!_playImage) {
  129 + _playImage = [[UIImageView alloc] init];
  130 + [_playImage setImage:[UIImage loadBundleImage:@"witness_search_play"]];
  131 + }
  132 + return _playImage;
  133 +}
  134 +- (UILabel *)titleLabel
  135 +{
  136 + if (!_titleLabel) {
  137 + _titleLabel = [[UILabel alloc] init];
  138 + _titleLabel.textColor = UIColorHex(#333333);
  139 + _titleLabel.font = UIFontMake(15);
  140 + _titleLabel.numberOfLines = 2;
  141 + _titleLabel.textAlignment = NSTextAlignmentLeft;
  142 + }
  143 + return _titleLabel;
  144 +}
  145 +- (UIImageView *)logoImage
  146 +{
  147 + if (!_logoImage) {
  148 + _logoImage = [[UIImageView alloc] init];
  149 + _logoImage.contentMode = UIViewContentModeScaleAspectFill;
  150 + UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 20, 20) cornerRadius:10];
  151 + CAShapeLayer *maskLayer = [CAShapeLayer layer];
  152 + maskLayer.path = path.CGPath;
  153 + _logoImage.layer.mask = maskLayer;
  154 + }
  155 + return _logoImage;
  156 +}
  157 +- (UILabel *)nameLabel
  158 +{
  159 + if (!_nameLabel) {
  160 + _nameLabel = [[UILabel alloc] init];
  161 + _nameLabel.textColor = UIColorHex(#666666);
  162 + _nameLabel.font = UIFontMake(11);
  163 + _nameLabel.textAlignment = NSTextAlignmentLeft;
  164 + }
  165 + return _nameLabel;
  166 +}
  167 +- (QMUIButton *)likeBtn
  168 +{
  169 + if (!_likeBtn) {
  170 + _likeBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
  171 + [_likeBtn setImage:[UIImage loadBundleImage:@"witness_search_like"] forState:UIControlStateSelected];
  172 + [_likeBtn setImage:[UIImage loadBundleImage:@"witness_search_unLike"] forState:UIControlStateNormal];
  173 + _likeBtn.titleLabel.font = UIFontMake(13);
  174 + [_likeBtn setTitleColor:UIColorHex(#666666) forState:UIControlStateNormal];
  175 + [_likeBtn setTitleColor:UIColorHex(#666666) forState:UIControlStateSelected];
  176 + _likeBtn.spacingBetweenImageAndTitle = 5;
  177 + [_likeBtn addTarget:self action:@selector(likeBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  178 + }
  179 + return _likeBtn;
  180 +}
  181 +@end
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessSearchView.h 0 → 100644
  1 +//
  2 +// CNWitnessSearchView.h
  3 +// AFNetworking
  4 +//
  5 +// Created by CNLive on 2022/6/15.
  6 +//
  7 +
  8 +#import <UIKit/UIKit.h>
  9 +
  10 +NS_ASSUME_NONNULL_BEGIN
  11 +typedef void(^SearchBlock)(NSString *searchStr);
  12 +typedef void(^ClearBlock)(void);
  13 +@interface CNWitnessSearchView : UIView
  14 +@property (nonatomic, strong) UITextField *searchField;
  15 +@property (nonatomic, copy) SearchBlock searchBlock;//搜索回调
  16 +@property (nonatomic, copy) ClearBlock clearBlock; //清除输入内容回调
  17 +@end
  18 +
  19 +NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessSearchView.m 0 → 100644
  1 +//
  2 +// CNWitnessSearchView.m
  3 +// AFNetworking
  4 +//
  5 +// Created by CNLive on 2022/6/15.
  6 +//
  7 +
  8 +#import "CNWitnessSearchView.h"
  9 +@interface CNWitnessSearchView ()<UITextFieldDelegate>
  10 +@property (nonatomic, strong) UIImageView *searchImage;
  11 +@property (nonatomic, strong) UIView *lineView;
  12 +@end
  13 +
  14 +@implementation CNWitnessSearchView
  15 +- (instancetype)init
  16 +{
  17 + if (self = [super init]) {
  18 + [self addSubview:self.searchImage];
  19 + [self addSubview:self.searchField];
  20 + [self addSubview:self.lineView];
  21 + [self.searchImage mas_makeConstraints:^(MASConstraintMaker *make) {
  22 + make.left.equalTo(self).offset(15);
  23 + make.width.offset(16);
  24 + make.height.offset(16);
  25 + make.centerY.equalTo(self);
  26 + }];
  27 + [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  28 + make.left.equalTo(self.searchImage.mas_right).offset(10);
  29 + make.width.offset(0.5);
  30 + make.height.offset(11);
  31 + make.centerY.equalTo(self);
  32 + }];
  33 + [self.searchField mas_makeConstraints:^(MASConstraintMaker *make) {
  34 + make.left.equalTo(self.lineView.mas_right).offset(10);
  35 + make.right.equalTo(self).offset(-5);
  36 + make.top.bottom.equalTo(self);
  37 + make.centerY.equalTo(self);
  38 + }];
  39 +
  40 + }
  41 + return self;
  42 +}
  43 +
  44 +#pragma mark - UITextFieldDelegate
  45 +- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
  46 + if (([textField.text isEqualToString:@""]&&[string isEqualToString:@" "]) ||textField.text.length > 20) {
  47 + return NO;
  48 + }
  49 + if (string.length > 20) {
  50 + [QMUITips showError:@"粘贴内容不能超过20个字符" inView:AppKeyWindow hideAfterDelay:2];
  51 + return NO;
  52 + }
  53 + return YES;
  54 +}
  55 +- (BOOL)textFieldShouldClear:(UITextField *)textField{
  56 + !self.clearBlock?:self.clearBlock();
  57 + return YES;
  58 +}
  59 +- (BOOL)textFieldShouldReturn:(UITextField *)textField{
  60 + if ([textField.text isEqualToString:@""] || !textField.text) {
  61 + [QMUITips showWithText:@"请输入搜索内容" inView:AppKeyWindow hideAfterDelay:1.5];
  62 + return NO;
  63 + }
  64 + !self.searchBlock?:self.searchBlock(textField.text);
  65 + return YES;
  66 +}
  67 +#pragma mark - Setting&&Getting
  68 +- (UIImageView *)searchImage
  69 +{
  70 + if (!_searchImage) {
  71 + _searchImage = [[UIImageView alloc] init];
  72 + [_searchImage setImage:[UIImage loadBundleImage:@"witness_search"]];
  73 + }
  74 + return _searchImage;
  75 +}
  76 +- (UITextField *)searchField
  77 +{
  78 + if (!_searchField) {
  79 + _searchField = [[UITextField alloc] init];
  80 + _searchField.placeholder = @"请输入关键字";
  81 + _searchField.delegate = self;
  82 + _searchField.returnKeyType = UIReturnKeySearch;
  83 + _searchField.clearButtonMode = UITextFieldViewModeAlways;
  84 + _searchField.textColor = CNLiveColorWithHexString(@"#333333");
  85 + _searchField.font = UIFontCNMake(14);
  86 + }
  87 + return _searchField;
  88 +}
  89 +- (UIView *)lineView
  90 +{
  91 + if (!_lineView) {
  92 + _lineView = [[UIView alloc] init];
  93 + _lineView.backgroundColor = CNLiveColorWithHexString(@"#333333");
  94 + }
  95 + return _lineView;
  96 +}
  97 +@end
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessTopView.h 0 → 100644
  1 +//
  2 +// CNWitnessTopView.h
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/15.
  6 +//
  7 +
  8 +#import <UIKit/UIKit.h>
  9 +
  10 +NS_ASSUME_NONNULL_BEGIN
  11 +typedef void(^SearchBlock)(NSString *searchStr);
  12 +typedef void(^ClearBlock)(void);
  13 +@interface CNWitnessTopView : UIView
  14 +@property (nonatomic, strong)NSString *searchStr;
  15 +@property (nonatomic, copy) SearchBlock searchBlock;//搜索回调
  16 +@property (nonatomic, copy) ClearBlock clearBlock; //清除输入内容回调
  17 +- (void)pretendPush:(BOOL)isPretend;
  18 +@end
  19 +
  20 +NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessTopView.m 0 → 100644
  1 +//
  2 +// CNWitnessTopView.m
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/15.
  6 +//
  7 +
  8 +#import "CNWitnessTopView.h"
  9 +#import "CNWitnessSearchView.h"
  10 +@interface CNWitnessTopView ()
  11 +@property (nonatomic, strong)UIButton *cancelBtn; //取消按钮
  12 +@property (nonatomic, strong)UIButton *backBtn;//返回按钮
  13 +@property (nonatomic, strong)CNWitnessSearchView *searchView;//搜索框
  14 +@end
  15 +
  16 +@implementation CNWitnessTopView
  17 +- (instancetype)init
  18 +{
  19 + if (self = [super init]) {
  20 + self.backgroundColor = UIColorWhite;
  21 + [self addSubview:self.cancelBtn];
  22 + [self addSubview:self.searchView];
  23 + [self addSubview:self.backBtn];
  24 + [self.searchView mas_makeConstraints:^(MASConstraintMaker *make) {
  25 + make.left.equalTo(self).offset(15);
  26 + make.right.equalTo(self.cancelBtn.mas_left).offset(-14);
  27 + make.height.offset(36);
  28 + make.bottom.equalTo(self).offset(-7.5);
  29 + }];
  30 + [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  31 + make.height.offset(36);
  32 + make.right.equalTo(self).offset(-15);
  33 + make.centerY.equalTo(self.searchView);
  34 + }];
  35 + [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  36 + make.left.equalTo(self).offset(15);
  37 + make.centerY.equalTo(self.searchView);
  38 + make.width.height.mas_equalTo(19);
  39 + }];
  40 + }
  41 + return self;
  42 +}
  43 +#pragma mark - Action
  44 +- (void)pretendPush:(BOOL)isPretend{
  45 + if (isPretend) {
  46 + self.backBtn.hidden = NO;
  47 + self.cancelBtn.hidden = YES;
  48 + weakself
  49 + [UIView animateWithDuration:1.5 animations:^{
  50 + [weakSelf.searchView mas_updateConstraints:^(MASConstraintMaker *make) {
  51 + make.left.equalTo(self).offset(self.backBtn.right+15);
  52 + make.right.equalTo(self.cancelBtn.mas_left).offset(self.cancelBtn.width);
  53 + }];
  54 + }];
  55 +
  56 + }else{
  57 + self.backBtn.hidden = YES;
  58 + self.cancelBtn.hidden = NO;
  59 + weakself
  60 + [UIView animateWithDuration:1.5 animations:^{
  61 + [weakSelf.searchView mas_updateConstraints:^(MASConstraintMaker *make) {
  62 + make.left.equalTo(self).offset(15);
  63 + make.right.equalTo(self.cancelBtn.mas_left).offset(-14);
  64 + }];
  65 + }];
  66 +
  67 + }
  68 +}
  69 +- (void)backBtnClick{
  70 + !self.clearBlock?:self.clearBlock();
  71 +}
  72 +- (void)cancelBtnClick{
  73 + [[BaseAppDelegate sharedAppDelegate] popViewController];
  74 +}
  75 +#pragma mark - Setting
  76 +- (void)setSearchStr:(NSString *)searchStr
  77 +{
  78 + _searchStr = searchStr;
  79 + self.searchView.searchField.text = searchStr;
  80 +}
  81 +#pragma mark - Getting
  82 +- (CNWitnessSearchView *)searchView{
  83 + if (!_searchView) {
  84 + _searchView = [[CNWitnessSearchView alloc] init];
  85 + _searchView.backgroundColor = UIColorHex(#F6F7F9);
  86 + weakself
  87 + _searchView.searchBlock = ^(NSString * _Nonnull searchStr) {
  88 + !weakSelf.searchBlock?:weakSelf.searchBlock(searchStr);
  89 + };
  90 + _searchView.clearBlock = ^{
  91 + !weakSelf.clearBlock?:weakSelf.clearBlock();
  92 + };
  93 + _searchView.layer.cornerRadius = 16;
  94 + }
  95 + return _searchView;
  96 +}
  97 +- (UIButton *)cancelBtn
  98 +{
  99 + if (!_cancelBtn) {
  100 + _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  101 + [_cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
  102 + [_cancelBtn setTitleColor:CNLiveColorWithHexString(@"#00CD1E") forState:UIControlStateNormal];
  103 + _cancelBtn.titleLabel.font = UIFontCNMake(14);
  104 + _cancelBtn.backgroundColor = kClearColor;
  105 + [_cancelBtn sizeToFit];
  106 + [ _cancelBtn addTarget:self action:@selector(cancelBtnClick) forControlEvents:UIControlEventTouchUpInside];
  107 + }
  108 + return _cancelBtn;
  109 +}
  110 +- (UIButton *)backBtn
  111 +{
  112 + if (!_backBtn) {
  113 + _backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  114 + [_backBtn setImage:[UIImage loadBundleImage:@"backBlack"] forState:UIControlStateNormal];
  115 + [_backBtn addTarget:self action:@selector(backBtnClick) forControlEvents:UIControlEventTouchUpInside];
  116 + _backBtn.hidden = YES;
  117 + _backBtn.touchAreaInsets = UIEdgeInsetsMake(-5, -5, -5, -5);
  118 + }
  119 + return _backBtn;
  120 +}
  121 +@end
... ...
CNLiveVideoClassifyKit/Classes/SearchView/ViewController/CNWitnessSearchDetailController.h 0 → 100644
  1 +//
  2 +// CNWitnessSearchDetailController.h
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/16.
  6 +//
  7 +
  8 +typedef NS_ENUM(NSUInteger , CNWitnessSearchDetailType) {
  9 + CNWitnessSearchDetailTypeVideo = 0, //视频页
  10 + CNWitnessSearchDetailTypePerson = 1, //用户页
  11 +};
  12 +
  13 +#import <CNLiveBusinessBaseModule/CNLiveBusinessBaseModule.h>
  14 +
  15 +NS_ASSUME_NONNULL_BEGIN
  16 +
  17 +@interface CNWitnessSearchDetailController : CNCommonViewController<JXCategoryListContentViewDelegate>
  18 +@property (nonatomic, strong)NSString *searchStr;
  19 +@property (nonatomic, copy)void (^panGestureBlock)(UIPanGestureRecognizer *gestureRecognizer);
  20 +/// 初始化
  21 +/// @param type 页面类型
  22 +- (instancetype)initWithPageType:(CNWitnessSearchDetailType)type;
  23 +@end
  24 +
  25 +NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/SearchView/ViewController/CNWitnessSearchDetailController.m 0 → 100644
  1 +//
  2 +// CNWitnessSearchDetailController.m
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/16.
  6 +//
  7 +
  8 +#import "CNWitnessSearchDetailController.h"
  9 +#import "CNWitnessSearchPresent.h"
  10 +#import "CNWitnessSearchVideoCell.h"
  11 +#import "CNWitnessSearchPersonCell.h"
  12 +#import "CNWitnessSearchModel.h"
  13 +#import "CNCollectionViewLayout.h"
  14 +
  15 +static NSString *const CNWitnessSearchVideoCellID = @"CNWitnessSearchVideoCell";
  16 +static NSString *const CNWitnessSearchPersonCellID = @"CNWitnessSearchPersonCell";
  17 +@interface CNWitnessSearchDetailController ()<UICollectionViewDelegate,UICollectionViewDataSource,CNWaterFallLayoutDelegate,UIGestureRecognizerDelegate>
  18 +@property (nonatomic, assign)CNWitnessSearchDetailType type;
  19 +@property (nonatomic, strong)UICollectionView *collectionView;
  20 +@property (nonatomic, assign)NSInteger page;//请求页数
  21 +@property (nonatomic, strong)NSString *ts;
  22 +@property (nonatomic, strong)NSMutableArray *dataSource;
  23 +@end
  24 +
  25 +@implementation CNWitnessSearchDetailController
  26 +- (void)requestData{
  27 + if (![CNLiveNetworking isNetworking] && self.dataSource.count == 0) {
  28 + self.collectionView.mj_footer.hidden = YES;
  29 + [self showEmptyViewWithImage:[UIImage loadBundleImage:@"dd_wlcw"] text:@"网络开小差了,刷新试试" detailText:@"" buttonTitle:@" 刷新 " buttonAction:@selector(requestData)];
  30 + [self setCNAPIErrorEmptyView];
  31 + return;
  32 + }
  33 + weakself
  34 + [QMUITips showLoadingInView:self.view];
  35 + [CNWitnessSearchPresent requestSearchVideoListWithTS:self.ts searchType:self.type + 1 keyword:self.searchStr page:self.page responseBlock:^(NSArray *dataArray, BOOL isLastPage, NSString *error) {
  36 + [QMUITips hideAllTips];
  37 + [weakSelf.collectionView.mj_footer endRefreshing];
  38 + if (error) {
  39 + if (weakSelf.page == 1) {
  40 + weakSelf.collectionView.mj_footer.hidden = YES;
  41 + [weakSelf showEmptyViewWithImage:[UIImage loadBundleImage:@"wufalianjie"] text:@"接口开小差了,试试重新请求" detailText:@"" buttonTitle:@" 重试 " buttonAction:@selector(requestData)];
  42 + [weakSelf setCNAPIErrorEmptyView];
  43 + return;
  44 + }
  45 + [QMUITips showWithText:error inView:self.view hideAfterDelay:1.5];
  46 + return;
  47 + }
  48 + if (weakSelf.page == 1 && dataArray == 0) {
  49 + weakSelf.collectionView.mj_footer.hidden = YES;
  50 + [weakSelf showEmptyViewWithImage:[UIImage loadBundleImage:@"zw_zt"] text:@"未搜索到相关内容哦" detailText:@"" buttonTitle:NULL buttonAction:NULL];
  51 + [weakSelf setCNAPIErrorEmptyView];
  52 + return;
  53 + }
  54 + weakSelf.collectionView.mj_footer.hidden = NO;
  55 + if (isLastPage) {
  56 + [weakSelf.collectionView.mj_footer endRefreshingWithNoMoreData];
  57 + }
  58 + [self.emptyView removeFromSuperview];
  59 + [self.dataSource addObjectsFromArray:dataArray];
  60 + [self.collectionView reloadData];
  61 + }];
  62 +}
  63 +
  64 +- (instancetype)initWithPageType:(CNWitnessSearchDetailType)type
  65 +{
  66 + if (self = [super init]) {
  67 + self.type = type;
  68 + self.page = 1;
  69 + }
  70 + return self;
  71 +}
  72 +
  73 +- (void)viewDidLoad {
  74 + [super viewDidLoad];
  75 + [self.view addSubview:self.collectionView];
  76 + [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  77 + make.top.bottom.right.left.equalTo(self.view);
  78 + }];
  79 + if (self.type == CNWitnessSearchDetailTypeVideo) {
  80 + UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureEvent:)];
  81 + pan.delegate = self;
  82 + [self.view addGestureRecognizer:pan];
  83 + }
  84 +}
  85 +- (void)panGestureEvent:(UIPanGestureRecognizer *)gesture{
  86 + if (self.panGestureBlock) {
  87 + self.panGestureBlock(gesture);
  88 + }
  89 +}
  90 +- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
  91 + return YES;
  92 +}
  93 +#pragma mark - UIGestureRecognizerDelegate
  94 +
  95 +-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
  96 + [self.view endEditing:YES];
  97 +}
  98 +#pragma mark - UICollectionViewDataSource
  99 +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  100 + return self.dataSource.count;
  101 +}
  102 +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  103 + if (self.type == CNWitnessSearchDetailTypeVideo) {
  104 + CNWitnessSearchVideoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNWitnessSearchVideoCellID forIndexPath:indexPath];
  105 + cell.model = self.dataSource[indexPath.row];
  106 + return cell;
  107 + }else{
  108 + CNWitnessSearchPersonCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNWitnessSearchPersonCellID forIndexPath:indexPath];
  109 + cell.model = self.dataSource[indexPath.row];
  110 + return cell;
  111 + }
  112 +}
  113 +#pragma mark - CNWaterFallLayoutDelegate
  114 +//通过代理得到每个item 的一个高度
  115 +- (CGFloat)collectionViewLayout:(CNCollectionViewLayout*)layout heightAtIndexPath:(NSIndexPath*)indexPath{
  116 + CNWitnessSearchDetailModel *model = self.dataSource[indexPath.row];
  117 + CGFloat oneHeight = [@"北" heightForFont:UIFontMake(15) width:(kScreenWidth-33)/2-20];
  118 + CGFloat totalHeight = [model.title heightForFont:UIFontMake(15) width:(kScreenWidth-33)/2-20];
  119 + if (totalHeight > oneHeight *2) {
  120 + totalHeight = oneHeight *2;
  121 + }
  122 + if (model.isHorizontalScreen == 1) {
  123 + return 192 + totalHeight;
  124 + }
  125 + else{
  126 + return 290 + totalHeight;
  127 + }
  128 +}
  129 +#pragma mark - Setting
  130 +- (void)setSearchStr:(NSString *)searchStr{
  131 + if (![_searchStr isEqualToString:searchStr]) {
  132 + _searchStr = searchStr;
  133 + [self.dataSource removeAllObjects];
  134 + [self.collectionView reloadData];
  135 + self.page = 1;
  136 + [self requestData];
  137 + }
  138 +}
  139 +#pragma mark - Getting
  140 +- (UICollectionView *)collectionView
  141 +{
  142 + if (!_collectionView) {
  143 + if (self.type == CNWitnessSearchDetailTypeVideo) {
  144 + CNCollectionViewLayout *layout = [[CNCollectionViewLayout alloc] init];
  145 + layout.delegate = self;
  146 + layout.colCount = 2;
  147 + layout.colSpace = 9;
  148 + layout.lineSpace = 9;
  149 + layout.sectionInsets = UIEdgeInsetsMake(12, 12, 0, 12);
  150 + _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  151 + _collectionView.backgroundColor = UIColorHex(#F6F7F9);
  152 + }else{
  153 + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  154 + layout.itemSize = CGSizeMake(kScreenWidth - 24, 80);
  155 + layout.minimumLineSpacing = 0;
  156 + layout.minimumInteritemSpacing = 0;
  157 + layout.sectionInset = UIEdgeInsetsMake(0, 12, 0, 12);
  158 + _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  159 + _collectionView.backgroundColor = UIColorWhite;
  160 + }
  161 +
  162 +
  163 + _collectionView.delegate = self;
  164 + _collectionView.dataSource = self;
  165 + _collectionView.showsVerticalScrollIndicator = NO;
  166 + [_collectionView registerClass:[CNWitnessSearchVideoCell class] forCellWithReuseIdentifier:CNWitnessSearchVideoCellID];
  167 + [_collectionView registerClass:[CNWitnessSearchPersonCell class] forCellWithReuseIdentifier:CNWitnessSearchPersonCellID];
  168 + weakself
  169 + _collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
  170 + weakSelf.page ++;
  171 + [weakSelf requestData];
  172 + }];
  173 +// UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
  174 +// [weakSelf.view endEditing:YES];
  175 +// }];
  176 +// [_collectionView addGestureRecognizer:pan];
  177 + }
  178 + return _collectionView;
  179 +}
  180 +- (NSMutableArray *)dataSource
  181 +{
  182 + if (!_dataSource) {
  183 + _dataSource = [NSMutableArray array];
  184 + }
  185 + return _dataSource;
  186 +}
  187 +#pragma mark - JXCategoryListContentViewDelegate
  188 +- (UIView *)listView{
  189 + return self.view;
  190 +}
  191 +
  192 +@end
... ...
CNLiveVideoClassifyKit/Classes/SearchView/ViewController/CNWitnessSearchListController.h 0 → 100644
  1 +//
  2 +// CNWitnessSearchListController.h
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/16.
  6 +//
  7 +
  8 +#import <CNLiveBusinessBaseModule/CNLiveBusinessBaseModule.h>
  9 +
  10 +NS_ASSUME_NONNULL_BEGIN
  11 +
  12 +@interface CNWitnessSearchListController : CNCommonViewController
  13 +@property (nonatomic, strong)NSString *searchStr;
  14 +@property (nonatomic, copy)void (^panGestureBlock)(UIPanGestureRecognizer *gestureRecognizer);
  15 +@end
  16 +
  17 +NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/SearchView/ViewController/CNWitnessSearchListController.m 0 → 100644
  1 +//
  2 +// CNWitnessSearchListController.m
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by CNLive on 2022/6/16.
  6 +//
  7 +
  8 +#import "CNWitnessSearchListController.h"
  9 +#import "CNWitnessSearchDetailController.h"
  10 +
  11 +@interface CNWitnessSearchListController ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
  12 +@property (nonatomic, strong)JXCategoryTitleView *myCategoryView;//头部分组
  13 +@property (nonatomic, strong)JXCategoryListContainerView *listContainerView;//分类控制器对应VC管理器
  14 +@property (nonatomic, strong)JXCategoryIndicatorLineView *lineView;
  15 +@property (nonatomic, strong)NSArray *titles;//标题
  16 +@property (nonatomic, assign)NSInteger selectIndex;
  17 +@property (nonatomic, assign)CGFloat lineX;
  18 +@end
  19 +
  20 +@implementation CNWitnessSearchListController
  21 +
  22 +- (void)viewDidLoad {
  23 + [super viewDidLoad];
  24 + self.view.backgroundColor = UIColorHex(#E6E6E6);
  25 + [self.view addSubview:self.myCategoryView];
  26 + [self.view addSubview:self.listContainerView];
  27 + [self.myCategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
  28 + make.top.left.right.equalTo(self.view);
  29 + make.height.mas_equalTo(37);
  30 + }];
  31 + [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  32 + make.left.right.bottom.equalTo(self.view);
  33 + make.top.equalTo(self.myCategoryView.mas_bottom).offset(0.5);
  34 + }];
  35 +}
  36 +
  37 +- (BOOL)preferredNavigationBarHidden{
  38 + return YES;
  39 +}
  40 +#pragma mark - JXCategoryViewDelegate
  41 +- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
  42 + self.selectIndex = index;
  43 + NSDictionary *controllers = self.listContainerView.validListDict;
  44 + CNWitnessSearchListController *vc = controllers[@(index)];
  45 + vc.searchStr = self.searchStr;
  46 +}
  47 +#pragma mark - JXCategoryListContainerViewDelegate
  48 +- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
  49 + return self.titles.count;
  50 +}
  51 +- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
  52 + CNWitnessSearchDetailController *vc = [[CNWitnessSearchDetailController alloc] initWithPageType:index];
  53 + weakself
  54 + vc.panGestureBlock = ^(UIPanGestureRecognizer * _Nonnull gestureRecognizer) {
  55 + [weakSelf panGestureEvent:gestureRecognizer];
  56 + };
  57 + return vc;
  58 +}
  59 +- (void)panGestureEvent:(UIPanGestureRecognizer *)gesture{
  60 + CGPoint translation = [gesture translationInView:gesture.view];
  61 + CGFloat sensitivePosition = kScreenWidth / 2.f;
  62 + if (translation.x < 0) {
  63 + CGFloat lenth = -translation.x ;
  64 + if (gesture.state == UIGestureRecognizerStateChanged) {
  65 + [self.listContainerView.scrollView setOffsetX:lenth*3
  66 + animated:YES];
  67 + self.lineView.x = self.lineX + lenth/3;
  68 + } else if (gesture.state == UIGestureRecognizerStateEnded) {
  69 + if (lenth >= sensitivePosition) {
  70 + [self.myCategoryView selectItemAtIndex:1];
  71 + }else{
  72 + [self.listContainerView.scrollView setOffsetX:0
  73 + animated:YES];
  74 + self.lineView.x = self.lineX;
  75 + }
  76 + }
  77 +
  78 + }else if (self.panGestureBlock) {
  79 + self.panGestureBlock(gesture);
  80 + }
  81 +}
  82 +#pragma mark - Setting
  83 +- (void)setSearchStr:(NSString *)searchStr
  84 +{
  85 + _searchStr = searchStr;
  86 + self.lineX = self.lineView.x;
  87 + NSDictionary *controllers = self.listContainerView.validListDict;
  88 + CNWitnessSearchListController *vc = controllers[@(self.selectIndex)];
  89 + vc.searchStr = self.searchStr;
  90 +}
  91 +- (void)setSelectIndex:(NSInteger)selectIndex{
  92 + _selectIndex = selectIndex;
  93 +}
  94 +#pragma mark - Getting
  95 +- (NSArray *)titles
  96 +{
  97 + if (!_titles) {
  98 + _titles = @[@"视频",@"用户"];
  99 + }
  100 + return _titles;
  101 +}
  102 +- (JXCategoryTitleView *)myCategoryView{
  103 + if (!_myCategoryView) {
  104 + _myCategoryView = [[JXCategoryTitleView alloc] init];
  105 + _myCategoryView.backgroundColor = UIColorWhite;
  106 + _myCategoryView.delegate = self;
  107 + _myCategoryView.listContainer = self.listContainerView;
  108 + _myCategoryView.selectedAnimationEnabled = YES;
  109 + _myCategoryView.titles = self.titles;
  110 + _myCategoryView.titleFont = UIFontMake(15);
  111 + _myCategoryView.titleColor = UIColorHex(#999999);
  112 + _myCategoryView.titleSelectedFont = UIFontMake(15);
  113 + _myCategoryView.titleSelectedColor = UIColorHex(#333333);
  114 + _myCategoryView.indicators = @[self.lineView];
  115 + _myCategoryView.defaultSelectedIndex = 0;
  116 + _myCategoryView.separatorLineShowEnabled = YES;
  117 + }
  118 + return _myCategoryView;
  119 +}
  120 +- (JXCategoryIndicatorLineView *)lineView
  121 +{
  122 + if (!_lineView) {
  123 + _lineView = [[JXCategoryIndicatorLineView alloc] init];
  124 + _lineView.indicatorWidth = 15;
  125 + _lineView.indicatorColor = UIColorHex(#25CA5A);
  126 + }
  127 + return _lineView;
  128 +}
  129 +
  130 +- (JXCategoryListContainerView *)listContainerView
  131 +{
  132 + if (!_listContainerView) {
  133 + _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
  134 + }
  135 + return _listContainerView;
  136 +}
  137 +
  138 +@end
... ...
CNLiveVideoClassifyKit/Classes/SearchView/ViewController/CNWitnessSearchViewController.h 0 → 100644
  1 +//
  2 +// CNWitnessSearchViewController.h
  3 +// AFNetworking
  4 +//
  5 +// Created by CNLive on 2022/6/15.
  6 +//
  7 +
  8 +#import <CNLiveBusinessBaseModule/CNLiveBusinessBaseModule.h>
  9 +
  10 +NS_ASSUME_NONNULL_BEGIN
  11 +
  12 +@interface CNWitnessSearchViewController : CNCommonViewController
  13 +
  14 +@end
  15 +
  16 +NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/SearchView/ViewController/CNWitnessSearchViewController.m 0 → 100644
  1 +//
  2 +// CNWitnessSearchViewController.m
  3 +// AFNetworking
  4 +//
  5 +// Created by CNLive on 2022/6/15.
  6 +//
  7 +
  8 +#import "CNWitnessSearchViewController.h"
  9 +#import "CNWitnessSearchListController.h"
  10 +#import "CNWitnessTopView.h"
  11 +#import "CNWitnessSearchFooterView.h"
  12 +#import "CNWitnessSearchCell.h"
  13 +#import "CNWitnessSearchHeaderView.h"
  14 +#import "CNWitnessSearchPresent.h"
  15 +#import "CNWitnessSearchModel.h"
  16 +
  17 +static NSString *const CNWitnessSearchFooterViewID = @"CNWitnessSearchFooterView";
  18 +static NSString *const CNWitnessSearchCellID = @"CNWitnessSearchCell";
  19 +static NSString *const CNWitnessSearchHeaderViewID = @"CNWitnessSearchHeaderView";
  20 +
  21 +@interface CNWitnessSearchViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UIScrollViewDelegate,UIGestureRecognizerDelegate>
  22 +@property (nonatomic, strong)CNWitnessTopView *topView;
  23 +@property (nonatomic, strong)NSMutableArray *histories;
  24 +@property (nonatomic, strong)UICollectionView *collectionView;
  25 +@property (nonatomic, strong)NSArray *dataSource;
  26 +@property (nonatomic, strong)NSArray *hots;
  27 +@property (nonatomic, assign)BOOL isShowAll;
  28 +@property (nonatomic, assign)BOOL listViewShow;
  29 +@property (nonatomic, strong)CNWitnessSearchListController *listVC;
  30 +@end
  31 +
  32 +@implementation CNWitnessSearchViewController
  33 +- (void)searchRequeseHot{
  34 + weakself
  35 + [CNWitnessSearchPresent requestHotListResponse:^(NSArray * _Nonnull hots, NSString * _Nonnull errorString) {
  36 + if (!errorString) {
  37 + weakSelf.hots = hots;
  38 + [weakSelf dealHotsAndHistories];
  39 + }else{
  40 + [weakSelf searchRequeseHot];
  41 + }
  42 + }];
  43 +}
  44 +- (void)dealHotsAndHistories{
  45 + self.dataSource = [CNWitnessSearchPresent dealHots:self.hots isShowAll:self.isShowAll allHistories:self.histories.copy];
  46 + [self.collectionView reloadData];
  47 +}
  48 +- (void)viewDidLoad {
  49 + [super viewDidLoad];
  50 + self.navigationController.interactivePopGestureRecognizer.delegate = self;
  51 + self.view.backgroundColor = UIColorHex(#E6E6E6);
  52 + self.isShowAll = NO;
  53 + self.histories = [CNWitnessSearchPresent readSearchHistories];
  54 + [self dealHotsAndHistories];
  55 + [self searchRequeseHot];
  56 + [self.view addSubview:self.topView];
  57 + [self.view addSubview:self.collectionView];
  58 + [self.view addSubview:self.listVC.view];
  59 + [self addChildViewController:self.listVC];
  60 +
  61 + [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
  62 + make.left.right.equalTo(self.view);
  63 + make.top.equalTo(self.view);
  64 + make.height.mas_equalTo(46.5+ kStatusHeight);
  65 + }];
  66 + [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  67 + make.left.right.bottom.equalTo(self.view);
  68 + make.top.equalTo(self.topView.mas_bottom).offset(0.5);
  69 + }];
  70 + [self.listVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
  71 + make.left.equalTo(self.view).offset(kScreenWidth);
  72 + make.bottom.equalTo(self.view);
  73 + make.top.equalTo(self.collectionView);
  74 + make.width.mas_equalTo(kScreenWidth);
  75 + }];
  76 + UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureEvent:)];
  77 + [self.listVC.view addGestureRecognizer:pan];
  78 +}
  79 +- (BOOL)preferredNavigationBarHidden{
  80 + return YES;
  81 +}
  82 +#pragma mark - UIGestureRecognizerDelegate
  83 +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveEvent:(UIEvent *)event{
  84 + return !self.listViewShow;
  85 +}
  86 +- (void)panGestureEvent:(UIPanGestureRecognizer *)gesture{
  87 + CGPoint translation = [gesture translationInView:gesture.view];
  88 + CGFloat sensitivePosition = kScreenWidth / 2.f;
  89 + [self.view endEditing:YES];
  90 + if (translation.x > 0) {
  91 + if (gesture.state == UIGestureRecognizerStateChanged) {
  92 + [self.listVC.view mas_updateConstraints:^(MASConstraintMaker *make) {
  93 + make.left.equalTo(self.view).offset(translation.x);
  94 + }];
  95 + } else if (gesture.state == UIGestureRecognizerStateEnded) {
  96 + if (translation.x >= sensitivePosition) {
  97 + [self listViewShow:NO];
  98 + }else{
  99 + [self listViewShow:YES];
  100 + }
  101 + }
  102 + }
  103 +}
  104 +#pragma mark - UIScrollViewDelegate
  105 +- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
  106 + [self.view endEditing:YES];
  107 +}
  108 +- (BOOL)shouldHideKeyboardWhenTouchInView:(UIView *)view
  109 +{
  110 + return YES;
  111 +}
  112 +#pragma mark - UICollectionViewDelegate
  113 +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  114 + CNWitnessSearchModel *model = self.dataSource[indexPath.section];
  115 + self.topView.searchStr = model.list[indexPath.row];
  116 + [self historyArrayValueChange:model.list[indexPath.row]];
  117 +}
  118 +#pragma mark - UICollectionViewDataSource
  119 +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  120 + CNWitnessSearchModel *model = self.dataSource[section];
  121 + return model.list.count;
  122 +}
  123 +- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
  124 + return self.dataSource.count;
  125 +}
  126 +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  127 + CNWitnessSearchModel *model = self.dataSource[indexPath.section];
  128 + CNWitnessSearchCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNWitnessSearchCellID forIndexPath:indexPath];
  129 + [cell setString:model.list[indexPath.row] section:indexPath.section];
  130 + weakself
  131 + cell.deleteBlock = ^(NSString * _Nonnull str) {
  132 + [weakSelf.histories removeObject:str];
  133 + [CNWitnessSearchPresent saveSearchHistories:self.histories];
  134 + [weakSelf dealHotsAndHistories];
  135 + };
  136 + return cell;
  137 +}
  138 +- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
  139 +
  140 + if ([kind isEqualToString:@"UICollectionElementKindSectionHeader"]) {
  141 + CNWitnessSearchModel *model = self.dataSource[indexPath.section];
  142 + CNWitnessSearchHeaderView *header = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:CNWitnessSearchHeaderViewID forIndexPath:indexPath];
  143 + header.titleStr = model.title;
  144 + return header;
  145 + }else
  146 + {
  147 + CNWitnessSearchFooterView *footer = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:CNWitnessSearchFooterViewID forIndexPath:indexPath];
  148 + footer.isallShow = self.isShowAll;
  149 + weakself
  150 + footer.organizaBtnBlock = ^(NSInteger index) {
  151 + switch (index) {
  152 + case 0:
  153 + {
  154 + weakSelf.isShowAll = YES;
  155 + [weakSelf dealHotsAndHistories];
  156 + }
  157 + break;
  158 + case 1:
  159 + {
  160 + [weakSelf.histories removeAllObjects];
  161 + [CNWitnessSearchPresent saveSearchHistories:self.histories];
  162 + [weakSelf dealHotsAndHistories];
  163 + }
  164 + break;
  165 +
  166 + default:
  167 + break;
  168 + }
  169 + };
  170 + return footer;
  171 + }
  172 +
  173 +
  174 +}
  175 +#pragma mark - UICollectionViewDelegateFlowLayout
  176 +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
  177 + if (indexPath.section == 0) {
  178 + return CGSizeMake(kScreenWidth - 30, 50);
  179 + }else{
  180 + return CGSizeMake((kScreenWidth-30)/2, 30);
  181 + }
  182 +
  183 +}
  184 +- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
  185 + return UIEdgeInsetsMake(0, 15, 0, 15);
  186 +}
  187 +- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
  188 + return 0;
  189 +}
  190 +- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
  191 + return 0;
  192 +}
  193 +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
  194 + CNWitnessSearchModel *model = self.dataSource[section];
  195 + if ([model.title isNotBlank] && model.list.count>0) {
  196 + return CGSizeMake(collectionView.width - 30, 40);
  197 + }else{
  198 + return CGSizeMake(0, 0);
  199 + }
  200 +
  201 +}
  202 +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section{
  203 + if (section == 0 && self.histories.count > 3) {
  204 + return CGSizeMake(kScreenWidth - 30, 40);
  205 + }
  206 + return CGSizeMake(0, 0);
  207 +}
  208 +#pragma mark - Getting
  209 +- (CNWitnessTopView *)topView{
  210 + if (!_topView) {
  211 + _topView = [[CNWitnessTopView alloc] init];
  212 + weakself
  213 + _topView.searchBlock = ^(NSString * _Nonnull searchStr) {
  214 + [weakSelf historyArrayValueChange:searchStr];
  215 + };
  216 + _topView.clearBlock = ^{
  217 + [weakSelf listViewShow:NO];
  218 + };
  219 + }
  220 + return _topView;
  221 +}
  222 +- (UICollectionView *)collectionView
  223 +{
  224 + if (!_collectionView) {
  225 + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  226 + layout.sectionFootersPinToVisibleBounds = YES;
  227 + layout.sectionHeadersPinToVisibleBounds = YES;
  228 + _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  229 + _collectionView.backgroundColor = kWhiteColor;
  230 + _collectionView.delegate = self;
  231 + _collectionView.dataSource = self;
  232 + _collectionView.showsVerticalScrollIndicator = NO;
  233 + [_collectionView registerClass:[CNWitnessSearchCell class] forCellWithReuseIdentifier:CNWitnessSearchCellID];
  234 + [_collectionView registerClass:[CNWitnessSearchHeaderView class] forSupplementaryViewOfKind:@"UICollectionElementKindSectionHeader" withReuseIdentifier:CNWitnessSearchHeaderViewID];
  235 + [_collectionView registerClass:[CNWitnessSearchFooterView class] forSupplementaryViewOfKind:@"UICollectionElementKindSectionFooter" withReuseIdentifier:CNWitnessSearchFooterViewID];
  236 + _collectionView.mj_footer = [MJRefreshFooter footerWithRefreshingBlock:NULL];
  237 + _collectionView.mj_footer.hidden = YES;
  238 + }
  239 + return _collectionView;
  240 +}
  241 +- (CNWitnessSearchListController *)listVC{
  242 + if (!_listVC) {
  243 + _listVC = [[CNWitnessSearchListController alloc] init];
  244 + weakself
  245 + _listVC.panGestureBlock = ^(UIPanGestureRecognizer * _Nonnull gestureRecognizer) {
  246 + [weakSelf panGestureEvent:gestureRecognizer];
  247 + };
  248 + }
  249 + return _listVC;
  250 +}
  251 +
  252 +#pragma mark - Method
  253 +- (void)listViewShow:(BOOL)show{
  254 + [self.topView pretendPush:show];
  255 + self.listViewShow = show;
  256 + if (show) {
  257 + [UIView animateWithDuration:1.5 animations:^{
  258 + [self.listVC.view mas_updateConstraints:^(MASConstraintMaker *make) {
  259 + make.left.equalTo(self.view);
  260 + }];
  261 + }];
  262 + }else{
  263 + self.topView.searchStr = @"";
  264 + [UIView animateWithDuration:1.5 animations:^{
  265 + [self.listVC.view mas_updateConstraints:^(MASConstraintMaker *make) {
  266 + make.left.equalTo(self.view).offset(kScreenWidth);
  267 + }];
  268 + }];
  269 + }
  270 +}
  271 +- (void)historyArrayValueChange:(NSString *)string{
  272 + self.listVC.searchStr = string;
  273 + [self listViewShow:YES];
  274 + [self.view endEditing:YES];
  275 + if ([self isSearchEd:string]) {
  276 + [self.histories removeObject:string];
  277 + [self.histories insertObject:string atIndex:0];
  278 + }else{
  279 + if (self.histories.count < 10) {
  280 + [self.histories insertObject:string atIndex:0];
  281 + }else{
  282 + [self.histories insertObject:string atIndex:0];
  283 + [self.histories removeLastObject];
  284 + }
  285 + }
  286 + [CNWitnessSearchPresent saveSearchHistories:self.histories];
  287 + self.isShowAll = NO;
  288 + [self dealHotsAndHistories];
  289 +}
  290 +- (BOOL)isSearchEd:(NSString *)string
  291 +{
  292 + for (NSString *str in self.histories) {
  293 + if ([str isEqualToString:string]) {
  294 + return YES;
  295 + }
  296 + }
  297 + return NO;
  298 +}
  299 +@end
... ...
Example/CNLiveVideoClassifyKit.xcodeproj/project.pbxproj
... ... @@ -406,8 +406,8 @@
406 406 "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework",
407 407 "${BUILT_PRODUCTS_DIR}/CNLiveNewTripartiteManagement/CNLiveNewTripartiteManagement.framework",
408 408 "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework",
  409 + "${BUILT_PRODUCTS_DIR}/CNLiveTripartiteManagement/CNLiveTripartiteManagement.framework",
409 410 "${BUILT_PRODUCTS_DIR}/CNLiveUserManagement/CNLiveUserManagement.framework",
410   - "${BUILT_PRODUCTS_DIR}/FWDebug/FWDebug.framework",
411 411 "${BUILT_PRODUCTS_DIR}/JXCategoryView/JXCategoryView.framework",
412 412 "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework",
413 413 "${BUILT_PRODUCTS_DIR}/MJRefresh/MJRefresh.framework",
... ... @@ -443,8 +443,8 @@
443 443 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework",
444 444 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveNewTripartiteManagement.framework",
445 445 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework",
  446 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveTripartiteManagement.framework",
446 447 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserManagement.framework",
447   - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FWDebug.framework",
448 448 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/JXCategoryView.framework",
449 449 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJExtension.framework",
450 450 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJRefresh.framework",
... ... @@ -476,11 +476,15 @@
476 476 );
477 477 inputPaths = (
478 478 "${PODS_ROOT}/Target Support Files/Pods-CNLiveVideoClassifyKit_Example/Pods-CNLiveVideoClassifyKit_Example-resources.sh",
  479 + "${PODS_CONFIGURATION_BUILD_DIR}/CNLiveShareToolKit/CNLiveShareToolKit.bundle",
479 480 "${PODS_ROOT}/../../CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle",
  481 + "${PODS_ROOT}/WeiboSDK/libWeiboSDK/WeiboSDK.bundle",
480 482 );
481 483 name = "[CP] Copy Pods Resources";
482 484 outputPaths = (
  485 + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CNLiveShareToolKit.bundle",
483 486 "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CNSegmentControl.bundle",
  487 + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/WeiboSDK.bundle",
484 488 );
485 489 runOnlyForDeploymentPostprocessing = 0;
486 490 shellPath = /bin/sh;
... ...
Example/CNLiveVideoClassifyKit/CNLIVEAppDelegate.m
... ... @@ -7,17 +7,54 @@
7 7 //
8 8  
9 9 #import "CNLIVEAppDelegate.h"
  10 +#import <CNLiveRequestBastKit/CNLiveNetworking.h>
10 11 #import <CNLiveEnvironment/CNLiveEnvironment.h>
  12 +#import <CNLiveEnvironment/CNLiveEnvironmentManager.h>
  13 +#import <CNLiveUserManagement/CNUserInfoManager.h>
  14 +#import "CNLIVEViewController.h"
11 15  
12 16 @implementation CNLIVEAppDelegate
13 17  
14 18 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
15 19 {
16 20 [CNLiveEnvironmentManager setEnvironment:CNLiveDebugAppStore];//CNLiveDebugAppStore];//CNLiveProductionAppStore//CNLiveTestFlight
17   - // Override point for customization after application launch.
  21 +
  22 + [BHContext shareInstance].application = application;
  23 + [BHContext shareInstance].launchOptions = launchOptions;
  24 + [BHContext shareInstance].moduleConfigName = @"CNLiveBeeHive.bundle/BeeHive.bundle/BeeHive";
  25 + [BHContext shareInstance].serviceConfigName = @"CNLiveBeeHive.bundle/BeeHive.bundle/BHService";
  26 + [BeeHive shareInstance].enableException = YES;
  27 +
  28 + [super application:application didFinishLaunchingWithOptions:launchOptions];
  29 +
  30 + [CNUserInfoManager manager].userInfoModel.uid = @"353001";//@"10510277";//
  31 +
  32 + self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  33 + self.window.backgroundColor = [UIColor whiteColor];
  34 +
  35 + self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[CNLIVEViewController alloc] init]];
  36 +
  37 + [self.window makeKeyAndVisible];
  38 +
  39 + [self setParamNet];
18 40 return YES;
19 41 }
20   -
  42 +-(void)setParamNet
  43 +{
  44 + NSMutableDictionary * mDict = [[NSMutableDictionary alloc] init];
  45 + [mDict setValue:[CNUserInfoManager manager].userInfoModel.uid forKey:@"loginSid"];
  46 + [mDict setValue:@"com.cnlive.CNLiveNetAdd.debug" forKey:@"platform_id"];
  47 + [mDict setValue:[[[[UIDevice currentDevice] identifierForVendor] UUIDString] stringByReplacingOccurrencesOfString:@"-" withString:@""] forKey:@"uuid"];
  48 + [mDict setValue:@"i" forKey:@"plat"];
  49 + [mDict setValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] forKey:@"ver"];
  50 + [mDict setObject:AppId forKey:@"appId"];
  51 + [mDict setObject:[CNUserInfoManager manager].userInfoModel.uid forKey:@"sid"];
  52 + [CNLiveNetworking setupDefaultParam:mDict];
  53 + [CNLiveNetworking setupShowResult:NO];
  54 + [CNLiveNetworking setupSignKey:APPKey];
  55 + [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  56 + [CNLiveNetworking setResponseSerializerType:CNLiveResponseSerializerJSON];
  57 +}
21 58 - (void)applicationWillResignActive:(UIApplication *)application
22 59 {
23 60 // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
... ...
Example/CNLiveVideoClassifyKit/CNLIVEViewController.m
... ... @@ -10,6 +10,7 @@
10 10 #import <CNLiveBaseKit/CNLiveBaseKit.h>
11 11 #import "CNliveCollectionViewCell.h"
12 12 #import <CNLiveVideoClassifyKit/CNLivevideoClassifyPCH.h>
  13 +#import <CNLiveVideoClassifyKit/CNLiveListManager.h>
13 14 #import <CNLiveNetworking.h>
14 15 #import <NSString+CNLiveExtension.h>
15 16 #import <CNLiveEnvironment/CNLiveEnvironment.h>
... ... @@ -44,7 +45,7 @@
44 45 [BHConfig set:ChannelsSelectFirst value:@"0"];
45 46 [CNTools GetClassifyChannelsUrlsAndSave];
46 47 self.title = @"首页";
47   - segArr = @[@"分类"];
  48 + segArr = @[@"分类",@"搜索"];
48 49 [self.view addSubview:self.collectionView];
49 50 }
50 51 -(void)viewDidAppear:(BOOL)animated
... ... @@ -76,7 +77,7 @@
76 77 break;
77 78 case 1:
78 79 {
79   -
  80 + [CNLiveListManager pushWitnessSearchVC];
80 81 }
81 82 break;
82 83  
... ...
Example/Podfile
... ... @@ -9,7 +9,7 @@ target &#39;CNLiveVideoClassifyKit_Example&#39; do
9 9 pod 'CNLiveEnvironment'
10 10 pod 'CNLiveRequestBastKit'
11 11 pod 'CNLiveCWebViewModule'
12   - pod 'FWDebug', :configurations => ['Debug']
  12 +# pod 'FWDebug', :configurations => ['Debug']
13 13 # #依赖三方私有库,如果里面有.a的时候加上这个
14 14 pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
15 15 ########################################### #删除WebViewJavascriptBridge中的WebViewJavascriptBridge.h和WebViewJavascriptBridge.m文件
... ...
Example/Podfile.lock
... ... @@ -171,9 +171,22 @@ PODS:
171 171 - CNLiveRequestBastKit (0.2.5.7):
172 172 - AFNetworking
173 173 - CNLiveSDK/CNLiveStat (0.3.4.8)
  174 + - CNLiveShareToolKit (0.0.3):
  175 + - AFNetworking
  176 + - CNLiveCommonCategory
  177 + - CNLiveEnvironment
  178 + - CNLiveRequestBastKit
  179 + - CNLiveTripartiteManagement/SDWebImage
  180 + - CNLiveUserManagement
  181 + - MJExtension
  182 + - QMUIKit
  183 + - WechatOpenSDK (= 1.8.4)
  184 + - WeiboSDK
  185 + - CNLiveTripartiteManagement/SDWebImage (0.1.9):
  186 + - SDWebImage (= 5.2.3)
174 187 - CNLiveUserManagement (0.1.5):
175 188 - CNLiveNewTripartiteManagement/MJExtension
176   - - CNLiveVideoClassifyKit (0.4.2):
  189 + - CNLiveVideoClassifyKit (0.4.3):
177 190 - CNLiveBaseKit
178 191 - CNLiveBaseTools
179 192 - CNLiveBeeHive
... ... @@ -196,10 +209,10 @@ PODS:
196 209 - CNLiveNewTripartiteManagement/YYWebImage
197 210 - CNLiveRequestBastKit
198 211 - CNLiveSDK/CNLiveStat
  212 + - CNLiveShareToolKit
199 213 - CNLiveUserManagement
200 214 - JXCategoryView
201 215 - UMCCommon
202   - - FWDebug (1.10.1)
203 216 - JXCategoryView (1.5.9)
204 217 - Masonry (1.1.0)
205 218 - MJExtension (3.2.1)
... ... @@ -533,6 +546,8 @@ PODS:
533 546 - UMDevice
534 547 - UMDevice (2.2.1)
535 548 - WebViewJavascriptBridge (6.0.3)
  549 + - WechatOpenSDK (1.8.4)
  550 + - WeiboSDK (3.1.3)
536 551 - YYAsyncLayer (1.0)
537 552 - YYCache (1.0.4)
538 553 - YYCategories (1.0.4):
... ... @@ -554,7 +569,6 @@ DEPENDENCIES:
554 569 - CNLiveEnvironment
555 570 - CNLiveRequestBastKit
556 571 - CNLiveVideoClassifyKit (from `../`)
557   - - FWDebug
558 572  
559 573 SPEC REPOS:
560 574 http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git:
... ... @@ -572,11 +586,12 @@ SPEC REPOS:
572 586 - CNLiveEnvironment
573 587 - CNLiveNewTripartiteManagement
574 588 - CNLiveRequestBastKit
  589 + - CNLiveShareToolKit
  590 + - CNLiveTripartiteManagement
575 591 - CNLiveUserManagement
576 592 https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git:
577 593 - AFNetworking
578 594 - CNLiveSDK
579   - - FWDebug
580 595 - JXCategoryView
581 596 - Masonry
582 597 - MJExtension
... ... @@ -589,6 +604,8 @@ SPEC REPOS:
589 604 - UMCCommon
590 605 - UMDevice
591 606 - WebViewJavascriptBridge
  607 + - WechatOpenSDK
  608 + - WeiboSDK
592 609 - YYAsyncLayer
593 610 - YYCache
594 611 - YYCategories
... ... @@ -620,9 +637,10 @@ SPEC CHECKSUMS:
620 637 CNLiveNewTripartiteManagement: 29ddb2d23ee77bcd42ba5eaf5f1322ed37db5baa
621 638 CNLiveRequestBastKit: 9fe28913b94a0a072298eba3356f17b98ef0b6cd
622 639 CNLiveSDK: 75bafaafbb8c09dcb4420adfe0f05130405b25e7
  640 + CNLiveShareToolKit: 4d24fe14457b872f4072213b0807af9870a9ebe5
  641 + CNLiveTripartiteManagement: 9754e873f5fe77f05a05586b1fd302f7dd8f9be2
623 642 CNLiveUserManagement: ead053f2d701b01ea8fb5f1da572be788f2dd3cf
624   - CNLiveVideoClassifyKit: 93e209d722bc49c77af28be46023f668f7c07e86
625   - FWDebug: 5a20d089a300517153de1438d8128ad4c4690951
  643 + CNLiveVideoClassifyKit: c6399b27ae425a681b14cf54d72c896fa4efae46
626 644 JXCategoryView: 2ef9ecfd3735158d009ce02d1f29811aa822da65
627 645 Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
628 646 MJExtension: 635f2c663dcb1bf76fa4b715b2570a5710aec545
... ... @@ -635,6 +653,8 @@ SPEC CHECKSUMS:
635 653 UMCCommon: 67766370204f54467c2271a13397c403992ebeec
636 654 UMDevice: 053478c4b4d7292f31f0a275c227d3c4007a5571
637 655 WebViewJavascriptBridge: 7f5bc4d3581e672e8f32bd0f812d54bc69bb8e29
  656 + WechatOpenSDK: 9b721089507c895d05f997408c30bb6e6f5f9b60
  657 + WeiboSDK: acb067053668102cf07d01aa7604350162c2e466
638 658 YYAsyncLayer: df6b01ebc695c5f6b4c15dd5c23fa3e081eb25c0
639 659 YYCache: 8105b6638f5e849296c71f331ff83891a4942952
640 660 YYCategories: 6bcd4314c6661a561410dce4a793379ebd306abd
... ... @@ -645,6 +665,6 @@ SPEC CHECKSUMS:
645 665 YYText: 5c461d709e24d55a182d1441c41dc639a18a4849
646 666 YYWebImage: 5f7f36aee2ae293f016d418c7d6ba05c4863e928
647 667  
648   -PODFILE CHECKSUM: 8b9baccf9e475fa95c919cdeef4cb1daa577c0d6
  668 +PODFILE CHECKSUM: 15abd620d963efb1c7088ebf4d46af48a01be4ba
649 669  
650 670 COCOAPODS: 1.11.2
... ...