BGTabBarController.m 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  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>
  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) UIView *tipView;
  60. @end
  61. @implementation BGTabBarController
  62. BogoSingletonM(Instance);
  63. - (void)viewDidLoad
  64. {
  65. [super viewDidLoad];
  66. [[GiftListManager sharedInstance] reloadGiftList];
  67. [BGIMMsgHandler sharedInstance];
  68. [BGIMPrivateMsgHandler sharedInstance];
  69. if ([BGIMLoginManager sharedInstance].isIMSDKOK) {
  70. NSLog(@"已经登录了");
  71. }else{
  72. NSLog(@"没有");
  73. [[BGIMLoginManager sharedInstance] loginImSDK:YES succ:nil failed:nil];
  74. }
  75. self.delegate = self;
  76. // [self setupCustomTabBar];
  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.clickSquareBtnBlock = ^(NSInteger index) {
  268. [self showDynamicVC];
  269. };
  270. [self addChildViewController:home image:@"ic_tab_live_normal" seletedImage:@"ic_tab_live_selected" title:ASLocalizedString(@"首页")];
  271. // VoiceHomeListViewController *voiceRoom = [VoiceHomeListViewController new];
  272. // voiceRoom.types = @"1";
  273. // voiceRoom.delegate = home;
  274. // voiceRoom.topViewdelegate = self;
  275. // [self addChildViewController:voiceRoom image:@"语音1" seletedImage:@"语音2" title:ASLocalizedString(@"语音")];
  276. GKAllRefreshViewController *voiceRoom2 = [GKAllRefreshViewController new];
  277. voiceRoom2.types = @"1";
  278. [self addChildViewController:voiceRoom2 image:@"ic_tab_party_normal" seletedImage:@"ic_tab_party_sel" title:ASLocalizedString(@"派对")];
  279. // guangc
  280. if (![GlobalVariables sharedInstance].appModel.short_video.integerValue) {
  281. BogoSquareViewController *squareVC = [BogoSquareViewController new];
  282. squareVC.clickSquareBtnBlock = ^(NSInteger index) {
  283. [self showDynamicVC];
  284. };
  285. [self addChildViewController:squareVC image:@"ic_tab_moment_normal" seletedImage:@"ic_tab_moment_sel" title:ASLocalizedString(@"动态")];
  286. }else{
  287. BogoNewSquareViewController *squareVC = [BogoNewSquareViewController new];
  288. squareVC.clickSquareBtnBlock = ^(NSInteger index) {
  289. [self showDynamicVC];
  290. };
  291. [self addChildViewController:squareVC image:@"ic_tab_moment_normal" seletedImage:@"ic_tab_moment_sel" title:ASLocalizedString(@"动态")];
  292. }
  293. // 发布直播==》放在FWTabBar里面
  294. // [self setupTabBar];
  295. // 直播
  296. [self addChildViewController:[[BogoNewsViewController alloc] init] image:@"ic_tab_message_normal" seletedImage:@"ic_tab_message_sel" title:ASLocalizedString(@"消息")];
  297. // 我的
  298. [self addChildViewController:[[MineViewController alloc] initWithNibName:@"MineViewController" bundle:[NSBundle mainBundle]] image:@"ic_tab_me_normal" seletedImage:@"ic_tab_me_sel" title:ASLocalizedString(@"我的")];
  299. // 配置TabBar样式
  300. self.tabBar.backgroundColor = [UIColor whiteColor];
  301. self.tabBar.barTintColor = UIColor.whiteColor;
  302. self.tabBar.shadowImage = [UIImage new];
  303. [self.tabBar setBackgroundImage:[UIImage imageWithColor:[UIColor whiteColor]]];
  304. self.tabBar.tintColor = [UIColor colorWithHexString:@"#5C1CF7"];
  305. self.tabBar.unselectedItemTintColor = [UIColor colorWithHexString:@"#606060"];
  306. // 设置TabBar字体大小
  307. [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithHexString:@"#606060"]}
  308. forState:UIControlStateNormal];
  309. [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithHexString:@"#5C1CF7"]}
  310. forState:UIControlStateSelected];
  311. [[UINavigationBar appearance] setTitleTextAttributes:@{
  312. NSForegroundColorAttributeName: UIColor.whiteColor
  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. childController.title = title;
  376. UITabBarItem* itm= [[UITabBarItem alloc] initWithTitle:title
  377. image:[[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
  378. selectedImage:[[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  379. childController.tabBarItem = itm;
  380. // 导航条
  381. BGNavigationController *nav = [[BGNavigationController alloc] initWithRootViewController:childController];
  382. [self addChildViewController:nav];
  383. return childController;
  384. }
  385. //- (void)setupTabBar
  386. //{
  387. // BGTabBar *tabbar = [[BGTabBar alloc] init];
  388. // tabbar.backgroundColor = kWhiteColor;
  389. // [self setValue:tabbar forKey:@"tabBar"];
  390. // FWWeakify(self)
  391. // [tabbar setCenterBtnClickBlock:^{
  392. // FWStrongify(self)
  393. // [self onClickedCenterTabBar];
  394. // }];
  395. //}
  396. - (void)startLive {
  397. if ([GlobalVariables sharedInstance].appModel.must_authentication.intValue == 1) {
  398. if ([GlobalVariables sharedInstance].userModel.is_authentication.intValue != 2) {
  399. [self showAuthView];
  400. return;
  401. }
  402. }
  403. IMALoginParam *loginParam = [IMALoginParam loadFromLocal];
  404. if (loginParam.isAgree ==1)
  405. {
  406. if (AppDelegate.sharedAppDelegate.isInAudioVideoChatVc) {
  407. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"通话中,请结束通话后再试")];
  408. return;
  409. }
  410. PublishLivestViewController *pvc = [[PublishLivestViewController alloc] init];
  411. [[AppDelegate sharedAppDelegate] presentViewController:pvc animated:YES completion:^{
  412. }];
  413. }
  414. else
  415. {
  416. AgreementViewController *agreeVC = [AgreementViewController webControlerWithUrlStr:[GlobalVariables sharedInstance].appModel.agreement_link isShowIndicator:YES isShowNavBar:YES];
  417. [[AppDelegate sharedAppDelegate] presentViewController:agreeVC animated:YES completion:^{
  418. }];
  419. }
  420. }
  421. #pragma mark 点击直播
  422. - (void)onClickedCenterTabBar
  423. {
  424. // PopMenuCenter *popMenuCenter = [PopMenuCenter sharePopMenuCenter];
  425. // [popMenuCenter setTabBarC:self];
  426. // [popMenuCenter setStPopMenuShowState:STPopMenuShow];
  427. NSArray *objs = [[NSBundle mainBundle]loadNibNamed:@"HMCenterPopView" owner:nil options:nil];
  428. self.popView = objs.firstObject;
  429. [self setUpLocalizationStringForView:self.popView];
  430. FWWeakify(self)
  431. [self.popView setClickPopViewBtnBlock:^(HMCenterPopViewBtnType type) {
  432. FWStrongify(self)
  433. switch (type) {
  434. case HMCenterPopViewBtnTypeLive:
  435. {
  436. [self startLive];
  437. }
  438. break;
  439. case HMCenterPopViewBtnTypeVideo:
  440. {
  441. [self showDynamicVC];
  442. }
  443. break;
  444. case HMCenterPopViewBtnTypeClose:
  445. break;
  446. default:
  447. break;
  448. }
  449. }];
  450. [self.popView show:[UIApplication sharedApplication].keyWindow];
  451. }
  452. -(void)showDynamicVC{
  453. self.videoDynamicViewC = (VideoDynamicViewC *)[VideoDynamicViewC showSTBaseViewCOnSuperViewC:self.selectedViewController
  454. andFrameRect:CGRectMake(0, 0, kScreenW, kScreenH)
  455. andSTViewCTransitionType:STViewCTransitionTypeOfModal
  456. andComplete:^(BOOL finished,
  457. STBaseViewC *stBaseViewC) {
  458. }];
  459. self.videoDynamicViewC.recordTabBarC = self;
  460. [self.videoDynamicViewC videoDynamicView];
  461. // 开启IQ
  462. self.videoDynamicViewC.isOpenIQKeyboardManager = YES;
  463. // 加载View层
  464. //[videoDynamicViewC graphicDynamicView];
  465. //跳转
  466. //找到当前ViewC
  467. UIViewController *currentViewC = self.selectedViewController.childViewControllers[0];
  468. //TabBarc隐藏
  469. currentViewC.hidesBottomBarWhenPushed=YES;
  470. currentViewC.navigationController.navigationBar.tintColor = kAppGrayColor1;
  471. self.videoDynamicViewC.navigationController.navigationBar.hidden = NO;
  472. self.videoDynamicViewC.title = ASLocalizedString(@"发布短视频");
  473. self.videoDynamicViewC.navigationController.navigationBar.tintColor =kAppGrayColor1;
  474. //改变颜色 必须跳转后
  475. self.videoDynamicViewC.navigationController.navigationBar.hidden = NO;
  476. [self.videoDynamicViewC.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:kAppGrayColor1}];
  477. currentViewC.hidesBottomBarWhenPushed=NO;
  478. UIActionSheet *headImgSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
  479. [headImgSheet addButtonWithTitle:ASLocalizedString(@"拍摄视频")];
  480. [headImgSheet addButtonWithTitle:ASLocalizedString(@"相册中获取视频")];
  481. [headImgSheet addButtonWithTitle:ASLocalizedString(@"取消")];
  482. headImgSheet.cancelButtonIndex = headImgSheet.numberOfButtons-1;
  483. headImgSheet.delegate = self;
  484. [headImgSheet showInView:[UIApplication sharedApplication].keyWindow];
  485. }
  486. - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger) buttonIndex
  487. {
  488. if (buttonIndex == 0) {
  489. //如果短视频key为空,调本地视频
  490. if ([BGUtils isBlankString:[GlobalVariables sharedInstance].appModel.tencent_video_sdk_key]) {
  491. [[AppDelegate sharedAppDelegate]pushViewController:self.videoDynamicViewC animated:YES];
  492. [self.videoDynamicViewC ceartVideoViewWithType:(int)buttonIndex];
  493. return;
  494. }
  495. #warning 暂时注释
  496. UGCKitRecordViewController *recordViewController = [[UGCKitRecordViewController alloc] initWithConfig:nil theme:nil];
  497. recordViewController.completion = ^(UGCKitResult *result) {
  498. if (result.cancelled) {
  499. [[AppDelegate sharedAppDelegate]popViewController];
  500. // UGCKitEditViewController *vc= [UGCKitEditViewController new];
  501. // [[AppDelegate sharedAppDelegate]pushViewController:vc];
  502. }else{
  503. [self showEditViewController:result rotation:TCEditRotation0 inNavigationController:[AppDelegate sharedAppDelegate].topViewController.navigationController];
  504. // self.navigationController];
  505. }
  506. };
  507. // TCVideoRecordViewController *vc = [[TCVideoRecordViewController alloc] init];
  508. [[AppDelegate sharedAppDelegate] pushViewController:recordViewController animated:YES];
  509. return;
  510. }else if (buttonIndex == 1){
  511. [[AppDelegate sharedAppDelegate]pushViewController:self.videoDynamicViewC animated:YES];
  512. [self.videoDynamicViewC ceartVideoViewWithType:(int)buttonIndex];
  513. }
  514. }
  515. - (void)showEditViewController:(UGCKitResult *)result
  516. rotation:(TCEditRotation)rotation
  517. inNavigationController:(UINavigationController *)nav
  518. {
  519. UGCKitMedia *media = result.media;
  520. UGCKitEditConfig *config = [[UGCKitEditConfig alloc] init];
  521. config.rotation = (TCEditRotation)(rotation / 90);
  522. UIImage *tailWatermarkImage = [UIImage imageNamed:@"tcloud_logo"];
  523. TXVideoInfo *info = [TXVideoInfoReader getVideoInfoWithAsset:media.videoAsset];
  524. float w = 0.15;
  525. float x = (1.0 - w) / 2.0;
  526. float width = w * info.width;
  527. float height = width * tailWatermarkImage.size.height / tailWatermarkImage.size.width;
  528. float y = (info.height - height) / 2 / info.height;
  529. config.tailWatermark = [UGCKitWatermark watermarkWithImage:tailWatermarkImage
  530. frame:CGRectMake(x, y, w, 0)
  531. duration:2];
  532. __weak __typeof(self) wself = self;
  533. UGCKitEditViewController *vc = [[UGCKitEditViewController alloc] initWithMedia:media
  534. config:config
  535. theme:nil];
  536. __weak UGCKitEditViewController *weakEditController = vc;
  537. __weak UINavigationController *weakNavigation = nav;
  538. vc.onTapNextButton = ^(void (^finish)(BOOL)) {
  539. // [wself showEditFinishOptionsWithResult:result editController:weakEditController finishBloack:finish];
  540. finish(YES);
  541. };
  542. vc.completion = ^(UGCKitResult *result) {
  543. __strong __typeof(wself) self = wself; if (self == nil) { return; }
  544. if (result.cancelled) {
  545. [[AppDelegate sharedAppDelegate]popViewController];
  546. } else {
  547. [_videoDynamicViewC upLoadVideoUrl:vc.videoOutputPath];
  548. [[AppDelegate sharedAppDelegate]popToRootViewController];
  549. [[AppDelegate sharedAppDelegate]pushViewController:_videoDynamicViewC animated:YES];
  550. [self showVideoDynamicViewC];
  551. }
  552. [[NSUserDefaults standardUserDefaults] setObject:nil forKey:CACHE_PATH_LIST];
  553. // [self dismissViewControllerAnimated:YES completion:nil];
  554. };
  555. [[AppDelegate sharedAppDelegate]pushViewController:vc animated:YES];
  556. // [nav pushViewController:vc animated:YES];
  557. }
  558. #pragma mark - 5 - 视频动态页面
  559. -(void)showVideoDynamicViewC
  560. {
  561. _videoDynamicViewC = (VideoDynamicViewC *)[VideoDynamicViewC showSTBaseViewCOnSuperViewC:[AppDelegate sharedAppDelegate].topViewController.tabBarController.selectedViewController
  562. andFrameRect:CGRectMake(0, 0, kScreenW, kScreenH)
  563. andSTViewCTransitionType:STViewCTransitionTypeOfModal
  564. andComplete:^(BOOL finished,
  565. STBaseViewC *stBaseViewC) {
  566. }];
  567. _videoDynamicViewC.recordTabBarC = [AppDelegate sharedAppDelegate].topViewController.tabBarController;
  568. [_videoDynamicViewC videoDynamicView];
  569. [_videoDynamicViewC showPublishDynamic];
  570. // 开启IQ
  571. _videoDynamicViewC.title = ASLocalizedString(@"发布短视频");
  572. _videoDynamicViewC.navigationItem.title = ASLocalizedString(@"发布短视频");
  573. _videoDynamicViewC.navigationController.navigationBar.tintColor =kAppGrayColor1;
  574. self.navigationController.navigationItem.title = ASLocalizedString(@"发布短视频");
  575. //改变颜色 必须跳转后
  576. _videoDynamicViewC.navigationController.navigationBar.hidden = NO;
  577. [_videoDynamicViewC.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:kAppGrayColor1}];
  578. _videoDynamicViewC.isOpenIQKeyboardManager = YES;
  579. [self.navigationController popToRootViewControllerAnimated:YES];
  580. }
  581. //是否已认证
  582. -(void)showAuthView{
  583. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:ASLocalizedString(@"您当前还未实名认证,需要认证后才能开始直播")preferredStyle:UIAlertControllerStyleAlert];
  584. UIAlertAction *actionCacel = [UIAlertAction actionWithTitle:ASLocalizedString(@"取消")style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  585. }];
  586. UIAlertAction *actionConfirm = [UIAlertAction actionWithTitle:ASLocalizedString(@"立即认证")style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  587. UserModel *userModel = [GlobalVariables sharedInstance].userModel;
  588. SIdentificationVC *identificationVC = [[SIdentificationVC alloc]init];
  589. identificationVC.user_id = userModel.user_id;
  590. identificationVC.sexString = userModel.sex;
  591. identificationVC.nameString = userModel.nick_name;
  592. [[AppDelegate sharedAppDelegate] pushViewController:identificationVC animated:YES];
  593. }];
  594. [alertController addAction:actionCacel];
  595. [alertController addAction:actionConfirm];
  596. [[AppDelegate sharedAppDelegate].topViewController presentViewController:alertController animated:YES completion:nil];
  597. }
  598. - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(nonnull UIViewController *)viewController
  599. {
  600. NSInteger index = [tabBarController.viewControllers indexOfObject:viewController];
  601. // [self showNesBarRedNum];
  602. // if (index == 2) {//点击直播
  603. // [self onClickedCenterTabBar];
  604. //// IMALoginParam *loginParam = [IMALoginParam loadFromLocal];
  605. //// if (loginParam.isAgree ==1)
  606. //// {
  607. //// PublishLivestViewController *pvc = [[PublishLivestViewController alloc] init];
  608. //// [[AppDelegate sharedAppDelegate] presentViewController:pvc animated:YES completion:^{
  609. ////
  610. //// }];
  611. //// }
  612. //// else
  613. //// {
  614. //// AgreementViewController *agreeVC = [AgreementViewController webControlerWithUrlStr:[GlobalVariables sharedInstance].appModel.agreement_link isShowIndicator:YES isShowNavBar:YES];
  615. //// [[AppDelegate sharedAppDelegate] presentViewController:agreeVC animated:YES completion:^{
  616. ////
  617. //// }];
  618. //// }
  619. // return NO;
  620. // }
  621. #if kSupportH5Shopping
  622. NSInteger index = [tabBarController.viewControllers indexOfObject:viewController];
  623. if (index == 0)
  624. {
  625. [APP_DELEGATE beginEnterMianUI];
  626. return NO;
  627. }
  628. return YES;
  629. #else
  630. return YES;
  631. #endif
  632. }
  633. -(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
  634. // [self showNesBarRedNum];
  635. // switch (item.tag) {
  636. // case 1:
  637. // NSLog(@"tab bar: 1");
  638. // break;
  639. //
  640. // case 2:
  641. // NSLog(@"tab bar: 2");
  642. // break;
  643. // }
  644. }
  645. -(BogoYounthModePopView *)youthView{
  646. if (!_youthView) {
  647. _youthView = [[BogoYounthModePopView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kRealValue(331))];
  648. WeakSelf
  649. _youthView.clickInYounthBlock = ^(BOOL isComeIn) {
  650. // BogoYouthModeViewController *vc = [BogoYouthModeViewController new];
  651. //
  652. // [[AppDelegate sharedAppDelegate]pushViewController:vc animated:YES];
  653. //// [weakSelf.navigationController pushViewController:vc animated:YES];
  654. // [weakSelf.youthView hide];
  655. };
  656. }
  657. return _youthView;
  658. }
  659. - (void)clickLiveBtn
  660. {
  661. [self startLive];
  662. }
  663. #pragma mark - 语音视频通话
  664. - (void)IMChatMsgNotfication:(NSNotification *)notifcation {
  665. if (![NSThread isMainThread])
  666. {
  667. [self performSelectorOnMainThread:@selector(IMChatMsgNotfication:) withObject:notifcation waitUntilDone:NO];
  668. return;
  669. }
  670. [AudioChatTool.shareInstance receiveCallWithNotification:notifcation];
  671. SIMMsgObj *thatmsg = (SIMMsgObj *) notifcation.object;
  672. if (thatmsg.mMsgType == MSG_PRIVATE_CallAudio || thatmsg.mMsgType == MSG_PRIVATE_CallVideo) {
  673. } else {
  674. //并且还要清除 未读
  675. // [self.mChatFriend ignoreThisUnReadCount];
  676. // [self addOneMsg:thatmsg];
  677. [[AppDelegate sharedAppDelegate] showNesBarRedNum];
  678. }
  679. }
  680. - (void)viewDidAppear:(BOOL)animated {
  681. [super viewDidAppear:animated];
  682. [self judjeAppLaunchSuccess];
  683. }
  684. - (void)judjeAppLaunchSuccess {
  685. if (BGIMLoginManager.sharedInstance.isIMSDKOK && self.adShowFinished) {
  686. AppDelegate.sharedAppDelegate.isLaunchSuccess = YES;
  687. return;
  688. }
  689. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  690. [self judjeAppLaunchSuccess];
  691. });
  692. }
  693. @end