//
//  XVOrderSettingViewController.m
//  fastservice
//
//  Created by xuning on 2/8/24.
//  Copyright © 2024 FastService. All rights reserved.
//

#import "XVOrderSettingViewController.h"
#import "XVOrderSettiingTitleView.h"
#import "XVOrderSettingView.h"
#import "XVVerticalButton.h"
#import "XVDispatchOrderAlter.h"

@interface XVOrderSettingViewController ()

@property (nonatomic, strong) UIScrollView *scrollView;

@property (nonatomic, strong) XVOrderSettiingTitleView *title1View;
@property (nonatomic, strong) XVOrderSettingView *switch1View;
@property (nonatomic, strong) XVOrderSettingView *switch2View;
@property (nonatomic, strong) XVOrderSettingView *switch3View;
@property (nonatomic, strong) XVOrderSettingView *switch4View;
@property (nonatomic, strong) XVOrderSettingView *switch5View;
@property (nonatomic, strong) XVOrderSettingView *switch6View;


@property (nonatomic, strong) XVOrderSettiingTitleView *title2View;
@property (nonatomic, strong) XVOrderSettingView *switch7View;
@property (nonatomic, strong) XVOrderSettingView *switch8View;

@property (nonatomic, strong) XVOrderSettiingTitleView *title3View;
@property (nonatomic, strong) UIView *bottomView;
@property (nonatomic, strong) XVVerticalButton *orderTestButton;
@property (nonatomic, strong) XVVerticalButton *pushTestButton;



@end

@implementation XVOrderSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"接单设置";
    [self setupUI];
}
- (void)setupUI {
//    XVDispatchOrderAlter *view = [[XVDispatchOrderAlter alloc]init];
//    [self.view addSubview:view];
//    [view mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.right.top.mas_equalTo(self.view);
//    }];
//    return;
    [self.view addSubview:self.scrollView];
    
    [self.scrollView addSubview:self.title1View];
    [self.title1View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view).mas_offset(7);
        make.right.mas_equalTo(self.view).mas_offset(-7);
        make.top.mas_equalTo(self.scrollView).mas_offset(5);
        make.height.mas_equalTo(40);
    }];
    
    [self.scrollView addSubview:self.switch1View];
    [self.switch1View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.title1View);
        make.height.mas_equalTo(44);
        make.top.mas_equalTo(self.title1View.mas_bottom);
    }];
    
    [self.scrollView addSubview:self.switch2View];
    [self.switch2View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.mas_equalTo(self.switch1View);
        make.top.mas_equalTo(self.switch1View.mas_bottom);
    }];
    
    [self.scrollView addSubview:self.switch3View];
    [self.switch3View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.mas_equalTo(self.switch1View);
        make.top.mas_equalTo(self.switch2View.mas_bottom);
    }];
    [self.scrollView addSubview:self.switch4View];
    [self.switch4View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.mas_equalTo(self.switch1View);
        make.top.mas_equalTo(self.switch3View.mas_bottom);
    }];
    [self.scrollView addSubview:self.switch5View];
    [self.switch5View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.mas_equalTo(self.switch1View);
        make.top.mas_equalTo(self.switch4View.mas_bottom);
    }];
    [self.scrollView addSubview:self.switch6View];
    [self.switch6View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.mas_equalTo(self.switch1View);
        make.top.mas_equalTo(self.switch5View.mas_bottom);
    }];

    [self.scrollView addSubview:self.title2View];
    [self.title2View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.mas_equalTo(self.title1View);
        make.top.mas_equalTo(self.switch6View.mas_bottom).mas_offset(5);

    }];
    [self.scrollView addSubview:self.switch7View];
    [self.switch7View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.mas_equalTo(self.switch1View);
        make.top.mas_equalTo(self.title2View.mas_bottom);
    }];

    [self.scrollView addSubview:self.switch8View];
    [self.switch8View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.mas_equalTo(self.switch1View);
        make.top.mas_equalTo(self.switch7View.mas_bottom);
    }];
    [self.scrollView addSubview:self.title3View];
    [self.title3View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.mas_equalTo(self.title1View);
        make.top.mas_equalTo(self.switch8View.mas_bottom).mas_offset(5);

    }];
    [self.scrollView addSubview:self.bottomView];
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.title1View);
        make.top.mas_equalTo(self.title3View.mas_bottom);
        make.height.mas_equalTo(197);
        make.bottom.mas_equalTo(self.scrollView).mas_offset(-5);
    }];
    
    [self.bottomView addSubview:self.orderTestButton];
    [self.orderTestButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.bottomView).mas_offset(18);
        make.size.mas_equalTo(CGSizeMake(50, 48));
        make.top.mas_equalTo(self.title3View.mas_bottom).mas_offset(12);
    }];

    [self.bottomView addSubview:self.pushTestButton];
    [self.pushTestButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.orderTestButton.mas_right).mas_offset(13);
        make.size.mas_equalTo(CGSizeMake(50, 48));
        make.top.mas_equalTo(self.title3View.mas_bottom).mas_offset(12);
    }];

    
    
    [self.view layoutIfNeeded];
    
    [self.title1View addRoundedCorners:UIRectCornerTopLeft | UIRectCornerTopRight withRadii:CGSizeMake(10, 10)];
    [self.switch6View addRoundedCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight withRadii:CGSizeMake(10, 10)];

    [self.title2View addRoundedCorners:UIRectCornerTopLeft | UIRectCornerTopRight withRadii:CGSizeMake(10, 10)];
    [self.switch8View addRoundedCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight withRadii:CGSizeMake(10, 10)];

    [self.title3View addRoundedCorners:UIRectCornerTopLeft | UIRectCornerTopRight withRadii:CGSizeMake(10, 10)];
    [self.bottomView addRoundedCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight withRadii:CGSizeMake(10, 10)];

    
}

- (UIScrollView *)scrollView {
    if(_scrollView == nil) {
        _scrollView = [[UIScrollView alloc]initWithFrame:self.view.bounds];
        _scrollView.backgroundColor = DEFAULT_BACKGROUND_COLOR;
        _scrollView.alwaysBounceVertical = YES;
    }
    return _scrollView;
}

- (XVOrderSettiingTitleView *)title1View {
    if(_title1View == nil) {
        _title1View = [[XVOrderSettiingTitleView alloc]initWithTitle:@"抢单设置"];
    }
    return _title1View;
}
- (XVOrderSettingView *)switch1View {
    if(_switch1View == nil) {
        _switch1View = [[XVOrderSettingView alloc]initWithTitle:@"抢单模式（点击）"];
        
    }
    return _switch1View;
}

- (XVOrderSettingView *)switch2View {
    if(_switch2View == nil) {
        _switch2View = [[XVOrderSettingView alloc]initWithTitle:@"新订单弹窗"];
        
    }
    return _switch2View;
}


- (XVOrderSettingView *)switch3View {
    if(_switch3View == nil) {
        _switch3View = [[XVOrderSettingView alloc]initWithTitle:@"新订单语音播报"];
        
    }
    return _switch3View;
}


- (XVOrderSettingView *)switch4View {
    if(_switch4View == nil) {
        _switch4View = [[XVOrderSettingView alloc]initWithTitle:@"新订单/派单消息震动"];
        
    }
    return _switch4View;
}


- (XVOrderSettingView *)switch5View {
    if(_switch5View == nil) {
        _switch5View = [[XVOrderSettingView alloc]initWithTitle:@"抢单免弹框确认"];
        
    }
    return _switch5View;
}


- (XVOrderSettingView *)switch6View {
    if(_switch6View == nil) {
        _switch6View = [[XVOrderSettingView alloc]initWithTitle:@"开启屏幕常亮"];
        
    }
    return _switch6View;
}

- (XVOrderSettiingTitleView *)title2View {
    if(_title2View == nil) {
        _title2View = [[XVOrderSettiingTitleView alloc]initWithTitle:@"接单偏好"];
    }
    return _title2View;
}


- (XVOrderSettingView *)switch7View {
    if(_switch7View == nil) {
        _switch7View = [[XVOrderSettingView alloc]initWithTitle:@"不看预约单"];
        
    }
    return _switch7View;
}

- (XVOrderSettingView *)switch8View {
    if(_switch8View == nil) {
        _switch8View = [[XVOrderSettingView alloc]initWithTitle:@"顺路单推送"];
        
    }
    return _switch8View;
}
- (XVOrderSettiingTitleView *)title3View {
    if(_title3View == nil) {
        _title3View = [[XVOrderSettiingTitleView alloc]initWithTitle:@"检测工具"];
    }
    return _title3View;
}


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

- (XVVerticalButton *)orderTestButton {
    if(_orderTestButton == nil) {
        _orderTestButton =  [[XVVerticalButton alloc] init];
        _orderTestButton.imageIsRound = NO;
        _orderTestButton.imageViewMaxSize = CGSizeMake(24, 24);
        _orderTestButton.imageTextSpace = 3;
        [_orderTestButton setImage:IMG(@"ceshi") forState:(UIControlStateNormal)];
        [_orderTestButton setTitle:@"接单检测" forState:UIControlStateNormal];
        [_orderTestButton setTitleColor:F_606060_COLOR forState:UIControlStateNormal];
        _orderTestButton.titleLabel.font = [UIFont systemFontOfSize:12];
    }
    return _orderTestButton;
}
- (XVVerticalButton *)pushTestButton {
    if(_pushTestButton == nil) {
        _pushTestButton =  [[XVVerticalButton alloc] init];
        _pushTestButton.imageIsRound = NO;
        _pushTestButton.imageViewMaxSize = CGSizeMake(24, 24);
        _pushTestButton.imageTextSpace = 3;
        [_pushTestButton setImage:IMG(@"ceshi") forState:(UIControlStateNormal)];
        [_pushTestButton setTitle:@"推送测试" forState:UIControlStateNormal];
        [_pushTestButton setTitleColor:F_606060_COLOR forState:UIControlStateNormal];
        _pushTestButton.titleLabel.font = [UIFont systemFontOfSize:12];
    }
    return _pushTestButton;
}


@end
