NewSmallVideoViewController.m 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. //
  2. // NewSmallVideoViewController.m
  3. // BuguLive
  4. //
  5. // Created by 范东 on 2019/2/20.
  6. // Copyright © 2019 xfg. All rights reserved.
  7. //
  8. #import "NewSmallVideoViewController.h"
  9. #import "MSmallVideoVC.h"
  10. #import "SSearchVC.h"
  11. #import "LeaderboardViewController.h"
  12. @interface NewSmallVideoViewController (){
  13. MSmallVideoVC *_hotVC; //热门
  14. MSmallVideoVC *_latestVC; //最新
  15. MSmallVideoVC *_nearVC; //附近
  16. }
  17. @property(nonatomic,strong)NSMutableArray *infoArrays;
  18. @property (nonatomic, strong) NSMutableArray *itemTitleMutableArray; // 完整的分类标题容器
  19. @property (nonatomic, strong) NSMutableArray *classifiedModelMutableArray; // 服务端下发分类的模型容器
  20. @property (nonatomic, strong) NSMutableArray *videoVCMutableArray; // 服务端下发分类的对应的控制器容器
  21. @property(nonatomic, assign) CGFloat viewHeight;
  22. @property(nonatomic, strong) NSArray *listArr;
  23. @end
  24. @implementation NewSmallVideoViewController
  25. -(void)viewWillAppear:(BOOL)animated{
  26. [super viewWillAppear:YES];
  27. self.navigationController.navigationBarHidden = YES;
  28. }
  29. -(void)viewDidAppear:(BOOL)animated{
  30. [super viewDidAppear:animated];
  31. self.navigationController.navigationBarHidden = YES;
  32. }
  33. -(void)viewWillDisappear:(BOOL)animated{
  34. [super viewWillDisappear:animated];
  35. }
  36. - (void)viewDidLoad {
  37. [super viewDidLoad];
  38. self.infoArrays = [NSMutableArray array];
  39. //arrayWithObjects:ASLocalizedString(@"热门"),ASLocalizedString(@"最新"),ASLocalizedString(@"附近"),nil];
  40. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTableViewStatus) name:@"changeTableViewStatus" object:nil];
  41. self.classifiedModelMutableArray = [NSMutableArray array];
  42. self.videoVCMutableArray = [NSMutableArray array];
  43. self.classifiedModelMutableArray = [GlobalVariables sharedInstance].appModel.video_cate;
  44. [self setUpSegView];
  45. }
  46. -(void)setUpSegView{
  47. _listArr = @[ASLocalizedString(@"推荐"),ASLocalizedString(@"最新"),ASLocalizedString(@"附近")];
  48. [self.infoArrays addObjectsFromArray:_listArr];
  49. // 动态添加视频分类
  50. for (VideoClassifiedModel *model in [GlobalVariables sharedInstance].appModel.video_cate)
  51. {
  52. [self.infoArrays addObject:model.name];
  53. }
  54. _segHead = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(kRealValue(12), 0, kScreenW - kRealValue(12), kRealValue(50)) titles:self.infoArrays headStyle:SegmentHeadStyleLine layoutStyle:MLMSegmentLayoutLeft];
  55. //tab颜色
  56. _segHead.selectColor = [UIColor colorWithHexString:@"#9152F8"];
  57. _segHead.deSelectColor = [UIColor colorWithHexString:@"#777777"];
  58. _segHead.delegate = self;
  59. _segHead.fontScale = 1;
  60. // _segHead.lineHeight = 0;
  61. // _segHead.lineColor = kClearColor;
  62. _segHead.fontSize = 16;
  63. //滑块设置
  64. _segHead.slideHeight = kRealValue(32);
  65. _segHead.slideCorner = 4;
  66. _segHead.moreButton_width = kRealValue(20);
  67. _segHead.singleW_Add = kRealValue(20);
  68. _segHead.slideColor = nil;
  69. _segHead.lineScale = 0.6;
  70. _segHead.lineHeight = 3.5;
  71. _segHead.lineColor = [UIColor colorWithHexString:@"#9152F8"];
  72. _segHead.bottomLineHeight = 0;
  73. // bottomLineHeight
  74. // _segHead.slideScale = 1.5;
  75. _segHead.headColor = kClearColor;
  76. self.view.backgroundColor = kClearColor;
  77. _segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_segHead.frame), SCREEN_WIDTH, SCREEN_HEIGHT - self.segHead.bottom - kTabBarHeight) vcOrViews:[self vcArr:_listArr.count]];
  78. _segScroll.loadAll = NO;
  79. _segScroll.showIndex = 0;
  80. [MLMSegmentManager associateHead:_segHead withScroll:_segScroll completion:^{
  81. [self.view addSubview:_segHead];
  82. [self.view addSubview:_segScroll];
  83. [self setHeadBottomLineView];
  84. }];
  85. self.itemTitleMutableArray = [NSMutableArray array];
  86. self.videoVCMutableArray = [NSMutableArray array];
  87. // [self updateClassiFiedVC];
  88. }
  89. -(void)setHeadBottomLineView{
  90. UIView *line = [_segHead getScrollLineView];
  91. line.layer.cornerRadius = 2;
  92. line.layer.masksToBounds = YES;
  93. CAGradientLayer *gl = [CAGradientLayer layer];
  94. gl.frame = line.bounds;
  95. gl.startPoint = CGPointMake(0, 0.5);
  96. gl.endPoint = CGPointMake(1, 0.5);
  97. gl.colors = @[(__bridge id)[UIColor colorWithHexString:@"#9E64FF"].CGColor, (__bridge id)[UIColor colorWithHexString:@"#EF60F6"].CGColor];
  98. gl.locations = @[@(0), @(1.0f)];
  99. [line.layer insertSublayer:gl atIndex:0];
  100. }
  101. - (void)changeTableViewStatus{
  102. [_hotVC refreshHeader];
  103. [_latestVC refreshHeader];
  104. [_nearVC refreshHeader];
  105. }
  106. - (void)toChatListVC{
  107. BGConversationSegmentController *chatListVC = [[BGConversationSegmentController alloc]init];
  108. [[AppDelegate sharedAppDelegate] pushViewController:chatListVC animated:YES];
  109. }
  110. //进入贡献榜
  111. - (void)Incontribution
  112. {
  113. LeaderboardViewController *vc = [[LeaderboardViewController alloc]init];
  114. // vc.isHiddenTabbar = YES;
  115. [[AppDelegate sharedAppDelegate] pushViewController:vc animated:YES];
  116. }
  117. -(void)search{
  118. SSearchVC *searchVC = [[SSearchVC alloc]init];
  119. searchVC.searchType = @"0";
  120. [[AppDelegate sharedAppDelegate] pushViewController:searchVC animated:YES];
  121. }
  122. #pragma mark - 数据源
  123. - (NSArray *)vcArr:(NSInteger)count
  124. {
  125. NSMutableArray *arr = [NSMutableArray array];
  126. NSMutableDictionary *hotDic = [NSMutableDictionary dictionary];
  127. [hotDic setObject:@"1" forKey:@"order"];
  128. [hotDic setObject:@"0" forKey:@"cate"];
  129. NSMutableDictionary *latestDic = [NSMutableDictionary dictionary];
  130. [latestDic setObject:@"2" forKey:@"order"];
  131. [latestDic setObject:@"0" forKey:@"cate"];
  132. NSMutableDictionary *nearDic = [NSMutableDictionary dictionary];
  133. [nearDic setObject:@"3" forKey:@"order"];
  134. [nearDic setObject:@"0" forKey:@"cate"];
  135. _hotVC = [[MSmallVideoVC alloc]init];
  136. _hotVC.isHaveNavBar = NO;
  137. _hotVC.paramDict = hotDic;
  138. //dictionaryWithObjectsAndKeys:@{@"order":@"1",@"cate":@"0"},nil];
  139. // [NSDictionary dictionaryWithObject:@"1" forKey:@"order"];
  140. _latestVC = [[MSmallVideoVC alloc]init];
  141. _latestVC.isHaveNavBar = NO;
  142. _latestVC.paramDict = latestDic;
  143. //附近
  144. _nearVC = [[MSmallVideoVC alloc]init];
  145. _nearVC.isHaveNavBar = NO;
  146. _nearVC.paramDict = nearDic;
  147. self.viewHeight = kScreenH - self.segHead.bottom - kTabBarHeight - kRealValue(5);
  148. // kScreenH - kStatusBarHeight - kRealValue(44) - kTabBarHeight - MG_BOTTOM_MARGIN - kRealValue(10);
  149. // [self reSizeContentViewWithFrame:CGRectMake(0, 0, kScreenW, self.viewHeight)];
  150. _hotVC.view.height = self.viewHeight;
  151. _hotVC.view.top = 0;
  152. _hotVC.videoCollectionV.height = self.viewHeight;
  153. _latestVC.view.height = self.viewHeight;
  154. _latestVC.videoCollectionV.height = self.viewHeight;
  155. _nearVC.view.height = self.viewHeight;
  156. _nearVC.videoCollectionV.height = self.viewHeight;
  157. [arr addObject:_hotVC];
  158. [arr addObject:_latestVC];
  159. [arr addObject:_nearVC];
  160. if (self.classifiedModelMutableArray.count > 0)
  161. {
  162. }
  163. // self.classifiedModelMutableArray = [GlobalVariables sharedInstance].appModel.video_classified;
  164. for (NSInteger i = 0; i < self.classifiedModelMutableArray.count; ++i)
  165. {
  166. // 服务端下发的分类的在完整的分类容器中的起点
  167. MSmallVideoVC *videoVC = [[MSmallVideoVC alloc]init];
  168. videoVC.isHaveNavBar = NO;
  169. videoVC.view.height = self.viewHeight;
  170. videoVC.videoCollectionV.height = self.viewHeight;
  171. VideoClassifiedModel * model = [[GlobalVariables sharedInstance].appModel.video_cate objectAtIndex:i];
  172. // videoVC.view.frame = CGRectMake(0, 0, kScreenW, kScreenH - kTabBarHeight - kNavigationBarHeight - kRealValue(44));
  173. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  174. [dic setObject:model.id forKey:@"order"];
  175. [dic setObject:model.id forKey:@"cate"];
  176. videoVC.paramDict = dic;
  177. [arr addObject:videoVC];
  178. }
  179. return arr;
  180. }
  181. - (void)updateClassiFiedVC
  182. {
  183. }
  184. /*
  185. #pragma mark - Navigation
  186. // In a storyboard-based application, you will often want to do a little preparation before navigation
  187. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  188. // Get the new view controller using [segue destinationViewController].
  189. // Pass the selected object to the new view controller.
  190. }
  191. */
  192. @end