//
//  PostMessageView.m
//  Open
//
//  Created by 看看智能 on 2017/3/2.
//  Copyright © 2017年 黄江涛 . All rights reserved.
//。免费发布

#import "PostMessageView.h"

@implementation PostMessageView
-(instancetype)init
{
    self = [super init];
    if (self) {
        self.backgroundColor =[UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1.0];
        _view_1 =[UIView new];
        _view_1.backgroundColor =[UIColor whiteColor];
        [self addSubview:_view_1];

        if([[UIScreen mainScreen]bounds].size.height == 568)
        {
            [_view_1 mas_makeConstraints:^(MASConstraintMaker *make) {
                CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
                make.top.mas_equalTo(rectStatus.size.height + 44);
                make.left.right.mas_equalTo(0);
                make.height.mas_equalTo(340);
            }];
        }else{
            [_view_1 mas_makeConstraints:^(MASConstraintMaker *make) {
                CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
                make.top.mas_equalTo(rectStatus.size.height + 44);
                make.left.right.mas_equalTo(0);
                make.height.mas_equalTo(390);
            }];
        
        }
        
        
        
        
        
        
        
        _view_2 =[UIView new];
         _view_2.backgroundColor =[UIColor whiteColor];
        [self addSubview:_view_2];
        [_view_2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_view_1.mas_bottom).mas_equalTo(12);
            make.left.mas_equalTo(10);
            make.right.mas_equalTo(-10);
            make.height.mas_equalTo(180);
        }];

    }
    return self;
}


+ (PostMessageView *)sharedInstance{
    static PostMessageView *p = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        p = [PostMessageView new];
    });
    return p;
}
-(UITextField *)HeaderTitle
{
    if (!_HeaderTitle) {
        _HeaderTitle =[[UITextField alloc]init];
        _HeaderTitle.textColor =kRGBColor(51, 51, 15);
        _HeaderTitle.font=[UIFont systemFontOfSize:20];
        [_view_1 addSubview:_HeaderTitle];
        [_HeaderTitle mas_makeConstraints:^(MASConstraintMaker *make) {

            make.top.mas_equalTo(_view_1.mas_top).mas_equalTo(20);
            make.left.mas_equalTo(21);
            make.size.mas_equalTo(CGSizeMake(300, 21));
        }];
    }
    return _HeaderTitle;
}
-(UIButton *)buttomWithSender
{
    if (!_buttomWithSender) {
        _buttomWithSender =[UIButton buttonWithType:0];
        _buttomWithSender.backgroundColor=kRGBColor(34, 167, 222);
        _buttomWithSender.titleLabel.textAlignment =NSTextAlignmentCenter;
        _buttomWithSender.titleLabel.font =[UIFont systemFontOfSize:15];
        _buttomWithSender.layer.cornerRadius=13;
        _buttomWithSender.clipsToBounds=YES;
        [_view_1 addSubview:_buttomWithSender];
        [_buttomWithSender mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_HeaderTitle.mas_bottom).mas_equalTo(22);
            make.leftMargin.mas_equalTo(_HeaderTitle.mas_leftMargin);
            make.width.mas_equalTo(64);
            make.height.mas_equalTo(29);
        }];
    }
    return _buttomWithSender;
}







-(UIImageView*)imaginaryLine
{
    if (!_imaginaryLine) {
        _imaginaryLine =[[UIImageView alloc]init];
        [_view_1 addSubview:_imaginaryLine];
        [_imaginaryLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_buttomWithSender.mas_bottom).mas_equalTo(9);
            make.width.mas_equalTo(_view_1.mas_width).mas_equalTo(-20);
            make.height.mas_equalTo(1);
            make.centerX.mas_equalTo(0);
        }];
    }
    return _imaginaryLine;
}

-(UITextView *)publishView
{
    if (!_publishView) {
        _publishView =[[UITextView alloc]init];
        _publishView.backgroundColor=[UIColor blackColor];
        _publishView.font=[UIFont systemFontOfSize:15];
        _publishView.textColor = [UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1.0];
        [_view_1 addSubview:_publishView];
        [_publishView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_imaginaryLine.mas_bottom).mas_equalTo(7);
            make.centerX.mas_equalTo(0);
            make.width.mas_equalTo(_view_1.mas_width).mas_equalTo(-40);
            make.height.mas_equalTo(170);
         
        }];
        if([[UIScreen mainScreen]bounds].size.height == 568)
        {
            [_publishView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.mas_equalTo(_imaginaryLine.mas_bottom).mas_equalTo(7);
                make.centerX.mas_equalTo(0);
                make.width.mas_equalTo(_view_1.mas_width).mas_equalTo(-40);
                make.height.mas_equalTo(120);
                
            }];
        }
    }
     return _publishView;
}
-(UILabel *)publishViewLab
{
    if (!_publishViewLab) {
        _publishViewLab =[[UILabel alloc]init];
        _publishViewLab.font=[UIFont systemFontOfSize:15];
        _publishViewLab.textColor=[UIColor grayColor];
        _publishViewLab.textAlignment=NSTextAlignmentLeft;
        [_publishView addSubview:_publishViewLab];
        [_publishViewLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_publishView.mas_top).mas_equalTo(5);
            make.leftMargin.mas_equalTo(_publishView.mas_leftMargin).mas_equalTo(3);
        }];
    }
    return _publishViewLab;
}
-(UIButton *)buttomWithImage
{
    if (!_buttomWithImage) {
        _buttomWithImage =[UIButton buttonWithType:0];
        [_view_1 addSubview:_buttomWithImage];
        [_buttomWithImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_publishView.mas_bottom).mas_equalTo(0);
            make.leftMargin.mas_equalTo(_publishView.mas_leftMargin);
            make.size.mas_equalTo(CGSizeMake(75, 75));
        }];
    }
    return _buttomWithImage;
}
-(UIImageView*)line
{
    if (!_line) {
        _line =[[UIImageView alloc]init];
        [_view_1 addSubview:_line];
        [_line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_buttomWithImage.mas_bottom);
            make.width.mas_equalTo(_view_1.mas_width).mas_equalTo(-20);
            make.height.mas_equalTo(1);
            make.centerX.mas_equalTo(0);
        }];
    }
    return _line;
}
-(UIImageView*)Smallline
{
    if (!_Smallline) {
        _Smallline =[[UIImageView alloc]init];
        [_view_1 addSubview:_Smallline];
        [_Smallline mas_makeConstraints:^(MASConstraintMaker *make) {
            make.topMargin.mas_equalTo(self.buttomWithSender.mas_topMargin);
            make.bottomMargin.mas_equalTo(self.buttomWithSender.mas_bottomMargin);
            make.left.mas_equalTo(self.buttomWithSender.mas_right).mas_equalTo(10);
            make.width.mas_equalTo(1);
        }];
    }
    return _Smallline;
}
-(UIButton *)publishChild
{
    if (!_publishChild) {
        _publishChild =[UIButton buttonWithType:0];
        _publishChild.backgroundColor=kRGBColor(34, 167, 222);
        _publishChild.layer.cornerRadius=13;
        _publishChild.clipsToBounds=YES;
        _publishChild.titleLabel.font =[UIFont systemFontOfSize:12];
        [_view_1 addSubview:_publishChild];
        [_publishChild mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(_Smallline.mas_right).mas_equalTo(10);
            make.topMargin.mas_equalTo(_Smallline.mas_topMargin);
            make.bottomMargin.mas_equalTo(_Smallline.mas_bottomMargin);
            make.width.mas_equalTo(50);
        }];
    }
    return _publishChild;
}



-(UIButton *)buttomAddress
{
    if (!_buttomAddress) {
        _buttomAddress =[UIButton buttonWithType:0];
        [_buttomAddress setImage:[UIImage imageNamed:@"KK_location"] forState:UIControlStateNormal];
        [_buttomAddress setTitle:@"显示地点" forState:UIControlStateNormal];
        [_buttomAddress setTitleColor:[UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1.0] forState:UIControlStateNormal ];
        _buttomAddress.titleLabel.font = [UIFont systemFontOfSize: 15];
        [_view_1 addSubview:_buttomAddress];
        [_buttomAddress mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_line.mas_bottom).mas_equalTo(4);
            make.leftMargin.mas_equalTo(_buttomWithImage.mas_leftMargin);
           
        }];
    }
    return _buttomAddress;
}
-(UIButton *)buttomAddressImage
{
    if (!_buttomAddressImage) {
        _buttomAddressImage =[UIButton buttonWithType:0];
        [_buttomAddressImage setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
        [_view_1 addSubview:_buttomAddressImage];
        [_buttomAddressImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.topMargin.mas_equalTo(_buttomAddress.mas_topMargin).mas_equalTo(0);
            make.right.mas_equalTo(-10);
        }];
    }
    return _buttomAddressImage;
}

-(UILabel *)contactTitle
{
    if (!_contactTitle) {
        _contactTitle =[[UILabel alloc]init];
        _contactTitle.text=@"请留下您的联系方式:";
        _contactTitle.font=[UIFont systemFontOfSize:18];
        _contactTitle.textColor=kRGBColor(123, 123, 123);
        _contactTitle.textAlignment=NSTextAlignmentLeft;
        [_view_2 addSubview:_contactTitle];
        [_contactTitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_view_2.mas_top).mas_equalTo(10);
            make.left.mas_equalTo(_view_2.mas_left).mas_equalTo(10);
        }];
    }
    return _contactTitle;
}
-(UILabel *)nameLab
{
    if (!_nameLab) {
        _nameLab =[[UILabel alloc]init];
        _nameLab.text=@"姓名:";
        _nameLab.font=[UIFont systemFontOfSize:15];
        _nameLab.textColor=kRGBColor(123, 123, 123);
        _nameLab.textAlignment=NSTextAlignmentLeft;
        [_view_2 addSubview:_nameLab];
        [_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_contactTitle.mas_bottom).mas_equalTo(20);
            make.leftMargin.mas_equalTo(_contactTitle.mas_leftMargin);
        }];
    }
    return _nameLab;
}
-(UILabel *)telLab
{
    if (!_telLab) {
        _telLab =[[UILabel alloc]init];
        _telLab.text=@"电话:";
        _telLab.font=[UIFont systemFontOfSize:15];
        _telLab.textColor=kRGBColor(123, 123, 123);
        _telLab.textAlignment=NSTextAlignmentLeft;
        [_view_2 addSubview:_telLab];
        [_telLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_nameLab.mas_bottom).mas_equalTo(20);
            make.leftMargin.mas_equalTo(_nameLab.mas_leftMargin);
        }];
    }
    return _telLab;
}







-(UITextField *)textFieldName
{
    if (!_textFieldName) {
        _textFieldName =[[UITextField alloc]init];
    
        [_view_2 addSubview:_textFieldName];
        [_textFieldName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_contactTitle.mas_bottom).mas_equalTo(15);
            make.left.mas_equalTo(_nameLab.mas_right).mas_equalTo(10);
            make.size.mas_equalTo(CGSizeMake(130, 30));
        }];
    }
    return _textFieldName;
}
-(UITextField *)textFieldTel
{
    if (!_textFieldTel) {
        _textFieldTel =[[UITextField alloc]init];
        _textFieldTel.placeholder =@"输入标题";
        [_view_2 addSubview:_textFieldTel];
        [_textFieldTel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.topMargin.mas_equalTo(_telLab.mas_topMargin).mas_equalTo(-5);
            make.leftMargin.mas_equalTo(_textFieldName.mas_leftMargin);
            make.size.mas_equalTo(CGSizeMake(286, 30));
        }];
    }
    return _textFieldTel;
}

-(UIButton *)publishSenderMessage
{
    if (!_publishSenderMessage) {
        _publishSenderMessage =[UIButton buttonWithType:0];
        _publishSenderMessage.backgroundColor=kRGBColor(123, 123, 123);
        [_publishSenderMessage setTitle:@"发布" forState:UIControlStateNormal];
 
        [self addSubview:_publishSenderMessage];
        [_publishSenderMessage mas_makeConstraints:^(MASConstraintMaker *make) {
        
            make.left.right.mas_equalTo(0);
            make.bottom.mas_equalTo(0);
            make.height.mas_equalTo(40);
        }];
    }
    return _publishSenderMessage;
}
-(UILabel *)addressLabel
{
    if (!_addressLabel) {
        _addressLabel =[[UILabel alloc]init];
       
        _addressLabel.font=[UIFont systemFontOfSize:15];
        _addressLabel.textColor=kRGBColor(123, 123, 123);
        _addressLabel.textAlignment=NSTextAlignmentLeft;
        [_view_2 addSubview:_addressLabel];
        [_addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_telLab.mas_bottom).mas_equalTo(20);
            make.leftMargin.mas_equalTo(_telLab.mas_leftMargin);
        }];
    }
    return _addressLabel;
}
-(UITextField *)addressTextField
{
    if (!_addressTextField) {
        _addressTextField =[[UITextField alloc]init];
        [_view_2 addSubview:_addressTextField];
        [_addressTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.topMargin.mas_equalTo(_addressLabel.mas_topMargin).mas_equalTo(-5);
            make.left.mas_equalTo(_addressLabel.mas_right).mas_equalTo(10);
            make.size.mas_equalTo(CGSizeMake(286, 30));
        }];
    }
    return _addressTextField;
}

@end
