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

#import "XVHealthCardViewController.h"
#import "XVHealthCardStatusView.h"
#import "XVHealthCardTypeViewController.h"

@interface XVHealthCardViewController ()

@property (nonatomic, strong) UIScrollView *scrollView;


@property (nonatomic, strong) XVHealthCardStatusView *statusView;

@property (nonatomic, strong) UIButton *uploadButton;

@end

@implementation XVHealthCardViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"健康证";
    
    [self setupUI];
}

- (void)setupUI {
    
    
    [self.view addSubview:self.uploadButton];
    [self.uploadButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view).mas_offset(15);
        make.right.mas_equalTo(self.view).mas_offset(-15);
        make.height.mas_equalTo(47);
        if (@available(iOS 11.0, *)) {
            make.bottom.mas_equalTo(self.view.mas_safeAreaLayoutGuideBottom).mas_offset(-7);
        } else {
            make.bottom.mas_equalTo(self.view).mas_offset(-7);
        }
    }];
    
    kViewBorderRadius(self.uploadButton, 4, 0, COLOR_THEMEGRENN);
    
    [self.view addSubview:self.scrollView];
    [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(self.view);
        make.bottom.mas_equalTo(self.uploadButton.mas_top);
    }];
    
    [self.scrollView addSubview:self.statusView];
    [self.statusView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.scrollView).mas_offset(18);
        make.left.mas_equalTo(self.view).mas_offset(9);
        make.right.mas_equalTo(self.view).mas_offset(-9);
        make.height.mas_equalTo(165*widthScale);
    }];
    kViewBorderRadius(self.statusView, 20, 0, [UIColor whiteColor]);
}

- (UIButton *)uploadButton {
    if (_uploadButton == nil) {
        _uploadButton = [[UIButton alloc]initWithTitle:@"上传健康证" fontSize:14 titleColor:[UIColor whiteColor] bgColor:COLOR_THEMEGRENN];
        [_uploadButton addBlockForControlEvents:(UIControlEventTouchUpInside) block:^(id  _Nonnull sender) {
            XVHealthCardTypeViewController *typeVc = [[XVHealthCardTypeViewController alloc]init];
            [self.navigationController pushViewController:typeVc animated:YES];
        }];
    }
    return _uploadButton;
}

- (UIScrollView *)scrollView {
    if (_scrollView == nil) {
        _scrollView = [[UIScrollView alloc]init];
        _scrollView.backgroundColor = DEFAULT_BACKGROUND_COLOR;
        _scrollView.alwaysBounceVertical = YES;
    }
    return _scrollView;
}

- (XVHealthCardStatusView *)statusView {
    if (_statusView == nil) {
        _statusView = [[XVHealthCardStatusView alloc]init];
        _statusView.backgroundColor = [UIColor whiteColor];
    }
    return _statusView;
}

@end
