//
//  XVMyViewController.m
//  fastservice
//
//  Created by xuning on 4/28/25.
//  Copyright © 2025 FastService. All rights reserved.
//

#import "XVMyViewController.h"
#import "XVMyCertificateView.h"

@interface XVMyViewController ()
@property (nonatomic, strong) UIImageView *userImageView;

@property (nonatomic, strong) UILabel *nameLabel;

@property (nonatomic, strong) UIImageView *levelImageView;

@property (nonatomic, strong) UILabel *phoneLabel;


@property (nonatomic, strong) UIButton *eyeButton;

// 健康证
@property (nonatomic, strong) UIButton *healthButton;

@property (nonatomic, strong) UIButton *idButton;

@property (nonatomic, strong) UIImageView *levelBgView;


@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UIView *bottomView;


@property (nonatomic, strong) XVMyCertificateView *realNameView;

@property (nonatomic, strong) XVMyCertificateView *vehicleView;

@property (nonatomic, strong) XVMyCertificateView *healthView;

@property (nonatomic, strong) XVMyCertificateView *deviceView;



@end

@implementation XVMyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavigationBarsetBackgroundColor:DEFAULT_BACKGROUND_COLOR];
    [self setupUI];
}

- (void)setupUI {
    
    [self.view addSubview:self.userImageView];
    [self.userImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view).mas_offset(11);
        make.left.mas_equalTo(self.view).mas_offset(25);
        make.size.mas_equalTo(CGSizeMake(66, 66));
    }];
    
    [self.view addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.userImageView.mas_right).mas_offset(13);
        make.top.mas_equalTo(self.userImageView);
    }];
    
    [self.view addSubview:self.levelImageView];
    [self.levelImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.nameLabel);
        make.size.mas_equalTo(CGSizeMake(84, 24));
        make.left.mas_equalTo(self.nameLabel.mas_right).mas_offset(4);
    }];
    


    [self.view addSubview:self.phoneLabel];
    [self.phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.userImageView.mas_right).mas_offset(13);
        make.top.mas_equalTo(self.nameLabel.mas_bottom).mas_offset(7);
    }];
    
    [self.view addSubview:self.eyeButton];
    [self.eyeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(17, 17));
        make.centerY.mas_equalTo(self.phoneLabel);
        make.left.mas_equalTo(self.phoneLabel.mas_right).mas_offset(4);
    }];
    
    [self.view addSubview:self.healthButton];
    [self.healthButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(20, 20));
        make.centerY.mas_equalTo(self.phoneLabel);
        make.left.mas_equalTo(self.eyeButton.mas_right).mas_offset(4);
    }];

    
    [self.view addSubview:self.idButton];
    [self.idButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(20, 20));
        make.centerY.mas_equalTo(self.phoneLabel);
        make.left.mas_equalTo(self.healthButton.mas_right).mas_offset(4);
    }];
    
    [self.view addSubview:self.levelBgView];
    [self.levelBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.userImageView.mas_bottom).mas_offset(20);
        make.left.mas_equalTo(self.view).mas_offset(33);
        make.right.mas_equalTo(self.view).mas_offset(-33);
        make.height.mas_equalTo((SCREEN_WIDTH-70)*173/324);
    }];
    
    [self.view addSubview:self.bottomView];
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view).mas_offset(9);
        make.right.mas_equalTo(self.view).mas_offset(-9);
        make.top.mas_equalTo(self.levelBgView.mas_bottom).mas_offset(14);
        make.height.mas_equalTo(165);
    }];
    kViewBorderRadius(self.bottomView, 20, 0, [UIColor whiteColor]);
    [self.bottomView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.bottomView).mas_offset(16);
        make.left.mas_equalTo(self.bottomView).mas_offset(18);
    }];
    
    [self.bottomView addSubview:self.realNameView];
    [self.bottomView addSubview:self.vehicleView];
    [self.bottomView addSubview:self.healthView];
    [self.bottomView addSubview:self.deviceView];
    CGFloat w = (SCREEN_WIDTH-19) / 4;
    [self.realNameView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(17);
        make.left.mas_equalTo(self.bottomView);
        make.width.mas_equalTo(w);
        make.height.mas_equalTo(100);
    }];
    [self.vehicleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(17);
        make.left.mas_equalTo(self.realNameView.mas_right);
        make.width.mas_equalTo(w);
        make.height.mas_equalTo(100);
    }];

    [self.healthView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(17);
        make.left.mas_equalTo(self.vehicleView.mas_right);
        make.width.mas_equalTo(w);
        make.height.mas_equalTo(100);
    }];

    [self.deviceView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(17);
        make.left.mas_equalTo(self.healthView.mas_right);
        make.width.mas_equalTo(w);
        make.height.mas_equalTo(100);
    }];

    
}

- (UIImageView *)userImageView {
    if(_userImageView == nil) {
        _userImageView = [[UIImageView alloc]initWithImageName:@"qishi-head"];
    }
    return _userImageView;
}

- (UILabel *)nameLabel {
    if(_nameLabel == nil) {
        _nameLabel = [[UILabel alloc]initWithText:@"骑士" textColor:F_101010_COLOR textAlignment:(NSTextAlignmentLeft) fontSize:26];
    }
    return _nameLabel;
}

- (UILabel *)phoneLabel {
    if(_phoneLabel == nil) {
        _phoneLabel = [[UILabel alloc]initWithText:@"138****0018" textColor:F_101010_COLOR textAlignment:(NSTextAlignmentLeft) fontSize:20];
    }
    return _phoneLabel;
}

- (UIButton *)eyeButton {
    if (_eyeButton == nil) {
        _eyeButton = [[UIButton alloc]initWithNormalImageName:@"closeeyes" selectedImgName:@"openeyes"];
    }
    return _eyeButton;
}

- (UIButton *)healthButton {
    if (_healthButton == nil) {
        _healthButton =  [[UIButton alloc]initWithNormalImageName:@"fa5-address-card-fas 1 Copy 1" selectedImgName:@"fa5-address-card-fas 1"];
    }
    return _healthButton;
}

- (UIButton *)idButton {
    if (_idButton == nil) {
        _idButton =  [[UIButton alloc]initWithNormalImageName:@"riFill-shield-user-fill 1 Copy 1" selectedImgName:@"riFill-shield-user-fill 1"];
    }
    return _idButton;
}


- (UIImageView *)levelImageView {
    if (_levelImageView == nil) {
        _levelImageView = [[UIImageView alloc]initWithImageName:@"tongpai3x"];
        
    }
    return _levelImageView;
}

- (UIImageView *)levelBgView {
    if (_levelBgView == nil) {
        _levelBgView = [[UIImageView alloc]initWithImageName:@"群组 13"];
    }
    return _levelBgView;
}

- (UILabel *)titleLabel {
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc]initWithText:@"我的证件&设备" textColor:F_101010_COLOR textAlignment:(NSTextAlignmentLeft) fontSize:12];
        _titleLabel.font = [UIFont boldSystemFontOfSize:12];
    }
    return _titleLabel;
}

- (UIView *)bottomView {
    if (_bottomView == nil) {
        _bottomView = [[UIView alloc]init];
        _bottomView.backgroundColor = [UIColor whiteColor];
    }
    return _bottomView;
}

- (XVMyCertificateView *)realNameView {
    if (_realNameView == nil) {
        _realNameView = [[XVMyCertificateView alloc]init];
        [_realNameView setNormalImageName:@"群组 3" selectedImgName:@"群组 3" title:@"实名认证"];
    }
    return _realNameView;
}

- (XVMyCertificateView *)vehicleView {
    if (_vehicleView == nil) {
        _vehicleView = [[XVMyCertificateView alloc]init];
        [_vehicleView setNormalImageName:@"群组 1" selectedImgName:@"群组 1" title:@"车辆认证"];
    }
    return _vehicleView;
}


- (XVMyCertificateView *)healthView {
    if (_healthView == nil) {
        _healthView = [[XVMyCertificateView alloc]init];
        [_healthView setNormalImageName:@"群组 2" selectedImgName:@"群组 2" title:@"健康证"];
    }
    return _healthView;
}

- (XVMyCertificateView *)deviceView {
    if (_deviceView == nil) {
        _deviceView = [[XVMyCertificateView alloc]init];
        [_deviceView setNormalImageName:@"群组 18" selectedImgName:@"群组 18" title:@"智能设备"];
    }
    return _deviceView;
}


@end
