BogoHomeTopView.m 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. //
  2. // BogoHomeTopView.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2021/3/18.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BogoHomeTopView.h"
  9. #import "SSearchVC.h"
  10. #import "BGConversationSegmentController.h"
  11. #import "AgreementViewController.h"
  12. #import "PublishLivestViewController.h"
  13. #import "SIdentificationVC.h"
  14. #import "BogoSearchViewController.h"
  15. #import "LeaderboardViewController.h"
  16. @implementation BogoHomeTopView
  17. - (instancetype)initWithFrame:(CGRect)frame
  18. {
  19. self = [super initWithFrame:frame];
  20. if (self) {
  21. [self setUpView];
  22. }
  23. return self;
  24. }
  25. //- (instancetype)init
  26. //{
  27. // self = [super init];
  28. // if (self) {
  29. // [self setUpView];
  30. // }
  31. // return self;
  32. //}
  33. -(void)setUpView{
  34. self.topImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, self.height)];
  35. self.topImgView.image = [UIImage imageNamed:@"bogo_home_topImgView"];
  36. self.topImgView.userInteractionEnabled = YES;
  37. // CAGradientLayer *gl = [CAGradientLayer layer];
  38. // gl.frame = CGRectMake(0, 0, kScreenW, self.height);
  39. // gl.startPoint = CGPointMake(0, 0);
  40. // gl.endPoint = CGPointMake(1, 1);
  41. // gl.colors = @[(__bridge id)[UIColor colorWithRed:119/255.0 green:52/255.0 blue:254/255.0 alpha:1.0].CGColor,(__bridge id)[UIColor colorWithRed:175/255.0 green:26/255.0 blue:251/255.0 alpha:1.0].CGColor];
  42. // gl.locations = @[@(0.0),@(1.0f)];
  43. // [self.topImgView.layer addSublayer:gl];
  44. // self.topImgView.backgroundColor = [UIColor colorWithHexString:@""];
  45. self.searchField.left = kRealValue(12);
  46. self.searchField.top = kStatusBarHeight + 5;
  47. self.msgBtn.centerY = self.searchField.centerY;
  48. // = kRealValue(30) + self.searchField.height / 2 + 10;
  49. [self addSubview:self.topImgView];
  50. self.topImgView.hidden = YES;
  51. UIButton *searchBtn = [[UIButton alloc] init];
  52. [searchBtn setBackgroundImage:[UIImage imageNamed:@"habibi_sousuo"] forState:UIControlStateNormal];
  53. [self addSubview:searchBtn];
  54. UILabel * searchLabel = [[UILabel alloc] init];
  55. searchLabel.text = ASLocalizedString(@"搜索");
  56. searchLabel.font = [UIFont systemFontOfSize:12];
  57. searchLabel.textColor = [UIColor colorWithHexString:@"#333333"];
  58. [searchBtn addSubview:searchLabel];
  59. UIButton *startLive = [[UIButton alloc] init];
  60. [startLive setImage:[UIImage imageNamed:@"开播"] forState:UIControlStateNormal];
  61. [startLive addTarget:self action:@selector(handleLiveEvent) forControlEvents:UIControlEventTouchUpInside];
  62. [self addSubview:startLive];
  63. UIButton *paihangBtn = [[UIButton alloc] init];
  64. [paihangBtn setImage:[UIImage imageNamed:@"hbibi_paihagnbang"] forState:UIControlStateNormal];
  65. [self addSubview:paihangBtn];
  66. [paihangBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.right.equalTo(startLive.mas_left).offset(kRealValue(-10));
  68. make.size.height.equalTo(@kRealValue(30));
  69. make.size.width.equalTo(@kRealValue(30));
  70. make.centerY.equalTo(startLive);
  71. }];
  72. [searchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  73. // make.right.equalTo(paihangBtn.mas_left).offset(kRealValue(-10));
  74. // make.size.height.equalTo(@kRealValue(28));
  75. //// make.size.width.equalTo(@kRealValue(140));
  76. // make.width.mas_equalTo(140);
  77. // make.centerY.equalTo(startLive);
  78. make.right.mas_equalTo(paihangBtn.mas_left).mas_offset(-10);
  79. make.centerY.mas_equalTo(startLive);
  80. make.width.mas_equalTo(70);
  81. make.height.mas_equalTo(28);
  82. }];
  83. [searchLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.centerY.mas_equalTo(searchBtn);
  85. make.centerX.mas_equalTo(searchBtn).mas_offset(10);
  86. }];
  87. [startLive mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.right.equalTo(self).offset(kRealValue(-10));
  89. make.size.height.equalTo(@kRealValue(30));
  90. make.size.width.equalTo(@kRealValue(30));
  91. make.top.equalTo(self).offset(kStatusBarHeight + kRealValue(5));
  92. }];
  93. [searchBtn addTarget:self action:@selector(clickSearch:) forControlEvents:UIControlEventTouchUpInside];
  94. [paihangBtn addTarget:self action:@selector(clickPaihang) forControlEvents:UIControlEventTouchUpInside];
  95. // [self addSubview:self.searchField];
  96. // [self addSubview:self.msgBtn];
  97. }
  98. - (void)handleLiveEvent {
  99. if(self.delegate && [self.delegate respondsToSelector:@selector(clickLiveBtn)]) {
  100. [self.delegate clickLiveBtn];
  101. }
  102. }
  103. - (void)clickPaihang {
  104. LeaderboardViewController *lbVCtr = [[LeaderboardViewController alloc] init];
  105. lbVCtr.isHiddenTabbar = YES;
  106. [[AppDelegate sharedAppDelegate]pushViewController:lbVCtr animated:YES];
  107. }
  108. -(void)clickMsgBtn:(UIButton *)sender{
  109. // UserModel *userModel = [GlobalVariables sharedInstance].userModel;
  110. // NSString *idStr; //认证
  111. // if ([userModel.is_authentication intValue] ==0)
  112. // {
  113. // idStr = ASLocalizedString(@"未认证");
  114. // }
  115. // if ([userModel.is_authentication intValue] ==1)
  116. // {
  117. // idStr = ASLocalizedString(@"等待审核");
  118. // }
  119. // if ([userModel.is_authentication intValue] ==2)
  120. // {
  121. // idStr = ASLocalizedString(@"已认证");
  122. // }
  123. // if ([userModel.is_authentication intValue] ==3)
  124. // {
  125. // idStr = ASLocalizedString(@"审核不通过");
  126. // }
  127. if ([GlobalVariables sharedInstance].appModel.must_authentication.intValue == 1) {
  128. if ([GlobalVariables sharedInstance].userModel.is_authentication.intValue != 2) {
  129. [self showAuthView];
  130. return;
  131. }
  132. }
  133. IMALoginParam *loginParam = [IMALoginParam loadFromLocal];
  134. if (loginParam.isAgree ==1)
  135. {
  136. if (AppDelegate.sharedAppDelegate.isInAudioVideoChatVc) {
  137. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"通话中,请结束通话后再试")];
  138. return;
  139. }
  140. PublishLivestViewController *pvc = [[PublishLivestViewController alloc] init];
  141. [[AppDelegate sharedAppDelegate] presentViewController:pvc animated:YES completion:^{
  142. }];
  143. }
  144. else
  145. {
  146. AgreementViewController *agreeVC = [AgreementViewController webControlerWithUrlStr:[GlobalVariables sharedInstance].appModel.agreement_link isShowIndicator:YES isShowNavBar:YES];
  147. [[AppDelegate sharedAppDelegate] presentViewController:agreeVC animated:YES completion:^{
  148. }];
  149. }
  150. // BGConversationSegmentController *chatListVC = [[BGConversationSegmentController alloc]init];
  151. // [[AppDelegate sharedAppDelegate] pushViewController:chatListVC animated:YES];
  152. }
  153. //是否已认证
  154. -(void)showAuthView{
  155. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:ASLocalizedString(@"您当前还未实名认证,需要认证后才能开始直播")preferredStyle:UIAlertControllerStyleAlert];
  156. UIAlertAction *actionCacel = [UIAlertAction actionWithTitle:ASLocalizedString(@"取消")style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  157. }];
  158. UIAlertAction *actionConfirm = [UIAlertAction actionWithTitle:ASLocalizedString(@"立即认证")style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  159. UserModel *userModel = [GlobalVariables sharedInstance].userModel;
  160. SIdentificationVC *identificationVC = [[SIdentificationVC alloc]init];
  161. identificationVC.user_id = userModel.user_id;
  162. identificationVC.sexString = userModel.sex;
  163. identificationVC.nameString = userModel.nick_name;
  164. [[AppDelegate sharedAppDelegate] pushViewController:identificationVC animated:YES];
  165. }];
  166. [alertController addAction:actionCacel];
  167. [alertController addAction:actionConfirm];
  168. [[AppDelegate sharedAppDelegate].topViewController presentViewController:alertController animated:YES completion:nil];
  169. }
  170. -(void)clickSearch:(UITapGestureRecognizer *)sender{
  171. // SSearchVC *searchVC = [[SSearchVC alloc]init];
  172. // searchVC.searchType = @"0";
  173. // [[AppDelegate sharedAppDelegate] pushViewController:searchVC animated:YES];
  174. BogoSearchViewController *searchVC = [[BogoSearchViewController alloc]initWithNibName:@"BogoSearchViewController" bundle:[NSBundle mainBundle]];
  175. [[AppDelegate sharedAppDelegate] pushViewController:searchVC animated:YES];
  176. }
  177. -(UITextField *)searchField{
  178. if (!_searchField) {
  179. _searchField = [[UITextField alloc]initWithFrame:CGRectMake(kRealValue(12), 0, kScreenW - kRealValue(39) - kRealValue(22) - kRealValue(12 * 2),kRealValue(32))];
  180. _searchField.text = ASLocalizedString(@"请输入搜索内容");
  181. _searchField.font = [UIFont systemFontOfSize:14];
  182. _searchField.textColor = [UIColor colorWithHexString:@"#AAAAAA"];
  183. _searchField.backgroundColor = kWhiteColor;
  184. _searchField.layer.cornerRadius = kRealValue(32 / 2);
  185. _searchField.layer.masksToBounds = YES;
  186. UIView *leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 33, 33)];
  187. UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 15, 15)];
  188. imageView.image = [UIImage imageNamed:@"bogo_home_top_search"];
  189. imageView.center = leftView.center;
  190. [leftView addSubview:imageView];
  191. _searchField.leftView = leftView;
  192. _searchField.leftViewMode = UITextFieldViewModeAlways;
  193. _searchField.delegate = self;
  194. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickSearch:)];
  195. [_searchField addGestureRecognizer:tap];
  196. }
  197. return _searchField;
  198. }
  199. -(UIButton *)msgBtn{
  200. if (!_msgBtn) {
  201. _msgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  202. [_msgBtn setImage:[UIImage imageNamed:@"bogo_home_live_start"] forState:UIControlStateNormal];
  203. [_msgBtn addTarget:self action:@selector(clickMsgBtn:) forControlEvents:UIControlEventTouchUpInside];
  204. _msgBtn.frame = CGRectMake(kScreenW - kRealValue(50), 0, kRealValue(30), kRealValue(50));
  205. }
  206. return _msgBtn;
  207. }
  208. @end