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

#import "GMFaceShotPopView.h"

@interface GMFaceShotPopView()

@end

@implementation GMFaceShotPopView

- (void)setup {
    [super setup];
    self.animationType = GMPopupAnimationTypeFade;
    // 设置 container
    self.container.backgroundColor = [UIColor whiteColor];
    self.container.frame = CGRectMake(53, (MAINSCREEN_HEIGHT - 370) / 2 - 50, MAINSCREEN_WIDTH - 106, 370);
    self.container.layer.cornerRadius = 10;
    self.container.clipsToBounds = YES;
    
    // 添加三个View
    GMView *view1 = [self creatViewWithimageName:@"facev4_popView1" title:@"平视摄像头" dect:@"脸部在拍照区域内"];
    view1.frame = CGRectMake(0, 5, self.container.width, 120);
    GMView *view2 = [self creatViewWithimageName:@"facev4_popView2" title:@"摘下眼镜" dect:@"眉毛眼睛清晰露出"];
    view2.frame = CGRectMake(0, 125, self.container.width, 120);
    GMView *view3 = [self creatViewWithimageName:@"facev4_popView3" title:@"点击拍照" dect:@"生成脸型风格报告"];
    view3.frame = CGRectMake(0, 245, self.container.width, 120);
    [self.container addSubview:view1];
    [self.container addSubview:view2];
    [self.container addSubview:view3];
    
    // 添加底部关闭按钮
    UIImageView *closeIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sign_rule_close"]];
    closeIcon.frame = CGRectMake((MAINSCREEN_WIDTH - 35) / 2, CGRectGetMaxY(self.container.frame) + 20, 35, 35);
    closeIcon.userInteractionEnabled = YES;
    [self addSubview:closeIcon];
    
    // 添加点击效果
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideView)];
    [self addGestureRecognizer:tap];
}

- (GMView *)creatViewWithimageName:(NSString *)imageName title:(NSString *)title dect:(NSString *)dect {
    GMView *bgView = [[GMView alloc] init];
    bgView.backgroundColor = [UIColor whiteColor];
    bgView.frame = CGRectMake(0, 0, MAINSCREEN_WIDTH - 106, 120);
    // imageView
    GMImageView *imageView = [[GMImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
    imageView.contentMode = UIViewContentModeScaleAspectFit;
    imageView.frame = CGRectMake(28, 20, 70, 80);
    imageView.userInteractionEnabled = YES;
    imageView.backgroundColor = UIColor.clearColor;
    [bgView addSubview:imageView];
    // title
    GMLabel *titleLabel = [[GMLabel alloc] init];
    titleLabel.textColor = UIColor.headlineText;
    titleLabel.font = [UIFont gmBoldFont:15];
    titleLabel.frame = CGRectMake(123, 41, bgView.width - 143, 15);
    titleLabel.text = title;
    [bgView addSubview:titleLabel];
    // dect
    GMLabel *dectLabel = [GMLabel labelWithTextColor:UIColor.auxiliaryTextDark fontSize:13];
    dectLabel.text = dect;
    dectLabel.frame = CGRectMake(123, 64, bgView.width - 143, 15);
    [bgView addSubview:dectLabel];
    return bgView;
}

- (void)hideView {
    [self hide];
}

@end
