BogoSquareViewController.m 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. //
  2. // BogoSquareViewController.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2021/4/10.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BogoSquareViewController.h"
  9. #import "YHTimeLineViewController.h"
  10. #import "NewSmallVideoViewController.h"
  11. #import "BogoSquarePopView.h"
  12. #import "ReleaseDynamicVC.h"
  13. #import "HMVideoPlayerViewController.h"
  14. #import "MSmallVideoVC.h"
  15. @interface BogoSquareViewController ()
  16. @property(nonatomic, strong) NSArray *listArr;
  17. @property(nonatomic, strong) UIButton *publishBtn;
  18. @property(nonatomic, strong) BogoSquarePopView *popView;
  19. @property(nonatomic, strong) YHTimeLineViewController *dynamicVC;
  20. @property(nonatomic, strong) HMVideoPlayerViewController *videoVC;
  21. @end
  22. @implementation BogoSquareViewController
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. // Do any additional setup after loading the view.
  26. UIImageView *topImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, SCREEN_HEIGHT)];
  27. topImgView.image = [UIImage imageNamed:@"lg_bg"];
  28. [self.view addSubview:topImgView];
  29. self.dynamicVC = [YHTimeLineViewController new];
  30. [self setUpSegView];
  31. // self.publishBtn.hidden = YES;
  32. [self.view addSubview:self.publishBtn];
  33. }
  34. - (void)viewWillAppear:(BOOL)animated {
  35. [super viewWillAppear:animated];
  36. self.navigationController.navigationBarHidden = YES;
  37. }
  38. -(void)setUpSegView{
  39. _listArr = @[ASLocalizedString(@"动态")];
  40. _segHead = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(15, kStatusBarHeight, 200, kRealValue(40)) titles:_listArr headStyle:SegmentHeadStyleLine layoutStyle:MLMSegmentLayoutLeft];
  41. // _segHead.centerX = kScreenW / 2;
  42. //tab颜色
  43. _segHead.selectColor = [UIColor colorWithHexString:@"#333333"];
  44. _segHead.deSelectColor = [UIColor colorWithHexString:@"#666666"];
  45. _segHead.delegate = self;
  46. _segHead.selectFont = [UIFont boldSystemFontOfSize:18];
  47. _segHead.deSelectFont = [UIFont systemFontOfSize:14];
  48. // _segHead.fontScale = 1.1;
  49. // _segHead.fontSize = 18;
  50. //滑块设置
  51. // _segHead.slideHeight = kRealValue(32);
  52. // _segHead.slideCorner = 4;
  53. //// _segHead.moreButton_width = kRealValue(140);
  54. // _segHead.singleW_Add = kRealValue(35);
  55. // _segHead.slideColor = [UIColor colorWithHexString:@"#78FFCB"];
  56. _segHead.lineScale = 0.3;
  57. _segHead.lineHeight = 3.5;
  58. _segHead.lineColor = [UIColor colorWithHexString:@"#78FFCB"];
  59. _segHead.bottomLineHeight = 0;
  60. UIView * line = [self.segHead getScrollLineView];
  61. CGRect rect = line.frame;
  62. rect.origin.y -= 7;
  63. line.frame = rect;
  64. // line.backgroundColor = [UIColor colorWithHexString:@"#78FFCB"];
  65. // UIView *line = [_segHead getLineView];
  66. // CAGradientLayer *gl = [CAGradientLayer layer];
  67. // gl.frame = line.bounds;
  68. // gl.startPoint = CGPointMake(0, 0.5);
  69. // gl.endPoint = CGPointMake(1, 0.5);
  70. // gl.colors = @[(__bridge id)[UIColor colorWithHexString:@"#48C6FF"].CGColor, (__bridge id)[UIColor colorWithHexString:@"#78FFCB"].CGColor];
  71. // gl.locations = @[@(0), @(1.0f)];
  72. // [line.layer insertSublayer:gl atIndex:0];
  73. // line.backgroundColor = kRedColor;
  74. _segHead.headColor = kClearColor;
  75. self.view.backgroundColor = kClearColor;
  76. _segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_segHead.frame), SCREEN_WIDTH, SCREEN_HEIGHT - self.segHead.bottom - kTabBarHeight) vcOrViews:[self vcArr:_listArr.count]];
  77. _segScroll.loadAll = NO;
  78. _segScroll.showIndex = 0;
  79. [MLMSegmentManager associateHead:_segHead withScroll:_segScroll contentChangeAni:YES completion:^{
  80. [self.view addSubview:_segHead];
  81. [self.view addSubview:_segScroll];
  82. // [self setHeadBottomLineView];
  83. } selectEnd:^(NSInteger index) {
  84. if (self.videoVC) {
  85. self.videoVC.isViewAppear = index == 0;
  86. }
  87. }];
  88. self.publishBtn.centerY = _segHead.centerY;
  89. }
  90. //-(void)setHeadBottomLineView{
  91. // UIView *line = [_segHead getScrollLineView];
  92. //
  93. // line.layer.cornerRadius = 2;
  94. // line.layer.masksToBounds = YES;
  95. //
  96. // CAGradientLayer *gl = [CAGradientLayer layer];
  97. // gl.frame = line.bounds;
  98. // gl.startPoint = CGPointMake(0, 0.5);
  99. // gl.endPoint = CGPointMake(1, 0.5);
  100. // gl.colors = @[(__bridge id)[UIColor colorWithHexString:@"#9E64FF"].CGColor, (__bridge id)[UIColor colorWithHexString:@"#EF60F6"].CGColor];
  101. // gl.locations = @[@(0), @(1.0f)];
  102. // [line.layer insertSublayer:gl atIndex:0];
  103. //}
  104. #pragma mark - 数据源
  105. - (NSArray *)vcArr:(NSInteger)count
  106. {
  107. NSMutableArray *arr = [NSMutableArray array];
  108. NSMutableDictionary *hotDic = [NSMutableDictionary dictionary];
  109. [hotDic setObject:@"1" forKey:@"order"];
  110. [hotDic setObject:@"0" forKey:@"cate"];
  111. MSmallVideoVC *hotVC = [[MSmallVideoVC alloc]init];
  112. hotVC.isHaveNavBar = NO;
  113. hotVC.paramDict = hotDic;
  114. // NewSmallVideoViewController *videoVC = [NewSmallVideoViewController new];
  115. [arr addObject:self.dynamicVC];
  116. // [arr addObject:hotVC];
  117. return arr;
  118. }
  119. #pragma mark - 点击事件
  120. -(void)clickPublish:(UIButton *)sender{
  121. self.popView.listArr = @[ASLocalizedString(@"动态")];
  122. // self.popView.frame = CGRectMake(kScreenW - kRealValue(98 + 22), self.publishBtn.bottom, kRealValue(90), kRealValue(98));
  123. [self.popView show:[UIApplication sharedApplication].keyWindow frame:CGRectMake(kScreenW - kRealValue(98), self.publishBtn.bottom, kRealValue(90), kRealValue(40 * self.popView.listArr.count) + kRealValue(10))];
  124. self.popView.clickIndexBlock = ^(NSInteger index) {
  125. if (index == 0) {
  126. [self popDynamicView];
  127. // if (self.clickSquareBtnBlock) {
  128. // self.clickSquareBtnBlock(index);
  129. // }
  130. }else{
  131. [self popDynamicView];
  132. // [self.dynamicVC handleSearchEvent];
  133. }
  134. };
  135. }
  136. -(void)popDynamicView{
  137. ReleaseDynamicVC *pushVC = [ReleaseDynamicVC new];
  138. __weak __typeof(self)weakSelf = self;
  139. pushVC.postFinishBlock = ^(BOOL isFinish) {
  140. if (isFinish) {
  141. [[NSNotificationCenter defaultCenter]postNotificationName:KBogoTimeReloadList object:nil];
  142. }
  143. };
  144. [[AppDelegate sharedAppDelegate]presentViewController:pushVC animated:YES completion:nil];
  145. }
  146. -(UIButton *)publishBtn{
  147. if (!_publishBtn) {
  148. _publishBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  149. _publishBtn.frame = CGRectMake(kScreenW - kRealValue(44) - kRealValue(10), 0, kRealValue(44), kRealValue(44));
  150. [_publishBtn setImage:[UIImage imageNamed:@"bogo_publish_btn"] forState:UIControlStateNormal];
  151. [_publishBtn addTarget:self action:@selector(clickPublish:) forControlEvents:UIControlEventTouchUpInside];
  152. }
  153. return _publishBtn;
  154. }
  155. /*
  156. #pragma mark - Navigation
  157. // In a storyboard-based application, you will often want to do a little preparation before navigation
  158. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  159. // Get the new view controller using [segue destinationViewController].
  160. // Pass the selected object to the new view controller.
  161. }
  162. */
  163. -(BogoSquarePopView *)popView{
  164. if (!_popView) {
  165. _popView = [[BogoSquarePopView alloc]initWithFrame:CGRectMake(0, 0, kRealValue(90), kRealValue(98))];
  166. }
  167. return _popView;
  168. }
  169. @end