Commit 18b43dc493b992a4022855e43aaf7b8849058220
1 parent
d4abf9b9
分类控制器修改
Showing
34 changed files
with
1569 additions
and
79 deletions
CNLiveVideoClassifyKit.podspec
| ... | ... | @@ -32,15 +32,21 @@ TODO: Add long description of the pod here. |
| 32 | 32 | |
| 33 | 33 | s.source_files = 'CNLiveVideoClassifyKit/Classes/**/*' |
| 34 | 34 | |
| 35 | - | |
| 36 | - s.resource_bundles = { | |
| 37 | - 'CNLiveVideoClassifyKit' => ['CNLiveVideoClassifyKit/Assets/Assets.xcassets'] | |
| 38 | - } | |
| 39 | - | |
| 40 | - # s.public_header_files = 'Pod/Classes/**/*.h' | |
| 35 | + s.resources = 'CNLiveVideoClassifyKit/Assets/**/*.bundle' | |
| 36 | +# s.resource_bundles = { | |
| 37 | +# 'CNLiveVideoClassifyKit' => ['CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle'] | |
| 38 | +# } | |
| 39 | + s.prefix_header_contents = '#import "CNLivevideoClassifyPCH.h"' | |
| 40 | + s.public_header_files = 'Pod/Classes/**/*.h' | |
| 41 | 41 | # s.frameworks = 'UIKit', 'MapKit' |
| 42 | 42 | s.dependency 'JXCategoryView' |
| 43 | - s.dependency 'MJExtension' | |
| 43 | + s.dependency 'CNLiveTripartiteManagement/MJExtension' | |
| 44 | 44 | s.dependency 'CNLiveBaseKit' |
| 45 | 45 | s.dependency 'CNLiveBaseClass' |
| 46 | + s.dependency 'CNLiveUserManagement' | |
| 47 | + s.dependency 'CNLiveCommonCategory' | |
| 48 | + s.dependency 'CNLiveTripartiteManagement/SDWebImage' | |
| 49 | + s.dependency 'CNLiveTripartiteManagement/Masonry' | |
| 50 | + s.dependency 'CNLiveTripartiteManagement/YYKit' | |
| 51 | + | |
| 46 | 52 | end | ... | ... |
CNLiveVideoClassifyKit/Assets/Assets.xcassets/Contents.json deleted
100644 → 0
CNLiveVideoClassifyKit/Assets/Assets.xcassets/selectImage.imageset/Contents.json deleted
100644 → 0
| 1 | -{ | |
| 2 | - "images" : [ | |
| 3 | - { | |
| 4 | - "idiom" : "universal", | |
| 5 | - "scale" : "1x" | |
| 6 | - }, | |
| 7 | - { | |
| 8 | - "filename" : "crab_selected.png", | |
| 9 | - "idiom" : "universal", | |
| 10 | - "scale" : "2x" | |
| 11 | - }, | |
| 12 | - { | |
| 13 | - "filename" : "crab_selected-1.png", | |
| 14 | - "idiom" : "universal", | |
| 15 | - "scale" : "3x" | |
| 16 | - } | |
| 17 | - ], | |
| 18 | - "info" : { | |
| 19 | - "author" : "xcode", | |
| 20 | - "version" : 1 | |
| 21 | - } | |
| 22 | -} |
CNLiveVideoClassifyKit/Assets/Assets.xcassets/selectImage.imageset/crab_selected-1.png deleted
100644 → 0
2.14 KB
CNLiveVideoClassifyKit/Assets/Assets.xcassets/selectImage.imageset/crab_selected.png deleted
100644 → 0
2.14 KB
CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/ik_subtitle_more_black@2x.png
0 → 100644
1.39 KB
CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/ik_subtitle_more_black@3x.png
0 → 100644
5.42 KB
CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/ik_subtitle_more_white@2x.png
0 → 100644
1.97 KB
CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/ik_subtitle_more_white@3x.png
0 → 100644
4.77 KB
CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/jj_close@2x.png
0 → 100644
429 Bytes
CNLiveVideoClassifyKit/Assets/CNSegmentControl.bundle/jj_close@3x.png
0 → 100644
1.31 KB
CNLiveVideoClassifyKit/Classes/Controller/CNCategoryBaseViewController.h
| ... | ... | @@ -6,11 +6,12 @@ |
| 6 | 6 | //分类试图控制器基类 |
| 7 | 7 | |
| 8 | 8 | #import <CNLiveBaseClass/CNLiveBaseViewController.h> |
| 9 | +#import <JXCategoryView/JXCategoryView.h> | |
| 9 | 10 | |
| 10 | 11 | NS_ASSUME_NONNULL_BEGIN |
| 11 | 12 | |
| 12 | 13 | @interface CNCategoryBaseViewController : CNLiveBaseViewController<JXCategoryListContainerViewDelegate,JXCategoryViewDelegate> |
| 13 | -@property (nonatomic, strong) NSArray *titles; | |
| 14 | +@property (nonatomic, strong) NSMutableArray *titles; | |
| 14 | 15 | @property (nonatomic, strong) JXCategoryBaseView *categoryView; |
| 15 | 16 | @property (nonatomic, strong) JXCategoryListContainerView *listContainerView; |
| 16 | 17 | @property (nonatomic, assign) BOOL isNeedIndicatorPositionChangeItem; | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/CNCategoryBaseViewController.m
| ... | ... | @@ -8,7 +8,6 @@ |
| 8 | 8 | #import "CNCategoryBaseViewController.h" |
| 9 | 9 | #import "ListViewController.h" |
| 10 | 10 | |
| 11 | - | |
| 12 | 11 | @interface CNCategoryBaseViewController () |
| 13 | 12 | |
| 14 | 13 | @end |
| ... | ... | @@ -17,9 +16,11 @@ |
| 17 | 16 | |
| 18 | 17 | - (void)viewDidLoad { |
| 19 | 18 | [super viewDidLoad]; |
| 19 | + [self handleDateWithChannelsArray]; | |
| 20 | 20 | [self.view addSubview: self.categoryView]; |
| 21 | 21 | [self.view addSubview:self.listContainerView]; |
| 22 | 22 | self.view.backgroundColor = [UIColor whiteColor]; |
| 23 | + self.navigationHidden = YES; | |
| 23 | 24 | |
| 24 | 25 | // Do any additional setup after loading the view. |
| 25 | 26 | } |
| ... | ... | @@ -35,9 +36,13 @@ |
| 35 | 36 | { |
| 36 | 37 | [super viewWillAppear:animated]; |
| 37 | 38 | self.navigationController.interactivePopGestureRecognizer.enabled = YES; |
| 39 | + self.navigationHidden = YES; | |
| 38 | 40 | } |
| 39 | 41 | |
| 40 | 42 | #pragma mark - Public |
| 43 | +-(void)handleDateWithChannelsArray{ | |
| 44 | + | |
| 45 | +} | |
| 41 | 46 | -(JXCategoryBaseView *)preferredCategoryView{ |
| 42 | 47 | return [[JXCategoryBaseView alloc] init]; |
| 43 | 48 | } |
| ... | ... | @@ -78,8 +83,18 @@ |
| 78 | 83 | - (JXCategoryListContainerView *)listContainerView |
| 79 | 84 | { |
| 80 | 85 | if (!_listContainerView) { |
| 81 | - _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_CollectionView delegate:self]; | |
| 86 | + _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self]; | |
| 87 | + _listContainerView.scrollView.backgroundColor = [UIColor clearColor]; | |
| 88 | + _listContainerView.listCellBackgroundColor = [UIColor clearColor]; | |
| 82 | 89 | } |
| 83 | 90 | return _listContainerView; |
| 84 | 91 | } |
| 92 | + | |
| 93 | +-(NSMutableArray *)titles | |
| 94 | +{ | |
| 95 | + if (!_titles) { | |
| 96 | + _titles = [[NSMutableArray alloc] init]; | |
| 97 | + } | |
| 98 | + return _titles; | |
| 99 | +} | |
| 85 | 100 | @end | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/CNLiveClassifySegmentController.m
| ... | ... | @@ -6,53 +6,274 @@ |
| 6 | 6 | // |
| 7 | 7 | |
| 8 | 8 | #import "CNLiveClassifySegmentController.h" |
| 9 | -#import <JXCategoryView/JXCategoryTitleImageView.h> | |
| 9 | +#import <UIKit/UIKit.h> | |
| 10 | +#import "CNCustomChannelListView.h" | |
| 11 | +#import "CNCategoryGetChannelModel.h" | |
| 12 | +#import "ListViewController.h" | |
| 13 | +#import "CNLiveSubSegmentController.h" | |
| 14 | + | |
| 15 | +@interface CNLiveClassifySegmentController ()<JXCategoryViewDelegate> | |
| 16 | + | |
| 17 | +@property (nonatomic, strong)JXCategoryTitleImageView *myCategoryView; //选择器 | |
| 18 | +@property (nonatomic, strong) UIButton *customChannelsBtn; | |
| 19 | +@property (nonatomic, strong) UIButton *loginBtn; | |
| 20 | +@property (nonatomic, strong) CNCustomChannelListView *customChannelsV; | |
| 21 | +//@property (nonatomic, strong) CNTouristsLoginTipsView *fuzzyView;//游客登录弹框 | |
| 22 | +@property (nonatomic, strong) UIImageView *topBgImg; //头部图片 | |
| 23 | +@property (nonatomic, assign) CGFloat topBgImgHeight;//头部图片高度 | |
| 24 | +@property (nonatomic, assign) CGFloat lastOffsetY; | |
| 25 | + | |
| 26 | +@property (nonatomic, assign) NSInteger currentIndex;//当前页 | |
| 27 | + | |
| 28 | +@property (nonatomic, strong) NSString * currentAtatusColor; | |
| 29 | + | |
| 30 | +@property (nonatomic, strong) NSMutableArray *dataArray; //数据 | |
| 31 | +@property (nonatomic, strong) NSMutableArray *bgImages; //背景图 | |
| 32 | +@property (nonatomic, strong) NSMutableArray *bgColors; //背景色 | |
| 33 | +@property (nonatomic, strong) NSMutableArray *imageNames; //选择器图片 | |
| 34 | +@property (nonatomic, strong) NSMutableArray *imageTypes; //展示类型:图片/文字 | |
| 35 | +@property (nonatomic, strong) NSMutableArray *statusBarColors; //状态栏颜色 | |
| 36 | +@property (nonatomic, strong) NSMutableArray *textColors; //未选中字体颜色 | |
| 37 | +@property (nonatomic, strong) NSMutableArray *textColorSeleteds; //选中字体颜色 | |
| 10 | 38 | |
| 11 | -@interface CNLiveClassifySegmentController () | |
| 12 | -@property (nonatomic, strong)JXCategoryTitleImageView *myCategoryView; | |
| 13 | 39 | @end |
| 14 | 40 | |
| 15 | 41 | @implementation CNLiveClassifySegmentController |
| 16 | - | |
| 42 | +static CGFloat moveHeight = 50; | |
| 17 | 43 | - (void)viewDidLoad { |
| 18 | 44 | [super viewDidLoad]; |
| 19 | - self.titles = @[@"推荐",@"视讯中国",@"听见中国",@"健康中国",@"发现中国"]; | |
| 20 | - NSArray *selectImageNames = @[@"selectImage",@"selectImage",@"selectImage",@"selectImage",@"selectImage"]; | |
| 45 | + self.topBgImgHeight = kStatusHeight+100; | |
| 46 | + [self.view insertSubview:self.topBgImg atIndex:0]; | |
| 47 | + | |
| 48 | + for (int i = 0;i<self.imageNames.count;i++) { | |
| 49 | + NSURL *url = [NSURL URLWithString:self.imageNames[i]]; | |
| 50 | + [self.imageNames replaceObjectAtIndex:i withObject:url]; | |
| 51 | + } | |
| 52 | + //分类控制器基础配置 | |
| 21 | 53 | self.myCategoryView.titles = self.titles; |
| 22 | - self.myCategoryView.selectedImageNames = selectImageNames; | |
| 54 | + self.myCategoryView.delegate = self; | |
| 55 | + self.myCategoryView.translatesAutoresizingMaskIntoConstraints = NO; | |
| 56 | + self.myCategoryView.imageURLs = self.imageNames; | |
| 57 | + self.myCategoryView.loadImageCallback = ^(UIImageView *imageView, NSURL *imageURL) { | |
| 58 | + [imageView sd_setImageWithURL:imageURL]; | |
| 59 | + }; | |
| 60 | + self.myCategoryView.titleColorGradientEnabled = YES; | |
| 61 | + self.myCategoryView.contentEdgeInsetLeft = 10; | |
| 62 | + self.myCategoryView.titleFont = [UIFont fontWithName:@"PingFangSC-Medium" size:15]; | |
| 23 | 63 | self.myCategoryView.imageZoomEnabled = YES; |
| 24 | 64 | self.myCategoryView.imageZoomScale = 1.3; |
| 25 | - self.myCategoryView.averageCellSpacingEnabled = NO; | |
| 65 | + self.myCategoryView.selectedAnimationEnabled = YES; | |
| 66 | + self.myCategoryView.titleLabelZoomEnabled = YES; | |
| 67 | + self.myCategoryView.titleLabelZoomScale = 1.4; | |
| 68 | + self.myCategoryView.cellWidthZoomEnabled = YES; | |
| 69 | + self.myCategoryView.cellWidthZoomScale = 1.3; | |
| 70 | + self.myCategoryView.imageSize = CGSizeMake(56, 18); | |
| 26 | 71 | [self configCategoryViewWithType:JXCategoryTitleImageType_OnlyImage selectIndex:0]; |
| 72 | + | |
| 73 | + self.listContainerView.translatesAutoresizingMaskIntoConstraints = NO; | |
| 74 | +// //增加上下滑动手势 | |
| 75 | +// UISwipeGestureRecognizer *recognizerUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)]; | |
| 76 | +// [recognizerUp setDirection:UISwipeGestureRecognizerDirectionUp]; | |
| 77 | +// [self.listContainerView addGestureRecognizer:recognizerUp]; | |
| 78 | +// | |
| 79 | +// UISwipeGestureRecognizer *recognizerDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)]; | |
| 80 | +// [recognizerDown setDirection:UISwipeGestureRecognizerDirectionDown]; | |
| 81 | +// [self.listContainerView addGestureRecognizer:recognizerDown]; | |
| 27 | 82 | // Do any additional setup after loading the view. |
| 28 | 83 | } |
| 84 | + | |
| 85 | +-(void)viewDidLayoutSubviews | |
| 86 | +{ | |
| 87 | + [super viewDidLayoutSubviews]; | |
| 88 | + [self.myCategoryView.heightAnchor constraintEqualToConstant:[self preferredCategoryViewHeight]].active = YES; | |
| 89 | + [self.myCategoryView.leftAnchor constraintEqualToAnchor:self.view.leftAnchor].active = YES; | |
| 90 | + [self.myCategoryView.topAnchor constraintEqualToAnchor:self.myCategoryView.topAnchor].active = YES; | |
| 91 | + [self.myCategoryView.rightAnchor constraintEqualToAnchor:self.view.rightAnchor].active = YES; | |
| 92 | + [self.myCategoryView.bottomAnchor constraintEqualToAnchor:self.listContainerView.topAnchor].active = YES; | |
| 93 | + [self.listContainerView.leftAnchor constraintEqualToAnchor:self.view.leftAnchor].active = YES; | |
| 94 | + [self.listContainerView.rightAnchor constraintEqualToAnchor:self.view.rightAnchor].active = YES; | |
| 95 | + CGFloat listContainerViewHeight = self.view.bounds.size.height; | |
| 96 | + [self.listContainerView.heightAnchor constraintEqualToConstant:listContainerViewHeight].active = YES; | |
| 97 | + | |
| 98 | +} | |
| 99 | + | |
| 100 | +-(void)viewDidAppear:(BOOL)animated | |
| 101 | +{ | |
| 102 | + [super viewDidAppear:animated]; | |
| 103 | +} | |
| 104 | + | |
| 105 | +-(UIStatusBarStyle)preferredStatusBarStyle | |
| 106 | +{ | |
| 107 | + if (self.currentAtatusColor.intValue == 0) { | |
| 108 | + return UIStatusBarStyleLightContent; | |
| 109 | + }else | |
| 110 | + { | |
| 111 | + return UIStatusBarStyleDefault; | |
| 112 | + } | |
| 113 | + | |
| 114 | +} | |
| 29 | 115 | #pragma mark - Method |
| 30 | 116 | |
| 117 | +//配置选中状态显示图片,未选中展示文字 | |
| 31 | 118 | - (void)configCategoryViewWithType:(JXCategoryTitleImageType)imageType selectIndex:(NSInteger)index |
| 32 | 119 | { |
| 33 | 120 | |
| 34 | 121 | NSMutableArray *types = [NSMutableArray array]; |
| 35 | 122 | for (int i = 0; i < self.titles.count; i ++) { |
| 36 | 123 | if (i == index) { |
| 124 | + NSURL *url = self.imageNames[i]; | |
| 125 | + NSString *str = [url absoluteString]; | |
| 126 | + if ([str isEqual:@""]) { | |
| 127 | + [types addObject:@(JXCategoryTitleImageType_OnlyTitle)]; | |
| 128 | + }else{ | |
| 37 | 129 | [types addObject:@(imageType)]; |
| 130 | + } | |
| 38 | 131 | }else{ |
| 39 | 132 | [types addObject:@(JXCategoryTitleImageType_OnlyTitle)]; |
| 40 | 133 | } |
| 41 | 134 | } |
| 135 | + NSString *backgroundImage = [self.bgImages safetyObjectAtIndex:index]; | |
| 136 | + [self.topBgImg sd_setImageWithURL:[NSURL URLWithString:backgroundImage]]; | |
| 137 | + NSString *backgroundColor = [self.bgColors safetyObjectAtIndex:index]; | |
| 138 | + self.topBgImg.backgroundColor = CNLiveColorWithHexString(backgroundColor); | |
| 139 | + self.myCategoryView.titleColor = self.textColors[index]; | |
| 140 | + self.myCategoryView.titleSelectedColor = self.textColorSeleteds[index]; | |
| 42 | 141 | self.myCategoryView.imageTypes = types; |
| 43 | - [self.categoryView reloadData]; | |
| 142 | + if (!self.currentAtatusColor || ![self.currentAtatusColor isEqualToString:self.statusBarColors[index]] ) { | |
| 143 | + self.currentAtatusColor = self.statusBarColors[index]; | |
| 144 | + [self setNeedsStatusBarAppearanceUpdate]; | |
| 145 | + } | |
| 146 | + for (int i = 0; i < self.titles.count; i ++) { | |
| 147 | + [self.myCategoryView reloadCellAtIndex:i]; | |
| 148 | + } | |
| 149 | +} | |
| 150 | + | |
| 151 | +//解析数据 | |
| 152 | +-(void)handleDateWithChannelsArray | |
| 153 | +{ | |
| 154 | + NSString *normalStr = [[NSUserDefaults standardUserDefaults] objectForKey:CNLiveNetAddGetCategoryChannels]; | |
| 155 | + NSDictionary *dic =CNLiveStringJsonToDictionary(normalStr); | |
| 156 | + NSArray *normalArray = dic[@"data"]; | |
| 157 | + [self.dataArray removeAllObjects]; | |
| 158 | + [self.titles removeAllObjects]; | |
| 159 | + [self.imageNames removeAllObjects]; | |
| 160 | + [self.bgImages removeAllObjects]; | |
| 161 | + [self.bgColors removeAllObjects]; | |
| 162 | + [self.textColors removeAllObjects]; | |
| 163 | + [self.textColorSeleteds removeAllObjects]; | |
| 164 | + [self.statusBarColors removeAllObjects]; | |
| 165 | + for (NSDictionary *dic in normalArray) { | |
| 166 | + CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic]; | |
| 167 | + [self.dataArray addObject:model]; | |
| 168 | + [self.titles addObject:model.showName]; | |
| 169 | + if (model.img) { | |
| 170 | + [self.imageNames addObject:model.img]; | |
| 171 | + }else{ | |
| 172 | + [self.imageNames addObject:@""]; | |
| 173 | + } | |
| 174 | + if (!CNLiveStringIsEmpty(model.backgroundImg)) { | |
| 175 | + [self.bgImages addObject:model.backgroundImg]; | |
| 176 | + } else { | |
| 177 | + [self.bgImages addObject:@""]; | |
| 178 | + } | |
| 179 | + if (!CNLiveStringIsEmpty(model.backgroundColor)) { | |
| 180 | + [self.bgColors addObject:model.backgroundColor]; | |
| 181 | + } else { | |
| 182 | + [self.bgColors addObject:@"#FFFFFF"]; | |
| 183 | + } | |
| 184 | + if (!CNLiveStringIsEmpty(model.textColor)) { | |
| 185 | + [self.textColors addObject:CNLiveColorWithHexString(model.textColor)]; | |
| 186 | + } else { | |
| 187 | + [self.textColors addObject:CNLiveColorWithHexString(@"#848494")]; | |
| 188 | + } | |
| 189 | + if (!CNLiveStringIsEmpty(model.textColorSelected)) { | |
| 190 | + [self.textColorSeleteds addObject:CNLiveColorWithHexString(model.textColorSelected)]; | |
| 191 | + } else { | |
| 192 | + [self.textColorSeleteds addObject:CNLiveColorWithHexString(@"#13CC0C")]; | |
| 193 | + } | |
| 194 | + if (!CNLiveStringIsEmpty(model.statusBarColor)) { | |
| 195 | + [self.statusBarColors addObject:model.statusBarColor]; | |
| 196 | + [self setNeedsStatusBarAppearanceUpdate]; | |
| 197 | + }else | |
| 198 | + { | |
| 199 | + [self.statusBarColors addObject:@"1"]; | |
| 200 | + } | |
| 201 | + } | |
| 202 | +} | |
| 203 | +- (void)listScrollViewDidScroll:(UIScrollView *)scrollView { | |
| 204 | + CGPoint point = CGPointZero; | |
| 205 | + CGFloat offsetY = 0; | |
| 206 | + if (scrollView.contentOffset.y <= 0 && self.myCategoryView.frame.origin.y != kStatusHeight) { | |
| 207 | + point = [scrollView.panGestureRecognizer translationInView:scrollView]; | |
| 208 | + offsetY = point.y - self.lastOffsetY; | |
| 209 | + }else { | |
| 210 | + if ((scrollView.contentOffset.y < 0 && self.myCategoryView.frame.origin.y == kStatusHeight) || scrollView.contentOffset.y + scrollView.bounds.size.height >= scrollView.contentSize.height) { | |
| 211 | + return; | |
| 212 | + } | |
| 213 | + point = scrollView.contentOffset; | |
| 214 | + offsetY = -(point.y - self.lastOffsetY); | |
| 215 | + } | |
| 216 | + | |
| 217 | + if (self.lastOffsetY == 0) { | |
| 218 | + self.lastOffsetY = point.y; | |
| 219 | + return; | |
| 220 | + } | |
| 221 | + CGRect naviBarFrame = self.myCategoryView.frame; | |
| 222 | + naviBarFrame.origin.y += offsetY; | |
| 223 | + naviBarFrame.origin.y = MAX(-[self preferredCategoryViewHeight], MIN(kStatusHeight, naviBarFrame.origin.y)); | |
| 224 | + self.myCategoryView.frame = naviBarFrame; | |
| 225 | + double percent = (naviBarFrame.origin.y + [self preferredCategoryViewHeight])/[self preferredCategoryViewHeight]; | |
| 226 | + self.myCategoryView.alpha = percent; | |
| 227 | + self.lastOffsetY = point.y; | |
| 228 | +} | |
| 229 | + | |
| 230 | +-(void)managerScrollView:(BOOL)enabled | |
| 231 | +{ | |
| 232 | + for (UIView *view in self.listContainerView.scrollView.subviews) { | |
| 233 | + if ([view.viewController isKindOfClass:[CNLiveSubSegmentController class]]) { | |
| 234 | + for (UIView *subView in view.subviews) { | |
| 235 | + if ([subView isKindOfClass:[JXCategoryListContainerView class]]) { | |
| 236 | + JXCategoryListContainerView *titleView = (JXCategoryListContainerView *)subView; | |
| 237 | + titleView.scrollView.scrollEnabled = enabled; | |
| 238 | + self.listContainerView.scrollView.scrollEnabled = !enabled; | |
| 239 | + } | |
| 240 | + } | |
| 241 | + | |
| 242 | + } | |
| 243 | + } | |
| 44 | 244 | } |
| 45 | 245 | #pragma mark - JXCategoryViewDelegate |
| 46 | 246 | |
| 47 | 247 | - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index { |
| 48 | 248 | NSLog(@"%@", NSStringFromSelector(_cmd)); |
| 49 | - | |
| 249 | + self.currentIndex = index; | |
| 50 | 250 | // 侧滑手势处理 |
| 51 | 251 | self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0); |
| 52 | 252 | [self configCategoryViewWithType:JXCategoryTitleImageType_OnlyImage selectIndex:index]; |
| 53 | 253 | } |
| 54 | - | |
| 55 | - | |
| 254 | +#pragma mark - JXCategoryListContainerViewDelegate | |
| 255 | +-(id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index | |
| 256 | +{ | |
| 257 | + CNCategoryGetChannelModel *model = self.dataArray[index]; | |
| 258 | + if (model.pageStyleList.count>0) { | |
| 259 | + self.topBgImg.frame = CGRectMake(0, 0, KScreenWidth, self.topBgImgHeight); | |
| 260 | + CNLiveSubSegmentController *subVC = [[CNLiveSubSegmentController alloc] initWithModel:model]; | |
| 261 | + weakself | |
| 262 | + subVC.scrollViewDidScrollBlock = ^(UIScrollView * _Nonnull scrollView) { | |
| 263 | + [weakSelf listScrollViewDidScroll:scrollView]; | |
| 264 | + }; | |
| 265 | + subVC.willBeginDragging = ^(CGFloat lastOffsetY) { | |
| 266 | + weakSelf.lastOffsetY = lastOffsetY; | |
| 267 | + }; | |
| 268 | + subVC.didEndDragging = ^(CGFloat lastOffsetY) { | |
| 269 | + weakSelf.lastOffsetY = lastOffsetY; | |
| 270 | + }; | |
| 271 | + return subVC; | |
| 272 | + } | |
| 273 | + self.topBgImg.frame = CGRectMake(0, 0, KScreenWidth, self.topBgImgHeight - 50); | |
| 274 | + ListViewController *list = [ListViewController new]; | |
| 275 | + return list; | |
| 276 | +} | |
| 56 | 277 | #pragma mark - Public |
| 57 | 278 | -(JXCategoryBaseView *)preferredCategoryView |
| 58 | 279 | { |
| ... | ... | @@ -65,7 +286,97 @@ |
| 65 | 286 | return (JXCategoryTitleImageView *)self.categoryView; |
| 66 | 287 | } |
| 67 | 288 | |
| 289 | +- (UIImageView *)topBgImg | |
| 290 | +{ | |
| 291 | + if (!_topBgImg) { | |
| 292 | + _topBgImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, self.topBgImgHeight)]; | |
| 293 | + _topBgImg.contentMode = UIViewContentModeScaleAspectFill; | |
| 294 | + | |
| 295 | + } | |
| 296 | + return _topBgImg; | |
| 297 | +} | |
| 298 | + | |
| 299 | +- (UIButton *)customChannelsBtn { | |
| 300 | + if (!_customChannelsBtn) { | |
| 301 | + _customChannelsBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 19, 19)]; | |
| 302 | + [_customChannelsBtn setImage:[UIImage imageNamed:@"ik_subtitle_more-black"] forState:UIControlStateNormal]; | |
| 303 | + [self.customChannelsBtn setImage:[UIImage imageNamed:@"ik_subtitle_more-white"] forState:UIControlStateSelected]; | |
| 304 | + [_customChannelsBtn addTarget:self action:@selector(customAction:) forControlEvents:UIControlEventTouchUpInside]; | |
| 305 | + _customChannelsBtn.touchAreaInsets = UIEdgeInsetsMake(20, 20, 20, 20); | |
| 306 | + } | |
| 307 | + return _customChannelsBtn; | |
| 308 | +} | |
| 309 | + | |
| 68 | 310 | |
| 311 | +- (UIButton *)loginBtn { | |
| 312 | + if (!_loginBtn) { | |
| 313 | + _loginBtn = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 314 | + _loginBtn.backgroundColor = RGBA(35, 212, 30, 1); | |
| 315 | + _loginBtn.frame = CGRectMake(0, 0, 52, 24); | |
| 316 | + _loginBtn.layer.cornerRadius = 12; | |
| 317 | + _loginBtn.layer.masksToBounds = YES; | |
| 318 | + [_loginBtn setTitle:@"登录" forState:UIControlStateNormal]; | |
| 319 | + [_loginBtn setTitleColor:kWhiteColor forState:UIControlStateNormal]; | |
| 320 | + _loginBtn.titleLabel.font = [UIFont systemFontOfSize:13]; | |
| 321 | + [_loginBtn addTarget:self action:@selector(loginAction:) forControlEvents:UIControlEventTouchUpInside]; | |
| 322 | + _loginBtn.touchAreaInsets = UIEdgeInsetsMake(8, 8, 8, 8); | |
| 323 | + } | |
| 324 | + return _loginBtn; | |
| 325 | +} | |
| 326 | + | |
| 327 | +-(NSMutableArray *)imageNames | |
| 328 | +{ | |
| 329 | + if (!_imageNames) { | |
| 330 | + _imageNames = [[NSMutableArray alloc] init]; | |
| 331 | + } | |
| 332 | + return _imageNames; | |
| 333 | +} | |
| 334 | +- (NSMutableArray *)bgImages | |
| 335 | +{ | |
| 336 | + if (!_bgImages) { | |
| 337 | + _bgImages = [[NSMutableArray alloc] init]; | |
| 338 | + } | |
| 339 | + return _bgImages; | |
| 340 | +} | |
| 341 | + | |
| 342 | +- (NSMutableArray *)bgColors | |
| 343 | +{ | |
| 344 | + if (!_bgColors) { | |
| 345 | + _bgColors = [[NSMutableArray alloc] init]; | |
| 346 | + } | |
| 347 | + return _bgColors; | |
| 348 | +} | |
| 349 | + | |
| 350 | +-(NSMutableArray *)textColors | |
| 351 | +{ | |
| 352 | + if (!_textColors) { | |
| 353 | + _textColors = [[NSMutableArray alloc] init]; | |
| 354 | + } | |
| 355 | + return _textColors; | |
| 356 | +} | |
| 357 | + | |
| 358 | +-(NSMutableArray *)textColorSeleteds | |
| 359 | +{ | |
| 360 | + if (!_textColorSeleteds) { | |
| 361 | + _textColorSeleteds = [[NSMutableArray alloc] init]; | |
| 362 | + } | |
| 363 | + return _textColorSeleteds; | |
| 364 | +} | |
| 365 | + | |
| 366 | +-(NSMutableArray *)dataArray | |
| 367 | +{ | |
| 368 | + if (!_dataArray) { | |
| 369 | + _dataArray = [[NSMutableArray alloc] init]; | |
| 370 | + } | |
| 371 | + return _dataArray; | |
| 372 | +} | |
| 373 | +- (NSMutableArray *)statusBarColors | |
| 374 | +{ | |
| 375 | + if (!_statusBarColors) { | |
| 376 | + _statusBarColors = [[NSMutableArray alloc] init]; | |
| 377 | + } | |
| 378 | + return _statusBarColors; | |
| 379 | +} | |
| 69 | 380 | /* |
| 70 | 381 | #pragma mark - Navigation |
| 71 | 382 | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/CNLiveSubSegmentController.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveSubSegmentController.h | |
| 3 | +// CNLiveVideoClassifyKit | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/8/30. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNCategoryBaseViewController.h" | |
| 9 | +@class CNCategoryGetChannelModel; | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLiveSubSegmentController : CNCategoryBaseViewController<JXCategoryListContentViewDelegate> | |
| 14 | +-(instancetype)initWithModel:(CNCategoryGetChannelModel *)model; | |
| 15 | +@property (nonatomic, copy) void (^scrollViewDidScrollBlock)(UIScrollView *); | |
| 16 | +@property (nonatomic, copy) void (^willBeginDragging)(CGFloat ); | |
| 17 | +@property (nonatomic, copy) void (^didEndDragging)(CGFloat ); | |
| 18 | + | |
| 19 | +//- (void)stopScrolling; | |
| 20 | + | |
| 21 | +@end | |
| 22 | + | |
| 23 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/CNLiveSubSegmentController.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveSubSegmentController.m | |
| 3 | +// CNLiveVideoClassifyKit | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/8/30. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveSubSegmentController.h" | |
| 9 | +#import "CNCategoryGetChannelModel.h" | |
| 10 | +#import "ListViewController.h" | |
| 11 | + | |
| 12 | +@interface CNLiveSubSegmentController () | |
| 13 | +@property (nonatomic, strong)JXCategoryTitleView *myCategoryView; | |
| 14 | +@property (nonatomic, strong)NSArray *pageListArr; | |
| 15 | +@property (nonatomic, strong)UIColor *textColor; | |
| 16 | +@property (nonatomic, strong)UIColor *backgroundColor; | |
| 17 | +@property (nonatomic, strong)NSString *backImage; | |
| 18 | + | |
| 19 | + | |
| 20 | +@end | |
| 21 | + | |
| 22 | +@implementation CNLiveSubSegmentController | |
| 23 | + | |
| 24 | +-(instancetype)initWithModel:(CNCategoryGetChannelModel *)model | |
| 25 | +{ | |
| 26 | + self = [super init]; | |
| 27 | + if(self){ | |
| 28 | + self.pageListArr = model.pageStyleList; | |
| 29 | + if (!CNLiveStringIsEmpty(model.textColor)) { | |
| 30 | + self.textColor = CNLiveColorWithHexString(model.textColor); | |
| 31 | + }else | |
| 32 | + { | |
| 33 | + self.textColor = CNLiveColorWithHexString(@"#848494"); | |
| 34 | + } | |
| 35 | + if (!CNLiveStringIsEmpty(model.backgroundColor)) { | |
| 36 | + self.backgroundColor = CNLiveColorWithHexString(model.backgroundColor); | |
| 37 | + }else | |
| 38 | + { | |
| 39 | + self.backgroundColor = CNLiveColorWithHexString(@"#FFFFFF"); | |
| 40 | + } | |
| 41 | + | |
| 42 | + self.backImage = model.backgroundImg; | |
| 43 | + | |
| 44 | + } | |
| 45 | + return self; | |
| 46 | +} | |
| 47 | + | |
| 48 | +- (void)viewDidLoad { | |
| 49 | + [super viewDidLoad]; | |
| 50 | + self.view.backgroundColor = [UIColor clearColor]; | |
| 51 | + self.myCategoryView.titles = self.titles; | |
| 52 | + if (CNLiveStringIsEmpty(self.backImage)) { | |
| 53 | + self.view.backgroundColor = self.backgroundColor; | |
| 54 | + } | |
| 55 | + self.myCategoryView.titleColor = self.textColor; | |
| 56 | + self.myCategoryView.titleSelectedColor = self.textColor; | |
| 57 | + self.myCategoryView.cellSpacing = 32; | |
| 58 | + self.myCategoryView.contentEdgeInsetLeft = 25; | |
| 59 | + self.myCategoryView.averageCellSpacingEnabled = NO; | |
| 60 | + self.myCategoryView.titleFont = [UIFont fontWithName:@"PingFangSC-Medium" size:14]; | |
| 61 | + JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init]; | |
| 62 | + lineView.indicatorWidth = 18; | |
| 63 | + lineView.indicatorColor = self.textColor; | |
| 64 | + self.myCategoryView.indicators = @[lineView]; | |
| 65 | + [self.categoryView reloadData]; | |
| 66 | + self.listContainerView.scrollView.scrollEnabled = NO; | |
| 67 | + // Do any additional setup after loading the view. | |
| 68 | +} | |
| 69 | +-(void)viewDidLayoutSubviews | |
| 70 | +{ | |
| 71 | + [super viewDidLayoutSubviews]; | |
| 72 | + | |
| 73 | + self.categoryView.frame = CGRectMake(0, 0, self.view.bounds.size.width, [self preferredCategoryViewHeight]); | |
| 74 | + self.listContainerView.frame = CGRectMake(0, [self preferredCategoryViewHeight]+10, self.view.bounds.size.width, self.view.bounds.size.height - [self preferredCategoryViewHeight]); | |
| 75 | +} | |
| 76 | +#pragma mark - Method | |
| 77 | +-(void)handleDateWithChannelsArray{ | |
| 78 | + [self.titles removeAllObjects]; | |
| 79 | + | |
| 80 | + for (CNCategoryGetChannelModel *model in self.pageListArr) { | |
| 81 | + [self.titles addObject:model.name]; | |
| 82 | + } | |
| 83 | +} | |
| 84 | +#pragma mark - Public | |
| 85 | +-(JXCategoryTitleView *)preferredCategoryView{ | |
| 86 | + return [[JXCategoryTitleView alloc] init]; | |
| 87 | +} | |
| 88 | +-(CGFloat)preferredCategoryViewHeight | |
| 89 | +{ | |
| 90 | + return 40; | |
| 91 | +} | |
| 92 | +#pragma mark - JXCategoryListContainerViewDelegate | |
| 93 | + | |
| 94 | +-(id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index | |
| 95 | +{ | |
| 96 | + ListViewController *list = [ListViewController new]; | |
| 97 | + weakself | |
| 98 | + list.scrollViewDidScrollBlock = ^(UIScrollView * _Nonnull scrollView) { | |
| 99 | + weakSelf.scrollViewDidScrollBlock(scrollView); | |
| 100 | + }; | |
| 101 | + list.willBeginDragging = ^(UIScrollView * _Nonnull scrollView) { | |
| 102 | + weakSelf.willBeginDragging(0); | |
| 103 | + }; | |
| 104 | + list.didEndDragging = ^(UIScrollView * _Nonnull scrollView) { | |
| 105 | + weakSelf.didEndDragging(0); | |
| 106 | + }; | |
| 107 | + return list; | |
| 108 | +} | |
| 109 | +#pragma mark - JXCategoryListContentViewDelegate | |
| 110 | + | |
| 111 | +/** | |
| 112 | + 实现 <JXCategoryListContentViewDelegate> 协议方法,返回该视图控制器所拥有的「视图」 | |
| 113 | + */ | |
| 114 | +- (UIView *)listView { | |
| 115 | + return self.view; | |
| 116 | +} | |
| 117 | + | |
| 118 | +#pragma mark - Getting&&Setting | |
| 119 | +-(JXCategoryTitleView *)myCategoryView | |
| 120 | +{ | |
| 121 | + return (JXCategoryTitleView *)self.categoryView; | |
| 122 | +} | |
| 123 | + | |
| 124 | +/* | |
| 125 | +#pragma mark - Navigation | |
| 126 | + | |
| 127 | +// In a storyboard-based application, you will often want to do a little preparation before navigation | |
| 128 | +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
| 129 | + // Get the new view controller using [segue destinationViewController]. | |
| 130 | + // Pass the selected object to the new view controller. | |
| 131 | +} | |
| 132 | +*/ | |
| 133 | + | |
| 134 | +@end | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/ListViewController.h
| ... | ... | @@ -6,12 +6,16 @@ |
| 6 | 6 | // |
| 7 | 7 | |
| 8 | 8 | #import <UIKit/UIKit.h> |
| 9 | -#import <JXCategoryView/JXCategoryView.h> | |
| 9 | + | |
| 10 | 10 | |
| 11 | 11 | NS_ASSUME_NONNULL_BEGIN |
| 12 | 12 | |
| 13 | 13 | @interface ListViewController : UIViewController<JXCategoryListContentViewDelegate> |
| 14 | +@property (nonatomic, copy) void (^scrollViewDidScrollBlock)(UIScrollView *); | |
| 15 | +@property (nonatomic, copy) void (^willBeginDragging)(UIScrollView *); | |
| 16 | +@property (nonatomic, copy) void (^didEndDragging)(UIScrollView *); | |
| 14 | 17 | |
| 18 | +- (void)stopScrolling; | |
| 15 | 19 | @end |
| 16 | 20 | |
| 17 | 21 | NS_ASSUME_NONNULL_END | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/ListViewController.m
| ... | ... | @@ -7,16 +7,56 @@ |
| 7 | 7 | |
| 8 | 8 | #import "ListViewController.h" |
| 9 | 9 | |
| 10 | -@interface ListViewController () | |
| 11 | - | |
| 10 | +@interface ListViewController ()<UITableViewDataSource, UITableViewDelegate> | |
| 11 | +@property (nonatomic, strong) UITableView *tableView; | |
| 12 | 12 | @end |
| 13 | 13 | |
| 14 | 14 | @implementation ListViewController |
| 15 | 15 | |
| 16 | 16 | - (void)viewDidLoad { |
| 17 | 17 | [super viewDidLoad]; |
| 18 | + self.view.backgroundColor = [UIColor whiteColor]; | |
| 19 | + self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; | |
| 20 | + if (@available(iOS 11.0, *)) { | |
| 21 | + if ([self.tableView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) { | |
| 22 | + self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; | |
| 23 | + } | |
| 24 | + } | |
| 25 | + self.tableView.dataSource = self; | |
| 26 | + self.tableView.delegate = self; | |
| 27 | + [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"]; | |
| 28 | + [self.view addSubview:self.tableView]; | |
| 18 | 29 | // Do any additional setup after loading the view. |
| 19 | 30 | } |
| 31 | +- (void)viewDidLayoutSubviews { | |
| 32 | + [super viewDidLayoutSubviews]; | |
| 33 | + | |
| 34 | + self.tableView.frame = self.view.bounds; | |
| 35 | +} | |
| 36 | +- (void)stopScrolling { | |
| 37 | + [self.tableView setContentOffset:self.tableView.contentOffset animated:NO]; | |
| 38 | +} | |
| 39 | +- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath { | |
| 40 | + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath]; | |
| 41 | + cell.textLabel.text = [NSString stringWithFormat:@"row:%ld", indexPath.row]; | |
| 42 | + return cell; | |
| 43 | +} | |
| 44 | + | |
| 45 | +- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section { | |
| 46 | + return 100; | |
| 47 | +} | |
| 48 | + | |
| 49 | +- (void)scrollViewDidScroll:(UIScrollView *)scrollView { | |
| 50 | + !self.scrollViewDidScrollBlock ?: self.scrollViewDidScrollBlock(scrollView); | |
| 51 | +} | |
| 52 | + | |
| 53 | +- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { | |
| 54 | + !self.willBeginDragging ?: self.willBeginDragging(scrollView); | |
| 55 | +} | |
| 56 | + | |
| 57 | +- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { | |
| 58 | + !self.didEndDragging ?: self.didEndDragging(scrollView); | |
| 59 | +} | |
| 20 | 60 | #pragma mark - JXCategoryListContentViewDelegate |
| 21 | 61 | |
| 22 | 62 | /** | ... | ... |
CNLiveVideoClassifyKit/Classes/Header/CNLiveCommonDefines.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveCommonDefines.h | |
| 3 | +// Pods | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/8/17. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#ifndef CNLiveCommonDefines_h | |
| 9 | +#define CNLiveCommonDefines_h | |
| 10 | + | |
| 11 | +//#ifndef CNTouristsId | |
| 12 | +//#define CNTouristsId @"100056" //游客Id | |
| 13 | +//#endif | |
| 14 | +#ifndef CNLiveNetAddGetCategoryChannels | |
| 15 | +#define CNLiveNetAddGetCategoryChannels @"CNLiveNetAddGetCategoryChannels" | |
| 16 | +#endif | |
| 17 | +#define NormalChannelArray @"CNLiveNetAddNormalChannelArray" //常用频道 | |
| 18 | +#define OtherChannelArray @"CNLiveNetAddOtherChannelArray" //其他频道 | |
| 19 | +//#define wjjLastAudioInfoSaveKey @"wjjLastAudioInfoSaveKey" | |
| 20 | +//#define CNConnectSuccNotification @"CNConnectSuccNotification" | |
| 21 | +// | |
| 22 | +//// 本地存储音频信息KEY | |
| 23 | +//#define wjjLastAudioInfoSaveKey @"wjjLastAudioInfoSaveKey" | |
| 24 | +//#define wjjIsShowWitnessShadeKey @"wjjIsShowWitnessShadeKey" | |
| 25 | +//#define wjjIsShowSportShadeKey @"wjjIsShowSportShadeKey" | |
| 26 | +//#define wjjIsShowSupervisionShadeKey @"wjjIsShowSupervisionShadeKey"//监管 | |
| 27 | +// | |
| 28 | +//// 分类-听见中国-音频播放进度 | |
| 29 | +//#ifndef WjjAudioPlayerScheduleNotification | |
| 30 | +//#define WjjAudioPlayerScheduleNotification @"WjjAudioPlayerScheduleNotification" | |
| 31 | +//#endif | |
| 32 | +// | |
| 33 | +// | |
| 34 | +//#ifndef WjjAudioPlayerStatusNotification | |
| 35 | +//#define WjjAudioPlayerStatusNotification @"WjjAudioPlayerStatusNotification" | |
| 36 | +//#endif | |
| 37 | +//// 分类-听见中国-播放哪一首音频(contenId) | |
| 38 | +//#ifndef WjjAudioPlayerWhichPlayingNotification | |
| 39 | +//#define WjjAudioPlayerWhichPlayingNotification @"WjjAudioPlayerWhichPlayingNotification" | |
| 40 | +//#endif | |
| 41 | +//// 分类-听见中国-自动切换下一首音频(selectedIndex)详情里面的列表 | |
| 42 | +//#ifndef WjjAudioPlayerWhichPlayingListViewNotification | |
| 43 | +//#define WjjAudioPlayerWhichPlayingListViewNotification @"WjjAudioPlayerWhichPlayingListViewNotification" | |
| 44 | +//#endif | |
| 45 | +//// 分类-听见中国-通知栏中切换上下首音频(Index) | |
| 46 | +//#ifndef WjjNotificationBarChangeUpDownAudioNotification | |
| 47 | +//#define WjjNotificationBarChangeUpDownAudioNotification @"WjjNotificationBarChangeUpDownAudioNotification" | |
| 48 | +//#endif | |
| 49 | +//// 分类-听见中国-一首音频播放完成 | |
| 50 | +//#ifndef WjjAudioPlayDidFinishNotification | |
| 51 | +//#define WjjAudioPlayDidFinishNotification @"WjjAudioPlayDidFinishNotification" | |
| 52 | +//#endif | |
| 53 | +// | |
| 54 | +//// 分类停止播放目击者列表中的视频 | |
| 55 | +//#ifndef WjjH5StopVideoPlayerNotification | |
| 56 | +//#define WjjH5StopVideoPlayerNotification @"WjjH5StopVideoPlayerNotification" | |
| 57 | +//#endif | |
| 58 | +// | |
| 59 | +//#define kCNLiveGeneralMargin 10*RATIO //通用间距 | |
| 60 | +//#define kCNLiveNotGeneralMargin 10 //通用间距 | |
| 61 | +//#define KCNLiveShortGeneralMargin 8.5*RATIO //小间距 | |
| 62 | +//#define KCNLiveShortNotGeneralMargin 8.5 //间距 | |
| 63 | +//#define kCNLiveCellTopMargin 10 * RATIO //cell 顶部灰色留白(添加扩大因数) | |
| 64 | +//#define kCNLiveCellTopFactorMargin 10 //cell 顶部灰色留白(不添加扩大因数) | |
| 65 | +//#define kCNLiveCellPaddingPic 5 // cell 多张图片中间留白 | |
| 66 | +//#define TableViewDefaultOffestHeight 64.f | |
| 67 | +// | |
| 68 | +//static NSString *const CNLiveFirendCircleEmptyItemDesc = @"当前版本过低,暂不支持查看此动态,请升级网家家最新版本查看消息。"; | |
| 69 | +// | |
| 70 | +//#pragma mark - 电商中国首页 | |
| 71 | +////NSString * const kDSHappinessPageControlScrollEnableNotification = @"kDSHappinessPageControlScrollEnableNotification"; | |
| 72 | +// | |
| 73 | +// | |
| 74 | +// | |
| 75 | +//#define cn_WjjH5_Host(url) [NSString stringWithFormat:@"%@%@",[CNLiveEnvironmentManager manager].kWjjH5_Host,url] | |
| 76 | +// | |
| 77 | +//#define RGBACOLOR(r,g,b,a) \ | |
| 78 | +//[UIColor colorWithRed:r/256.f green:g/256.f blue:b/256.f alpha:a] | |
| 79 | + | |
| 80 | +#endif /* CNLiveCommonDefines_h */ | ... | ... |
CNLiveVideoClassifyKit/Classes/Header/CNLiveViewClassifyKitPCH.h deleted
100644 → 0
| 1 | -// | |
| 2 | -// CNLiveViewClassifyKitPCH.h | |
| 3 | -// Pods | |
| 4 | -// | |
| 5 | -// Created by CNLive on 2021/8/12. | |
| 6 | -// | |
| 7 | - | |
| 8 | -#ifndef CNLiveViewClassifyKitPCH_h | |
| 9 | -#define CNLiveViewClassifyKitPCH_h | |
| 10 | - | |
| 11 | - | |
| 12 | -#import <QMUIKit/QMUIKit.h> | |
| 13 | -#import <CNLiveBaseKit/CNLiveBaseKit.h> | |
| 14 | -#import <JXCategoryView/JXCategoryView.h> | |
| 15 | - | |
| 16 | - | |
| 17 | -#endif /* CNLiveViewClassifyKitPCH_h */ |
CNLiveVideoClassifyKit/Classes/Header/CNLivevideoClassifyPCH.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLivevideoClassifyPCH.h | |
| 3 | +// Pods | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/8/18. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#ifndef CNLivevideoClassifyPCH_h | |
| 9 | +#define CNLivevideoClassifyPCH_h | |
| 10 | + | |
| 11 | +#import <JXCategoryView/JXCategoryTitleImageView.h> | |
| 12 | +#import <CNLiveBaseKit/CNLiveBaseKit.h> | |
| 13 | +#import <CNLiveUserManagement/CNUserInfoManager.h> | |
| 14 | +#import <JXCategoryView/JXCategoryView.h> | |
| 15 | +#import <Masonry/Masonry.h> | |
| 16 | +#import <YYKit/YYKit.h> | |
| 17 | +#import <SDWebImage/SDWebImage.h> | |
| 18 | +#import <CNLiveCommonCategory/CNLiveCommonCategory.h> | |
| 19 | +#import <CNLiveCommonCategory/UIColor+CNLiveExtension.h> | |
| 20 | +#import <MJExtension/MJExtension.h> | |
| 21 | +#import "CNLiveCommonDefines.h" | |
| 22 | + | |
| 23 | + | |
| 24 | +#endif /* CNLivevideoClassifyPCH_h */ | ... | ... |
CNLiveVideoClassifyKit/Classes/Model/CNCategoryGetChannelModel.h
0 → 100644
| 1 | +// | |
| 2 | +// CNCategoryGetChannelModel.h | |
| 3 | +// CNLiveNetAdd | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 2018/7/3. | |
| 6 | +// Copyright © 2018年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <Foundation/Foundation.h> | |
| 10 | + | |
| 11 | +@interface CNCategoryGetChannelModel : NSObject | |
| 12 | + | |
| 13 | +//@property (nonatomic, strong) NSString *title; | |
| 14 | +//@property (nonatomic, strong) NSString *img; | |
| 15 | +//@property (nonatomic, strong) NSString *type; | |
| 16 | +@property (nonatomic, strong) NSString *cid; | |
| 17 | +//@property (nonatomic, strong) NSString *url; | |
| 18 | +@property (nonatomic, strong) NSString *icon; | |
| 19 | + | |
| 20 | +@property (nonatomic ,assign) BOOL flag; | |
| 21 | +@property (nonatomic ,copy) NSString *pageUrl; | |
| 22 | +@property (nonatomic ,copy) NSString *channelName; | |
| 23 | +@property (nonatomic ,copy) NSString *channelType; | |
| 24 | +@property (nonatomic ,copy) NSString *channelId; | |
| 25 | +@property (nonatomic ,copy) NSString *channelVer; | |
| 26 | + | |
| 27 | +@property (nonatomic ,copy) NSString *id; | |
| 28 | +@property (nonatomic ,copy) NSString *typeName; | |
| 29 | +@property (nonatomic ,copy) NSString *parentId; | |
| 30 | +@property (nonatomic ,copy) NSString *siteId; | |
| 31 | +@property (nonatomic ,copy) NSString *enable; | |
| 32 | +@property (nonatomic ,copy) NSString *backgroundColor; | |
| 33 | +@property (nonatomic ,copy) NSString *statusBarColor; | |
| 34 | +@property (nonatomic ,copy) NSString *pageId; | |
| 35 | +@property (nonatomic ,copy) NSString *backgroundImg; | |
| 36 | +@property (nonatomic ,copy) NSString *backgroundImgH5; | |
| 37 | +@property (nonatomic ,copy) NSString *thirdUrl; | |
| 38 | +@property (nonatomic ,copy) NSString *textColor; | |
| 39 | +@property (nonatomic ,copy) NSString *type; | |
| 40 | +@property (nonatomic ,copy) NSString *textColorSelected; | |
| 41 | +@property (nonatomic ,copy) NSString *img; | |
| 42 | +@property (nonatomic ,strong) NSArray <CNCategoryGetChannelModel*>*pageStyleList; | |
| 43 | +@property (nonatomic ,copy) NSString *pageType; | |
| 44 | +@property (nonatomic ,copy) NSString *sort; | |
| 45 | +@property (nonatomic ,copy) NSString *name; | |
| 46 | +@property (nonatomic ,copy) NSString *showName; | |
| 47 | +@property (nonatomic ,copy) NSString *defaultPage;//二级默认选中页 | |
| 48 | +@property (nonatomic ,copy) NSString *module;//二级小功能模块,1搜索,2扫一扫 | |
| 49 | + | |
| 50 | +- (NSInteger)containsWithChannelArray:(NSArray <NSString *>*)channelArray; | |
| 51 | + | |
| 52 | +@end | ... | ... |
CNLiveVideoClassifyKit/Classes/Model/CNCategoryGetChannelModel.m
0 → 100644
| 1 | +// | |
| 2 | +// CNCategoryGetChannelModel.m | |
| 3 | +// CNLiveNetAdd | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 2018/7/3. | |
| 6 | +// Copyright © 2018年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "CNCategoryGetChannelModel.h" | |
| 10 | +#import "NSString+CNLiveExtension.h" | |
| 11 | + | |
| 12 | +@implementation CNCategoryGetChannelModel | |
| 13 | + | |
| 14 | +- (instancetype)init | |
| 15 | +{ | |
| 16 | + if (self = [super init]) { | |
| 17 | + [self loadModel]; | |
| 18 | + } | |
| 19 | + return self; | |
| 20 | +} | |
| 21 | + | |
| 22 | +- (void)loadModel | |
| 23 | +{ | |
| 24 | + [CNCategoryGetChannelModel mj_setupObjectClassInArray:^NSDictionary *{ | |
| 25 | + return @{@"pageStyleList":[CNCategoryGetChannelModel class]}; | |
| 26 | + }]; | |
| 27 | +} | |
| 28 | + | |
| 29 | +- (NSInteger)containsWithChannelArray:(NSArray <NSString *>*)channelArray { | |
| 30 | + | |
| 31 | + NSInteger i = 0; | |
| 32 | + for (NSString *str in channelArray) { | |
| 33 | + NSDictionary *dic = CNLiveStringJsonToDictionary(str); | |
| 34 | + CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic]; | |
| 35 | + if ([model.id isEqualToString:self.id]) { | |
| 36 | + return i; | |
| 37 | + } | |
| 38 | + i++; | |
| 39 | + } | |
| 40 | + return -1; | |
| 41 | +} | |
| 42 | + | |
| 43 | +@end | ... | ... |
CNLiveVideoClassifyKit/Classes/view/CNCustomChannelListCell.h
0 → 100644
| 1 | +// | |
| 2 | +// CNCustomChannelListCell.h | |
| 3 | +// CNLiveNetAdd | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 2018/8/21. | |
| 6 | +// Copyright © 2018年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <UIKit/UIKit.h> | |
| 10 | + | |
| 11 | +@interface CNCustomChannelListCell : UICollectionViewCell | |
| 12 | + | |
| 13 | +@property (nonatomic, strong)UIImageView *imageView; | |
| 14 | +@property (nonatomic, strong)UILabel *titleLbl; | |
| 15 | +@property (nonatomic, assign)BOOL isHideAdd; | |
| 16 | +@property (nonatomic, assign)BOOL isNeedAdd; //yes 为+ no 为- | |
| 17 | + | |
| 18 | +@end | ... | ... |
CNLiveVideoClassifyKit/Classes/view/CNCustomChannelListCell.m
0 → 100644
| 1 | +// | |
| 2 | +// CNCustomChannelListCell.m | |
| 3 | +// CNLiveNetAdd | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 2018/8/21. | |
| 6 | +// Copyright © 2018年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "CNCustomChannelListCell.h" | |
| 10 | + | |
| 11 | +#define CellWidth (KScreenWidth / 3) | |
| 12 | +static CGFloat const imageViewHeight = 25.0f; | |
| 13 | + | |
| 14 | +@interface CNCustomChannelListCell () | |
| 15 | + | |
| 16 | +@property (nonatomic, strong)UIImageView *addImageView; | |
| 17 | + | |
| 18 | +@end | |
| 19 | + | |
| 20 | +@implementation CNCustomChannelListCell | |
| 21 | + | |
| 22 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 23 | +{ | |
| 24 | + self = [super initWithFrame:frame]; | |
| 25 | + if (self) { | |
| 26 | + | |
| 27 | + self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake((CellWidth-imageViewHeight)*0.5, 15, imageViewHeight, imageViewHeight)]; | |
| 28 | + self.imageView.image = [UIImage imageNamed:@"more_zwf"]; | |
| 29 | + [self addSubview:self.imageView]; | |
| 30 | + | |
| 31 | + self.titleLbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 15 + imageViewHeight + 22, CellWidth, 14*RATIO)]; | |
| 32 | + self.titleLbl.textAlignment = NSTextAlignmentCenter; | |
| 33 | + self.titleLbl.textColor = KGray102Color; | |
| 34 | + self.titleLbl.font = UIFontCNMake(14); | |
| 35 | + [self addSubview:self.titleLbl]; | |
| 36 | + | |
| 37 | + self.addImageView = [[UIImageView alloc] initWithFrame:CGRectMake(CellWidth - 20, 6, 14, 14)]; | |
| 38 | + self.addImageView.image = [UIImage imageNamed:@"more_add"]; | |
| 39 | + self.addImageView.hidden = YES; | |
| 40 | + [self addSubview:self.addImageView]; | |
| 41 | + | |
| 42 | + } | |
| 43 | + return self; | |
| 44 | +} | |
| 45 | + | |
| 46 | +#pragma mark <SetMethod> | |
| 47 | +- (void)setIsHideAdd:(BOOL)isHideAdd | |
| 48 | +{ | |
| 49 | + _isHideAdd = isHideAdd; | |
| 50 | + if (isHideAdd) { | |
| 51 | + self.addImageView.hidden = YES; | |
| 52 | + } | |
| 53 | + else { | |
| 54 | + self.addImageView.hidden = NO; | |
| 55 | + } | |
| 56 | +} | |
| 57 | + | |
| 58 | +- (void)setIsNeedAdd:(BOOL)isNeedAdd | |
| 59 | +{ | |
| 60 | + _isNeedAdd = isNeedAdd; | |
| 61 | + if (isNeedAdd) { | |
| 62 | + self.addImageView.image = [UIImage imageNamed:@"more_add"]; | |
| 63 | + } | |
| 64 | + else { | |
| 65 | + self.addImageView.image = [UIImage imageNamed:@"more_reduce"]; | |
| 66 | + } | |
| 67 | +} | |
| 68 | + | |
| 69 | +@end | ... | ... |
CNLiveVideoClassifyKit/Classes/view/CNCustomChannelListReusableView.h
0 → 100644
| 1 | +// | |
| 2 | +// CNCustomChannelListReusableView.h | |
| 3 | +// CNLiveNetAdd | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 2018/8/21. | |
| 6 | +// Copyright © 2018年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <UIKit/UIKit.h> | |
| 10 | + | |
| 11 | +@interface CNCustomChannelListReusableView : UICollectionReusableView | |
| 12 | + | |
| 13 | +@property (nonatomic, strong)UILabel *label; | |
| 14 | +@property (nonatomic, assign)BOOL showTip; | |
| 15 | + | |
| 16 | +@end | ... | ... |
CNLiveVideoClassifyKit/Classes/view/CNCustomChannelListReusableView.m
0 → 100644
| 1 | +// | |
| 2 | +// CNCustomChannelListReusableView.m | |
| 3 | +// CNLiveNetAdd | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 2018/8/21. | |
| 6 | +// Copyright © 2018年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "CNCustomChannelListReusableView.h" | |
| 10 | + | |
| 11 | +@interface CNCustomChannelListReusableView () | |
| 12 | + | |
| 13 | +@property (nonatomic, strong) UILabel *tipLab; | |
| 14 | + | |
| 15 | +@end | |
| 16 | + | |
| 17 | +@implementation CNCustomChannelListReusableView | |
| 18 | + | |
| 19 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 20 | +{ | |
| 21 | + self = [super initWithFrame:frame]; | |
| 22 | + if (self) { | |
| 23 | + self.backgroundColor = [UIColor clearColor]; | |
| 24 | + self.label = [[UILabel alloc] initWithFrame:CGRectMake(13, 25, KScreenWidth - 26, 16*RATIO)]; | |
| 25 | + self.label.backgroundColor = [UIColor clearColor]; | |
| 26 | + self.label.textColor = KTextBlackColor; | |
| 27 | + [self addSubview:self.label]; | |
| 28 | + [self addSubview:self.tipLab]; | |
| 29 | + [self.tipLab mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 30 | + make.left.equalTo(self.label); | |
| 31 | + make.top.equalTo(self.label.mas_bottom).offset(8); | |
| 32 | + make.width.mas_equalTo(KScreenWidth-24); | |
| 33 | + make.height.mas_equalTo(12*RATIO); | |
| 34 | + }]; | |
| 35 | + } | |
| 36 | + return self; | |
| 37 | +} | |
| 38 | + | |
| 39 | +- (void)setShowTip:(BOOL)showTip { | |
| 40 | + _showTip = showTip; | |
| 41 | + | |
| 42 | + if (showTip) { | |
| 43 | + self.tipLab.hidden = NO; | |
| 44 | + } else { | |
| 45 | + self.tipLab.hidden = YES; | |
| 46 | + } | |
| 47 | + | |
| 48 | +} | |
| 49 | + | |
| 50 | +- (UILabel *)tipLab { | |
| 51 | + if (!_tipLab) { | |
| 52 | + _tipLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth-24, 12*RATIO)]; | |
| 53 | + _tipLab.font = UIFontBoldCNMake(12.0f); | |
| 54 | + _tipLab.textColor = KGray153Color; | |
| 55 | + _tipLab.text = @"长按拖动可自定义排序及增减频道"; | |
| 56 | + _tipLab.hidden = YES; | |
| 57 | + } | |
| 58 | + return _tipLab; | |
| 59 | +} | |
| 60 | + | |
| 61 | +@end | ... | ... |
CNLiveVideoClassifyKit/Classes/view/CNCustomChannelListView.h
0 → 100644
| 1 | +// | |
| 2 | +// CNCustomChannelListView.h | |
| 3 | +// CNLiveNetAdd | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 2018/12/17. | |
| 6 | +// Copyright © 2018年 cnlive. All rights reserved. | |
| 7 | +// 编辑分类频道页面 | |
| 8 | + | |
| 9 | +#import <UIKit/UIKit.h> | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@protocol CNCustomChannelListViewDelegate <NSObject> | |
| 14 | +//点击关闭按钮 | |
| 15 | +- (void)closeCustomChannelsView; | |
| 16 | +//编辑完频道后点击完成 | |
| 17 | +- (void)changeChannelsList; | |
| 18 | +// 点击了我的频道偏移到对应频道 | |
| 19 | +- (void)didSelectedCommonChannelWithIndex:(NSInteger)index; | |
| 20 | +// 跳转其他频道 | |
| 21 | +- (void)pushToControllerWithIndex:(NSInteger)index; | |
| 22 | + | |
| 23 | +@end | |
| 24 | + | |
| 25 | +@interface CNCustomChannelListView : UIView | |
| 26 | + | |
| 27 | +@property (nonatomic, weak) id <CNCustomChannelListViewDelegate>delegate; | |
| 28 | + | |
| 29 | +@end | |
| 30 | + | |
| 31 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveVideoClassifyKit/Classes/view/CNCustomChannelListView.m
0 → 100644
| 1 | +// | |
| 2 | +// CNCustomChannelListView.m | |
| 3 | +// CNLiveNetAdd | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 2018/12/17. | |
| 6 | +// Copyright © 2018年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "CNCustomChannelListView.h" | |
| 10 | +#import "CNCustomChannelListCell.h" | |
| 11 | +#import "CNCategoryGetChannelModel.h" | |
| 12 | +#import "CNCustomChannelListReusableView.h" | |
| 13 | +#import "NSString+CNLiveExtension.h" | |
| 14 | + | |
| 15 | +static NSString * const reuseIdentifier = @"CustomChannelsCell"; | |
| 16 | +static NSString * const headerIdentifier = @"CustomChannelsHeader"; | |
| 17 | + | |
| 18 | +@interface CNCustomChannelListView ()<UICollectionViewDelegate, UICollectionViewDataSource> | |
| 19 | + | |
| 20 | +@property (nonatomic, strong) UILabel *titleLab; | |
| 21 | +@property (nonatomic, strong) UIButton *closeBtn; | |
| 22 | +@property (nonatomic, strong) UIButton *finishBtn; | |
| 23 | +@property (nonatomic, strong) UIView *lineV; | |
| 24 | +@property (nonatomic, strong) UICollectionView *collectionView; | |
| 25 | +@property (nonatomic, strong) UILongPressGestureRecognizer *longPress; | |
| 26 | +@property (nonatomic, strong) UITapGestureRecognizer *tap; | |
| 27 | + | |
| 28 | +@property (nonatomic, strong) NSMutableArray *commonChannel; | |
| 29 | +@property (nonatomic, strong) NSMutableArray *otherChannel; | |
| 30 | + | |
| 31 | +@property (nonatomic, assign)BOOL isEdit; | |
| 32 | +@property (nonatomic, assign)BOOL isTopY; | |
| 33 | +@property (nonatomic, assign)BOOL isBottomY; | |
| 34 | +@property (nonatomic, assign)BOOL isMoveBegin; | |
| 35 | + | |
| 36 | +@end | |
| 37 | + | |
| 38 | +@implementation CNCustomChannelListView | |
| 39 | + | |
| 40 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 41 | +{ | |
| 42 | + self = [super initWithFrame:frame]; | |
| 43 | + if (self) { | |
| 44 | + [self setupUI]; | |
| 45 | + } | |
| 46 | + return self; | |
| 47 | +} | |
| 48 | + | |
| 49 | +- (void)setupUI { | |
| 50 | + | |
| 51 | + [self addSubview:self.titleLab]; | |
| 52 | + [self addSubview:self.closeBtn]; | |
| 53 | + self.closeBtn.centerY = self.titleLab.centerY; | |
| 54 | + self.closeBtn.right = KScreenWidth-22; | |
| 55 | + [self addSubview:self.finishBtn]; | |
| 56 | + self.finishBtn.centerY = self.titleLab.centerY; | |
| 57 | + self.finishBtn.right = KScreenWidth-16; | |
| 58 | + [self addSubview:self.lineV]; | |
| 59 | + self.lineV.top = self.titleLab.bottom+10; | |
| 60 | + [self addSubview:self.collectionView]; | |
| 61 | + [self.collectionView registerClass:[CNCustomChannelListCell class] forCellWithReuseIdentifier:reuseIdentifier]; | |
| 62 | + [self.collectionView registerClass:[CNCustomChannelListReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:headerIdentifier]; | |
| 63 | + | |
| 64 | + [self getLocalDataAndRefresh]; | |
| 65 | +} | |
| 66 | + | |
| 67 | +- (void)layoutSubviews { | |
| 68 | + [super layoutSubviews]; | |
| 69 | + | |
| 70 | +} | |
| 71 | + | |
| 72 | +#pragma mark - 加载本地数据 | |
| 73 | +- (void)getLocalDataAndRefresh | |
| 74 | +{ | |
| 75 | + NSString *normalKey = [NSString stringWithFormat:@"%@_%@",NormalChannelArray,CNUserShareModel.uid]; | |
| 76 | + NSString *otherKey = [NSString stringWithFormat:@"%@_%@",OtherChannelArray,CNUserShareModel.uid]; | |
| 77 | + self.commonChannel = [NSMutableArray arrayWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:normalKey]]; | |
| 78 | + self.otherChannel = [NSMutableArray arrayWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:otherKey]]; | |
| 79 | + | |
| 80 | + [self.collectionView reloadData]; | |
| 81 | +} | |
| 82 | + | |
| 83 | +#pragma mark - | |
| 84 | +#pragma mark - Action !!!!!!!!!!!!!!!!!!!!!!!! | |
| 85 | +// 关闭 | |
| 86 | +- (void)closeAction:(UIButton *)sender { | |
| 87 | + | |
| 88 | + if (self.delegate && [self.delegate respondsToSelector:@selector(closeCustomChannelsView)]) { | |
| 89 | + [self.delegate closeCustomChannelsView]; | |
| 90 | + } | |
| 91 | +} | |
| 92 | +// 完成 | |
| 93 | +- (void)finishAction:(UIButton *)sender { | |
| 94 | + | |
| 95 | + [self setUIWithIsEdit:NO]; | |
| 96 | + NSString *normalKey = [NSString stringWithFormat:@"%@_%@",NormalChannelArray,CNUserShareModel.uid]; | |
| 97 | + NSString *otherKey = [NSString stringWithFormat:@"%@_%@",OtherChannelArray,CNUserShareModel.uid]; | |
| 98 | + [[NSUserDefaults standardUserDefaults] setObject:self.commonChannel forKey:normalKey]; | |
| 99 | + [[NSUserDefaults standardUserDefaults] setObject:self.otherChannel forKey:otherKey]; | |
| 100 | + [[NSUserDefaults standardUserDefaults] synchronize]; | |
| 101 | + | |
| 102 | + if (self.delegate && [self.delegate respondsToSelector:@selector(changeChannelsList)]) { | |
| 103 | + [self.delegate changeChannelsList]; | |
| 104 | + } | |
| 105 | +} | |
| 106 | +// 是否编辑 | |
| 107 | +- (void)setUIWithIsEdit:(BOOL)edit { | |
| 108 | + | |
| 109 | + if (edit) { | |
| 110 | + self.isEdit = YES; | |
| 111 | + self.closeBtn.hidden = YES; | |
| 112 | + self.finishBtn.hidden = NO; | |
| 113 | + [self.collectionView reloadData]; | |
| 114 | + } else { | |
| 115 | + self.isEdit = NO; | |
| 116 | + self.closeBtn.hidden = NO; | |
| 117 | + self.finishBtn.hidden = YES; | |
| 118 | + [self.collectionView reloadData]; | |
| 119 | + } | |
| 120 | +} | |
| 121 | +// 截图 | |
| 122 | +- (UIView *)customSnapshotFromView:(UIView *)inputView { | |
| 123 | + | |
| 124 | + // Make an image from the input view. | |
| 125 | + UIGraphicsBeginImageContextWithOptions(inputView.bounds.size, NO, 0); | |
| 126 | + [inputView.layer renderInContext:UIGraphicsGetCurrentContext()]; | |
| 127 | + UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
| 128 | + UIGraphicsEndImageContext(); | |
| 129 | + | |
| 130 | + // Create an image view. | |
| 131 | + UIView *snapshot = [[UIImageView alloc] initWithImage:image]; | |
| 132 | + snapshot.layer.masksToBounds = NO; | |
| 133 | + snapshot.layer.cornerRadius = 0.0; | |
| 134 | + snapshot.layer.shadowOffset = CGSizeMake(-5.0, 0.0); | |
| 135 | + snapshot.layer.shadowRadius = 5.0; | |
| 136 | + snapshot.layer.shadowOpacity = 0.4; | |
| 137 | + | |
| 138 | + return snapshot; | |
| 139 | +} | |
| 140 | + | |
| 141 | +#pragma mark - GestureAction !!!!!!!!!!!!!!!!! | |
| 142 | +#pragma mark - 长按 !!!!!!!!!!!!!!!!!! | |
| 143 | +- (void)longPressAction:(UILongPressGestureRecognizer *)longPress | |
| 144 | +{ | |
| 145 | + UIGestureRecognizerState state = longPress.state; | |
| 146 | + | |
| 147 | + CGPoint location = [longPress locationInView:self.collectionView]; | |
| 148 | + NSIndexPath *indexPath = [self.collectionView indexPathForItemAtPoint:location]; | |
| 149 | + | |
| 150 | + static UICollectionViewCell *firstCell = nil; | |
| 151 | + static UICollectionViewCell *lastCell = nil; | |
| 152 | + static float topY; | |
| 153 | + static float bottomY; | |
| 154 | + | |
| 155 | + NSIndexPath *firstIndexPath = [NSIndexPath indexPathForRow:0 inSection:indexPath.section]; | |
| 156 | + firstCell = [self.collectionView cellForItemAtIndexPath:firstIndexPath]; | |
| 157 | + if (firstCell && self.isTopY == NO) { | |
| 158 | + topY = firstCell.frame.origin.y; | |
| 159 | + self.isTopY = YES; | |
| 160 | + } | |
| 161 | + else if(location.y <= topY) { | |
| 162 | + location.y = topY; | |
| 163 | + } | |
| 164 | + | |
| 165 | + NSInteger numberOfSection = [self.collectionView numberOfItemsInSection:indexPath.section]; | |
| 166 | + NSIndexPath *lastIndexPath = [NSIndexPath indexPathForRow:numberOfSection - 1 inSection:indexPath.section]; | |
| 167 | + lastCell = [self.collectionView cellForItemAtIndexPath:lastIndexPath]; | |
| 168 | + if (lastCell && self.isBottomY == NO) { | |
| 169 | + | |
| 170 | + bottomY = lastCell.frame.origin.y + lastCell.frame.size.height; | |
| 171 | + self.isBottomY = YES; | |
| 172 | + } | |
| 173 | + else if(self.isBottomY == YES) { | |
| 174 | + if (location.y >= bottomY) { | |
| 175 | + location.y = bottomY; | |
| 176 | + } | |
| 177 | + } | |
| 178 | + | |
| 179 | + static UIView *snapshot = nil; | |
| 180 | + static NSIndexPath *sourceIndexPath = nil; | |
| 181 | + | |
| 182 | + switch (state) { | |
| 183 | + | |
| 184 | + case UIGestureRecognizerStateBegan: | |
| 185 | + { | |
| 186 | +// indexPath.section == 1 || 其它频道长按编辑解禁 | |
| 187 | + if ((indexPath.section == 0 && indexPath.row == 0)) { | |
| 188 | + self.isMoveBegin = YES; | |
| 189 | + return; | |
| 190 | + } | |
| 191 | + if ((indexPath.section == 1)) {//其他频道禁止拖动 | |
| 192 | + self.isMoveBegin = YES; | |
| 193 | + } | |
| 194 | + | |
| 195 | + if (indexPath) { | |
| 196 | + sourceIndexPath = indexPath; | |
| 197 | + | |
| 198 | + CNCustomChannelListCell *cell = (CNCustomChannelListCell *)[self.collectionView cellForItemAtIndexPath:indexPath]; | |
| 199 | + if (!cell) { | |
| 200 | + return; | |
| 201 | + } | |
| 202 | + | |
| 203 | + if (!self.isEdit) { | |
| 204 | + [self setUIWithIsEdit:YES]; | |
| 205 | + } | |
| 206 | + | |
| 207 | + dispatch_async(dispatch_get_main_queue(), ^{ | |
| 208 | + //刷新完成 | |
| 209 | + CGPoint location2 = [longPress locationInView:self.collectionView]; | |
| 210 | + NSIndexPath *indexPath2 = [self.collectionView indexPathForItemAtPoint:location2]; | |
| 211 | + CNCustomChannelListCell *cell2 = (CNCustomChannelListCell *)[self.collectionView cellForItemAtIndexPath:indexPath2]; | |
| 212 | + | |
| 213 | + snapshot = [self customSnapshotFromView:cell2]; | |
| 214 | + | |
| 215 | + __block CGPoint center = cell2.center; | |
| 216 | + snapshot.center = center; | |
| 217 | + | |
| 218 | + [self.collectionView addSubview:snapshot]; | |
| 219 | + | |
| 220 | + [UIView animateWithDuration:0.25 animations:^{ | |
| 221 | + | |
| 222 | + // center.y = location.y; | |
| 223 | + // center.x = location.x; | |
| 224 | + // snapshot.center = center; | |
| 225 | + | |
| 226 | + snapshot.transform = CGAffineTransformMakeScale(1.05, 1.05); | |
| 227 | + snapshot.alpha = 0.98; | |
| 228 | + cell2.alpha = 0; | |
| 229 | + cell2.hidden = YES; | |
| 230 | + }]; | |
| 231 | + }); | |
| 232 | + | |
| 233 | + } | |
| 234 | + } | |
| 235 | + break; | |
| 236 | + | |
| 237 | + case UIGestureRecognizerStateChanged: | |
| 238 | + { | |
| 239 | + | |
| 240 | + if (self.isMoveBegin) { | |
| 241 | + return; | |
| 242 | + } | |
| 243 | + | |
| 244 | + CGPoint center = snapshot.center; | |
| 245 | + center.x = location.x; | |
| 246 | + center.y = location.y; | |
| 247 | + | |
| 248 | + snapshot.center = center; | |
| 249 | + | |
| 250 | + if (indexPath.section != sourceIndexPath.section) { | |
| 251 | + return; | |
| 252 | + } | |
| 253 | + | |
| 254 | + if (indexPath && indexPath.row != 0 && ![indexPath isEqual:sourceIndexPath]) { | |
| 255 | + | |
| 256 | + long fabs = indexPath.row - sourceIndexPath.row; | |
| 257 | + if (fabs < 0) { | |
| 258 | + | |
| 259 | + NSIndexPath *currentIndexPath = sourceIndexPath; | |
| 260 | + for (int i = 0; i < -fabs; i++) { | |
| 261 | + NSIndexPath *lastIndexPath = [NSIndexPath indexPathForRow:sourceIndexPath.row - i - 1 inSection:sourceIndexPath.section]; | |
| 262 | + [self.commonChannel exchangeObjectAtIndex:lastIndexPath.row withObjectAtIndex:currentIndexPath.row]; | |
| 263 | + [self.collectionView moveItemAtIndexPath:lastIndexPath toIndexPath:currentIndexPath]; | |
| 264 | + | |
| 265 | + currentIndexPath = lastIndexPath; | |
| 266 | + | |
| 267 | + } | |
| 268 | + } | |
| 269 | + else { | |
| 270 | + | |
| 271 | + NSIndexPath *currentIndexPath = sourceIndexPath; | |
| 272 | + for (int i = 0; i < fabs; i++) { | |
| 273 | + NSIndexPath *nextIndexPath = [NSIndexPath indexPathForRow:sourceIndexPath.row +i + 1 inSection:sourceIndexPath.section]; | |
| 274 | + [self.commonChannel exchangeObjectAtIndex:nextIndexPath.row withObjectAtIndex:currentIndexPath.row]; | |
| 275 | + [self.collectionView moveItemAtIndexPath:nextIndexPath toIndexPath:currentIndexPath]; | |
| 276 | + | |
| 277 | + currentIndexPath = nextIndexPath; | |
| 278 | + } | |
| 279 | + } | |
| 280 | + | |
| 281 | + sourceIndexPath = indexPath; | |
| 282 | + } | |
| 283 | + } | |
| 284 | + break; | |
| 285 | + | |
| 286 | + case UIGestureRecognizerStateEnded: | |
| 287 | + { | |
| 288 | + [snapshot removeFromSuperview]; | |
| 289 | + snapshot = nil; | |
| 290 | + CNCustomChannelListCell *cell = (CNCustomChannelListCell *)[self.collectionView cellForItemAtIndexPath:sourceIndexPath]; | |
| 291 | + | |
| 292 | + cell.hidden = NO; | |
| 293 | + cell.alpha = 1; | |
| 294 | + | |
| 295 | + self.isTopY = NO; | |
| 296 | + self.isBottomY = NO; | |
| 297 | + self.isMoveBegin = NO; | |
| 298 | + } | |
| 299 | + break; | |
| 300 | + | |
| 301 | + default: | |
| 302 | + break; | |
| 303 | + } | |
| 304 | +} | |
| 305 | +#pragma mark - 点击 !!!!!!!!!!!!!!!!! | |
| 306 | +- (void)tapAction:(UITapGestureRecognizer *)tap | |
| 307 | +{ | |
| 308 | + CGPoint location = [tap locationInView:self.collectionView]; | |
| 309 | + | |
| 310 | + NSIndexPath *indexPath = [self.collectionView indexPathForItemAtPoint:location]; | |
| 311 | + | |
| 312 | + if (!indexPath) { | |
| 313 | + return; | |
| 314 | + } | |
| 315 | + if (self.isEdit) { | |
| 316 | + if (indexPath.section == 0 && indexPath.row == 0) { | |
| 317 | + return; | |
| 318 | + } | |
| 319 | + | |
| 320 | + if (indexPath.section == 0) { | |
| 321 | + | |
| 322 | + NSIndexPath *secondSectionIndexPath = [NSIndexPath indexPathForRow:self.otherChannel.count inSection:indexPath.section + 1]; | |
| 323 | + | |
| 324 | + [self.otherChannel addObject:[self.commonChannel safetyObjectAtIndex:indexPath.row]]; | |
| 325 | + [self.commonChannel removeObjectAtIndex:indexPath.row]; | |
| 326 | + | |
| 327 | + CNCustomChannelListCell *cell = (CNCustomChannelListCell *)[self.collectionView cellForItemAtIndexPath:indexPath]; | |
| 328 | + cell.isNeedAdd = YES; | |
| 329 | + [self.collectionView moveItemAtIndexPath:indexPath toIndexPath:secondSectionIndexPath]; | |
| 330 | + } | |
| 331 | + else if (indexPath.section == 1) { | |
| 332 | + | |
| 333 | + NSIndexPath *firstSectionIndexPath = [NSIndexPath indexPathForRow:self.commonChannel.count inSection:indexPath.section - 1]; | |
| 334 | + [self.commonChannel addObject:[self.otherChannel safetyObjectAtIndex:indexPath.row]]; | |
| 335 | + [self.otherChannel removeObjectAtIndex:indexPath.row]; | |
| 336 | + | |
| 337 | + CNCustomChannelListCell *cell = (CNCustomChannelListCell *)[self.collectionView cellForItemAtIndexPath:indexPath]; | |
| 338 | + cell.isNeedAdd = NO; | |
| 339 | + [self.collectionView moveItemAtIndexPath:indexPath toIndexPath:firstSectionIndexPath]; | |
| 340 | + } | |
| 341 | + } | |
| 342 | + else { | |
| 343 | + | |
| 344 | + if (indexPath.section == 0) { | |
| 345 | + if (self.delegate && [self.delegate respondsToSelector:@selector(didSelectedCommonChannelWithIndex:)]) { | |
| 346 | + [self.delegate didSelectedCommonChannelWithIndex:indexPath.row]; | |
| 347 | + } | |
| 348 | + } else if (indexPath.section == 1) { | |
| 349 | + | |
| 350 | + if (self.delegate && [self.delegate respondsToSelector:@selector(pushToControllerWithIndex:)]) { | |
| 351 | + [self.delegate pushToControllerWithIndex:indexPath.row]; | |
| 352 | + } | |
| 353 | + } | |
| 354 | + } | |
| 355 | +} | |
| 356 | + | |
| 357 | + | |
| 358 | +#pragma mark - | |
| 359 | +#pragma mark - Delegate | |
| 360 | +#pragma mark - UICollectionViewDelegateFlowLayout !!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 361 | +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section | |
| 362 | +{ | |
| 363 | + if (section==0) { | |
| 364 | + return CGSizeMake(KScreenWidth, 56+12*RATIO); | |
| 365 | + } else if (section==1) { | |
| 366 | + return CGSizeMake(KScreenWidth, 56); | |
| 367 | + } else { | |
| 368 | + return CGSizeZero; | |
| 369 | + } | |
| 370 | +} | |
| 371 | + | |
| 372 | +- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{ | |
| 373 | + | |
| 374 | + CNCustomChannelListReusableView *view = [collectionView dequeueReusableSupplementaryViewOfKind :kind withReuseIdentifier:headerIdentifier forIndexPath:indexPath]; | |
| 375 | + view.label.font = UIFontBoldCNMake(16); | |
| 376 | + | |
| 377 | + if ([kind isEqualToString: UICollectionElementKindSectionHeader]){ | |
| 378 | + if (indexPath.section == 0) { | |
| 379 | + view.label.text = @"我的频道:"; | |
| 380 | + view.showTip = YES; | |
| 381 | + } | |
| 382 | + else if (indexPath.section == 1) { | |
| 383 | + view.label.text = @"其它频道:"; | |
| 384 | + view.showTip = NO; | |
| 385 | + } | |
| 386 | + return view; | |
| 387 | + } | |
| 388 | + else { | |
| 389 | + return view; | |
| 390 | + } | |
| 391 | +} | |
| 392 | + | |
| 393 | +#pragma mark - UICollectionViewDataSource !!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 394 | +- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView | |
| 395 | +{ | |
| 396 | + return 2; | |
| 397 | +} | |
| 398 | + | |
| 399 | +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section | |
| 400 | +{ | |
| 401 | + if (section == 0) { | |
| 402 | + return self.commonChannel.count; | |
| 403 | + } | |
| 404 | + else if (section == 1) { | |
| 405 | + return self.otherChannel.count; | |
| 406 | + } | |
| 407 | + else { | |
| 408 | + return 0; | |
| 409 | + } | |
| 410 | +} | |
| 411 | + | |
| 412 | +- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath | |
| 413 | +{ | |
| 414 | + CNCustomChannelListCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; | |
| 415 | + | |
| 416 | + cell.userInteractionEnabled = NO; | |
| 417 | + | |
| 418 | + if (indexPath.section == 0) { | |
| 419 | + NSString *dataStr = [self.commonChannel safetyObjectAtIndex:indexPath.row]; | |
| 420 | + NSDictionary *dic = CNLiveStringJsonToDictionary(dataStr); | |
| 421 | + CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic]; | |
| 422 | + [cell.imageView sd_setImageWithURL:[NSURL URLWithString:model.icon?model.icon:@""] placeholderImage:[UIImage imageNamed:@"more_zwf"]]; | |
| 423 | + cell.titleLbl.text = model.showName; | |
| 424 | + if (indexPath.row == 0) { | |
| 425 | + cell.isHideAdd = YES; | |
| 426 | + } | |
| 427 | + else { | |
| 428 | + if (self.isEdit) { | |
| 429 | + cell.isHideAdd = NO; | |
| 430 | + } else { | |
| 431 | + cell.isHideAdd = YES; | |
| 432 | + } | |
| 433 | + cell.isNeedAdd = NO; | |
| 434 | + } | |
| 435 | + } | |
| 436 | + else if (indexPath.section == 1) { | |
| 437 | + NSString *dataStr = [self.otherChannel safetyObjectAtIndex:indexPath.row]; | |
| 438 | + NSDictionary *dic = CNLiveStringJsonToDictionary(dataStr); | |
| 439 | + CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic]; | |
| 440 | + [cell.imageView sd_setImageWithURL:[NSURL URLWithString:model.icon?model.icon:@""] placeholderImage:[UIImage imageNamed:@"more_zwf"]]; | |
| 441 | + cell.titleLbl.text = model.showName; | |
| 442 | + if (self.isEdit) { | |
| 443 | + cell.isHideAdd = NO; | |
| 444 | + } else { | |
| 445 | + cell.isHideAdd = YES; | |
| 446 | + } | |
| 447 | + cell.isNeedAdd = YES; | |
| 448 | + } | |
| 449 | + | |
| 450 | + return cell; | |
| 451 | +} | |
| 452 | + | |
| 453 | +#pragma mark - | |
| 454 | +#pragma mark - Getter !!!!!!!!!!!!!!!!!!!!!!!! | |
| 455 | +- (UILabel *)titleLab { | |
| 456 | + if (!_titleLab) { | |
| 457 | + _titleLab = [[UILabel alloc] initWithFrame:CGRectMake(13, kStatusHeight+13, 180, 20*RATIO)]; | |
| 458 | + _titleLab.font = UIFontBoldCNMake(19); | |
| 459 | + _titleLab.textColor = KTextBlackColor; | |
| 460 | + _titleLab.text = @"频道管理"; | |
| 461 | + } | |
| 462 | + return _titleLab; | |
| 463 | +} | |
| 464 | + | |
| 465 | +- (UIButton *)closeBtn { | |
| 466 | + if (!_closeBtn) { | |
| 467 | + _closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 16, 16)]; | |
| 468 | + [_closeBtn setImage:[UIImage imageNamed:@"jj_close"] forState:UIControlStateNormal]; | |
| 469 | + [_closeBtn addTarget:self action:@selector(closeAction:) forControlEvents:UIControlEventTouchUpInside]; | |
| 470 | + _closeBtn.touchAreaInsets = UIEdgeInsetsMake(20, 20, 20, 20); | |
| 471 | + } | |
| 472 | + return _closeBtn; | |
| 473 | +} | |
| 474 | + | |
| 475 | +- (UIButton*)finishBtn { | |
| 476 | + if (!_finishBtn) { | |
| 477 | + _finishBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 16*RATIO)]; | |
| 478 | + [_finishBtn setTitle:@"完成" forState:UIControlStateNormal]; | |
| 479 | + [_finishBtn setTitleColor:KTextBlackColor forState:UIControlStateNormal]; | |
| 480 | + _finishBtn.titleLabel.font = UIFontCNMake(16); | |
| 481 | + _finishBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight; | |
| 482 | + [_finishBtn addTarget:self action:@selector(finishAction:) forControlEvents:UIControlEventTouchUpInside]; | |
| 483 | + _finishBtn.touchAreaInsets = UIEdgeInsetsMake(20, 20, 20, 20); | |
| 484 | + _finishBtn.hidden = YES; | |
| 485 | + } | |
| 486 | + return _finishBtn; | |
| 487 | +} | |
| 488 | + | |
| 489 | +- (UIView *)lineV { | |
| 490 | + if (!_lineV) { | |
| 491 | + _lineV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 0.5)]; | |
| 492 | + _lineV.backgroundColor = KCommonLineColor; | |
| 493 | + } | |
| 494 | + return _lineV; | |
| 495 | +} | |
| 496 | + | |
| 497 | +- (UICollectionView *)collectionView { | |
| 498 | + if (!_collectionView) { | |
| 499 | + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; | |
| 500 | + layout.itemSize = CGSizeMake((KScreenWidth / 3), 15+25+22+14*RATIO+15); | |
| 501 | + layout.minimumInteritemSpacing = 0; | |
| 502 | + layout.minimumLineSpacing = 10; | |
| 503 | + _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, kNavigationBarHeight, KScreenWidth, KScreenHeight-kNavigationBarHeight-49-kVerticalBottomSafeHeight) collectionViewLayout:layout]; | |
| 504 | + _collectionView.backgroundColor = kWhiteColor; | |
| 505 | + _collectionView.delegate = self; | |
| 506 | + _collectionView.dataSource = self; | |
| 507 | + [_collectionView addGestureRecognizer:self.tap]; | |
| 508 | + [_collectionView addGestureRecognizer:self.longPress]; | |
| 509 | + } | |
| 510 | + return _collectionView; | |
| 511 | +} | |
| 512 | + | |
| 513 | +- (UILongPressGestureRecognizer *)longPress | |
| 514 | +{ | |
| 515 | + if (!_longPress) { | |
| 516 | + _longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressAction:)]; | |
| 517 | + } | |
| 518 | + return _longPress; | |
| 519 | +} | |
| 520 | + | |
| 521 | +- (UITapGestureRecognizer *)tap | |
| 522 | +{ | |
| 523 | + if (!_tap) { | |
| 524 | + _tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)]; | |
| 525 | + } | |
| 526 | + return _tap; | |
| 527 | +} | |
| 528 | + | |
| 529 | +- (NSMutableArray *)commonChannel | |
| 530 | +{ | |
| 531 | + if (!_commonChannel) { | |
| 532 | + _commonChannel = [[NSMutableArray alloc] initWithCapacity:10]; | |
| 533 | + } | |
| 534 | + return _commonChannel; | |
| 535 | +} | |
| 536 | + | |
| 537 | +- (NSMutableArray *)otherChannel | |
| 538 | +{ | |
| 539 | + if (!_otherChannel) { | |
| 540 | + _otherChannel = [[NSMutableArray alloc] initWithCapacity:10]; | |
| 541 | + } | |
| 542 | + return _otherChannel; | |
| 543 | +} | |
| 544 | + | |
| 545 | +@end | ... | ... |
Example/CNLiveVideoClassifyKit.xcodeproj/project.pbxproj
| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | objects = { |
| 8 | 8 | |
| 9 | 9 | /* Begin PBXBuildFile section */ |
| 10 | - 0816338F26BE298900B076D6 /* CNliveCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 0816338E26BE298900B076D6 /* CNliveCollectionViewCell.m */; }; | |
| 10 | + 083CB9C326D4ED2000E21EBC /* CNliveCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 0816338E26BE298900B076D6 /* CNliveCollectionViewCell.m */; }; | |
| 11 | 11 | 14963F4E510A1E5865D15ED8 /* Pods_CNLiveVideoClassifyKit_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7743536FE5FB6796BFAA55B5 /* Pods_CNLiveVideoClassifyKit_Tests.framework */; }; |
| 12 | 12 | 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; |
| 13 | 13 | 6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; }; |
| ... | ... | @@ -355,29 +355,45 @@ |
| 355 | 355 | ); |
| 356 | 356 | inputPaths = ( |
| 357 | 357 | "${PODS_ROOT}/Target Support Files/Pods-CNLiveVideoClassifyKit_Example/Pods-CNLiveVideoClassifyKit_Example-frameworks.sh", |
| 358 | + "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework", | |
| 358 | 359 | "${BUILT_PRODUCTS_DIR}/CNLiveBaseClass/CNLiveBaseClass.framework", |
| 359 | 360 | "${BUILT_PRODUCTS_DIR}/CNLiveBaseKit/CNLiveBaseKit.framework", |
| 360 | 361 | "${BUILT_PRODUCTS_DIR}/CNLiveCategory/CNLiveCategory.framework", |
| 362 | + "${BUILT_PRODUCTS_DIR}/CNLiveCommonCategory/CNLiveCommonCategory.framework", | |
| 361 | 363 | "${BUILT_PRODUCTS_DIR}/CNLiveCustomControl/CNLiveCustomControl.framework", |
| 364 | + "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework", | |
| 365 | + "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework", | |
| 362 | 366 | "${BUILT_PRODUCTS_DIR}/CNLiveTripartiteManagement/CNLiveTripartiteManagement.framework", |
| 367 | + "${BUILT_PRODUCTS_DIR}/CNLiveUserManagement/CNLiveUserManagement.framework", | |
| 363 | 368 | "${BUILT_PRODUCTS_DIR}/CNLiveVideoClassifyKit/CNLiveVideoClassifyKit.framework", |
| 364 | 369 | "${BUILT_PRODUCTS_DIR}/JXCategoryView/JXCategoryView.framework", |
| 365 | 370 | "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework", |
| 371 | + "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework", | |
| 366 | 372 | "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework", |
| 373 | + "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework", | |
| 367 | 374 | "${BUILT_PRODUCTS_DIR}/WebViewJavascriptBridge/WebViewJavascriptBridge.framework", |
| 375 | + "${BUILT_PRODUCTS_DIR}/YYKit/YYKit.framework", | |
| 368 | 376 | ); |
| 369 | 377 | name = "[CP] Embed Pods Frameworks"; |
| 370 | 378 | outputPaths = ( |
| 379 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework", | |
| 371 | 380 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseClass.framework", |
| 372 | 381 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseKit.framework", |
| 373 | 382 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCategory.framework", |
| 383 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonCategory.framework", | |
| 374 | 384 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCustomControl.framework", |
| 385 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework", | |
| 386 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework", | |
| 375 | 387 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveTripartiteManagement.framework", |
| 388 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserManagement.framework", | |
| 376 | 389 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveVideoClassifyKit.framework", |
| 377 | 390 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/JXCategoryView.framework", |
| 378 | 391 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJExtension.framework", |
| 392 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework", | |
| 379 | 393 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework", |
| 394 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", | |
| 380 | 395 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WebViewJavascriptBridge.framework", |
| 396 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYKit.framework", | |
| 381 | 397 | ); |
| 382 | 398 | runOnlyForDeploymentPostprocessing = 0; |
| 383 | 399 | shellPath = /bin/sh; |
| ... | ... | @@ -391,8 +407,8 @@ |
| 391 | 407 | isa = PBXSourcesBuildPhase; |
| 392 | 408 | buildActionMask = 2147483647; |
| 393 | 409 | files = ( |
| 410 | + 083CB9C326D4ED2000E21EBC /* CNliveCollectionViewCell.m in Sources */, | |
| 394 | 411 | 6003F59E195388D20070C39A /* CNLIVEAppDelegate.m in Sources */, |
| 395 | - 0816338F26BE298900B076D6 /* CNliveCollectionViewCell.m in Sources */, | |
| 396 | 412 | 6003F5A7195388D20070C39A /* CNLIVEViewController.m in Sources */, |
| 397 | 413 | 6003F59A195388D20070C39A /* main.m in Sources */, |
| 398 | 414 | ); | ... | ... |
Example/CNLiveVideoClassifyKit/CNLIVEAppDelegate.m
| ... | ... | @@ -7,11 +7,13 @@ |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | 9 | #import "CNLIVEAppDelegate.h" |
| 10 | +#import <CNLiveEnvironment/CNLiveEnvironment.h> | |
| 10 | 11 | |
| 11 | 12 | @implementation CNLIVEAppDelegate |
| 12 | 13 | |
| 13 | 14 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions |
| 14 | 15 | { |
| 16 | + [CNLiveEnvironmentManager setEnvironment:CNLiveDebugAppStore];//CNLiveDebugAppStore];//CNLiveProductionAppStore//CNLiveTestFlight | |
| 15 | 17 | // Override point for customization after application launch. |
| 16 | 18 | return YES; |
| 17 | 19 | } | ... | ... |
Example/CNLiveVideoClassifyKit/CNLIVEViewController.m
| ... | ... | @@ -10,8 +10,23 @@ |
| 10 | 10 | #import <CNLiveBaseKit/CNLiveBaseKit.h> |
| 11 | 11 | #import "CNliveCollectionViewCell.h" |
| 12 | 12 | #import <CNLiveVideoClassifyKit/CNLiveClassifySegmentController.h> |
| 13 | +#import <CNLiveNetworking.h> | |
| 14 | +#import <NSString+CNLiveExtension.h> | |
| 15 | +#import <CNLiveEnvironment/CNLiveEnvironment.h> | |
| 16 | +#import <CNUserInfoManager.h> | |
| 17 | +#import <CNLiveNetworking.h> | |
| 18 | +#import <CNLiveCommonCategory/CNLiveCommonCategory.h> | |
| 19 | +#import <MJExtension.h> | |
| 13 | 20 | |
| 14 | 21 | |
| 22 | +#ifndef CNTouristsId | |
| 23 | +#define CNTouristsId @"100056" //游客Id | |
| 24 | +#endif | |
| 25 | + | |
| 26 | +#ifndef CNLiveNetAddGetCategoryChannels | |
| 27 | +#define CNLiveNetAddGetCategoryChannels @"CNLiveNetAddGetCategoryChannels" | |
| 28 | +#endif | |
| 29 | + | |
| 15 | 30 | @interface CNLIVEViewController ()<UICollectionViewDelegate,UICollectionViewDataSource> |
| 16 | 31 | { |
| 17 | 32 | NSArray *segArr; |
| ... | ... | @@ -24,6 +39,18 @@ |
| 24 | 39 | - (void)viewDidLoad |
| 25 | 40 | { |
| 26 | 41 | [super viewDidLoad]; |
| 42 | + NSLog(@"%@,%@",CNCategoryGetChannelUrl,CNLiveStringIsEmpty(CNUserShareModel.uid)?CNTouristsId:CNUserShareModel.uid); | |
| 43 | + NSDictionary *dic = @{ | |
| 44 | + @"plat":@"i" | |
| 45 | + }; | |
| 46 | +[CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:CNCategoryGetChannelUrl Param:dic CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | |
| 47 | + if ([NSArray isArray:responseObject[@"data"]]) { | |
| 48 | + NSString *jsonStr = CNLiveNSDictionaryDicToJson(responseObject); | |
| 49 | + [[NSUserDefaults standardUserDefaults] setObject:jsonStr forKey:CNLiveNetAddGetCategoryChannels]; | |
| 50 | + [[NSUserDefaults standardUserDefaults] synchronize]; | |
| 51 | + } | |
| 52 | + | |
| 53 | +}]; | |
| 27 | 54 | self.title = @"首页"; |
| 28 | 55 | segArr = @[@"分类"]; |
| 29 | 56 | [self.view addSubview:self.collectionView]; | ... | ... |
Example/CNLiveVideoClassifyKit/CNLiveVideoClassifyKit-Info.plist
| ... | ... | @@ -2,6 +2,11 @@ |
| 2 | 2 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 3 | 3 | <plist version="1.0"> |
| 4 | 4 | <dict> |
| 5 | + <key>NSAppTransportSecurity</key> | |
| 6 | + <dict> | |
| 7 | + <key>NSAllowsArbitraryLoads</key> | |
| 8 | + <true/> | |
| 9 | + </dict> | |
| 5 | 10 | <key>CFBundleDevelopmentRegion</key> |
| 6 | 11 | <string>en</string> |
| 7 | 12 | <key>CFBundleDisplayName</key> | ... | ... |
Example/Podfile
| ... | ... | @@ -3,15 +3,27 @@ use_frameworks! |
| 3 | 3 | platform :ios, '9.0' |
| 4 | 4 | source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git' |
| 5 | 5 | source 'http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git' |
| 6 | +#source 'http://bj.gitlab.cnlive.com/DSIOSTeam/DSSpecRepos.git' | |
| 6 | 7 | target 'CNLiveVideoClassifyKit_Example' do |
| 7 | 8 | pod 'CNLiveVideoClassifyKit', :path => '../' |
| 8 | - pod 'JXCategoryView' | |
| 9 | - pod 'MJExtension' | |
| 10 | - #基础UI组件库 | |
| 11 | -# pod 'CNLiveCustomUI' | |
| 12 | - pod 'CNLiveBaseClass' | |
| 13 | - #基础组件库 | |
| 14 | - pod 'CNLiveBaseKit' | |
| 9 | + pod 'CNLiveEnvironment' | |
| 10 | + pod 'CNLiveRequestBastKit' | |
| 11 | + #依赖三方私有库,如果里面有.a的时候加上这个 | |
| 12 | + pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {} | |
| 13 | + ############################################ #删除WebViewJavascriptBridge中的WebViewJavascriptBridge.h和WebViewJavascriptBridge.m文件 | |
| 14 | + | |
| 15 | + dir_web = File.join(installer.sandbox.pod_dir('WebViewJavascriptBridge'), 'WebViewJavascriptBridge') | |
| 16 | + Dir.foreach(dir_web) {|x| | |
| 17 | + real_path = File.join(dir_web, x) | |
| 18 | + if (!File.directory?(real_path) && File.exists?(real_path)) | |
| 19 | + if(x == 'WebViewJavascriptBridge.h' || x == 'WebViewJavascriptBridge.m') | |
| 20 | + File.delete(real_path) | |
| 21 | + end | |
| 22 | + end | |
| 23 | + } | |
| 24 | + #删除WebViewJavascriptBridge中的WebViewJavascriptBridge.h和WebViewJavascriptBridge.m文件 | |
| 25 | + ################################################# | |
| 26 | + end | |
| 15 | 27 | target 'CNLiveVideoClassifyKit_Tests' do |
| 16 | 28 | inherit! :search_paths |
| 17 | 29 | ... | ... |