BogoNewSquareViewController.m 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. //
  2. // BogoNewSquareViewController.m
  3. // BuguLive
  4. //
  5. // Created by Mac on 2021/9/28.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BogoNewSquareViewController.h"
  9. #import "YHTimeLineViewController.h"
  10. #import "HMVideoPlayerViewController.h"
  11. #import "ReleaseDynamicVC.h"
  12. @interface BogoNewSquareViewController ()<UIScrollViewDelegate>
  13. @property(nonatomic, strong) UIButton *videoBtn;
  14. @property(nonatomic, strong) UIButton *dynamicBtn;
  15. @property(nonatomic, strong) UIImageView *lineView;
  16. @property(nonatomic, strong) UIButton *publishBtn;
  17. @property(nonatomic, strong) UIScrollView *scrollView;
  18. @property(nonatomic, strong) HMVideoPlayerViewController *videoVC;
  19. @property(nonatomic, strong) YHTimeLineViewController *timelineVC;
  20. @property(nonatomic, strong) QMUIPopupMenuView *popView;
  21. @end
  22. @implementation BogoNewSquareViewController
  23. - (void)viewDidLoad{
  24. [super viewDidLoad];
  25. //添加一个从上到下的渐变视图 #FBE2FF - #DFFFF9、
  26. CAGradientLayer *gradientLayer = [CAGradientLayer layer];
  27. gradientLayer.frame = CGRectMake(0, 0, kScreenW, 250);
  28. gradientLayer.colors = @[(__bridge id)[UIColor colorWithHexString:@"#FBE2FF"].CGColor, (__bridge id)[UIColor colorWithHexString:@"#DFFFF9"].CGColor];
  29. gradientLayer.startPoint = CGPointMake(0, 0);
  30. gradientLayer.endPoint = CGPointMake(0, 1);
  31. UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
  32. [view.layer insertSublayer:gradientLayer atIndex:0];
  33. [self.view addSubview:view];
  34. [self.view addSubview:self.scrollView];
  35. [self.view addSubview:self.videoBtn];
  36. [self.view addSubview:self.dynamicBtn];
  37. [self.view addSubview:self.lineView];
  38. [self.view addSubview:self.publishBtn];
  39. [self dynamicBtnAction];
  40. }
  41. - (void)viewWillAppear:(BOOL)animated{
  42. [super viewWillAppear:animated];
  43. [self.navigationController setNavigationBarHidden:YES animated:NO];
  44. }
  45. - (void)viewDidAppear:(BOOL)animated{
  46. [super viewDidAppear:animated];
  47. if (self.scrollView.contentOffset.x == 0) {
  48. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  49. }else{
  50. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  51. }
  52. }
  53. - (void)viewWillDisappear:(BOOL)animated{
  54. [super viewWillDisappear:animated];
  55. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  56. }
  57. - (void)videoBtnAction{
  58. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  59. [self.videoVC setIsViewAppear:YES];
  60. [self.scrollView scrollToLeftAnimated:NO];
  61. self.lineView.centerX = self.videoBtn.centerX;
  62. self.videoBtn.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
  63. self.dynamicBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  64. [self.videoBtn setTitleColor:FD_WhiteColor forState:UIControlStateNormal];
  65. [self.dynamicBtn setTitleColor:FD_WhiteColor forState:UIControlStateNormal];
  66. }
  67. - (void)dynamicBtnAction{
  68. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  69. [self.videoVC setIsViewAppear:NO];
  70. // [self.scrollView scrollToRight];
  71. [self.scrollView scrollToRightAnimated:NO];
  72. self.lineView.centerX = self.dynamicBtn.centerX;
  73. self.dynamicBtn.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
  74. self.videoBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  75. [self.videoBtn setTitleColor:[UIColor colorWithHexString:@"#1A1A1A"] forState:UIControlStateNormal];
  76. [self.dynamicBtn setTitleColor:[UIColor colorWithHexString:@"#1A1A1A"] forState:UIControlStateNormal];
  77. }
  78. - (void)publishBtnAction{
  79. [self.popView showWithAnimated:YES];
  80. }
  81. - (QMUIPopupMenuView *)popView{
  82. if (!_popView) {
  83. _popView = [[QMUIPopupMenuView alloc] init];
  84. _popView.automaticallyHidesWhenUserTap = YES;// 点击空白地方消失浮层
  85. _popView.shouldShowItemSeparator = YES;
  86. _popView.itemConfigurationHandler = ^(QMUIPopupMenuView *aMenuView, QMUIPopupMenuButtonItem *aItem, NSInteger section, NSInteger index) {
  87. // 利用 itemConfigurationHandler 批量设置所有 item 的样式
  88. [aItem.button setTitleColor:[UIColor qmui_colorWithHexString:@"333333"] forState:UIControlStateNormal];
  89. aItem.button.titleLabel.font = [UIFont systemFontOfSize:14];
  90. };
  91. _popView.items = @[[QMUIPopupMenuButtonItem itemWithImage:nil title:ASLocalizedString(@"短视频") handler:^(QMUIPopupMenuButtonItem *aItem) {
  92. [aItem.menuView hideWithAnimated:YES];
  93. if (self.clickSquareBtnBlock) {
  94. self.clickSquareBtnBlock(0);
  95. }
  96. }],
  97. [QMUIPopupMenuButtonItem itemWithImage:nil title:ASLocalizedString(@"动态") handler:^(QMUIPopupMenuButtonItem *aItem) {
  98. [aItem.menuView hideWithAnimated:YES];
  99. ReleaseDynamicVC *pushVC = [ReleaseDynamicVC new];
  100. __weak __typeof(self)weakSelf = self;
  101. pushVC.postFinishBlock = ^(BOOL isFinish) {
  102. if (isFinish) {
  103. [[NSNotificationCenter defaultCenter]postNotificationName:KBogoTimeReloadList object:nil];
  104. }
  105. };
  106. [[AppDelegate sharedAppDelegate]presentViewController:pushVC animated:YES completion:nil];
  107. }]];
  108. _popView.didHideBlock = ^(BOOL hidesByUserTap) {
  109. };
  110. _popView.sourceView = self.publishBtn;// 相对于 button4 布局
  111. }
  112. return _popView;
  113. }
  114. - (UIScrollView *)scrollView{
  115. if (!_scrollView) {
  116. _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH - kTabBarHeight)];
  117. _scrollView.contentSize = CGSizeMake(kScreenW * 2, 0);
  118. // _scrollView.delegate = self;
  119. if (@available(iOS 11.0, *)) {
  120. _scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  121. } else {
  122. // Fallback on earlier versions
  123. self.automaticallyAdjustsScrollViewInsets = NO;
  124. }
  125. _scrollView.pagingEnabled = YES;
  126. _scrollView.scrollEnabled = NO;
  127. HMVideoPlayerViewController *videoVC = [[HMVideoPlayerViewController alloc]initWithVideos:nil index:0 IsPushed:NO requestDict:nil];
  128. videoVC.view.frame = CGRectMake(0, 0, FD_ScreenWidth, FD_ScreenHeight - FD_Bottom_Height);
  129. [_scrollView addSubview:videoVC.view];
  130. self.videoVC = videoVC;
  131. YHTimeLineViewController *timelineVC = [YHTimeLineViewController new];
  132. timelineVC.view.frame = CGRectMake(FD_ScreenWidth, FD_Top_Height, FD_ScreenWidth, FD_ScreenHeight - FD_Bottom_Height - FD_Top_Height);
  133. [_scrollView addSubview:timelineVC.view];
  134. self.timelineVC = timelineVC;
  135. self.scrollView.backgroundColor = kClearColor;
  136. }
  137. return _scrollView;
  138. }
  139. - (UIButton *)videoBtn{
  140. if (!_videoBtn) {
  141. _videoBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, FD_StatusBar_Height, 84, FD_Navigation_Height)];
  142. // _videoBtn.right = FD_ScreenWidth / 2 - 15;
  143. _videoBtn.left = kScreenW / 2 + 15;
  144. [_videoBtn setTitleColor:[UIColor colorWithHexString:@"#1A1A1A"] forState:UIControlStateNormal];
  145. [_videoBtn setTitle:ASLocalizedString(@"短视频") forState:UIControlStateNormal];
  146. _videoBtn.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
  147. [_videoBtn addTarget:self action:@selector(videoBtnAction) forControlEvents:UIControlEventTouchUpInside];
  148. }
  149. return _videoBtn;
  150. }
  151. - (UIButton *)dynamicBtn{
  152. if (!_dynamicBtn) {
  153. _dynamicBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, FD_StatusBar_Height, 80, FD_Navigation_Height)];
  154. _dynamicBtn.right = FD_ScreenWidth / 2 - 15;
  155. // _dynamicBtn.left = kScreenW / 2 + 15;
  156. _dynamicBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  157. [_dynamicBtn setTitleColor:[UIColor colorWithHexString:@"#1A1A1A"] forState:UIControlStateNormal];
  158. [_dynamicBtn setTitle:ASLocalizedString(@"动态") forState:UIControlStateNormal];
  159. [_dynamicBtn addTarget:self action:@selector(dynamicBtnAction) forControlEvents:UIControlEventTouchUpInside];
  160. }
  161. return _dynamicBtn;
  162. }
  163. - (UIImageView *)lineView{
  164. if (!_lineView) {
  165. _lineView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 20, 4)];
  166. _lineView.centerX = self.videoBtn.centerX;
  167. _lineView.bottom = self.videoBtn.bottom;
  168. _lineView.image = [UIImage imageNamed:@"选中条"];
  169. _lineView.layer.cornerRadius = 2;
  170. _lineView.clipsToBounds = YES;
  171. }
  172. return _lineView;
  173. }
  174. - (UIButton *)publishBtn{
  175. if (!_publishBtn) {
  176. _publishBtn = [[UIButton alloc]initWithFrame:CGRectMake(FD_ScreenWidth - 60, FD_StatusBar_Height, 50, FD_Navigation_Height)];
  177. [_publishBtn setImage:[UIImage imageNamed:@"bogo_publish_btn"] forState:UIControlStateNormal];
  178. [_publishBtn addTarget:self action:@selector(publishBtnAction) forControlEvents:UIControlEventTouchUpInside];
  179. }
  180. return _publishBtn;
  181. }
  182. @end