// // GiGaMaskTaskViewController.m // GIGA // // Created by lianxiang on 2018/8/14. // Copyright © 2018年 com.giga.ios. All rights reserved. // #import "GiGaMaskTaskViewController.h" #import "MaskViewBootomWaringView.h" #import "GiGaUserLoginVC.h" #import "UserGuardViewController.h" #import "GiGaUserDefault.h" #import "GiGaAppGaurdVC.h" #import "GiGaMeViewController.h" #import "GiGaAdDetailViewController.h" #import "GiGaMasssagesVC.h" #import "GiGaQuestionVC.h" #import #import "GiGaLocalNotificationManager.h" #import "AppDelegate.h" #import "LXCountTimer.h" #import "GiGaHelper.h" #import #import "GiGaMeViewController.h" #import "GiGaFlyingCommitInputView.h" #import "GiGaFlingCommitVC.h" #import "MaskTimeCircularProgressView.h" //#import "UINavigationBar+Custom.h" #import "UIButton+WebCache.h" #import "GiGaUser.h" #import "GiGaUserManager.h" #import "GiGaBaseAPiRequest.h" #import "MaskTestResultVC.h" #import "GIGaMaskShareViewController.h" @interface GiGaMaskTaskViewController () { AVAudioPlayer *_musicPalyer; } @property (nonatomic,strong) UIButton *rightNavUserBtn; @property(nonatomic,strong)MaskViewBootomWaringView *waringView; @property(nonatomic,strong) UIImageView *maskImageView; @property(nonatomic,strong) UIImageView *faceView; @property (nonatomic,strong) UIImageView *hairImageView; @property(nonatomic) CGPoint attachPoint; @property(nonatomic,strong) MaskTimeCircularProgressView *cicleProgressView; @property(nonatomic,strong) UIImageView *swipeGaurdimagView; @property(nonatomic,strong) UIButton *startMaskButton; @property(nonatomic,strong) UIButton *startTestButton; //开启弹幕按钮 @property(nonatomic,strong) UIButton *openDanmuButton; @end @implementation GiGaMaskTaskViewController #pragma mark - property - (UIButton *)openDanmuButton{ if (!_openDanmuButton) { _openDanmuButton = [UIButton buttonWithType:UIButtonTypeCustom]; [_openDanmuButton addTarget:self action:@selector(openDanmuButtonAction) forControlEvents:UIControlEventTouchUpInside]; _openDanmuButton.backgroundColor = GIGARGB(112, 0, 0, 1); _openDanmuButton.frame = CGRectMake(KMainW - 25 -50,SAFE_NAV_HEIGHT + 15, 50, 20); _openDanmuButton.layer.masksToBounds = YES; _openDanmuButton.layer.cornerRadius = 10; NSAttributedString *att = [GiGaHelper stringWithText:@"弹幕" textColor:[UIColor whiteColor] textFont:GIGA_TEXTFONTMEDIUM(10) leterSpace:0]; [_openDanmuButton setAttributedTitle:att forState:UIControlStateNormal]; [_openDanmuButton setImage:[UIImage imageNamed:@"btn_talk"] forState:UIControlStateNormal]; //_openDanmuButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0); _openDanmuButton.titleEdgeInsets = UIEdgeInsetsMake(0, -25, 0, 25); } return _openDanmuButton; } //面膜 - (UIImageView *)maskImageView{ if (!_maskImageView) { _maskImageView = [[UIImageView alloc] init]; _maskImageView.userInteractionEnabled = YES; //_maskImageView.backgroundColor = [UIColor purpleColor]; _maskImageView.image = [UIImage imageNamed:@"mask_img_mask"]; UISwipeGestureRecognizer * upSwipeGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(maskupSwipeGesture)]; [upSwipeGesture setDirection:(UISwipeGestureRecognizerDirectionUp)]; [_maskImageView addGestureRecognizer:upSwipeGesture]; UITapGestureRecognizer *tapgesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(maskTapAction)]; [_maskImageView addGestureRecognizer:tapgesture]; } return _maskImageView; } //头发 - (UIImageView *)hairImageView{ if (!_hairImageView) { _hairImageView = [[UIImageView alloc] init]; _hairImageView.image = [UIImage imageNamed:@"mask_img_hair"]; } return _hairImageView; } //人脸 - (UIImageView *)faceView{ if (!_faceView) { _faceView = [[UIImageView alloc] init]; //_faceView.backgroundColor = [UIColor lightGrayColor]; _faceView.userInteractionEnabled = YES; _faceView.image = [UIImage imageNamed:@"mask_img_head"]; } return _faceView; } //倒计时圆环 - (MaskTimeCircularProgressView *)cicleProgressView{ if (!_cicleProgressView) { _cicleProgressView = [[MaskTimeCircularProgressView alloc] initWithFrame:CGRectMake(100, 251 + PhoneX_TopMargin, 125, 125) backColor:GIGARGB(88, 0, 2, 1) progressColor:[UIColor blueColor] lineWidth:10 timeinterval:10]; _cicleProgressView.delegate = self; _cicleProgressView.hidden = YES; } return _cicleProgressView; } //⬆️ - (UIImageView *)swipeGaurdimagView{ if (!_swipeGaurdimagView) { _swipeGaurdimagView = [[UIImageView alloc] init]; _swipeGaurdimagView.image = [UIImage imageNamed:@"mask_bg_up"]; } return _swipeGaurdimagView; } //开始面膜 - (UIButton *)startMaskButton{ if (!_startMaskButton) { _startMaskButton = [UIButton buttonWithType:UIButtonTypeCustom]; [_startMaskButton setBackgroundImage:[UIImage imageNamed:@"btn_start_mask"] forState:UIControlStateNormal]; NSAttributedString *title = [GiGaHelper stringWithText:@"开始敷面膜" textColor:[UIColor whiteColor] textFont:GIGA_TEXTFONTMEDIUM(13) leterSpace:0]; [_startMaskButton setAttributedTitle:title forState:UIControlStateNormal]; [_startMaskButton addTarget:self action:@selector(startMaskButtonAction) forControlEvents:UIControlEventTouchUpInside]; } return _startMaskButton; } //开始测试 - (UIButton *)startTestButton{ if (!_startTestButton) { _startTestButton = [UIButton buttonWithType:UIButtonTypeCustom]; [_startTestButton setBackgroundImage:[UIImage imageNamed:@"btn_start_test"] forState:UIControlStateNormal]; NSAttributedString *title = [GiGaHelper stringWithText:@"测试肤质" textColor:[UIColor whiteColor] textFont:GIGA_TEXTFONTBOLD(18) leterSpace:0]; [_startTestButton setAttributedTitle:title forState:UIControlStateNormal]; [_startTestButton addTarget:self action:@selector(testBtnAcion:) forControlEvents:UIControlEventTouchUpInside]; } return _startTestButton; } //底部提示栏 - (MaskViewBootomWaringView *)waringView{ if (!_waringView) { self.waringView = [[MaskViewBootomWaringView alloc] init]; self.waringView.frame = CGRectMake(0,CGRectGetMaxY(self.view.frame), self.view.frame.size.width, 60); } return _waringView; } #pragma mark 弹幕 -(void)createInputView{ GiGaFlingCommitVC* GiGaFlingVC = [[GiGaFlingCommitVC alloc] init]; if (ISIOS8) { GiGaFlingVC.modalPresentationStyle = UIModalPresentationOverCurrentContext; }else{ GiGaFlingVC.modalPresentationStyle = UIModalPresentationCurrentContext; } GiGaFlingVC.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3]; [self presentViewController:GiGaFlingVC animated:NO completion:nil]; } #pragma mark - 生命周期 -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; //取消导航对内容下移影响 [self.navigationController.navigationBar setTranslucent:YES]; self.openDanmuButton.hidden = NO; } -(void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = NO; } // 暂不用 app引导页 // BOOL showAppGaurd = [GiGaUserDefault isShowedAppGaurd]; // if (showAppGaurd == NO) { // [self showAPPappGaurdView]; // } //新手蒙版 BOOL isshowGaurd = [GiGaUserDefault isShowedGaurd]; if (isshowGaurd == NO) { NSLog(@"%d",(int)isshowGaurd ); [self showUserGaurdView]; } } -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [self.navigationController.navigationBar setTranslucent:NO]; if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = YES; } } - (void)viewDidLoad { [super viewDidLoad]; [self setUpNav]; [self initUI]; [self addNotify]; [self creatBackGroundMusic]; } #pragma mark - 响应事件 #pragma mark 上滑动手势 -(void)maskupSwipeGesture{ [self animaMask]; } #pragma mark 点击手势 -(void)maskTapAction{ [self animaMask]; } #pragma mark 点击测试按钮 -(void)startMaskButtonAction{ [self animaMask]; } #pragma mark - 开始面膜时间动画 合并 -(void)animaMask{ self.swipeGaurdimagView.hidden = YES; self.startMaskButton.hidden = YES; [self.view layoutIfNeeded]; [UIView animateWithDuration:1.0 animations:^{ [self.faceView mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.attachPoint.y -94); }]; [self.hairImageView mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.attachPoint.y - 94 - 34); }]; [self.maskImageView mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.attachPoint.y - 87); }]; [self.maskImageView setImage:[UIImage imageNamed:@"masking_img_mask"]]; [self.view layoutIfNeeded]; } completion:^(BOOL finished) { // self.cicleProgressView.hidden = NO; // self.maskImageView.userInteractionEnabled = NO; //开始面膜时间 //[self startMaskTime]; [self updateMaskingView]; }]; } #pragma mark 面膜中头像位置 -(void)updateMaskingView{ [self.view layoutIfNeeded]; [UIView animateWithDuration:1.0 animations:^{ [self.faceView mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(124 + PhoneX_TopMargin); }]; [self.hairImageView mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(90 + PhoneX_TopMargin); }]; [self.maskImageView mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.view.mas_top).offset(90 + PhoneX_TopMargin +43); }]; [self.view layoutIfNeeded]; } completion:^(BOOL finished) { self.cicleProgressView.hidden = NO; self.maskImageView.userInteractionEnabled = NO; [self startMaskTime]; }]; } #pragma mark 面膜时间结束复原动画 -(void)endMaskAnimation{ [self.maskImageView setImage:[UIImage imageNamed:@"mask_img_mask"]]; self.cicleProgressView.hidden = YES; self.swipeGaurdimagView.hidden = NO; self.startMaskButton.hidden = NO; [self.view layoutIfNeeded]; [UIView animateWithDuration:1.0 animations:^{ [self.faceView mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(124 + PhoneX_TopMargin); }]; [self.hairImageView mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(90 + PhoneX_TopMargin); }]; [self.maskImageView mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(254 + PhoneX_TopMargin); }]; //[self.view layoutIfNeeded]; } completion:^(BOOL finished) { self.maskImageView.userInteractionEnabled = YES; }]; } #pragma mark 布局 -(void)initUI{ self.view.backgroundColor = GIGA_MAIN_BGCOLOR; [self.view addSubview:self.openDanmuButton]; [self.view addSubview:self.faceView]; [self.view addSubview:self.maskImageView]; [self.view addSubview:self.hairImageView]; //[self.view bringSubviewToFront:self.maskImageView]; [self.view addSubview:self.swipeGaurdimagView]; [self.view addSubview:self.startMaskButton]; [self.view addSubview:self.startTestButton]; [self.view addSubview:self.cicleProgressView]; //face [self.faceView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.view.mas_top).offset(124 + PhoneX_TopMargin); make.size.mas_equalTo(CGSizeMake(77, 94)); make.centerX.mas_equalTo(self.view.mas_centerX); //make.left.mas_equalTo(self.view.mas_left).offset(153); }]; //hair [self.hairImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.view.mas_top).offset(90 + PhoneX_TopMargin); make.size.mas_equalTo(CGSizeMake(97, 109)); //make.centerX.mas_equalTo(self.view.mas_centerX); make.left.mas_equalTo(self.faceView.mas_left).offset(-14); }]; //mask [self.maskImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.view.mas_top).offset(254 + PhoneX_TopMargin); make.size.mas_equalTo(CGSizeMake(72, 87)); //make.centerX.mas_equalTo(self.view.mas_centerX); make.left.mas_equalTo(self.faceView.mas_left); }]; //circle [self.cicleProgressView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.view.mas_top).offset(251 + PhoneX_TopMargin); make.size.mas_equalTo(CGSizeMake(125, 125)); make.centerX.mas_equalTo(self.view.mas_centerX); }]; //up [self.swipeGaurdimagView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.view.mas_top).offset(368 + PhoneX_TopMargin); make.width.and.height.mas_equalTo(20); make.centerX.mas_equalTo(self.view.mas_centerX); }]; //startMask [self.startMaskButton mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.view.mas_top).offset(412 + PhoneX_TopMargin); make.size.mas_equalTo(CGSizeMake(117, 25)); make.centerX.mas_equalTo(self.view.mas_centerX); }]; //startTest [self.startTestButton mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.view.mas_top).offset(486 + PhoneX_TopMargin); make.size.mas_equalTo(CGSizeMake(132, 41)); make.centerX.mas_equalTo(self.view.mas_centerX); }]; [self.view layoutIfNeeded]; CGFloat Y = CGRectGetMaxY(self.faceView.frame) + (CGRectGetMaxY(self.maskImageView.frame) - CGRectGetMaxY(self.faceView.frame)) / 2; CGFloat X = CGRectGetMidX(self.view.frame); // 下巴合并位置 CGPoint anchorPoint = CGPointMake(X, Y); self.attachPoint = anchorPoint; [self.cicleProgressView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(Y + 68); make.height.and.width.mas_equalTo(136); make.centerX.mas_equalTo(self.view.mas_centerX); }]; } #pragma mark 面膜时间背景音乐 -(void)creatBackGroundMusic{ //初始化音频播放器 NSError *payerError; NSURL *musicUrl = [[NSURL alloc] initWithString:[[NSBundle mainBundle] pathForResource:@"pomodoSound" ofType:@"m4a"]] ; AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:musicUrl error:&payerError]; player.numberOfLoops = -1; _musicPalyer = player; [[AVAudioSession sharedInstance] setActive:YES error:nil]; //设置后台模式和锁屏模式下依然能够播放 [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil]; } #pragma mark 开始面膜时间 -(void)startMaskTime{ [self createInputView]; //出现弹幕 AppDelegate *delegate =(AppDelegate *) [[UIApplication sharedApplication] delegate]; if (delegate.isMasking) { return; } delegate.isMasking = YES; [_musicPalyer play]; [self setBackGroundPlayingInfo];//锁屏音频信息 //总时间隔 s NSTimeInterval timeInterVal = [GiGaUserDefault getUserMaskeTime]; [self.cicleProgressView startWith:timeInterVal]; //底部弹窗 [self showWaringView]; //app 前台时收到本地通知showAlert 后台时通知提醒 [[GiGaLocalNotificationManager localNotifiationCenter] sendLocalNotification:@"本地推送" fireTimeInterval:timeInterVal alertAction:@"测试面膜时间" withIdentifier:kLOCALNotifiID_MASKETIMEEND]; } #pragma mark 设置后台锁屏音频信息 -(void)setBackGroundPlayingInfo{ MPMediaItemArtwork *arwork = [[MPMediaItemArtwork alloc] initWithImage:[UIImage imageNamed:@"MaskTime.png"]]; NSDictionary *dic = @{ MPMediaItemPropertyTitle:@"面膜时间", MPMediaItemPropertyAlbumArtist:@"面膜时间", MPMediaItemPropertyArtist:@"敷膜中", MPMediaItemPropertyAlbumTitle:@"敷膜中", MPMediaItemPropertyGenre:@"???", MPMediaItemPropertyLyrics:@"面膜", MPMediaItemPropertyPodcastTitle:@"PodcastTitle", MPMediaItemPropertyArtwork:arwork }; [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:dic]; [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; } - (void)remoteControlReceivedWithEvent: (UIEvent *) receivedEvent { if (receivedEvent.type == UIEventTypeRemoteControl) { switch (receivedEvent.subtype) { case UIEventSubtypeRemoteControlPlay: //暂时不处理 //[_musicPalyer play]; break; case UIEventSubtypeRemoteControlPause: // [_musicPalyer pause]; break; default: NSLog(@"没有处理过这个事件------receivedEvent.subtype==%ld",(long)receivedEvent.subtype); break; } } } #pragma mark 面膜时间结束 -(void)maskTimeEnd{ NC_POST_NAME_OBJECT(kUserNoti_MASKEND, nil); //面膜时间结束时设置 全局变量 不再发送本地通知 提醒 AppDelegate *delegate =(AppDelegate *) [[UIApplication sharedApplication] delegate]; delegate.isMasking = NO; [_musicPalyer stop]; //复原动画 [self endMaskAnimation]; } #pragma mark 开始测试 -(void)testBtnAcion:(UIButton *)btn{ // NSDictionary *dic = @{ // @"dryness":@"0.41", // @"drynessPercent":@"41%", // @"mask":@"", // @"minute":@"19", // @"oiliness":@"0.59", // @"oilinessPercent":@"59%" // }; // MaskTestResult *model =[[MaskTestResult alloc] initWithDictionary:dic error:nil]; // MaskTestResultVC *resultVC = [[MaskTestResultVC alloc] init]; // resultVC.model = model; // [self.navigationController pushViewController:resultVC animated:YES]; // [self showAlertGoShareMaskTime]; GiGaQuestionVC *questionVC = [[GiGaQuestionVC alloc] init]; [self.navigationController pushViewController:questionVC animated:YES]; } -(void)addNotify{ //引导页 NC_ADD_TARGET_NAME_OBJECT(self, @selector(guardViewDissmiss), USER_GUARD_DISSMISS, nil) ; NC_ADD_TARGET_NAME_OBJECT(self, @selector(appGauardViewDissmiss),APP_GUARD_DISSMISS, nil) ; NC_ADD_TARGET_NAME_OBJECT(self, @selector(pushToAppAdDetailView),APP_PUSHTO_DETAILVIEW, nil) ; NC_ADD_TARGET_NAME_OBJECT(self, @selector(userLoginNotify), kUserLoginSuccessNoti, nil); NC_ADD_TARGET_NAME_OBJECT(self, @selector(userlogOutNotify), kUserLogOutNotify, nil); NC_ADD_TARGET_NAME_OBJECT(self, @selector(userAvatorUpDate), kUserAvatorUpdateNoti, nil) ; //用户关闭弹幕聊天 NC_ADD_TARGET_NAME_OBJECT(self, @selector(userCloseChatRoomAction), @"UserCloseChatRoomAction", nil); } #pragma mark 广告详情 -(void)pushToAppAdDetailView{ GiGaAdDetailViewController *detailVC=[[GiGaAdDetailViewController alloc] init]; [self.navigationController pushViewController:detailVC animated:YES]; } #pragma mark 新手引导蒙版消失 -(void)guardViewDissmiss{ [self showWaringView]; } #pragma mark app引导页消失 -(void)appGauardViewDissmiss{ //出现新手引导 BOOL isshowGaurd = [GiGaUserDefault isShowedGaurd]; if (isshowGaurd == NO) { NSLog(@"%d",(int)isshowGaurd ); [self showUserGaurdView]; } } -(void)dealloc{ NC_REMOVE_NAME(self, USER_GUARD_DISSMISS, nil); NC_REMOVE_NAME(self, APP_GUARD_DISSMISS, nil); NC_REMOVE_NAME(self, APP_PUSHTO_DETAILVIEW, nil); NC_REMOVE_NAME(self, kUserAvatorUpdateNoti, nil); NC_REMOVE_NAME(self, kUserLogOutNotify, nil); NC_REMOVE_NAME(self, kUserLoginSuccessNoti, nil); NC_REMOVE_NAME(self, @"UserCloseChatRoomAction", nil); } #pragma mark 新手引导 -(void)showUserGaurdView{ UserGuardViewController *userGuardVC = [[UserGuardViewController alloc] init]; if (ISIOS8) { userGuardVC.modalPresentationStyle = UIModalPresentationOverCurrentContext; }else{ userGuardVC.modalPresentationStyle = UIModalPresentationCurrentContext; } userGuardVC.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3]; [self presentViewController:userGuardVC animated:NO completion:nil]; } #pragma mark App引导页 -(void)showAPPappGaurdView{ GiGaAppGaurdVC *gaurdVC = [[GiGaAppGaurdVC alloc] init]; [self presentViewController:gaurdVC animated:YES completion:nil]; } #pragma mark - 导航按钮 -(void)setUpNav{ //leftItem // UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom]; // leftBtn.frame = CGRectMake(0, 0, 40, 40); // leftBtn.backgroundColor = [UIColor redColor]; // [leftBtn setImage:[UIImage imageNamed:@"btn_back"] forState:UIControlStateNormal]; // [leftBtn addTarget:self action:@selector(leftBtnAction) forControlEvents:UIControlEventTouchUpInside]; // self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftBtn]; //rightItem UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom]; rightBtn.frame = CGRectMake(0, 0, 40, 40); rightBtn.layer.masksToBounds = YES; rightBtn.layer.cornerRadius = 20; [rightBtn setImage:[UIImage imageNamed:@"nav_circle_avatar"] forState:UIControlStateNormal]; self.rightNavUserBtn = rightBtn; [rightBtn addTarget:self action:@selector(rightBtnAction) forControlEvents:UIControlEventTouchUpInside]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn]; if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 11.0) { [self.rightNavUserBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(40, 40)); }]; } BOOL isUserLogin = [GiGaUserDefault isUserLogin]; if (isUserLogin) { GiGaUser *user = [[GiGaUserManager shareUser] getCurrentUser]; if (user) { if (user.headImgUrl && ![user.headImgUrl isKindOfClass:[NSNull class]]) { [self refreshUserIcon:user.headImgUrl]; } } } } #pragma mark 用户头像更新 -(void)refreshUserIcon:(NSString *)imageUrl{ NSURL *url = [NSURL URLWithString:imageUrl]; [self.rightNavUserBtn sd_setImageWithURL:url forState:UIControlStateNormal]; } #pragma mark 消息 action -(void)leftBtnAction{ BOOL isUserLogin = [GiGaUserDefault isUserLogin]; if (isUserLogin) { GiGaMasssagesVC *masageVC= [[GiGaMasssagesVC alloc] init]; [self.navigationController pushViewController:masageVC animated:YES]; }else{ GiGaUserLoginVC *userlogInVC= [[GiGaUserLoginVC alloc] init]; GiGaBaseNavViewController *baseNav = [[GiGaBaseNavViewController alloc] initWithRootViewController:userlogInVC]; [self presentViewController:baseNav animated:YES completion:nil]; } } #pragma mark 个人中心 action -(void)rightBtnAction{ BOOL isUserLogin = [GiGaUserDefault isUserLogin]; if (isUserLogin) { GiGaMeViewController *meVC= [[GiGaMeViewController alloc] init]; [self.navigationController pushViewController:meVC animated:YES]; }else{ GiGaUserLoginVC *userlogInVC= [[GiGaUserLoginVC alloc] init]; GiGaBaseNavViewController *baseNav = [[GiGaBaseNavViewController alloc] initWithRootViewController:userlogInVC]; [self presentViewController:baseNav animated:YES completion:nil]; } } #pragma mark -bottomView -(void)showWaringView{ [self.view addSubview:self.waringView]; [UIView animateWithDuration:0.4 animations:^{ self.waringView.frame = CGRectMake(0,CGRectGetMaxY(self.view.frame) - 44 - PhoneX_BottomMargin, self.view.frame.size.width, 44); }]; [self.waringView showView]; } #pragma mark - MaskCirCularProGressViewDelegate - (void)updateProgressViewWith:(NSTimeInterval)timeInterval{ } - (void)progressDidFish{ NSLog(@"结束"); [self maskTimeEnd]; [self showAlertGoShareMaskTime]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - 登录成功通知接收 -(void)userLoginNotify{ GiGaUser *user = [[GiGaUserManager shareUser] getCurrentUser]; if (user.headImgUrl && ![user.headImgUrl isKindOfClass:[NSNull class]] ) { [self refreshUserIcon:user.headImgUrl]; } } #pragma mark - 退出登录通知 -(void)userlogOutNotify{ [self.rightNavUserBtn setImage:[UIImage imageNamed:@"nav_circle_avatar"] forState:UIControlStateNormal]; } #pragma mark -用户头像更新 -(void)userAvatorUpDate{ GiGaUser *user = [[GiGaUserManager shareUser] getCurrentUser]; if (user.headImgUrl && ![user.headImgUrl isKindOfClass:[NSNull class]] ) { [self refreshUserIcon:user.headImgUrl]; } } #pragma mark 去分享 -(void)showAlertGoShareMaskTime{ [self jxt_showAlertWithTitle:@"面膜时间" message:@"去分享我的面膜时间" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) { alertMaker.addActionCancelTitle(@"下次"); alertMaker.addActionDefaultTitle(@"去分享"); } actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) { if (buttonIndex == 1) { GIGaMaskShareViewController *shareVC = [[GIGaMaskShareViewController alloc] init]; [self.navigationController pushViewController:shareVC animated:YES];; } }]; } #pragma mark - 开启弹幕按钮事件 -(void)openDanmuButtonAction{ self.openDanmuButton.hidden = YES; [self createInputView]; } //通知用户挂断弹幕 -(void)userCloseChatRoomAction{ self.openDanmuButton.hidden = NO; } @end