//
//  GMFaceReplayViewController.m
//  Gengmei
//
//  Created by 刘鹿杰 on 2019/7/24.
//  Copyright © 2019 更美互动信息科技有限公司. All rights reserved.
//

#import "GMFaceReplayViewController.h"
#import "GMFaceV3Model.h"
#import "GMMarkView.h"
#import "ALTransFormFaceUtil.h"
#import "GMFaceV3Util.h"
#import "GMDrawDottedView.h"
#import "GMImageView+GMFace.h"
#import "GMTitleView.h"
#import "GMFaceReplayResultVC.h"
#import "GMScreenRecorderManager.h"
#import "GMFaceReplayModel.h"
#import "GMFaceInfoShareViewController.h"

#define AnimationDuration 0.35  // 动画执行时间
#define Blue_line [UIColor colorWithHexString:@"0x4EC4CD" alpha:0.6]
#define TitleToTopHight [OCNavigationBar barHeight] + 101

@interface GMFaceReplayViewController ()<GMScreenRecorderDelegate>

@property (nonatomic, strong) GMFaceV3Model *faceModel;
@property (nonatomic, strong) GMFaceReplayModel *replayModel;
// 记录第一个页面侧面弹出框View
@property (nonatomic, strong)NSMutableArray *fristLeftPopView;
@end

@implementation GMFaceReplayViewController

- (instancetype)initWithModel:(GMFaceV3Model *)faceModel replayModel:(nonnull GMFaceReplayModel *)replayModel {
    if (self = [super init]) {
        self.faceModel = faceModel;
        self.replayModel = replayModel;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationBar.hidden = YES;
    self.fd_interactivePopDisabled = YES;
    self.view.backgroundColor = [UIColor colorWithHexString:@"666666"];
    [self addImageView];                        // 设置ImageView
    if (self.replayModel.tapType != GMReplayViewTapPreview) {
        [GMScreenRecorderManager sharedManager].delegate = self;
    }
}

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    __weak typeof(self) weakSelf = self;
    if (self.replayModel.tapType != GMReplayViewTapPreview) {
        [GMScreenRecorderManager startRecord:NO suscess:^{  // 如果开启成功，开始展示动画
            [weakSelf setupSubView];
        }];
    }else{
        [self setupSubView];
    }
}


#pragma mark  - 主要代码
// 添加控件
- (void)setupSubView {
    [self addMaskView];                         // 添加遮罩层
    [self addTitleImageView:@"facev3_analyse"]; // 添加面部分析图片
    [self controlAnimation];                    // 控制动画
}

// 添加picImageView
- (void)addImageView {
    self.picImageView = [[GMImageView alloc] initWithImage:self.faceModel.image];
    self.picImageView.contentMode = UIViewContentModeScaleAspectFill;
    self.picImageView.frame = self.view.frame;
    [self.view addSubview:self.picImageView];
}

// 添加遮罩层
- (void)addMaskView {
    GMMarkView * markView = [[GMMarkView alloc] initWithType:self.replayModel];
    markView.backgroundColor = [UIColor colorWithHexString:@"000000" alpha:0.25];
    markView.alpha = 0;
    markView.frame = CGRectMake(0, 0, MAINSCREEN_WIDTH, MAINSCREEN_HEIGHT);
    [self.view addSubview:markView];
    [UIView animateWithDuration:AnimationDuration animations:^{
        markView.alpha = 1;
    }];
}

// 展示分析图片
- (void)addTitleImageView:(NSString *)imageName {
    self.titleImageView = [[GMImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
    self.titleImageView.contentMode = UIViewContentModeScaleAspectFit;
    self.titleImageView.frame = CGRectMake(15, -55, 248, 55);
    [UIView animateWithDuration:AnimationDuration animations:^{
        self.titleImageView.transform = CGAffineTransformMakeTranslation(0, [OCNavigationBar barHeight] + 71);
    }];
    [self.view addSubview:self.titleImageView];
}

#pragma mark - 动画控制
// 控制动画效果
- (void)controlAnimation  {
    __weak typeof(self) weakSelf = self; // 展示面部分析动画后， 停留0.5s，动画耗时0.75s 共用 1.5s
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.7 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (!weakSelf || weakSelf.stopGCD) { return ;}
        [weakSelf drawOneViewAnimation];  // 共耗时 0.5s
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            if (!weakSelf || weakSelf.stopGCD) { return ;}
            [weakSelf clearFristViewLineView];  // 耗时0.75s
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(AnimationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                if (!weakSelf || weakSelf.stopGCD) { return ;}
                [weakSelf addChinLineAddsanjiao];  // 逻辑待完善
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                    if (!weakSelf || weakSelf.stopGCD) { return ;}
                    [weakSelf controlVcAnimationFive];
                });
            });
        });
    });
}

// 控制第五个页面的动画
- (void)controlVcAnimationFive {
    [self clearFristViewLineView];  // 耗时0.75s
    __weak typeof(self) weakSelf = self;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(AnimationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (!weakSelf || weakSelf.stopGCD) { return ;}
        [weakSelf addTitleImageView:@"facev3_eye_analyse"]; // 0.35s
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(AnimationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            if (!weakSelf || weakSelf.stopGCD) { return ;}
            [weakSelf drawFiveViewAnimation]; // 3.75s
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.85 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                if (!weakSelf || weakSelf.stopGCD) { return ;}
                [weakSelf controlVcAddNewAnimation];
            });
        });
    });
}

// 控制新添加页面的动画
- (void)controlVcAddNewAnimation {
    __weak typeof(self) weakSelf = self;
    [weakSelf clearFristViewLineView];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(AnimationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (!weakSelf || weakSelf.stopGCD) { return ;}
        [weakSelf updatePicImageViewframeP]; // 更改回来控件的frame
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(AnimationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            if (!weakSelf || weakSelf.stopGCD) { return ;}
            [weakSelf drawAddNewAnimation];
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                if (!weakSelf || weakSelf.stopGCD) { return ;}
                [weakSelf controlVcAnimationSix];
            });
        });
    });
}

// 控制第六个页面的动画
- (void)controlVcAnimationSix {
    __weak typeof(self) weakSelf = self;
    [weakSelf clearFristViewLineView]; // 更改回来控件的frame
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(AnimationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (!weakSelf || weakSelf.stopGCD) { return ;}
        [weakSelf addTitleImageView:@"facev3_mouth_analyse"]; // 0.75s
        [weakSelf.allViewLine addObject:weakSelf.titleImageView];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(AnimationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            if (!weakSelf || weakSelf.stopGCD) { return ;}
            [weakSelf drawSixViewAnimation]; // 1.75s
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                if (!weakSelf || weakSelf.stopGCD) { return ;}
                GMFaceReplayResultVC *vc = [[GMFaceReplayResultVC alloc] initWithModel:weakSelf.faceModel replayModel:weakSelf.replayModel];
                [weakSelf.navigationController pushViewController:vc animated:YES];
            });
        });
    });
}

#pragma mark - 面部分析
- (void)drawOneViewAnimation {
    NSArray *pointsRight = self.faceModel.analysis.featureInfo.pointsRight;             // 脸右侧点位置
    NSArray *mouthArray = self.faceModel.analysis.goldTriangleInfo.pointsMouth;         // 获取嘴角两个点
    NSArray *subTitle1 = self.faceModel.analysis.featureInfo.subTitle;                  // 脸型描述文字
    NSArray *subTitle2 = self.faceModel.analysis.goldTriangleInfo.subTitle;             // 黄金三角页面描述文字
    NSArray *triangleArray = self.faceModel.analysis.goldTriangleInfo.pointsTriangle;   // 获取黄金三角三个点
    NSArray *chinArray = self.faceModel.analysis.goldTriangleInfo.pointsChin;           // 获取下巴的三个点
    NSArray *contentArray = self.faceModel.analysis.goldTriangleInfo.content;           // 获取所有角度
    // 新添加的字段
    NSArray *nbSubTitle = self.faceModel.analysis.niebuquankuanInfo.subTitle;
    NSArray *niebuPoints = self.faceModel.analysis.niebuquankuanInfo.niebuPoints;    // 添加画脸的线
    NSArray *quankuanPoints = self.faceModel.analysis.niebuquankuanInfo.quankuanPoints;
    NSArray *nbqkContentArray = self.faceModel.analysis.niebuquankuanInfo.content;
    // 画右侧轮廓
    CALayer *layer = [self drawLineMethod:pointsRight Color:Blue_line];
    [self.allViewLine addObject:layer];
    // 颞部数据处理
    GMFaceCommonPositionModel *niebuCenterModel = [self calculateCenterModelWithArray:niebuPoints];
    GMFaceCommonPositionModel *quankuanCenterModel = [self calculateCenterModelWithArray:quankuanPoints];
    GMFaceCommonContentModel *nbqkModel = nbqkContentArray[0];
    // 画6条横线
    NSMutableArray<GMFaceCommonPositionModel *> *lineArrayPoint = [NSMutableArray arrayWithObject:triangleArray[2]];
    [lineArrayPoint addObjectsFromArray:mouthArray];
    [lineArrayPoint addObject:chinArray[1]];
    [lineArrayPoint addObject:niebuCenterModel];
    [lineArrayPoint addObject:quankuanCenterModel];
    // 添加颞部新增横线
    [self creatHorizontalLine:lineArrayPoint];
    // 添加带箭头的文字描述 -- 人中长 Or 下巴长
    [self creatVorticalDescLine:@[lineArrayPoint[0],lineArrayPoint[1]] content:contentArray[1] offset:30];
    [self creatVorticalDescLine:@[lineArrayPoint[2],lineArrayPoint[3]] content:contentArray[2] offset:45];
    // 展示颞部比例
    [self creatVorticalDescLine:@[niebuCenterModel,quankuanCenterModel] content:nbqkModel offset:30];
    // 添加描述文字
    NSMutableArray *subTitle = [NSMutableArray arrayWithArray:subTitle1];
    [subTitle addObjectsFromArray:nbSubTitle];
    [subTitle addObjectsFromArray:subTitle2];
    [self leftPopTitleWith:self.fristLeftPopView AddSubtitle:subTitle Animation:0];
}

-(void)addChinLineAddsanjiao {
    NSArray *triangleArray = self.faceModel.analysis.goldTriangleInfo.pointsTriangle;   // 获取黄金三角三个点
    NSArray *chinArray = self.faceModel.analysis.goldTriangleInfo.pointsChin;           // 获取下巴的三个点
    NSArray *contentArray = self.faceModel.analysis.goldTriangleInfo.content;           // 获取所有角度
    // 添加下巴及角度
    [self addChinLine:chinArray descModel:contentArray.lastObject];
    //画黄金三角
    NSMutableArray *sanjiaoArray = [NSMutableArray arrayWithArray:triangleArray];
    [sanjiaoArray addObject:triangleArray.firstObject];
    CALayer *sanjiaolayer = [self drawLineMethod:sanjiaoArray Color:[UIColor whiteColor]];
    [self.allViewLine addObject:sanjiaolayer];
    // 画黄金三角文字
    [self creatFourWord:triangleArray addModel:contentArray.firstObject];
    // 添加需要移除的控件
    [self.allViewLine addObject:self.titleImageView];
    [self.allViewLine addObjectsFromArray:self.fristLeftPopView];
    [self.fristLeftPopView removeAllObjects];
}

#pragma mark - 眉眼分析

- (void)drawFiveViewAnimation {
    // 获取数据， 方便之后使用
    NSArray *contnetArray = self.faceModel.analysis.eyeEyebrowInfo.content;            // 描述文字数组
    NSArray *pointsEye = self.faceModel.analysis.eyeEyebrowInfo.pointsEye;             // 眼睛的点坐标
    NSArray *pointsEyeBrow = self.faceModel.analysis.eyeEyebrowInfo.pointsEyeBrow;     // 眉毛的点坐标
    NSArray *subTitle = self.faceModel.analysis.eyeEyebrowInfo.subTitle;               // 描述文字
    ALFaceRectModel *eyebrowRect = self.faceModel.analysis.eyeEyebrowInfo.eyebrowRect; // 眉毛矩形框
    ALFaceRectModel *eyeRect = self.faceModel.analysis.eyeEyebrowInfo.eyeRect;         // 眼睛矩形框
    GMFaceCommonPositionModel *ptriangle = self.faceModel.analysis.goldTriangleInfo.pointsTriangle[2]; // 获取P点坐标
    // 定义缩放比例
    CGFloat scale = 1.6;
    // 计算P点的新坐标
    GMFaceCommonPositionModel *newPoint = [GMFaceCommonPositionModel creatFaceCommonModelWithX:ptriangle.x *scale addY:ptriangle.y *scale];
    // 要平移到的最终位置
    GMFaceCommonPositionModel *finalPoint = [GMFaceCommonPositionModel creatFaceCommonModelWithX:MAINSCREEN_WIDTH addY:MAINSCREEN_HEIGHT * 0.70];
    // 计算便宜量
    CGFloat x = finalPoint.x  - newPoint.x;
    CGFloat y = finalPoint.y - newPoint.y;
    // 更改现在的位置
    [UIView animateWithDuration:AnimationDuration animations:^{
        self.picImageView.frame = CGRectMake(x, y, self.picImageView.frame.size.width * scale, self.picImageView.frame.size.height * scale);
    }];
    // 计算新的坐标点 并且多加了一个起始点
    __weak typeof (self) weakSelf = self;
    NSMutableArray *newPointsEyeBrow = [self bigImagePointWithScale:scale offsetX:x offsetY:y poinyArray:pointsEyeBrow];
    NSMutableArray *newPointsEye = [self bigImagePointWithScale:scale offsetX:x offsetY:y poinyArray:pointsEye];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(AnimationDuration * 2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (!weakSelf || weakSelf.stopGCD) { return ;}
        // 画眉毛
        [newPointsEyeBrow addObject:newPointsEyeBrow.firstObject];
        CALayer *eyeBrowlayer = [weakSelf drawLineMethod:[newPointsEyeBrow copy] Color:Blue_line];
        [weakSelf.allViewLine addObject:eyeBrowlayer];
        // 画眼睛
        [newPointsEye addObject:newPointsEye.firstObject];
        CALayer *eyelayer = [weakSelf drawLineMethod:[newPointsEye copy] Color:Blue_line];
        [weakSelf.allViewLine addObject:eyelayer];
    });
    //  原始坐标点
    NSArray *eyebrowMidlePoint = [self midlePointWithModel:eyebrowRect];
    NSArray *eyeMidlePoint = [self midlePointWithModel:eyeRect];          //  点坐标
    // 计算新点的坐标
    NSArray *eyebrowNewPoint = [self bigImagePointWithScale:scale offsetX:x offsetY:y poinyArray:eyebrowMidlePoint];
    NSArray *eyeNewPoint = [self bigImagePointWithScale:scale offsetX:x offsetY:y poinyArray:eyeMidlePoint];
    // 画竖线
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(AnimationDuration * 3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (!weakSelf || weakSelf.stopGCD) { return ;}
        [weakSelf fiveViewdrawlineWithEye:eyeNewPoint eyebrow:eyebrowNewPoint];
    });
    // 画虚线
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(AnimationDuration * 4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (!weakSelf || weakSelf.stopGCD) { return ;}
        [weakSelf fiveViewdrawDottodlineWithEye:eyeNewPoint eyebrow:eyebrowNewPoint modelAry:contnetArray];
    });
    // 添加描述文字
    [self leftPopTitleWith:self.allViewLine AddSubtitle:subTitle Animation:1.5];
}

#pragma mark  新添加页面动画
- (void)drawAddNewAnimation {
    // 人中、嘴唇
    NSArray *contnetArray = self.faceModel.analysis.renzhongzuichunkediInfo.content;
    NSArray *subTitle = self.faceModel.analysis.renzhongzuichunkediInfo.subTitle;
    NSArray *renzhongPoints = self.faceModel.analysis.renzhongzuichunkediInfo.renzhongPoints;
    NSArray *zuichunPoints = self.faceModel.analysis.renzhongzuichunkediInfo.zuichunPoints;
    NSArray *kediPoints = self.faceModel.analysis.renzhongzuichunkediInfo.kediPoints;
    // 瞳距鼻翼宽比
    NSArray *tjbContnetArray = self.faceModel.analysis.tongjubiyiInfo.content;
    NSArray *tjbSubTitle = self.faceModel.analysis.tongjubiyiInfo.subTitle;
    NSArray *tongjuPoints = self.faceModel.analysis.tongjubiyiInfo.tongjuPoints;
    NSArray *biyiPoints = self.faceModel.analysis.tongjubiyiInfo.biyiPoints;
    // 获取中心点
    GMFaceCommonPositionModel *tongjuCenterPoints = [self calculateCenterModelWithArray:tongjuPoints];
    GMFaceCommonPositionModel *biyiCenterModel = [self calculateCenterModelWithArray:biyiPoints];
    // 鼻翼宽度
    CGFloat tongjuWidth = [self calculateWidthWithArray:tongjuPoints];
    CGFloat biyiWidth = [self calculateWidthWithArray:biyiPoints];
    // 添加横线
    NSArray<GMFaceCommonPositionModel *> *hArrry = @[tongjuCenterPoints,biyiCenterModel,renzhongPoints[0],renzhongPoints[1],zuichunPoints[1],kediPoints[1]];
    NSArray *widthArray = @[@(tongjuWidth),@(biyiWidth),@(100),@(100),@(100),@(100)];
    [self drawSixhLine:hArrry widthArray:widthArray];
    // 画中间的描述文字
    [self creatVerticalDottedLineWith:tjbContnetArray[0] addArray:@[tongjuCenterPoints,biyiCenterModel]offset:0];
    [self creatVerticalDottedLineWith:contnetArray[0] addArray:renzhongPoints offset:0];
    [self creatVerticalDottedLineWith:contnetArray[1] addArray:zuichunPoints offset:30];
    [self creatVerticalDottedLineWith:contnetArray[2] addArray:kediPoints offset:-20];
    // 添加描述文字
    NSMutableArray *allsubTitle = [NSMutableArray arrayWithArray:tjbSubTitle];
    [allsubTitle addObjectsFromArray:subTitle];
    // 添加描述文字
    [self leftPopTitleWith:self.allViewLine AddSubtitle:allsubTitle Animation:0];
    [self.allViewLine addObject:self.titleImageView];
}

#pragma mark - 鼻唇分析

- (void)drawSixViewAnimation {
    NSArray *contnetArray = self.faceModel.analysis.mouthNoseInfo.content;
    NSArray *subTitle = self.faceModel.analysis.mouthNoseInfo.subTitle;
    NSArray *pointsNose = self.faceModel.analysis.mouthNoseInfo.pointsNose;
    NSArray *pointsMouth = self.faceModel.analysis.mouthNoseInfo.pointsMouth;
    ALFaceRectModel *mouthRect = self.faceModel.analysis.mouthNoseInfo.mouthRect;
    // 双C线
    NSArray *contentCxian = self.faceModel.analysis.shuangCxianInfo.content;
    NSArray *subTitleCxian = self.faceModel.analysis.shuangCxianInfo.subTitle;
    NSArray *pointListCxian = self.faceModel.analysis.shuangCxianInfo.pointList;
    
    // 画嘴角线条
    for (GMFacePointsMouthInfoModel *mouthModel in pointsMouth) {
        CALayer *eyeBrowlayer = [self drawLineMethod:mouthModel.points Color:Blue_line];
        [self.allViewLine addObject:eyeBrowlayer];
    }
    
    // 画双C线
    CALayer *cxianlayer = [self drawLineMethod:pointListCxian Color:Blue_line];
    [self.allViewLine addObject:cxianlayer];
    
    NSArray<GMFaceCommonPositionModel *> *rectArray = [self midlePointWithModel:mouthRect];
    GMFaceCommonPositionModel* model0 = rectArray[0];
    GMFaceCommonPositionModel* model1 = rectArray[1];
    GMFaceCommonPositionModel* model2 = rectArray[2];
    GMFaceCommonPositionModel* model3 = rectArray[3];
    __weak typeof (self) weakSelf = self;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(AnimationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (!weakSelf || weakSelf.stopGCD) { return ;}
        // 添加Cxian文字
        GMFaceCommonPositionModel *positionModel = pointListCxian[1];
        CGRect cxianSize = CGRectMake(positionModel.x + 10, positionModel.y - 15, 100, 45);
        GMFaceCommonContentModel *cxianContentModel = contentCxian[0];
        GMLabel *dectLabelCxian = [weakSelf creatLabelWithText:[NSString stringWithFormat:@"%@\n%@",cxianContentModel.title,cxianContentModel.value] Font:9 Color:UIColor.whiteColor Size:cxianSize];
        dectLabelCxian.alpha = 0.0;
        dectLabelCxian.numberOfLines = 2;
        dectLabelCxian.textAlignment = NSTextAlignmentLeft;
        [weakSelf.allViewLine addObject:dectLabelCxian];
        [UIView animateWithDuration:AnimationDuration animations:^{
            dectLabelCxian.alpha = 1.0;
        }];
        // 获取矩形框宽高
        CGSize rectSize = [weakSelf getWidthAddHightWithRect:rectArray];
        // 画四条竖线
        NSArray<GMFaceCommonPositionModel *> *verticalArrry = @[pointsNose[0],pointsNose[1],rectArray[0],rectArray[2]];
        NSArray *hightArray = @[@(77),@(77),@(rectSize.height + 30),@(rectSize.height + 30)];
        [weakSelf drawSixVerticalLine:verticalArrry hightArray:hightArray];
        // 画三条横线
        NSArray *realLine = weakSelf.faceModel.analysis.santingInfo.realLinePoints;
        NSArray<GMFaceCommonPositionModel *> *hArrry = @[realLine[1],rectArray[1],rectArray[3]];
        NSArray *widthArray = @[@(115),@(rectSize.width + 30),@(rectSize.width + 30)];
        [weakSelf drawSixhLine:hArrry widthArray:widthArray];
        // 画带箭头的线条
        [weakSelf drawDottodLineWithPointArray:pointsNose content:contnetArray[0] type:drawViewTypeHorizontalDotted place:wordPlaceTop];

        GMFaceCommonPositionModel* newModel0 = model1;
        newModel0.x = model2.x;
        NSArray *rightArray = @[newModel0, model3];
        [weakSelf drawDottodLineWithPointArray:rightArray content:contnetArray[1] type:drawViewTypeVerticalDotted place:wordPlaceRight];
        
        GMFaceCommonPositionModel* newModel1 = model0;
        newModel1.y = model3.y + 15;
        NSArray *bootmArray = @[newModel1, model2];
        [weakSelf drawDottodLineWithPointArray:bootmArray content:contnetArray[2] type:drawViewTypeHorizontalDotted place:wordPlaceBottom];
    });
    // 添加描述文字
    NSMutableArray *allsubTitle = [NSMutableArray arrayWithArray:subTitle];
    [allsubTitle addObjectsFromArray:subTitleCxian];
    [self leftPopTitleWith:self.allViewLine AddSubtitle:subTitle Animation:0.5];
}

// 返回方法！
- (void)backMethod {
    // 返回到具体页面
    self.stopGCD = YES;
    BOOL isPop = YES;
    for (UIViewController *vc in AppDelegate.navigation.childViewControllers) {
        if ([vc isKindOfClass:[GMFaceInfoShareViewController class]]){
            isPop = NO;
            [AppDelegate.navigation popToViewController:vc animated:YES];
            return;
        }
    }
    if (isPop) {
        [AppDelegate.navigation popToRootViewControllerAnimated:YES];
    }
}

#pragma mark - 代理方法

// 开启录屏时发现未知错误 -- 文字提醒
-(void)didStartRecordWithErrorString:(NSString *)errorString{
    [self showWarning:errorString];
    // 返回到上一页
    __weak typeof(self) weakSelf = self;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [weakSelf backMethod];
    });
}

-(NSMutableArray *)fristLeftPopView{
    if (!_fristLeftPopView) {
        _fristLeftPopView = [NSMutableArray array];
    }
    return _fristLeftPopView;
}

@end
