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

#import "XVOrderInfoViewController.h"
#import "XVOrderInfoTopView.h"
#import "XVOrderInfoViewCell.h"

#define ORIGIN_Y_MIN 0
#define ORIGIN_Y_MID 180
#define ORIGIN_Y_MAX 360


@interface XVOrderInfoViewController ()<UIGestureRecognizerDelegate>


@property (nonatomic, strong) XVOrderInfoTopView *topView;
@property (nonatomic, strong) UITableView *tableView;

@end

@implementation XVOrderInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [[UIColor whiteColor]colorWithAlphaComponent:0];
    
    [self setupUI];
    
}
- (void)setupUI {
    
    [self.view addSubview:self.scrollView];
    self.scrollView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-KTOP_HEIGHT);
    
    [self.scrollView addSubview:self.topView];
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.view);
        make.top.mas_equalTo(self.scrollView);
    }];
    

    [self.scrollView addSubview:self.tableView];
    [self.tableView layoutIfNeeded];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.topView.mas_bottom);
        make.left.right.mas_equalTo(self.view);
        make.height.mas_equalTo(self.tableView.contentSize.height);
        make.bottom.mas_equalTo(self.scrollView);
    }];

    
}

#pragma mark - TableViewDelegate & Datasource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    XVOrderInfoViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"XVOrderInfoViewCell"];
    cell.backgroundColor = [UIColor whiteColor];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 54;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 54)];
    UILabel *label = [[UILabel alloc]initWithText:@"订单信息" textColor:F_101010_COLOR textAlignment:(NSTextAlignmentLeft) fontSize:18];
    label.font = [UIFont boldSystemFontOfSize:18];
    label.frame = CGRectMake(25, 20, SCREEN_WIDTH-40, 25);
    [v addSubview:label];
    v.backgroundColor = [UIColor whiteColor];
    return v;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    if(section == 2) {
        return CGFLOAT_MIN;
    }else{
        return 1;
    }
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    UIView *v = [[UIView alloc]initWithFrame:CGRectMake(22, 0, SCREEN_WIDTH-44, 1)];
    
    v.backgroundColor = kHexRGB(0xEEEEEE);
    return v;

}



- (UIScrollView *)scrollView {
    if(_scrollView == nil) {
        _scrollView = [[UIScrollView alloc]init];
        _scrollView.backgroundColor = [[UIColor whiteColor]colorWithAlphaComponent:0];

    }
    return _scrollView;
}

- (XVOrderInfoTopView *)topView {
    if(_topView == nil) {
        _topView = [[XVOrderInfoTopView alloc]init];
        _topView.backgroundColor = [UIColor whiteColor];
    }
    return _topView;
}

- (UITableView *)tableView {
    if (_tableView == nil) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.emptyDataSetSource = self;
        _tableView.emptyDataSetDelegate = self;
        _tableView.tableFooterView = [UIView new];
        _tableView.backgroundColor = [UIColor whiteColor];
        _tableView.scrollEnabled = NO;

        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.estimatedRowHeight = 0;
        _tableView.estimatedSectionFooterHeight = 0;
        _tableView.estimatedSectionHeaderHeight = 0;
        
        [_tableView registerClass:[XVOrderInfoViewCell class] forCellReuseIdentifier:@"XVOrderInfoViewCell"];

    }
    return _tableView;
}
@end
