add flying commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// GiGaFlingCommitVC.h
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/8/28.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface GiGaFlingCommitVC : UIViewController
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,98 @@
|
||||
//
|
||||
// GiGaFlingCommitVC.m
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/8/28.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import "GiGaFlingCommitVC.h"
|
||||
#import "GiGaFlyingCommitInputView.h"
|
||||
#import "LXDanMuManager.h"
|
||||
#import "GiGaCommentView.h"
|
||||
#import "GiGaCommentModel.h"
|
||||
#import "LXDanMuManagerConfig.h"
|
||||
#import "IQKeyboardManager.h"
|
||||
|
||||
//弹幕控制器
|
||||
@interface GiGaFlingCommitVC ()
|
||||
@property (nonatomic,strong) GiGaFlyingCommitInputView *commitInputView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation GiGaFlingCommitVC
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
NC_ADD_TARGET_NAME_OBJECT(self, @selector(maskTimeEnd), kUserNoti_MASKEND, nil);
|
||||
[self.view addSubview: self.commitInputView];
|
||||
self.commitInputView.SendCommentHandler = ^(NSString *content) {
|
||||
GILog(@"发送->:%@",content);
|
||||
};
|
||||
[[LXDanMuManager shareInstance] createDanmuWithTrackSpeedArray:@[@1.00,@1.00,@3.00,@4.00] centerY:self.view.frame.size.height / 4 trackWidth:self.view.frame.size.width showInView:self.view];
|
||||
[[LXDanMuManager shareInstance] start];
|
||||
|
||||
[NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(danmuAction) userInfo:nil repeats:YES];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void)danmuAction{
|
||||
|
||||
[self showFlyingCommit];
|
||||
}
|
||||
|
||||
- (GiGaFlyingCommitInputView *)commitInputView{
|
||||
|
||||
if (!_commitInputView) {
|
||||
// _commitInputView = [[GiGaFlyingCommitInputView alloc] initWithFrame:CGRectMake(0,self.view.frame.size.height - 60 , KMainW, 60)];
|
||||
_commitInputView = [[GiGaFlyingCommitInputView alloc] initWithFrame:self.view.bounds];
|
||||
[_commitInputView setPalceholderText:@"请输入弹幕"];
|
||||
}
|
||||
return _commitInputView;
|
||||
}
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
[IQKeyboardManager sharedManager].enable = NO;
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated{
|
||||
[super viewWillDisappear:animated];
|
||||
[IQKeyboardManager sharedManager].enable = YES;
|
||||
}
|
||||
|
||||
-(void)showFlyingCommit{
|
||||
NSArray *classArray = @[@"GiGaCommentView",@"GiGaCommentView"];
|
||||
NSArray *nameArray = @[@"mc子龙",@"小明",@"赵四",@"狂小狗",@"葬爱"];
|
||||
NSArray *msgArray = @[@"老铁666",@"主播,多少礼物给卡黄啊?",@"文明观球,大家有秩序排队观看,不要着急",@"主播,我报警啦",@"就是个萨比,还扮滴酷酷滴aaaaa"];
|
||||
NSArray *avatarArray = @[@"home_login_qq_color",@"home_login_qq_color",@"home_login_qq_color",@"home_login_qq_color",@"home_login_qq_color"];
|
||||
int classRandomIndex = arc4random() % 2;
|
||||
int nameRandomIndex = arc4random() % 5;
|
||||
int msgRandomIndex = arc4random() % 5;
|
||||
int avatarRandomIndex = arc4random() % 5;
|
||||
|
||||
GiGaCommentModel *model = [[GiGaCommentModel alloc]init];
|
||||
model.userName = nameArray[nameRandomIndex];
|
||||
model.msg = msgArray[msgRandomIndex];
|
||||
model.userAvatar = avatarArray[avatarRandomIndex];
|
||||
GiGaCommentView *customView = [[NSClassFromString(classArray[classRandomIndex]) alloc] initWithMsgModel:model height:TRACK_HEIGHT];
|
||||
[[LXDanMuManager shareInstance] appendDanMuWithCustomView:customView toTrackIndex:-1];
|
||||
}
|
||||
|
||||
-(void)maskTimeEnd{
|
||||
|
||||
[[LXDanMuManager shareInstance] destory];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
-(void)dealloc{
|
||||
NC_REMOVE_NAME(self, kUserNoti_MASKEND, nil);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -23,28 +23,70 @@
|
||||
#import "GiGaHelper.h"
|
||||
#import <MediaPlayer/MediaPlayer.h>
|
||||
#import "GiGaMeViewController.h"
|
||||
|
||||
@interface GiGaMaskTaskViewController ()
|
||||
#import "GiGaFlyingCommitInputView.h"
|
||||
#import "GiGaFlingCommitVC.h"
|
||||
@interface GiGaMaskTaskViewController ()<UITextFieldDelegate>
|
||||
{
|
||||
AVAudioPlayer *_musicPalyer;
|
||||
}
|
||||
@property(nonatomic,strong)MaskViewBootomWaringView *waringView;
|
||||
@property(nonatomic,strong)UILabel *countLabel;
|
||||
@property (strong ,nonatomic) LXCountTimer *timer;
|
||||
//@property (nonatomic,strong) GiGaFlyingCommitInputView *commitInputView;
|
||||
@property(nonatomic,strong) UIImageView *maskImageView;
|
||||
@property(nonatomic,strong) UIImageView *faceView;
|
||||
@property(nonatomic,strong) UIDynamicAnimator *animator;
|
||||
@property(nonatomic,strong) UIAttachmentBehavior *attachmentBehavior;
|
||||
@property(nonatomic) CGPoint attachPoint;
|
||||
@property(nonatomic) UISnapBehavior *snapBehavior;
|
||||
|
||||
@end
|
||||
|
||||
@implementation GiGaMaskTaskViewController
|
||||
|
||||
//倒计时label
|
||||
-(UILabel *)countLabel{
|
||||
if (!_countLabel) {
|
||||
_countLabel = [[UILabel alloc] init];
|
||||
_countLabel.textColor = [UIColor redColor];
|
||||
_countLabel.text = @"30:00";
|
||||
_countLabel.text = @"00:00";
|
||||
_countLabel.textAlignment = NSTextAlignmentCenter;
|
||||
|
||||
}
|
||||
return _countLabel;
|
||||
}
|
||||
//面膜
|
||||
- (UIImageView *)maskImageView{
|
||||
if (!_maskImageView) {
|
||||
_maskImageView = [[UIImageView alloc] init];
|
||||
_maskImageView.userInteractionEnabled = YES;
|
||||
_maskImageView.backgroundColor = [UIColor purpleColor];
|
||||
UIPanGestureRecognizer *pangesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureAction:)];
|
||||
[_maskImageView addGestureRecognizer:pangesture];
|
||||
}
|
||||
return _maskImageView;
|
||||
}
|
||||
//人脸
|
||||
- (UIImageView *)faceView{
|
||||
if (!_faceView) {
|
||||
_faceView = [[UIImageView alloc] init];
|
||||
_faceView.backgroundColor = [UIColor lightGrayColor];
|
||||
_faceView.userInteractionEnabled = YES;
|
||||
}
|
||||
return _faceView;
|
||||
}
|
||||
|
||||
-(void)createInputView{
|
||||
|
||||
GiGaFlingCommitVC* GiGaFlingVC = [[GiGaFlingCommitVC alloc] init];
|
||||
if (ISIOS8) {
|
||||
GiGaFlingVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
|
||||
}else{
|
||||
GiGaFlingVC.modalPresentationStyle = UIModalPresentationCurrentContext;
|
||||
}
|
||||
GiGaFlingVC.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
|
||||
[self presentViewController:GiGaFlingVC animated:NO completion:nil];
|
||||
|
||||
}
|
||||
|
||||
-(LXCountTimer *)timer{
|
||||
@@ -55,6 +97,73 @@
|
||||
return _timer;
|
||||
}
|
||||
|
||||
//滑动手势
|
||||
-(void)panGestureAction:(UIPanGestureRecognizer *)pan{
|
||||
|
||||
CGPoint panLocation = [pan locationInView:self.view];
|
||||
NSLog(@"panlocation.y:%f",panLocation.y);
|
||||
if (pan.state == UIGestureRecognizerStateBegan) {
|
||||
|
||||
[self animaMask];
|
||||
// self.attachmentBehavior = [[UIAttachmentBehavior alloc] initWithItem:self.faceView attachedToAnchor:self.attachPoint];
|
||||
// [self.animator addBehavior: self.attachmentBehavior ];
|
||||
|
||||
}else if (pan.state == UIGestureRecognizerStateChanged){
|
||||
// [self.snapBehavior setSnapPoint:self.attachPoint];
|
||||
// [self.attachmentBehavior setAnchorPoint:panLocation];
|
||||
|
||||
}else if (pan.state == UIGestureRecognizerStateEnded){
|
||||
// [self.animator addBehavior:self.snapBehavior];
|
||||
// [self.animator removeBehavior:self.attachmentBehavior];
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -开始面膜时间动画
|
||||
-(void)animaMask{
|
||||
|
||||
[self.view layoutIfNeeded];
|
||||
[UIView animateWithDuration:1.0 animations:^{
|
||||
[self.maskImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.attachPoint.y - 50);
|
||||
}];
|
||||
[self.faceView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.attachPoint.y - 50);
|
||||
}];
|
||||
[self.countLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.attachPoint.y + 50 + 10);
|
||||
}];
|
||||
[self.view layoutIfNeeded];
|
||||
} completion:^(BOOL finished) {
|
||||
self.countLabel.hidden = NO;
|
||||
self.maskImageView.userInteractionEnabled = NO;
|
||||
//开始面膜时间
|
||||
[self startMaskTime];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark 面膜时间结束复原动画
|
||||
-(void)endMaskAnimation{
|
||||
|
||||
self.countLabel.hidden = YES;
|
||||
[self.view layoutIfNeeded];
|
||||
[UIView animateWithDuration:1.0 animations:^{
|
||||
[self.maskImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(100 + 100 + 200);
|
||||
}];
|
||||
|
||||
[self.faceView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(100);
|
||||
}];
|
||||
|
||||
[self.view layoutIfNeeded];
|
||||
|
||||
} completion:^(BOOL finished) {
|
||||
self.maskImageView.userInteractionEnabled = YES;
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
@@ -71,16 +180,37 @@
|
||||
|
||||
-(void)initUI{
|
||||
|
||||
[self.view addSubview:self.maskImageView];
|
||||
[self.view addSubview:self.faceView];
|
||||
[self.view bringSubviewToFront:self.maskImageView];
|
||||
[self.view addSubview:self.countLabel];
|
||||
|
||||
[self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.view.mas_top).offset(200);
|
||||
make.width.mas_equalTo(100);
|
||||
make.height.mas_equalTo(30);
|
||||
make.centerX.mas_equalTo(self.view.mas_centerX);
|
||||
self.animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];
|
||||
|
||||
//face
|
||||
[self.faceView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.view.mas_top).offset(100);
|
||||
make.left.mas_equalTo(self.view.mas_centerX).offset(-50);
|
||||
make.size.mas_equalTo(CGSizeMake(100, 100));
|
||||
|
||||
}];
|
||||
|
||||
//mask
|
||||
[self.maskImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
|
||||
make.top.mas_equalTo(self.view.mas_top).offset(100 + 100 + 200);
|
||||
make.left.mas_equalTo(self.view.mas_centerX).offset(-50);
|
||||
make.size.mas_equalTo(CGSizeMake(100, 100));
|
||||
|
||||
}];
|
||||
|
||||
[self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.view.mas_top).offset(200);
|
||||
make.width.and.height.mas_equalTo(100);
|
||||
make.centerX.mas_equalTo(self.view.mas_centerX);
|
||||
}];
|
||||
self.countLabel.hidden = YES;
|
||||
|
||||
UIButton *testBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[testBtn setTitle:@"测试肤质" forState:UIControlStateNormal];
|
||||
[testBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||
@@ -94,8 +224,15 @@
|
||||
make.centerX.mas_equalTo(self.view.mas_centerX);
|
||||
make.width.mas_equalTo(150);
|
||||
make.height.mas_equalTo(40);
|
||||
make.bottom.mas_equalTo(self.view.mas_bottom).offset(-200);
|
||||
make.bottom.mas_equalTo(self.view.mas_bottom).offset(-130);
|
||||
}];
|
||||
|
||||
[self.view layoutIfNeeded];
|
||||
CGFloat Y = CGRectGetMinY(self.maskImageView.frame) - 100;
|
||||
CGFloat X = CGRectGetMidX(self.view.frame);
|
||||
CGPoint anchorPoint = CGPointMake(X, Y);
|
||||
self.attachPoint = anchorPoint;
|
||||
// self.snapBehavior = [[UISnapBehavior alloc] initWithItem:self.maskImageView snapToPoint:self.attachPoint];
|
||||
}
|
||||
|
||||
#pragma mark 开始计时
|
||||
@@ -131,14 +268,12 @@
|
||||
//设置后台模式和锁屏模式下依然能够播放
|
||||
//[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma mark 开始面膜时间
|
||||
-(void)startMaskTime{
|
||||
|
||||
[self createInputView]; //出现弹幕
|
||||
AppDelegate *delegate =(AppDelegate *) [[UIApplication sharedApplication] delegate];
|
||||
if (delegate.isMasking) {
|
||||
return;
|
||||
@@ -148,7 +283,7 @@
|
||||
[self setBackGroundPlayingInfo];//锁屏音频信息
|
||||
|
||||
//总时间隔 s
|
||||
NSTimeInterval timeInterVal = 58;
|
||||
NSTimeInterval timeInterVal = 61;
|
||||
NSString *timeformat = [GiGaHelper stringWithNSTimerinterval:timeInterVal];
|
||||
NSArray *timesArr = [timeformat componentsSeparatedByString:@":"];
|
||||
NSString *hour = timesArr[0];
|
||||
@@ -158,6 +293,7 @@
|
||||
|
||||
[self showWaringView];
|
||||
|
||||
return;
|
||||
//app 前台时收到本地通知showAlert 后台时通知提醒
|
||||
[[GiGaLocalNotificationManager localNotifiationCenter] sendLocalNotification:@"本地推送" fireTimeInterval:timeInterVal alertAction:@"测试面膜时间" withIdentifier:kLOCALNotifiID_MASKETIMEEND];
|
||||
|
||||
@@ -183,7 +319,7 @@
|
||||
|
||||
}
|
||||
|
||||
- (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent {
|
||||
- (void)remoteControlReceivedWithEvent: (UIEvent *) receivedEvent {
|
||||
|
||||
if (receivedEvent.type == UIEventTypeRemoteControl) {
|
||||
switch (receivedEvent.subtype) {
|
||||
@@ -207,20 +343,22 @@
|
||||
#pragma mark 面膜时间结束
|
||||
-(void)maskTimeEnd{
|
||||
|
||||
NC_POST_NAME_OBJECT(kUserNoti_MASKEND, nil);
|
||||
//面膜时间结束时设置 全局变量 不再发送本地通知 提醒
|
||||
AppDelegate *delegate =(AppDelegate *) [[UIApplication sharedApplication] delegate];
|
||||
delegate.isMasking = NO;
|
||||
[_musicPalyer stop];
|
||||
[self.timer destoryTimer];
|
||||
|
||||
//复原动画
|
||||
[self endMaskAnimation];
|
||||
}
|
||||
|
||||
#pragma mark 开始测试
|
||||
-(void)testBtnAcion:(UIButton *)btn{
|
||||
|
||||
|
||||
[self startMaskTime];
|
||||
return ;
|
||||
// [self startMaskTime];
|
||||
// return ;
|
||||
|
||||
BOOL isUserLogin = [GiGaUserDefault isUserLogin];
|
||||
|
||||
@@ -305,7 +443,6 @@
|
||||
|
||||
#pragma mark - setUpNav
|
||||
-(void)setUpNav{
|
||||
|
||||
//leftItem
|
||||
UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
leftBtn.frame = CGRectMake(0, 0, 40, 40);
|
||||
@@ -381,5 +518,4 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user