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

#import "GMTestSkinTeachPopView.h"
#import "GMTestSkinTeachVC.h"
@import GMRouter;
#define containerHeight ((MAINSCREEN_WIDTH - 105) * 249 / 270)

@interface GMTestSkinTeachPopView()

@end

@implementation GMTestSkinTeachPopView

-(void)setup{
    [super setup];
    self.animationType = GMPopupAnimationTypeFade;
    self.disableCancelTouch = YES;
    // 设置 container
    self.container.backgroundColor = [UIColor clearColor];
    [self.container mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(MAINSCREEN_WIDTH - 105, containerHeight));
        make.centerX.equalTo(self.mas_centerX);
        make.centerY.equalTo(self.mas_centerY);
    }];

    // 添加View
    GMView *contentView = [[GMView alloc] init];
    contentView.backgroundColor = [UIColor whiteColor];
    contentView.layer.cornerRadius = 10;
    contentView.clipsToBounds = YES;
    [self.container addSubview:contentView];
    [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self.container.mas_width);
        make.top.equalTo(self.container.mas_top).offset(35);
        make.centerX.equalTo(self.mas_centerX);
        make.height.mas_equalTo(containerHeight - 35);
    }];
    
    // imageView
    GMImageView *imageView = [[GMImageView alloc] initWithImage:[UIImage imageNamed:@"face_skin_popIcon"]];
    [self.container addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.container.mas_top);
        make.centerX.equalTo(self.mas_centerX);
    }];
    
    // 添加描述label
    GMLabel *textlabel = [[GMLabel alloc] init];
    textlabel.numberOfLines = 2;
    NSString *tipString = @"检测肤质使用摄像头自动拍照\n请认真看教程哦";
    NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
    paragraphStyle.lineSpacing = 8;
    NSDictionary *attriDict = @{NSParagraphStyleAttributeName:paragraphStyle,NSFontAttributeName:[UIFont gmFont:15],NSForegroundColorAttributeName:UIColor.headlineText};
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:tipString attributes:attriDict];
    textlabel.attributedText = attributedString;
    textlabel.textAlignment = NSTextAlignmentCenter;
    [contentView addSubview:textlabel];
    [textlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(contentView.mas_centerX);
        make.centerY.equalTo(contentView.mas_centerY);
    }];
    
    // 添加btn
    GMButton *btn = [[GMButton alloc] init];
    [contentView addSubview:btn];
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    UIImage *image = [[UIImage imageNamed:@"face_startActicn_btn"] resizableImageWithCapInsets:UIEdgeInsetsMake(20, 100, 20, 100) resizingMode:UIImageResizingModeStretch];
    [btn setBackgroundImage:image forState:UIControlStateNormal];
    [btn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    [btn.titleLabel setFont:[UIFont gmLightFont:16]];
    [btn setTitle:@"知道啦" forState:UIControlStateNormal];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(contentView.mas_bottom).offset(-23);
        make.centerX.equalTo(contentView.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(200, 40));
    }];
}

- (void)btnClick {
    [UIView animateWithDuration:self.animationDuration animations:^{
        self.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
        [[GMRouter sharedInstance] pushScheme:@"gengmei://test_skin"];
//        GMTestSkinTeachVC *testSkinVc = [[GMTestSkinTeachVC alloc] init];
//        [AppDelegate.navigation pushViewController:testSkinVc animated:YES];
    }];
}
@end
