//
//  SelectLocationBaseView.m
//  Open
//
//  Created by 雷俊博 on 2019/12/13.
//  Copyright © 2019 黄江涛 . All rights reserved.
//

#import "SelectLocationBaseView.h"

@implementation SelectLocationBaseView
#pragma mark - life cycle
- (void)initUI
{
    self.frame = SCREEN_BOUNDS;
    // 背景遮罩图层
    [self addSubview:self.backgroundView];
    // 弹出视图
    [self addSubview:self.alertView];
    // 设置弹出视图子视图
    // 添加顶部标题栏
    [self.alertView addSubview:self.topView];
    
    // 添加分割线
    [self.topView addSubview:self.lineView];
}


#pragma mark - event response
-(void)didTapBackgroundView:(UITapGestureRecognizer *)sender
{
    
}


#pragma mark - getters and setters
- (UIView *)backgroundView
{
    if (!_backgroundView) {
        _backgroundView = [[UIView alloc]initWithFrame:SCREEN_BOUNDS];
        _backgroundView.backgroundColor = [UIColor blackColor] ;
        _backgroundView.alpha = 0.3f ;
        _backgroundView.userInteractionEnabled = YES;
        UITapGestureRecognizer *myTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapBackgroundView:)];
        [_backgroundView addGestureRecognizer:myTap];
    }
    return _backgroundView;
}
- (UIView *)topView
{
    if (!_topView) {
        _topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, kTopViewHeight + 0.5)];
        _topView.backgroundColor = [UIColor whiteColor];
    }
    return _topView;
}
- (UIView *)alertView
{
    if (!_alertView) {
        _alertView = [[UIView alloc]initWithFrame:CGRectMake(0, ScreenHeight - kTopViewHeight - kSelectedAddressHeight, ScreenWidth, kTopViewHeight + kSelectedAddressHeight)];
        _alertView.backgroundColor = [UIColor whiteColor];
    }
    return _alertView;
}



- (UIView *)lineView
{
    if (!_lineView) {
        _lineView = [[UIView alloc]initWithFrame:CGRectMake(0, kTopViewHeight, ScreenWidth, 0.5)];
        _lineView.backgroundColor = [UIColor colorWithRed:225/255.0 green:225/255.0 blue:225/255.0 alpha:1.0];
        [self.alertView addSubview:_lineView];
    }
    return _lineView;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
