| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908 |
- //
- // BGTabBarController.m
- // BuguLive
- //
- // Created by xfg on 2017/6/26.
- // Copyright © 2017年 xfg. All rights reserved.
- //
- #import "BGTabBarController.h"
- #import "BGTabBar.h"
- #import "BGNavigationController.h"
- #import "HMHomeViewController.h"
- #import "PublishLivestViewController.h"
- #import "AgreementViewController.h"
- #import "MPersonCenterVC.h"
- #import "MSmallVideoVC.h"
- #import "ListDayViewController.h"
- #import "LeaderboardViewController.h"
- #import "SChargerVC.h"
- #import "LEEAlertHelper.h"
- #import "LEEAlert.h"
- #import "HMCenterPopView.h"
- #import "SmallVideoViewController.h"
- #import "CustomPagerController.h"
- #import "AppDelegate.h"
- #import "NewSmallVideoViewController.h"
- #import "TCVideoRecordViewController.h"
- #import "YHTimeLineViewController.h"
- #import "MGAlertIncodeView.h"
- #import "UpgradeTipView.h"
- //#import <UGCKit/UGCKit.h>
- #import <UGCKit/UGCKit.h>
- #import <TXLiteAVSDK_Professional/TXVideoEditer.h>
- //主页
- #import "BogoHomeViewController.h"
- //广场
- #import "BogoSquareViewController.h"
- //消息
- #import "BogoNewsViewController.h"
- //青少年模式弹窗
- #import "BogoYounthModePopView.h"
- #import "SIdentificationVC.h"
- #import "IMALoginParam.h"
- #import "BogoNewsTabNumModel.h"
- #import "MineViewController.h"
- #import "BogoShopKit.h"
- #import "BogoYouthModeViewController.h"
- #import "BogoYoungModeVideoViewController.h"
- #import "BogoYoungModeVideoViewController.h"
- #import "BogoNewSquareViewController.h"
- #import "VoiceHomeListViewController.h"
- #import "GKDBViewController.h"
- #import "GKAllRefreshViewController.h"
- #import "AudioChatTool.h"
- @interface BGTabBarController ()<UITabBarControllerDelegate,UIActionSheetDelegate,BogoHomeTopViewDelegate>
- @property (nonatomic, strong) HMCenterPopView *popView;
- @property (nonatomic, strong) VideoDynamicViewC *videoDynamicViewC;
- @property(nonatomic, strong) MGAlertIncodeView *alertView;
- @property(nonatomic, strong) BogoYounthModePopView *youthView;
- @property(nonatomic, strong) UIImageView *tabBgImgView;
- @property(nonatomic, strong) UIView *tipView;
- @end
- @implementation BGTabBarController
- BogoSingletonM(Instance);
- - (void)viewDidLoad
- {
- [super viewDidLoad];
-
-
- [[GiftListManager sharedInstance] reloadGiftList];
-
- [BGIMMsgHandler sharedInstance];
- [BGIMPrivateMsgHandler sharedInstance];
-
- if ([BGIMLoginManager sharedInstance].isIMSDKOK) {
- NSLog(@"已经登录了");
- }else{
- NSLog(@"没有");
-
- [[BGIMLoginManager sharedInstance] loginImSDK:YES succ:nil failed:nil];
- }
-
- self.delegate = self;
-
- [self setUpChildViewControllers];
- self.view.backgroundColor = kWhiteColor;
- self.alertView = [MGAlertIncodeView new];
- self.alertView.frame = CGRectMake(0, 0, kScreenW, kScreenH);
- self.alertView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4];
- FWWeakify(self)
- self.alertView.clickBlock = ^(NSInteger i) {
- FWStrongify(self)
- if (i == 0) {
- // [self.alertView removeAllSubViews];
- self.alertView.hidden = YES;
- }
- };
-
- self.alertView.hidden = YES;
- [self.view addSubview:self.alertView];
-
- if (kIsCheckingVersion())
- {
-
- }
- else
- {
- #ifdef DEBUG
- #else
- [self checkCode];
- #endif
- }
-
- // [[UIBarButtonItem appearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:kClearColor,
- // NSFontAttributeName:[UIFont systemFontOfSize:20.0]
- // } forState:UIControlStateNormal];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(isOpenYoung:) name:@"isOpenYoung" object:nil];
-
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDarkContent];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(IMChatMsgNotfication:) name:g_notif_chatmsg object:nil];
- }
- - (void)getGiftNumber {
- NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
- [dict setValue:@"deal" forKey:@"ctl"];
- [dict setValue:@"get_gift_quantity" forKey:@"act"];
- [[NetHttpsManager manager] POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) {
- NSLog(@"104responseJson%@",responseJson);
- if ([responseJson toInt:@"status"] == 1) {
- NSArray *list = responseJson[@"data"];
- [GlobalVariables sharedInstance].giftQuantityModelList = [NSArray modelArrayWithClass:GiftQuantityModel.class json:list];
-
- // for (int i = 0; i<list.count; i++) {
- // GiftQuantityModel *model = [GiftQuantityModel modelWithDictionary:list[i]];
- //
- // }
- }else{
- //接口请求失败
- NSLog(ASLocalizedString(@"礼物responseJson:%@"),responseJson);
- }
- } FailureBlock:^(NSError *error) {
- NSLog(ASLocalizedString(@"礼物error:%@"),error);
- }];
- }
- - (void)isOpenYoung:(NSNotification *)center{
- // NSDictionary *dic = center.object;
-
- if ([GlobalVariables sharedInstance].userModel.is_open_young.integerValue) {
- NSMutableDictionary *hotDic = [NSMutableDictionary dictionary];
-
- [hotDic setObject:@"1" forKey:@"order"];
- [hotDic setObject:@"0" forKey:@"cate"];
- BogoYoungModeVideoViewController *vc = [BogoYoungModeVideoViewController new];
- vc.isHaveNavBar = NO;
- vc.paramDict = hotDic;
- vc.notHaveTabbar = NO;
- vc.hidesBottomBarWhenPushed = YES;
- [self.viewControllers.firstObject pushViewController:vc animated:YES];
- }else{
- if (![GlobalVariables sharedInstance].isShutDownYoung) {
- [self.youthView show:self.view type:FDPopTypeCenter];
- }else{
- [self.view addSubview:self.tipView];
- [UIView animateWithDuration:0.25 animations:^{
- self.tipView.alpha = 1;
- }];
- [self performSelector:@selector(hideTipView) afterDelay:3];
- }
- }
- }
- - (void)hideTipView{
- [UIView animateWithDuration:0.25 animations:^{
- self.tipView.alpha = 0;
- } completion:^(BOOL finished) {
- [self.tipView removeFromSuperview];
- }];
- }
- - (UIView *)tipView{
- if (!_tipView) {
- _tipView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 180, 40)];
- _tipView.backgroundColor = [FD_BlackColor colorWithAlphaComponent:0.4];
- _tipView.layer.cornerRadius = 20;
- _tipView.clipsToBounds = YES;
- UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 140, 20)];
- titleLabel.textColor = FD_WhiteColor;
- titleLabel.center = _tipView.center;
- titleLabel.text =ASLocalizedString( @"青少年模式已关闭");
- titleLabel.font = [UIFont systemFontOfSize:14];
- titleLabel.textAlignment = NSTextAlignmentCenter;
- [_tipView addSubview:titleLabel];
- _tipView.center = self.view.center;
- _tipView.alpha = 0;
- }
- return _tipView;
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self getGiftNumber];
- [[AppDelegate sharedAppDelegate] showNesBarRedNum];
- NSLog(@"%@",self.view);
-
- }
- - (void)checkCode {
-
- NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
- [mDict setObject:@"login" forKey:@"ctl"];
- [mDict setObject:@"is_invitation" forKey:@"act"];
-
- [[NetHttpsManager manager] POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) {
-
-
- if([[GlobalVariables sharedInstance].appModel.is_invite_code intValue] == 1)
- {
-
- if([responseJson toInt:@"state"] == 0)
- {
- self.alertView.hidden = NO;
- self.alertView.textField.placeholder = ASLocalizedString(@"请输入邀请码");
- }
- }
- else
- {
-
- if([responseJson toInt:@"state"] == 0)
- {
- self.alertView.hidden = NO;
- }
-
- }
-
- } FailureBlock:^(NSError *error) {
-
- }];
- }
- -(void)postCode:(NSString *)code
- {
- NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
- [mDict setObject:@"login" forKey:@"ctl"];
- [mDict setObject:@"invitation" forKey:@"act"];
- [mDict setObject:code forKey:@"invitation_id"];
-
- [[NetHttpsManager manager] POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) {
-
- if ([responseJson toInt:@"status"] == 1)
-
- {
- [LEEAlert closeWithCompletionBlock:^{
-
- }];
- [FanweMessage alert:ASLocalizedString(@"提交成功")];
- }
- else
- {
-
- __block UITextField *tf = nil;
-
- [BGHUDHelper alert:[responseJson valueForKey:@"error"] action:^{
- [LEEAlert alert].config
- .LeeTitle(ASLocalizedString(@"邀请码"))
- .LeeAddTextField(^(UITextField *textField) {
-
- // 这里可以进行自定义的设置
- textField.placeholder = ASLocalizedString(@"请输入邀请码");
-
- textField.textColor = [UIColor darkGrayColor];
-
- tf = textField; //赋值
- })
- .LeeAction(ASLocalizedString(@"确定"), ^{
-
- if(tf.text == nil || tf.text.length < 1)
- {
- // [self checkCode];
- [BGHUDHelper alert:ASLocalizedString(@"邀请码不能为空")action:^{
- [self checkCode];
- }];
- // [BGHUDHelper alert:ASLocalizedString(@"邀请码不能为空")];
- return;
- }
-
- [self postCode:tf.text];
- [tf resignFirstResponder];
- })
- // 点击事件的Block如果不需要可以传nil
- .LeeShow();
- }];
- }
- } FailureBlock:^(NSError *error) {
-
- }];
- //
- }
- #pragma mark - 设置子控制器
- - (void)setUpChildViewControllers
- {
- // if (@available(iOS 13.0, *)) {
- //
- // [[UITabBar appearance] setUnselectedItemTintColor:[UIColor colorWithHexString:@"#999999"]];
- // self.tabBar.tintColor = [UIColor colorWithHexString:@"#9152F8"];
- //// kAppMainColor;
- // }else{
- //
- // }
-
-
- // 首页
- BogoHomeViewController *home = [[BogoHomeViewController alloc] init];
- home.topViewdelegate = self;
- home.clickSquareBtnBlock = ^(NSInteger index) {
- [self showDynamicVC];
- };
- [self addChildViewController:home image:@"ic_live_tab_live_normal" seletedImage:@"ic_live_tab_live_selected" title:ASLocalizedString(@"直播")];
-
- // VoiceHomeListViewController *voiceRoom = [VoiceHomeListViewController new];
- // voiceRoom.types = @"1";
- // voiceRoom.delegate = home;
- // voiceRoom.topViewdelegate = self;
- // [self addChildViewController:voiceRoom image:@"语音1" seletedImage:@"语音2" title:ASLocalizedString(@"语音")];
-
- GKAllRefreshViewController *voiceRoom2 = [GKAllRefreshViewController new];
- voiceRoom2.types = @"1";
- voiceRoom2.delegate = home;
- voiceRoom2.topViewdelegate = self;
- [self addChildViewController:voiceRoom2 image:@"语音1" seletedImage:@"语音2" title:ASLocalizedString(@"语音")];
-
-
- // guangc
- if (![GlobalVariables sharedInstance].appModel.short_video.integerValue) {
- BogoSquareViewController *squareVC = [BogoSquareViewController new];
- squareVC.clickSquareBtnBlock = ^(NSInteger index) {
- [self showDynamicVC];
- };
- [self addChildViewController:squareVC image:@"ic_live_tab_rank_normal" seletedImage:@"ic_live_tab_rank_selected" title:ASLocalizedString(@"动态")];
- }else{
- BogoNewSquareViewController *squareVC = [BogoNewSquareViewController new];
- squareVC.clickSquareBtnBlock = ^(NSInteger index) {
- [self showDynamicVC];
- };
- [self addChildViewController:squareVC image:@"ic_live_tab_rank_normal" seletedImage:@"ic_live_tab_rank_selected" title:ASLocalizedString(@"动态")];
- }
- // 发布直播==》放在FWTabBar里面
- // [self setupTabBar];
- // 直播
-
- [self addChildViewController:[[BogoNewsViewController alloc] init] image:@"ic_live_tab_video_normal" seletedImage:@"ic_live_tab_video_selected" title:ASLocalizedString(@"消息")];
- // 我的
- [self addChildViewController:[[MineViewController alloc] initWithNibName:@"MineViewController" bundle:[NSBundle mainBundle]] image:@"ic_live_tab_me_normal" seletedImage:@"ic_live_tab_me_selected" title:ASLocalizedString(@"我的")];
-
- //fix
- if(self.tabBgImgView == nil)
- {
- [self.tabBgImgView removeFromSuperview];
-
- self.tabBgImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, -14, kScreenW, FD_Bottom_Height + 14)];
- // tabBgImgView.backgroundColor = kRedColor;
- self.tabBgImgView.image = [UIImage imageNamed:@"mg_tab_bgImg"];
- self.tabBgImgView.contentMode = UIViewContentModeScaleToFill;
- [self.tabBar addSubview:self.tabBgImgView];
- self.tabBar.backgroundImage = [UIImage imageNamed:@"mg_tab_bgImg"];
- self.tabBar.backgroundColor = kWhiteColor;
- }
-
- }
- //-(void)showNesBarRedNum{
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // UITabBarItem *itme = [self.tabBar.items objectAtIndex:3];
- // SFriendObj *xxx = nil;
- //
- // // [SFriendObj getMyFriendMsgList:0
- // // lastObj:xxx
- // // block:^(SResBase *resb, NSArray *all, int unReadNum) {
- // NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- // [parmDict setObject:@"dynamic" forKey:@"ctl"];
- // [parmDict setObject:@"unread_messages" forKey:@"act"];
- //
- // [[NetHttpsManager manager]POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
- //
- // if ([[responseJson valueForKey:@"status"]integerValue] == 1) {
- //
- // BogoNewsTabNumModel *model = [BogoNewsTabNumModel modelWithDictionary:[responseJson valueForKey:@"data"]];
- //
- //
- // // if ((model.bzone_reply + model.bzone_like) == 0) {
- // // itme.badgeValue = nil;
- // // }else{
- // //
- // //
- // // }
- // [SFriendObj getAllUnReadCountComplete:^(int num) {
- // if ((model.bzone_reply + model.bzone_like + num) == 0) {
- // itme.badgeValue = nil;
- // }else{
- // itme.badgeValue = [NSString stringWithFormat:@"%ld",model.bzone_reply + model.bzone_like + num + model.msg.count];
- // }
- //
- // }];
- // // self.headView.model = model;
- //
- // }
- //
- // } FailureBlock:^(NSError *error) {
- //
- // }];
- // });
- //
- //
- //
- //}
- -(UIImage *)imageResize :(UIImage*)img andResizeTo:(CGSize)newSize withTop:(CGFloat)top
- {
- CGFloat scale = [[UIScreen mainScreen]scale];
-
- //UIGraphicsBeginImageContext(newSize);
- UIGraphicsBeginImageContextWithOptions(newSize, NO, scale);
- [img drawInRect:CGRectMake(0,top,newSize.width,newSize.height)];
- UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return newImage;
- }
- #pragma mark - 添加子控制器
- - (UIViewController *)addChildViewController:(UIViewController *)childController image:(NSString *)image seletedImage:(NSString *)selectedImage title:(NSString *)title
- {
- // if (![BGUtils isBlankString:title])
- // {
- childController.title = title;
-
- NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary];
- normalAttrs[NSForegroundColorAttributeName] = kAppGrayColor3;
- [childController.tabBarItem setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];
-
- NSMutableDictionary *selectedAtrrs = [NSMutableDictionary dictionary];
- selectedAtrrs[NSForegroundColorAttributeName] = UIColorFromRGB(0x4BC8FC);
- [childController.tabBarItem setTitleTextAttributes:selectedAtrrs forState:UIControlStateSelected];
-
- // childController.tabBarItem.imageInsets = UIEdgeInsetsMake(12, 12, 12, 12);
- // childController.tabBarItem.imageInsets = UIEdgeInsetsMake(-10, 0, -5, 0);
-
- // childController.tabBarItem.imageInsets = UIEdgeInsetsMake(-10, 0, -5, 0);
- // }
- // else
- // {
- // childController.tabBarItem.imageInsets = UIEdgeInsetsMake(-16, 0, -5, 0);
- // }
-
- // 设置图片
- // if ([title isEqualToString:@""]) {
- //// UIImage *imageS = [[self imageResize:[UIImage imageNamed:image] andResizeTo:CGSizeMake(50, 50)] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
- //// [childController.tabBarItem setImage:imageS];
- //// [imageS drawInRect:CGRectMake(-10,0,50,50)];
- // [childController.tabBarItem setImage:[[self imageResize:[UIImage imageNamed:image] andResizeTo:CGSizeMake(kRealValue(45), kRealValue(45)) withTop:0] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
- // }else{
-
- UITabBarItem* itm= [[UITabBarItem alloc] initWithTitle:title image:[UIImage imageNamed:image] selectedImage:[UIImage imageNamed:selectedImage]];
- childController.tabBarItem = itm;
-
- [childController.tabBarItem setImage:[[self imageResize:[UIImage imageNamed:image] andResizeTo:CGSizeMake(20, 20) withTop:0] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
- [childController.tabBarItem setSelectedImage:[[self imageResize:[UIImage imageNamed:selectedImage] andResizeTo:CGSizeMake(20, 20) withTop:0] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
-
- // }
-
-
- // 导航条
- BGNavigationController *nav = [[BGNavigationController alloc] initWithRootViewController:childController];
- [self addChildViewController:nav];
- return childController;
- }
- //- (void)setupTabBar
- //{
- // BGTabBar *tabbar = [[BGTabBar alloc] init];
- // tabbar.backgroundColor = kWhiteColor;
- // [self setValue:tabbar forKey:@"tabBar"];
- // FWWeakify(self)
- // [tabbar setCenterBtnClickBlock:^{
- // FWStrongify(self)
- // [self onClickedCenterTabBar];
- // }];
- //}
- - (void)startLive {
- if ([GlobalVariables sharedInstance].appModel.must_authentication.intValue == 1) {
- if ([GlobalVariables sharedInstance].userModel.is_authentication.intValue != 2) {
- [self showAuthView];
- return;
- }
- }
-
-
-
- IMALoginParam *loginParam = [IMALoginParam loadFromLocal];
- if (loginParam.isAgree ==1)
- {
-
- if (AppDelegate.sharedAppDelegate.isInAudioVideoChatVc) {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"通话中,请结束通话后再试")];
- return;
- }
-
- PublishLivestViewController *pvc = [[PublishLivestViewController alloc] init];
- [[AppDelegate sharedAppDelegate] presentViewController:pvc animated:YES completion:^{
-
- }];
- }
- else
- {
- AgreementViewController *agreeVC = [AgreementViewController webControlerWithUrlStr:[GlobalVariables sharedInstance].appModel.agreement_link isShowIndicator:YES isShowNavBar:YES];
- [[AppDelegate sharedAppDelegate] presentViewController:agreeVC animated:YES completion:^{
-
- }];
- }
- }
- #pragma mark 点击直播
- - (void)onClickedCenterTabBar
- {
- // PopMenuCenter *popMenuCenter = [PopMenuCenter sharePopMenuCenter];
- // [popMenuCenter setTabBarC:self];
- // [popMenuCenter setStPopMenuShowState:STPopMenuShow];
-
- NSArray *objs = [[NSBundle mainBundle]loadNibNamed:@"HMCenterPopView" owner:nil options:nil];
- self.popView = objs.firstObject;
- [self setUpLocalizationStringForView:self.popView];
- FWWeakify(self)
- [self.popView setClickPopViewBtnBlock:^(HMCenterPopViewBtnType type) {
- FWStrongify(self)
- switch (type) {
- case HMCenterPopViewBtnTypeLive:
- {
-
- [self startLive];
- }
- break;
- case HMCenterPopViewBtnTypeVideo:
- {
-
- [self showDynamicVC];
-
- }
- break;
- case HMCenterPopViewBtnTypeClose:
- break;
- default:
- break;
- }
- }];
- [self.popView show:[UIApplication sharedApplication].keyWindow];
- }
- -(void)showDynamicVC{
- self.videoDynamicViewC = (VideoDynamicViewC *)[VideoDynamicViewC showSTBaseViewCOnSuperViewC:self.selectedViewController
- andFrameRect:CGRectMake(0, 0, kScreenW, kScreenH)
- andSTViewCTransitionType:STViewCTransitionTypeOfModal
- andComplete:^(BOOL finished,
- STBaseViewC *stBaseViewC) {
-
- }];
- self.videoDynamicViewC.recordTabBarC = self;
- [self.videoDynamicViewC videoDynamicView];
-
- // 开启IQ
- self.videoDynamicViewC.isOpenIQKeyboardManager = YES;
- // 加载View层
- //[videoDynamicViewC graphicDynamicView];
- //跳转
- //找到当前ViewC
- UIViewController *currentViewC = self.selectedViewController.childViewControllers[0];
- //TabBarc隐藏
- currentViewC.hidesBottomBarWhenPushed=YES;
- currentViewC.navigationController.navigationBar.tintColor = kAppGrayColor1;
- self.videoDynamicViewC.navigationController.navigationBar.hidden = NO;
- self.videoDynamicViewC.title = ASLocalizedString(@"发布短视频");
- self.videoDynamicViewC.navigationController.navigationBar.tintColor =kAppGrayColor1;
-
-
-
-
- //改变颜色 必须跳转后
- self.videoDynamicViewC.navigationController.navigationBar.hidden = NO;
- [self.videoDynamicViewC.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:kAppGrayColor1}];
- currentViewC.hidesBottomBarWhenPushed=NO;
-
- UIActionSheet *headImgSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
- [headImgSheet addButtonWithTitle:ASLocalizedString(@"拍摄视频")];
- [headImgSheet addButtonWithTitle:ASLocalizedString(@"相册中获取视频")];
- [headImgSheet addButtonWithTitle:ASLocalizedString(@"取消")];
- headImgSheet.cancelButtonIndex = headImgSheet.numberOfButtons-1;
- headImgSheet.delegate = self;
- [headImgSheet showInView:[UIApplication sharedApplication].keyWindow];
- }
- - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger) buttonIndex
- {
- if (buttonIndex == 0) {
-
- //如果短视频key为空,调本地视频
- if ([BGUtils isBlankString:[GlobalVariables sharedInstance].appModel.tencent_video_sdk_key]) {
- [[AppDelegate sharedAppDelegate]pushViewController:self.videoDynamicViewC animated:YES];
- [self.videoDynamicViewC ceartVideoViewWithType:(int)buttonIndex];
- return;
- }
- #warning 暂时注释
-
- UGCKitRecordViewController *recordViewController = [[UGCKitRecordViewController alloc] initWithConfig:nil theme:nil];
- recordViewController.completion = ^(UGCKitResult *result) {
-
- if (result.cancelled) {
- [[AppDelegate sharedAppDelegate]popViewController];
- // UGCKitEditViewController *vc= [UGCKitEditViewController new];
- // [[AppDelegate sharedAppDelegate]pushViewController:vc];
- }else{
- [self showEditViewController:result rotation:TCEditRotation0 inNavigationController:[AppDelegate sharedAppDelegate].topViewController.navigationController];
- // self.navigationController];
- }
-
- };
-
- // TCVideoRecordViewController *vc = [[TCVideoRecordViewController alloc] init];
- [[AppDelegate sharedAppDelegate] pushViewController:recordViewController animated:YES];
-
- return;
- }else if (buttonIndex == 1){
- [[AppDelegate sharedAppDelegate]pushViewController:self.videoDynamicViewC animated:YES];
- [self.videoDynamicViewC ceartVideoViewWithType:(int)buttonIndex];
- }
- }
- - (void)showEditViewController:(UGCKitResult *)result
- rotation:(TCEditRotation)rotation
- inNavigationController:(UINavigationController *)nav
- {
- UGCKitMedia *media = result.media;
- UGCKitEditConfig *config = [[UGCKitEditConfig alloc] init];
- config.rotation = (TCEditRotation)(rotation / 90);
- UIImage *tailWatermarkImage = [UIImage imageNamed:@"tcloud_logo"];
- TXVideoInfo *info = [TXVideoInfoReader getVideoInfoWithAsset:media.videoAsset];
- float w = 0.15;
- float x = (1.0 - w) / 2.0;
- float width = w * info.width;
- float height = width * tailWatermarkImage.size.height / tailWatermarkImage.size.width;
- float y = (info.height - height) / 2 / info.height;
- config.tailWatermark = [UGCKitWatermark watermarkWithImage:tailWatermarkImage
- frame:CGRectMake(x, y, w, 0)
- duration:2];
- __weak __typeof(self) wself = self;
- UGCKitEditViewController *vc = [[UGCKitEditViewController alloc] initWithMedia:media
- config:config
- theme:nil];
-
- __weak UGCKitEditViewController *weakEditController = vc;
- __weak UINavigationController *weakNavigation = nav;
-
- vc.onTapNextButton = ^(void (^finish)(BOOL)) {
- // [wself showEditFinishOptionsWithResult:result editController:weakEditController finishBloack:finish];
- finish(YES);
- };
- vc.completion = ^(UGCKitResult *result) {
- __strong __typeof(wself) self = wself; if (self == nil) { return; }
- if (result.cancelled) {
- [[AppDelegate sharedAppDelegate]popViewController];
- } else {
- [_videoDynamicViewC upLoadVideoUrl:vc.videoOutputPath];
- [[AppDelegate sharedAppDelegate]popToRootViewController];
- [[AppDelegate sharedAppDelegate]pushViewController:_videoDynamicViewC animated:YES];
- [self showVideoDynamicViewC];
- }
- [[NSUserDefaults standardUserDefaults] setObject:nil forKey:CACHE_PATH_LIST];
- // [self dismissViewControllerAnimated:YES completion:nil];
- };
-
- [[AppDelegate sharedAppDelegate]pushViewController:vc animated:YES];
- // [nav pushViewController:vc animated:YES];
- }
- #pragma mark - 5 - 视频动态页面
- -(void)showVideoDynamicViewC
- {
-
- _videoDynamicViewC = (VideoDynamicViewC *)[VideoDynamicViewC showSTBaseViewCOnSuperViewC:[AppDelegate sharedAppDelegate].topViewController.tabBarController.selectedViewController
- andFrameRect:CGRectMake(0, 0, kScreenW, kScreenH)
- andSTViewCTransitionType:STViewCTransitionTypeOfModal
- andComplete:^(BOOL finished,
- STBaseViewC *stBaseViewC) {
-
- }];
-
- _videoDynamicViewC.recordTabBarC = [AppDelegate sharedAppDelegate].topViewController.tabBarController;
- [_videoDynamicViewC videoDynamicView];
- [_videoDynamicViewC showPublishDynamic];
- // 开启IQ
- _videoDynamicViewC.title = ASLocalizedString(@"发布短视频");
- _videoDynamicViewC.navigationItem.title = ASLocalizedString(@"发布短视频");
- _videoDynamicViewC.navigationController.navigationBar.tintColor =kAppGrayColor1;
- self.navigationController.navigationItem.title = ASLocalizedString(@"发布短视频");
- //改变颜色 必须跳转后
- _videoDynamicViewC.navigationController.navigationBar.hidden = NO;
- [_videoDynamicViewC.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:kAppGrayColor1}];
- _videoDynamicViewC.isOpenIQKeyboardManager = YES;
-
- [self.navigationController popToRootViewControllerAnimated:YES];
- }
- //是否已认证
- -(void)showAuthView{
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:ASLocalizedString(@"您当前还未实名认证,需要认证后才能开始直播")preferredStyle:UIAlertControllerStyleAlert];
-
- UIAlertAction *actionCacel = [UIAlertAction actionWithTitle:ASLocalizedString(@"取消")style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
-
- UIAlertAction *actionConfirm = [UIAlertAction actionWithTitle:ASLocalizedString(@"立即认证")style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- UserModel *userModel = [GlobalVariables sharedInstance].userModel;
- SIdentificationVC *identificationVC = [[SIdentificationVC alloc]init];
- identificationVC.user_id = userModel.user_id;
- identificationVC.sexString = userModel.sex;
- identificationVC.nameString = userModel.nick_name;
- [[AppDelegate sharedAppDelegate] pushViewController:identificationVC animated:YES];
- }];
-
- [alertController addAction:actionCacel];
- [alertController addAction:actionConfirm];
- [[AppDelegate sharedAppDelegate].topViewController presentViewController:alertController animated:YES completion:nil];
- }
- - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(nonnull UIViewController *)viewController
- {
- NSInteger index = [tabBarController.viewControllers indexOfObject:viewController];
- // [self showNesBarRedNum];
- // if (index == 2) {//点击直播
- // [self onClickedCenterTabBar];
- //// IMALoginParam *loginParam = [IMALoginParam loadFromLocal];
- //// if (loginParam.isAgree ==1)
- //// {
- //// PublishLivestViewController *pvc = [[PublishLivestViewController alloc] init];
- //// [[AppDelegate sharedAppDelegate] presentViewController:pvc animated:YES completion:^{
- ////
- //// }];
- //// }
- //// else
- //// {
- //// AgreementViewController *agreeVC = [AgreementViewController webControlerWithUrlStr:[GlobalVariables sharedInstance].appModel.agreement_link isShowIndicator:YES isShowNavBar:YES];
- //// [[AppDelegate sharedAppDelegate] presentViewController:agreeVC animated:YES completion:^{
- ////
- //// }];
- //// }
- // return NO;
- // }
-
- #if kSupportH5Shopping
- NSInteger index = [tabBarController.viewControllers indexOfObject:viewController];
- if (index == 0)
- {
- [APP_DELEGATE beginEnterMianUI];
- return NO;
- }
- return YES;
- #else
- return YES;
- #endif
- }
- -(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
-
- // [self showNesBarRedNum];
- // switch (item.tag) {
- // case 1:
- // NSLog(@"tab bar: 1");
- // break;
- //
- // case 2:
- // NSLog(@"tab bar: 2");
- // break;
- // }
- }
- -(BogoYounthModePopView *)youthView{
- if (!_youthView) {
- _youthView = [[BogoYounthModePopView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kRealValue(331))];
- WeakSelf
- _youthView.clickInYounthBlock = ^(BOOL isComeIn) {
-
- // BogoYouthModeViewController *vc = [BogoYouthModeViewController new];
- //
- // [[AppDelegate sharedAppDelegate]pushViewController:vc animated:YES];
- //// [weakSelf.navigationController pushViewController:vc animated:YES];
- // [weakSelf.youthView hide];
- };
- }
- return _youthView;
- }
- - (void)clickLiveBtn
- {
- [self startLive];
- }
- #pragma mark - 语音视频通话
- - (void)IMChatMsgNotfication:(NSNotification *)notifcation {
- if (![NSThread isMainThread])
- {
- [self performSelectorOnMainThread:@selector(IMChatMsgNotfication:) withObject:notifcation waitUntilDone:NO];
- return;
- }
-
- [AudioChatTool.shareInstance receiveCallWithNotification:notifcation];
-
- SIMMsgObj *thatmsg = (SIMMsgObj *) notifcation.object;
- if (thatmsg.mMsgType == MSG_PRIVATE_CallAudio || thatmsg.mMsgType == MSG_PRIVATE_CallVideo) {
-
- } else {
- //并且还要清除 未读
- // [self.mChatFriend ignoreThisUnReadCount];
-
- // [self addOneMsg:thatmsg];
- [[AppDelegate sharedAppDelegate] showNesBarRedNum];
- }
-
-
-
- }
- - (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
-
- [self judjeAppLaunchSuccess];
- }
- - (void)judjeAppLaunchSuccess {
-
- if (BGIMLoginManager.sharedInstance.isIMSDKOK && self.adShowFinished) {
- AppDelegate.sharedAppDelegate.isLaunchSuccess = YES;
- return;
- }
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self judjeAppLaunchSuccess];
- });
- }
- @end
|