BGTabBarController.m 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. //
  2. // BGTabBarController.m
  3. // BuguLive
  4. //
  5. // Created by xfg on 2017/6/26.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "BGTabBarController.h"
  9. #import "BGTabBar.h"
  10. #import "BGNavigationController.h"
  11. #import "HMHomeViewController.h"
  12. #import "PublishLivestViewController.h"
  13. #import "AgreementViewController.h"
  14. #import "MPersonCenterVC.h"
  15. #import "MSmallVideoVC.h"
  16. #import "ListDayViewController.h"
  17. #import "LeaderboardViewController.h"
  18. #import "SChargerVC.h"
  19. #import "LEEAlertHelper.h"
  20. #import "LEEAlert.h"
  21. #import "HMCenterPopView.h"
  22. #import "SmallVideoViewController.h"
  23. #import "CustomPagerController.h"
  24. #import "AppDelegate.h"
  25. #import "NewSmallVideoViewController.h"
  26. #import "TCVideoRecordViewController.h"
  27. #import "YHTimeLineViewController.h"
  28. #import "MGAlertIncodeView.h"
  29. #import "UpgradeTipView.h"
  30. //#import <UGCKit/UGCKit.h>
  31. #import <UGCKit/UGCKit.h>
  32. #import <TXLiteAVSDK_Professional/TXVideoEditer.h>
  33. //主页
  34. #import "BogoHomeViewController.h"
  35. //广场
  36. #import "BogoSquareViewController.h"
  37. //消息
  38. #import "BogoNewsViewController.h"
  39. //青少年模式弹窗
  40. #import "BogoYounthModePopView.h"
  41. #import "SIdentificationVC.h"
  42. #import "IMALoginParam.h"
  43. #import "BogoNewsTabNumModel.h"
  44. #import "MineViewController.h"
  45. #import "BogoShopKit.h"
  46. #import "BogoYouthModeViewController.h"
  47. #import "BogoYoungModeVideoViewController.h"
  48. #import "BogoYoungModeVideoViewController.h"
  49. #import "BogoNewSquareViewController.h"
  50. #import "VoiceHomeListViewController.h"
  51. #import "GKDBViewController.h"
  52. #import "GKAllRefreshViewController.h"
  53. #import "AudioChatTool.h"
  54. @interface BGTabBarController ()<UITabBarControllerDelegate,UIActionSheetDelegate,BogoHomeTopViewDelegate>
  55. @property (nonatomic, strong) HMCenterPopView *popView;
  56. @property (nonatomic, strong) VideoDynamicViewC *videoDynamicViewC;
  57. @property(nonatomic, strong) MGAlertIncodeView *alertView;
  58. @property(nonatomic, strong) BogoYounthModePopView *youthView;
  59. @property(nonatomic, strong) UIImageView *tabBgImgView;
  60. @property(nonatomic, strong) UIView *tipView;
  61. @end
  62. @implementation BGTabBarController
  63. BogoSingletonM(Instance);
  64. - (void)viewDidLoad
  65. {
  66. [super viewDidLoad];
  67. [[GiftListManager sharedInstance] reloadGiftList];
  68. [BGIMMsgHandler sharedInstance];
  69. [BGIMPrivateMsgHandler sharedInstance];
  70. if ([BGIMLoginManager sharedInstance].isIMSDKOK) {
  71. NSLog(@"已经登录了");
  72. }else{
  73. NSLog(@"没有");
  74. [[BGIMLoginManager sharedInstance] loginImSDK:YES succ:nil failed:nil];
  75. }
  76. self.delegate = self;
  77. [self setUpChildViewControllers];
  78. self.view.backgroundColor = kWhiteColor;
  79. self.alertView = [MGAlertIncodeView new];
  80. self.alertView.frame = CGRectMake(0, 0, kScreenW, kScreenH);
  81. self.alertView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4];
  82. FWWeakify(self)
  83. self.alertView.clickBlock = ^(NSInteger i) {
  84. FWStrongify(self)
  85. if (i == 0) {
  86. // [self.alertView removeAllSubViews];
  87. self.alertView.hidden = YES;
  88. }
  89. };
  90. self.alertView.hidden = YES;
  91. [self.view addSubview:self.alertView];
  92. if (kIsCheckingVersion())
  93. {
  94. }
  95. else
  96. {
  97. #ifdef DEBUG
  98. #else
  99. [self checkCode];
  100. #endif
  101. }
  102. // [[UIBarButtonItem appearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:kClearColor,
  103. // NSFontAttributeName:[UIFont systemFontOfSize:20.0]
  104. // } forState:UIControlStateNormal];
  105. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(isOpenYoung:) name:@"isOpenYoung" object:nil];
  106. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDarkContent];
  107. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(IMChatMsgNotfication:) name:g_notif_chatmsg object:nil];
  108. }
  109. - (void)getGiftNumber {
  110. NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
  111. [dict setValue:@"deal" forKey:@"ctl"];
  112. [dict setValue:@"get_gift_quantity" forKey:@"act"];
  113. [[NetHttpsManager manager] POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) {
  114. NSLog(@"104responseJson%@",responseJson);
  115. if ([responseJson toInt:@"status"] == 1) {
  116. NSArray *list = responseJson[@"data"];
  117. [GlobalVariables sharedInstance].giftQuantityModelList = [NSArray modelArrayWithClass:GiftQuantityModel.class json:list];
  118. // for (int i = 0; i<list.count; i++) {
  119. // GiftQuantityModel *model = [GiftQuantityModel modelWithDictionary:list[i]];
  120. //
  121. // }
  122. }else{
  123. //接口请求失败
  124. NSLog(ASLocalizedString(@"礼物responseJson:%@"),responseJson);
  125. }
  126. } FailureBlock:^(NSError *error) {
  127. NSLog(ASLocalizedString(@"礼物error:%@"),error);
  128. }];
  129. }
  130. - (void)isOpenYoung:(NSNotification *)center{
  131. // NSDictionary *dic = center.object;
  132. if ([GlobalVariables sharedInstance].userModel.is_open_young.integerValue) {
  133. NSMutableDictionary *hotDic = [NSMutableDictionary dictionary];
  134. [hotDic setObject:@"1" forKey:@"order"];
  135. [hotDic setObject:@"0" forKey:@"cate"];
  136. BogoYoungModeVideoViewController *vc = [BogoYoungModeVideoViewController new];
  137. vc.isHaveNavBar = NO;
  138. vc.paramDict = hotDic;
  139. vc.notHaveTabbar = NO;
  140. vc.hidesBottomBarWhenPushed = YES;
  141. [self.viewControllers.firstObject pushViewController:vc animated:YES];
  142. }else{
  143. if (![GlobalVariables sharedInstance].isShutDownYoung) {
  144. [self.youthView show:self.view type:FDPopTypeCenter];
  145. }else{
  146. [self.view addSubview:self.tipView];
  147. [UIView animateWithDuration:0.25 animations:^{
  148. self.tipView.alpha = 1;
  149. }];
  150. [self performSelector:@selector(hideTipView) afterDelay:3];
  151. }
  152. }
  153. }
  154. - (void)hideTipView{
  155. [UIView animateWithDuration:0.25 animations:^{
  156. self.tipView.alpha = 0;
  157. } completion:^(BOOL finished) {
  158. [self.tipView removeFromSuperview];
  159. }];
  160. }
  161. - (UIView *)tipView{
  162. if (!_tipView) {
  163. _tipView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 180, 40)];
  164. _tipView.backgroundColor = [FD_BlackColor colorWithAlphaComponent:0.4];
  165. _tipView.layer.cornerRadius = 20;
  166. _tipView.clipsToBounds = YES;
  167. UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 140, 20)];
  168. titleLabel.textColor = FD_WhiteColor;
  169. titleLabel.center = _tipView.center;
  170. titleLabel.text =ASLocalizedString( @"青少年模式已关闭");
  171. titleLabel.font = [UIFont systemFontOfSize:14];
  172. titleLabel.textAlignment = NSTextAlignmentCenter;
  173. [_tipView addSubview:titleLabel];
  174. _tipView.center = self.view.center;
  175. _tipView.alpha = 0;
  176. }
  177. return _tipView;
  178. }
  179. - (void)viewWillAppear:(BOOL)animated {
  180. [super viewWillAppear:animated];
  181. [self getGiftNumber];
  182. [[AppDelegate sharedAppDelegate] showNesBarRedNum];
  183. NSLog(@"%@",self.view);
  184. }
  185. - (void)checkCode {
  186. NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
  187. [mDict setObject:@"login" forKey:@"ctl"];
  188. [mDict setObject:@"is_invitation" forKey:@"act"];
  189. [[NetHttpsManager manager] POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) {
  190. if([[GlobalVariables sharedInstance].appModel.is_invite_code intValue] == 1)
  191. {
  192. if([responseJson toInt:@"state"] == 0)
  193. {
  194. self.alertView.hidden = NO;
  195. self.alertView.textField.placeholder = ASLocalizedString(@"请输入邀请码");
  196. }
  197. }
  198. else
  199. {
  200. if([responseJson toInt:@"state"] == 0)
  201. {
  202. self.alertView.hidden = NO;
  203. }
  204. }
  205. } FailureBlock:^(NSError *error) {
  206. }];
  207. }
  208. -(void)postCode:(NSString *)code
  209. {
  210. NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
  211. [mDict setObject:@"login" forKey:@"ctl"];
  212. [mDict setObject:@"invitation" forKey:@"act"];
  213. [mDict setObject:code forKey:@"invitation_id"];
  214. [[NetHttpsManager manager] POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) {
  215. if ([responseJson toInt:@"status"] == 1)
  216. {
  217. [LEEAlert closeWithCompletionBlock:^{
  218. }];
  219. [FanweMessage alert:ASLocalizedString(@"提交成功")];
  220. }
  221. else
  222. {
  223. __block UITextField *tf = nil;
  224. [BGHUDHelper alert:[responseJson valueForKey:@"error"] action:^{
  225. [LEEAlert alert].config
  226. .LeeTitle(ASLocalizedString(@"邀请码"))
  227. .LeeAddTextField(^(UITextField *textField) {
  228. // 这里可以进行自定义的设置
  229. textField.placeholder = ASLocalizedString(@"请输入邀请码");
  230. textField.textColor = [UIColor darkGrayColor];
  231. tf = textField; //赋值
  232. })
  233. .LeeAction(ASLocalizedString(@"确定"), ^{
  234. if(tf.text == nil || tf.text.length < 1)
  235. {
  236. // [self checkCode];
  237. [BGHUDHelper alert:ASLocalizedString(@"邀请码不能为空")action:^{
  238. [self checkCode];
  239. }];
  240. // [BGHUDHelper alert:ASLocalizedString(@"邀请码不能为空")];
  241. return;
  242. }
  243. [self postCode:tf.text];
  244. [tf resignFirstResponder];
  245. })
  246. // 点击事件的Block如果不需要可以传nil
  247. .LeeShow();
  248. }];
  249. }
  250. } FailureBlock:^(NSError *error) {
  251. }];
  252. //
  253. }
  254. #pragma mark - 设置子控制器
  255. - (void)setUpChildViewControllers
  256. {
  257. // if (@available(iOS 13.0, *)) {
  258. //
  259. // [[UITabBar appearance] setUnselectedItemTintColor:[UIColor colorWithHexString:@"#999999"]];
  260. // self.tabBar.tintColor = [UIColor colorWithHexString:@"#9152F8"];
  261. //// kAppMainColor;
  262. // }else{
  263. //
  264. // }
  265. // 首页
  266. BogoHomeViewController *home = [[BogoHomeViewController alloc] init];
  267. home.topViewdelegate = self;
  268. home.clickSquareBtnBlock = ^(NSInteger index) {
  269. [self showDynamicVC];
  270. };
  271. [self addChildViewController:home image:@"ic_live_tab_live_normal" seletedImage:@"ic_live_tab_live_selected" title:ASLocalizedString(@"直播")];
  272. // VoiceHomeListViewController *voiceRoom = [VoiceHomeListViewController new];
  273. // voiceRoom.types = @"1";
  274. // voiceRoom.delegate = home;
  275. // voiceRoom.topViewdelegate = self;
  276. // [self addChildViewController:voiceRoom image:@"语音1" seletedImage:@"语音2" title:ASLocalizedString(@"语音")];
  277. GKAllRefreshViewController *voiceRoom2 = [GKAllRefreshViewController new];
  278. voiceRoom2.types = @"1";
  279. voiceRoom2.delegate = home;
  280. voiceRoom2.topViewdelegate = self;
  281. [self addChildViewController:voiceRoom2 image:@"语音1" seletedImage:@"语音2" title:ASLocalizedString(@"语音")];
  282. // guangc
  283. if (![GlobalVariables sharedInstance].appModel.short_video.integerValue) {
  284. BogoSquareViewController *squareVC = [BogoSquareViewController new];
  285. squareVC.clickSquareBtnBlock = ^(NSInteger index) {
  286. [self showDynamicVC];
  287. };
  288. [self addChildViewController:squareVC image:@"ic_live_tab_rank_normal" seletedImage:@"ic_live_tab_rank_selected" title:ASLocalizedString(@"动态")];
  289. }else{
  290. BogoNewSquareViewController *squareVC = [BogoNewSquareViewController new];
  291. squareVC.clickSquareBtnBlock = ^(NSInteger index) {
  292. [self showDynamicVC];
  293. };
  294. [self addChildViewController:squareVC image:@"ic_live_tab_rank_normal" seletedImage:@"ic_live_tab_rank_selected" title:ASLocalizedString(@"动态")];
  295. }
  296. // 发布直播==》放在FWTabBar里面
  297. // [self setupTabBar];
  298. // 直播
  299. [self addChildViewController:[[BogoNewsViewController alloc] init] image:@"ic_live_tab_video_normal" seletedImage:@"ic_live_tab_video_selected" title:ASLocalizedString(@"消息")];
  300. // 我的
  301. [self addChildViewController:[[MineViewController alloc] initWithNibName:@"MineViewController" bundle:[NSBundle mainBundle]] image:@"ic_live_tab_me_normal" seletedImage:@"ic_live_tab_me_selected" title:ASLocalizedString(@"我的")];
  302. //fix
  303. if(self.tabBgImgView == nil)
  304. {
  305. [self.tabBgImgView removeFromSuperview];
  306. self.tabBgImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, -14, kScreenW, FD_Bottom_Height + 14)];
  307. // tabBgImgView.backgroundColor = kRedColor;
  308. self.tabBgImgView.image = [UIImage imageNamed:@"mg_tab_bgImg"];
  309. self.tabBgImgView.contentMode = UIViewContentModeScaleToFill;
  310. [self.tabBar addSubview:self.tabBgImgView];
  311. self.tabBar.backgroundImage = [UIImage imageNamed:@"mg_tab_bgImg"];
  312. self.tabBar.backgroundColor = kWhiteColor;
  313. }
  314. }
  315. //-(void)showNesBarRedNum{
  316. //
  317. // dispatch_async(dispatch_get_main_queue(), ^{
  318. //
  319. // UITabBarItem *itme = [self.tabBar.items objectAtIndex:3];
  320. // SFriendObj *xxx = nil;
  321. //
  322. // // [SFriendObj getMyFriendMsgList:0
  323. // // lastObj:xxx
  324. // // block:^(SResBase *resb, NSArray *all, int unReadNum) {
  325. // NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  326. // [parmDict setObject:@"dynamic" forKey:@"ctl"];
  327. // [parmDict setObject:@"unread_messages" forKey:@"act"];
  328. //
  329. // [[NetHttpsManager manager]POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
  330. //
  331. // if ([[responseJson valueForKey:@"status"]integerValue] == 1) {
  332. //
  333. // BogoNewsTabNumModel *model = [BogoNewsTabNumModel modelWithDictionary:[responseJson valueForKey:@"data"]];
  334. //
  335. //
  336. // // if ((model.bzone_reply + model.bzone_like) == 0) {
  337. // // itme.badgeValue = nil;
  338. // // }else{
  339. // //
  340. // //
  341. // // }
  342. // [SFriendObj getAllUnReadCountComplete:^(int num) {
  343. // if ((model.bzone_reply + model.bzone_like + num) == 0) {
  344. // itme.badgeValue = nil;
  345. // }else{
  346. // itme.badgeValue = [NSString stringWithFormat:@"%ld",model.bzone_reply + model.bzone_like + num + model.msg.count];
  347. // }
  348. //
  349. // }];
  350. // // self.headView.model = model;
  351. //
  352. // }
  353. //
  354. // } FailureBlock:^(NSError *error) {
  355. //
  356. // }];
  357. // });
  358. //
  359. //
  360. //
  361. //}
  362. -(UIImage *)imageResize :(UIImage*)img andResizeTo:(CGSize)newSize withTop:(CGFloat)top
  363. {
  364. CGFloat scale = [[UIScreen mainScreen]scale];
  365. //UIGraphicsBeginImageContext(newSize);
  366. UIGraphicsBeginImageContextWithOptions(newSize, NO, scale);
  367. [img drawInRect:CGRectMake(0,top,newSize.width,newSize.height)];
  368. UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
  369. UIGraphicsEndImageContext();
  370. return newImage;
  371. }
  372. #pragma mark - 添加子控制器
  373. - (UIViewController *)addChildViewController:(UIViewController *)childController image:(NSString *)image seletedImage:(NSString *)selectedImage title:(NSString *)title
  374. {
  375. // if (![BGUtils isBlankString:title])
  376. // {
  377. childController.title = title;
  378. NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary];
  379. normalAttrs[NSForegroundColorAttributeName] = kAppGrayColor3;
  380. [childController.tabBarItem setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];
  381. NSMutableDictionary *selectedAtrrs = [NSMutableDictionary dictionary];
  382. selectedAtrrs[NSForegroundColorAttributeName] = UIColorFromRGB(0x4BC8FC);
  383. [childController.tabBarItem setTitleTextAttributes:selectedAtrrs forState:UIControlStateSelected];
  384. // childController.tabBarItem.imageInsets = UIEdgeInsetsMake(12, 12, 12, 12);
  385. // childController.tabBarItem.imageInsets = UIEdgeInsetsMake(-10, 0, -5, 0);
  386. // childController.tabBarItem.imageInsets = UIEdgeInsetsMake(-10, 0, -5, 0);
  387. // }
  388. // else
  389. // {
  390. // childController.tabBarItem.imageInsets = UIEdgeInsetsMake(-16, 0, -5, 0);
  391. // }
  392. // 设置图片
  393. // if ([title isEqualToString:@""]) {
  394. //// UIImage *imageS = [[self imageResize:[UIImage imageNamed:image] andResizeTo:CGSizeMake(50, 50)] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  395. //// [childController.tabBarItem setImage:imageS];
  396. //// [imageS drawInRect:CGRectMake(-10,0,50,50)];
  397. // [childController.tabBarItem setImage:[[self imageResize:[UIImage imageNamed:image] andResizeTo:CGSizeMake(kRealValue(45), kRealValue(45)) withTop:0] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  398. // }else{
  399. UITabBarItem* itm= [[UITabBarItem alloc] initWithTitle:title image:[UIImage imageNamed:image] selectedImage:[UIImage imageNamed:selectedImage]];
  400. childController.tabBarItem = itm;
  401. [childController.tabBarItem setImage:[[self imageResize:[UIImage imageNamed:image] andResizeTo:CGSizeMake(20, 20) withTop:0] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  402. [childController.tabBarItem setSelectedImage:[[self imageResize:[UIImage imageNamed:selectedImage] andResizeTo:CGSizeMake(20, 20) withTop:0] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  403. // }
  404. // 导航条
  405. BGNavigationController *nav = [[BGNavigationController alloc] initWithRootViewController:childController];
  406. [self addChildViewController:nav];
  407. return childController;
  408. }
  409. //- (void)setupTabBar
  410. //{
  411. // BGTabBar *tabbar = [[BGTabBar alloc] init];
  412. // tabbar.backgroundColor = kWhiteColor;
  413. // [self setValue:tabbar forKey:@"tabBar"];
  414. // FWWeakify(self)
  415. // [tabbar setCenterBtnClickBlock:^{
  416. // FWStrongify(self)
  417. // [self onClickedCenterTabBar];
  418. // }];
  419. //}
  420. - (void)startLive {
  421. if ([GlobalVariables sharedInstance].appModel.must_authentication.intValue == 1) {
  422. if ([GlobalVariables sharedInstance].userModel.is_authentication.intValue != 2) {
  423. [self showAuthView];
  424. return;
  425. }
  426. }
  427. IMALoginParam *loginParam = [IMALoginParam loadFromLocal];
  428. if (loginParam.isAgree ==1)
  429. {
  430. if (AppDelegate.sharedAppDelegate.isInAudioVideoChatVc) {
  431. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"通话中,请结束通话后再试")];
  432. return;
  433. }
  434. PublishLivestViewController *pvc = [[PublishLivestViewController alloc] init];
  435. [[AppDelegate sharedAppDelegate] presentViewController:pvc animated:YES completion:^{
  436. }];
  437. }
  438. else
  439. {
  440. AgreementViewController *agreeVC = [AgreementViewController webControlerWithUrlStr:[GlobalVariables sharedInstance].appModel.agreement_link isShowIndicator:YES isShowNavBar:YES];
  441. [[AppDelegate sharedAppDelegate] presentViewController:agreeVC animated:YES completion:^{
  442. }];
  443. }
  444. }
  445. #pragma mark 点击直播
  446. - (void)onClickedCenterTabBar
  447. {
  448. // PopMenuCenter *popMenuCenter = [PopMenuCenter sharePopMenuCenter];
  449. // [popMenuCenter setTabBarC:self];
  450. // [popMenuCenter setStPopMenuShowState:STPopMenuShow];
  451. NSArray *objs = [[NSBundle mainBundle]loadNibNamed:@"HMCenterPopView" owner:nil options:nil];
  452. self.popView = objs.firstObject;
  453. [self setUpLocalizationStringForView:self.popView];
  454. FWWeakify(self)
  455. [self.popView setClickPopViewBtnBlock:^(HMCenterPopViewBtnType type) {
  456. FWStrongify(self)
  457. switch (type) {
  458. case HMCenterPopViewBtnTypeLive:
  459. {
  460. [self startLive];
  461. }
  462. break;
  463. case HMCenterPopViewBtnTypeVideo:
  464. {
  465. [self showDynamicVC];
  466. }
  467. break;
  468. case HMCenterPopViewBtnTypeClose:
  469. break;
  470. default:
  471. break;
  472. }
  473. }];
  474. [self.popView show:[UIApplication sharedApplication].keyWindow];
  475. }
  476. -(void)showDynamicVC{
  477. self.videoDynamicViewC = (VideoDynamicViewC *)[VideoDynamicViewC showSTBaseViewCOnSuperViewC:self.selectedViewController
  478. andFrameRect:CGRectMake(0, 0, kScreenW, kScreenH)
  479. andSTViewCTransitionType:STViewCTransitionTypeOfModal
  480. andComplete:^(BOOL finished,
  481. STBaseViewC *stBaseViewC) {
  482. }];
  483. self.videoDynamicViewC.recordTabBarC = self;
  484. [self.videoDynamicViewC videoDynamicView];
  485. // 开启IQ
  486. self.videoDynamicViewC.isOpenIQKeyboardManager = YES;
  487. // 加载View层
  488. //[videoDynamicViewC graphicDynamicView];
  489. //跳转
  490. //找到当前ViewC
  491. UIViewController *currentViewC = self.selectedViewController.childViewControllers[0];
  492. //TabBarc隐藏
  493. currentViewC.hidesBottomBarWhenPushed=YES;
  494. currentViewC.navigationController.navigationBar.tintColor = kAppGrayColor1;
  495. self.videoDynamicViewC.navigationController.navigationBar.hidden = NO;
  496. self.videoDynamicViewC.title = ASLocalizedString(@"发布短视频");
  497. self.videoDynamicViewC.navigationController.navigationBar.tintColor =kAppGrayColor1;
  498. //改变颜色 必须跳转后
  499. self.videoDynamicViewC.navigationController.navigationBar.hidden = NO;
  500. [self.videoDynamicViewC.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:kAppGrayColor1}];
  501. currentViewC.hidesBottomBarWhenPushed=NO;
  502. UIActionSheet *headImgSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
  503. [headImgSheet addButtonWithTitle:ASLocalizedString(@"拍摄视频")];
  504. [headImgSheet addButtonWithTitle:ASLocalizedString(@"相册中获取视频")];
  505. [headImgSheet addButtonWithTitle:ASLocalizedString(@"取消")];
  506. headImgSheet.cancelButtonIndex = headImgSheet.numberOfButtons-1;
  507. headImgSheet.delegate = self;
  508. [headImgSheet showInView:[UIApplication sharedApplication].keyWindow];
  509. }
  510. - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger) buttonIndex
  511. {
  512. if (buttonIndex == 0) {
  513. //如果短视频key为空,调本地视频
  514. if ([BGUtils isBlankString:[GlobalVariables sharedInstance].appModel.tencent_video_sdk_key]) {
  515. [[AppDelegate sharedAppDelegate]pushViewController:self.videoDynamicViewC animated:YES];
  516. [self.videoDynamicViewC ceartVideoViewWithType:(int)buttonIndex];
  517. return;
  518. }
  519. #warning 暂时注释
  520. UGCKitRecordViewController *recordViewController = [[UGCKitRecordViewController alloc] initWithConfig:nil theme:nil];
  521. recordViewController.completion = ^(UGCKitResult *result) {
  522. if (result.cancelled) {
  523. [[AppDelegate sharedAppDelegate]popViewController];
  524. // UGCKitEditViewController *vc= [UGCKitEditViewController new];
  525. // [[AppDelegate sharedAppDelegate]pushViewController:vc];
  526. }else{
  527. [self showEditViewController:result rotation:TCEditRotation0 inNavigationController:[AppDelegate sharedAppDelegate].topViewController.navigationController];
  528. // self.navigationController];
  529. }
  530. };
  531. // TCVideoRecordViewController *vc = [[TCVideoRecordViewController alloc] init];
  532. [[AppDelegate sharedAppDelegate] pushViewController:recordViewController animated:YES];
  533. return;
  534. }else if (buttonIndex == 1){
  535. [[AppDelegate sharedAppDelegate]pushViewController:self.videoDynamicViewC animated:YES];
  536. [self.videoDynamicViewC ceartVideoViewWithType:(int)buttonIndex];
  537. }
  538. }
  539. - (void)showEditViewController:(UGCKitResult *)result
  540. rotation:(TCEditRotation)rotation
  541. inNavigationController:(UINavigationController *)nav
  542. {
  543. UGCKitMedia *media = result.media;
  544. UGCKitEditConfig *config = [[UGCKitEditConfig alloc] init];
  545. config.rotation = (TCEditRotation)(rotation / 90);
  546. UIImage *tailWatermarkImage = [UIImage imageNamed:@"tcloud_logo"];
  547. TXVideoInfo *info = [TXVideoInfoReader getVideoInfoWithAsset:media.videoAsset];
  548. float w = 0.15;
  549. float x = (1.0 - w) / 2.0;
  550. float width = w * info.width;
  551. float height = width * tailWatermarkImage.size.height / tailWatermarkImage.size.width;
  552. float y = (info.height - height) / 2 / info.height;
  553. config.tailWatermark = [UGCKitWatermark watermarkWithImage:tailWatermarkImage
  554. frame:CGRectMake(x, y, w, 0)
  555. duration:2];
  556. __weak __typeof(self) wself = self;
  557. UGCKitEditViewController *vc = [[UGCKitEditViewController alloc] initWithMedia:media
  558. config:config
  559. theme:nil];
  560. __weak UGCKitEditViewController *weakEditController = vc;
  561. __weak UINavigationController *weakNavigation = nav;
  562. vc.onTapNextButton = ^(void (^finish)(BOOL)) {
  563. // [wself showEditFinishOptionsWithResult:result editController:weakEditController finishBloack:finish];
  564. finish(YES);
  565. };
  566. vc.completion = ^(UGCKitResult *result) {
  567. __strong __typeof(wself) self = wself; if (self == nil) { return; }
  568. if (result.cancelled) {
  569. [[AppDelegate sharedAppDelegate]popViewController];
  570. } else {
  571. [_videoDynamicViewC upLoadVideoUrl:vc.videoOutputPath];
  572. [[AppDelegate sharedAppDelegate]popToRootViewController];
  573. [[AppDelegate sharedAppDelegate]pushViewController:_videoDynamicViewC animated:YES];
  574. [self showVideoDynamicViewC];
  575. }
  576. [[NSUserDefaults standardUserDefaults] setObject:nil forKey:CACHE_PATH_LIST];
  577. // [self dismissViewControllerAnimated:YES completion:nil];
  578. };
  579. [[AppDelegate sharedAppDelegate]pushViewController:vc animated:YES];
  580. // [nav pushViewController:vc animated:YES];
  581. }
  582. #pragma mark - 5 - 视频动态页面
  583. -(void)showVideoDynamicViewC
  584. {
  585. _videoDynamicViewC = (VideoDynamicViewC *)[VideoDynamicViewC showSTBaseViewCOnSuperViewC:[AppDelegate sharedAppDelegate].topViewController.tabBarController.selectedViewController
  586. andFrameRect:CGRectMake(0, 0, kScreenW, kScreenH)
  587. andSTViewCTransitionType:STViewCTransitionTypeOfModal
  588. andComplete:^(BOOL finished,
  589. STBaseViewC *stBaseViewC) {
  590. }];
  591. _videoDynamicViewC.recordTabBarC = [AppDelegate sharedAppDelegate].topViewController.tabBarController;
  592. [_videoDynamicViewC videoDynamicView];
  593. [_videoDynamicViewC showPublishDynamic];
  594. // 开启IQ
  595. _videoDynamicViewC.title = ASLocalizedString(@"发布短视频");
  596. _videoDynamicViewC.navigationItem.title = ASLocalizedString(@"发布短视频");
  597. _videoDynamicViewC.navigationController.navigationBar.tintColor =kAppGrayColor1;
  598. self.navigationController.navigationItem.title = ASLocalizedString(@"发布短视频");
  599. //改变颜色 必须跳转后
  600. _videoDynamicViewC.navigationController.navigationBar.hidden = NO;
  601. [_videoDynamicViewC.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:kAppGrayColor1}];
  602. _videoDynamicViewC.isOpenIQKeyboardManager = YES;
  603. [self.navigationController popToRootViewControllerAnimated:YES];
  604. }
  605. //是否已认证
  606. -(void)showAuthView{
  607. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:ASLocalizedString(@"您当前还未实名认证,需要认证后才能开始直播")preferredStyle:UIAlertControllerStyleAlert];
  608. UIAlertAction *actionCacel = [UIAlertAction actionWithTitle:ASLocalizedString(@"取消")style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  609. }];
  610. UIAlertAction *actionConfirm = [UIAlertAction actionWithTitle:ASLocalizedString(@"立即认证")style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  611. UserModel *userModel = [GlobalVariables sharedInstance].userModel;
  612. SIdentificationVC *identificationVC = [[SIdentificationVC alloc]init];
  613. identificationVC.user_id = userModel.user_id;
  614. identificationVC.sexString = userModel.sex;
  615. identificationVC.nameString = userModel.nick_name;
  616. [[AppDelegate sharedAppDelegate] pushViewController:identificationVC animated:YES];
  617. }];
  618. [alertController addAction:actionCacel];
  619. [alertController addAction:actionConfirm];
  620. [[AppDelegate sharedAppDelegate].topViewController presentViewController:alertController animated:YES completion:nil];
  621. }
  622. - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(nonnull UIViewController *)viewController
  623. {
  624. NSInteger index = [tabBarController.viewControllers indexOfObject:viewController];
  625. // [self showNesBarRedNum];
  626. // if (index == 2) {//点击直播
  627. // [self onClickedCenterTabBar];
  628. //// IMALoginParam *loginParam = [IMALoginParam loadFromLocal];
  629. //// if (loginParam.isAgree ==1)
  630. //// {
  631. //// PublishLivestViewController *pvc = [[PublishLivestViewController alloc] init];
  632. //// [[AppDelegate sharedAppDelegate] presentViewController:pvc animated:YES completion:^{
  633. ////
  634. //// }];
  635. //// }
  636. //// else
  637. //// {
  638. //// AgreementViewController *agreeVC = [AgreementViewController webControlerWithUrlStr:[GlobalVariables sharedInstance].appModel.agreement_link isShowIndicator:YES isShowNavBar:YES];
  639. //// [[AppDelegate sharedAppDelegate] presentViewController:agreeVC animated:YES completion:^{
  640. ////
  641. //// }];
  642. //// }
  643. // return NO;
  644. // }
  645. #if kSupportH5Shopping
  646. NSInteger index = [tabBarController.viewControllers indexOfObject:viewController];
  647. if (index == 0)
  648. {
  649. [APP_DELEGATE beginEnterMianUI];
  650. return NO;
  651. }
  652. return YES;
  653. #else
  654. return YES;
  655. #endif
  656. }
  657. -(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
  658. // [self showNesBarRedNum];
  659. // switch (item.tag) {
  660. // case 1:
  661. // NSLog(@"tab bar: 1");
  662. // break;
  663. //
  664. // case 2:
  665. // NSLog(@"tab bar: 2");
  666. // break;
  667. // }
  668. }
  669. -(BogoYounthModePopView *)youthView{
  670. if (!_youthView) {
  671. _youthView = [[BogoYounthModePopView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kRealValue(331))];
  672. WeakSelf
  673. _youthView.clickInYounthBlock = ^(BOOL isComeIn) {
  674. // BogoYouthModeViewController *vc = [BogoYouthModeViewController new];
  675. //
  676. // [[AppDelegate sharedAppDelegate]pushViewController:vc animated:YES];
  677. //// [weakSelf.navigationController pushViewController:vc animated:YES];
  678. // [weakSelf.youthView hide];
  679. };
  680. }
  681. return _youthView;
  682. }
  683. - (void)clickLiveBtn
  684. {
  685. [self startLive];
  686. }
  687. #pragma mark - 语音视频通话
  688. - (void)IMChatMsgNotfication:(NSNotification *)notifcation {
  689. if (![NSThread isMainThread])
  690. {
  691. [self performSelectorOnMainThread:@selector(IMChatMsgNotfication:) withObject:notifcation waitUntilDone:NO];
  692. return;
  693. }
  694. [AudioChatTool.shareInstance receiveCallWithNotification:notifcation];
  695. SIMMsgObj *thatmsg = (SIMMsgObj *) notifcation.object;
  696. if (thatmsg.mMsgType == MSG_PRIVATE_CallAudio || thatmsg.mMsgType == MSG_PRIVATE_CallVideo) {
  697. } else {
  698. //并且还要清除 未读
  699. // [self.mChatFriend ignoreThisUnReadCount];
  700. // [self addOneMsg:thatmsg];
  701. [[AppDelegate sharedAppDelegate] showNesBarRedNum];
  702. }
  703. }
  704. - (void)viewDidAppear:(BOOL)animated {
  705. [super viewDidAppear:animated];
  706. [self judjeAppLaunchSuccess];
  707. }
  708. - (void)judjeAppLaunchSuccess {
  709. if (BGIMLoginManager.sharedInstance.isIMSDKOK && self.adShowFinished) {
  710. AppDelegate.sharedAppDelegate.isLaunchSuccess = YES;
  711. return;
  712. }
  713. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  714. [self judjeAppLaunchSuccess];
  715. });
  716. }
  717. @end