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

#import "XVOrderInfoTopView.h"

@interface XVOrderInfoTopView()
// 直送
@property (nonatomic, strong) UILabel *orderTypeLabel;
// 18:00 立即取货
@property (nonatomic, strong) UILabel *timeLabel;

// ¥5.5
@property (nonatomic, strong) UILabel *priceLabel;

@property (nonatomic, strong) UIImageView *quImageView;

@property (nonatomic, strong) UILabel *quLabel;

@property (nonatomic, strong) UIImageView *shouImageView;

@property (nonatomic, strong) UILabel *shouLabel;


// tagView
@property (nonatomic, strong) UIView *tagView;

// 取货地址
@property (nonatomic, strong) UILabel *pickupAddressLabel;
// 取货详细地址
@property (nonatomic, strong) UILabel *pickupDetailAddressLabel;

@property (nonatomic, strong) UIView *lineView;

@property (nonatomic, strong) UIButton *pickupCallBtn;

@property (nonatomic, strong) UIButton *deliveryCallBtn;


@property (nonatomic, strong) UILabel *distanceLabel;
@property (nonatomic, strong) UILabel *deliveryAddressLabel;
// 收货人
@property (nonatomic, strong) UILabel *deliveryNameLabel;

// 分割线
@property (nonatomic, strong) UIView *dividerView;

@property (nonatomic, strong) UIView *remarkBgView;

// 备注
@property (nonatomic, strong) YYLabel *remarkLabel;
@end

@implementation XVOrderInfoTopView


- (instancetype)initWithFrame:(CGRect)frame {
    if(self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    
    [self addSubview:self.lineView];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(30, 1));
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self).mas_offset(13);
    }];
    
    [self addSubview:self.orderTypeLabel];
    [self.orderTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self).mas_offset(34);
        make.left.mas_equalTo(self).mas_offset(25);
        make.size.mas_equalTo(CGSizeMake(62, 25));
    }];
    kViewBorderRadius(self.orderTypeLabel, 5, 0, [UIColor clearColor]);
    
    [self addSubview:self.priceLabel];
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self).mas_offset(-28);
        make.centerY.mas_equalTo(self.orderTypeLabel);
    }];
    
    [self addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.orderTypeLabel.mas_right).mas_offset(19);
        make.centerY.mas_equalTo(self.orderTypeLabel);
    }];
    
    [self addSubview:self.quImageView];
    [self.quImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.orderTypeLabel.mas_bottom).mas_offset(27);
        make.left.mas_equalTo(self.orderTypeLabel);
        make.size.mas_equalTo(CGSizeMake(24, 24));
    }];
    
    [self addSubview:self.pickupCallBtn];
    [self.pickupCallBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.quImageView);
        make.size.mas_equalTo(CGSizeMake(30, 30));
        make.right.mas_equalTo(self).mas_offset(-28);
    }];
    
    [self addSubview:self.pickupAddressLabel];
    [self.pickupAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.quImageView.mas_right).mas_offset(4);
        make.right.mas_equalTo(self.pickupCallBtn.mas_left).mas_offset(-28);
        make.centerY.mas_equalTo(self.quImageView);
    }];
    
    [self addSubview:self.pickupDetailAddressLabel];
    [self.pickupDetailAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.pickupAddressLabel);
        make.right.mas_equalTo(self.pickupAddressLabel);
        make.top.mas_equalTo(self.pickupAddressLabel.mas_bottom).mas_offset(8);
    }];

    [self addSubview:self.shouImageView];
    [self.shouImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.height.mas_equalTo(self.quImageView);
        make.top.mas_equalTo(self.pickupDetailAddressLabel.mas_bottom).mas_offset(25);
    }];
    
    [self addSubview:self.deliveryCallBtn];
    [self.deliveryCallBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.width.height.mas_equalTo(self.pickupCallBtn);
        make.centerY.mas_equalTo(self.shouImageView);
    }];
    
    [self addSubview:self.deliveryAddressLabel];
    [self.deliveryAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.shouImageView.mas_right).mas_offset(4);
        make.right.mas_equalTo(self.deliveryCallBtn.mas_left).mas_offset(-28);
        make.centerY.mas_equalTo(self.shouImageView);
    }];
    
    [self addSubview:self.deliveryNameLabel];
    [self.deliveryNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.deliveryAddressLabel);
        make.top.mas_equalTo(self.deliveryAddressLabel.mas_bottom).mas_offset(8);
    }];
    
    [self addSubview:self.dividerView];
    [self.dividerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).mas_offset(22);
        make.right.mas_equalTo(self).mas_offset(-22);
        make.top.mas_equalTo(self.deliveryNameLabel.mas_bottom).mas_offset(14);
        make.height.mas_equalTo(1);
    }];
    
    [self addSubview:self.tagView];
    [self.tagView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).mas_offset(20);
        make.right.mas_equalTo(self).mas_offset(-20);
        make.top.mas_equalTo(self.dividerView.mas_bottom).mas_offset(12);
        make.height.mas_equalTo(20);
    }];
    
    [self addSubview:self.remarkBgView];
    [self.remarkBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).mas_offset(20);
        make.right.mas_equalTo(self).mas_offset(-20);
        make.top.mas_equalTo(self.tagView.mas_bottom).mas_offset(12);
        make.bottom.mas_equalTo(self);
    }];
    
    [self.remarkBgView addSubview:self.remarkLabel];
    [self.remarkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(22, 26, 22, 26));
    }];
    

    
}

- (UIView *)lineView {
    if (_lineView == nil) {
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = F_BBBBBB_COLOR;
    }
    return _lineView;
}

- (UILabel *)orderTypeLabel {
    if(_orderTypeLabel == nil) {
        _orderTypeLabel = [[UILabel alloc]initWithText:@"直送" textColor:[UIColor whiteColor] textAlignment:(NSTextAlignmentCenter) fontSize:10];
        _orderTypeLabel.backgroundColor = COLOR_THEMEGRENN;
    }
    return _orderTypeLabel;
}

- (UILabel *)timeLabel {
    if(_timeLabel == nil) {
        _timeLabel = [[UILabel alloc]initWithText:@"18:00 立即取货" textColor:[UIColor colorWithHexString:@"#585858"] textAlignment:(NSTextAlignmentCenter) fontSize:18];
    }
    return _timeLabel;
}

- (UILabel *)priceLabel {
    if(_priceLabel == nil) {
        _priceLabel = [[UILabel alloc]initWithText:@"¥5.5" textColor:[UIColor colorWithHexString:@"##FF461F"] textAlignment:(NSTextAlignmentCenter) fontSize:18];
    }
    return _priceLabel;
}

- (UIImageView *)quImageView {
    
    if(_quImageView == nil) {
        _quImageView = [[UIImageView alloc]initWithImageName:@"fas fa-map-marker"];
        [_quImageView addSubview:self.quLabel];
        [self.quLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_equalTo(UIEdgeInsetsMake(2, 6, 5, 6));
        }];
    }
    return _quImageView;
}

- (UILabel *)quLabel {
    if(_quLabel == nil) {
        _quLabel = [[UILabel alloc]initWithText:@"取" textColor:[UIColor whiteColor] textAlignment:(NSTextAlignmentCenter) fontSize:12];
    }
    return _quLabel;
}

- (UIImageView *)shouImageView {
    
    if(_shouImageView == nil) {
        _shouImageView = [[UIImageView alloc]initWithImageName:@"fas fa-map-marker1"];
        [_shouImageView addSubview:self.shouLabel];
        [self.shouLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_equalTo(UIEdgeInsetsMake(2, 6, 5, 6));
        }];

    }
    return _shouImageView;
}

- (UILabel *)shouLabel {
    if(_shouLabel == nil) {
        _shouLabel = [[UILabel alloc]initWithText:@"收" textColor:[UIColor whiteColor] textAlignment:(NSTextAlignmentCenter) fontSize:12];
    }
    return _shouLabel;
}

- (UIButton *)pickupCallBtn {
    if(_pickupCallBtn == nil) {
        _pickupCallBtn = [[UIButton alloc]initWithNormalImageName:@"if-phone-circle" selectedImgName:@"if-phone-circle"];
    }
    return _pickupCallBtn;
}

- (UIButton *)deliveryCallBtn {
    if(_deliveryCallBtn == nil) {
        _deliveryCallBtn = [[UIButton alloc]initWithNormalImageName:@"if-phone-circle Copy" selectedImgName:@"if-phone-circle Copy"];
    }
    return _deliveryCallBtn;
}

- (UIView *)tagView {
    if (_tagView == nil) {
        _tagView = [[UIView alloc]init];
        _tagView.backgroundColor = kRandomColor;
    }
    return _tagView;
}

- (UILabel *)distanceLabel {
    if (_distanceLabel == nil) {
        _distanceLabel = [[UILabel alloc]initWithText:@"1.9" textColor:F_101010_COLOR textAlignment:(NSTextAlignmentCenter) fontSize:12];
        _distanceLabel.numberOfLines = 0;
    }
    return _distanceLabel;
}



- (UILabel *)pickupAddressLabel {
    if (_pickupAddressLabel == nil) {
        _pickupAddressLabel = [[UILabel alloc]initWithText:@"小鱼的测试店铺(花园桥店) " textColor:F_101010_COLOR textAlignment:(NSTextAlignmentLeft) fontSize:20];
        _pickupAddressLabel.numberOfLines = 0;
        _pickupAddressLabel.font = [UIFont boldSystemFontOfSize:20];
    }
    return _pickupAddressLabel;
}
- (UILabel *)pickupDetailAddressLabel {
    if (_pickupDetailAddressLabel == nil) {
        _pickupDetailAddressLabel = [[UILabel alloc]initWithText:@"北京动物园大猩猩馆000000000" textColor:F_101010_COLOR textAlignment:(NSTextAlignmentLeft) fontSize:12];
        _pickupDetailAddressLabel.numberOfLines = 0;
    }
    return _pickupDetailAddressLabel;
}
- (UILabel *)deliveryAddressLabel {
    if (_deliveryAddressLabel == nil) {
        _deliveryAddressLabel = [[UILabel alloc]initWithText:@"白石桥南地铁站" textColor:F_101010_COLOR textAlignment:(NSTextAlignmentLeft) fontSize:18];
        _deliveryAddressLabel.numberOfLines = 0;
        _deliveryAddressLabel.font = [UIFont boldSystemFontOfSize:20];
    }
    return _deliveryAddressLabel;
}

- (UILabel *)deliveryNameLabel {
    if (_deliveryNameLabel == nil) {
        _deliveryNameLabel = [[UILabel alloc]initWithText:@"收货人:嫦娥仙子" textColor:F_101010_COLOR textAlignment:(NSTextAlignmentLeft) fontSize:14];
        _deliveryNameLabel.numberOfLines = 0;
        
    }
    return _deliveryNameLabel;

}

- (UIView *)dividerView {
    if(_dividerView == nil) {
        _dividerView = [[UIView alloc]init];
        _dividerView.backgroundColor = kHexRGB(0xEEEEEE);
    }
    return _dividerView;
}

- (UIView *)remarkBgView {
    if(_remarkBgView == nil) {
        _remarkBgView = [[UIView alloc]init];
        _remarkBgView.backgroundColor = RGBAColor(250, 140, 53, 0.09);
    }
    return _remarkBgView;
}

- (YYLabel *)remarkLabel {
    if (_remarkLabel == nil) {
        _remarkLabel = [[YYLabel alloc]init];
        _remarkLabel.text = @"这里是备注";
        _remarkLabel.font = [UIFont systemFontOfSize:14];
        _remarkLabel.backgroundColor = RGBAColor(250, 140, 53, 0.09);
        _remarkLabel.textColor = kHexRGB(0x808080);
        _remarkLabel.preferredMaxLayoutWidth = SCREEN_WIDTH - 84;
        _remarkLabel.textTapAction = ^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
            //点击展开

        };
    }
    return _remarkLabel;
}



@end
