add flying commit

This commit is contained in:
lianxiang
2018-08-28 17:00:43 +08:00
parent 6a8d55457a
commit 54e936535f
24 changed files with 1353 additions and 23 deletions
@@ -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