//
//  HWToolBar.m
//  双子星云手机
//
//  Created by 余衡武 on 2022/3/9.
//

#import "HWToolBar.h"

@implementation HWToolBar

+ (instancetype)shareInstance {
    return [[NSBundle mainBundle] loadNibNamed:@"HWToolBar" owner:self options:nil].firstObject;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self.backBtn setTitle:@"" forState:(UIControlStateNormal)];
    [self.forwardBtn setTitle:@"" forState:(UIControlStateNormal)];
    [self.toolBtn setTitle:@"" forState:(UIControlStateNormal)];
    [self.homeBtn setTitle:@"" forState:(UIControlStateNormal)];
    [self.pageBtn setTitle:@"" forState:(UIControlStateNormal)];
    self.backBtn.enabled = NO;
    self.forwardBtn.enabled = NO;
    
    self.lineVIew.backgroundColor = HWFFFFFF08Color;
    self.backgroundColor = HW1D1E1FColor;
}

#pragma mark 点击事件
- (IBAction)backBtnClick:(UIButton *)sender {
//    HLog(@"后退");
    if ([_delegate respondsToSelector:@selector(backBtnDidClick)]) {
        [_delegate backBtnDidClick];
    }
}

- (IBAction)forwardBtnClick:(UIButton *)sender {
//    HLog(@"前进");
    if ([_delegate respondsToSelector:@selector(forwardBtnDidClick)]) {
        [_delegate forwardBtnDidClick];
    }
}

- (IBAction)toolBtnClick:(UIButton *)sender {
//    HLog(@"工具");
    if ([_delegate respondsToSelector:@selector(toolBtnDidClick)]) {
        [_delegate toolBtnDidClick];
    }
}

- (IBAction)homeBtnClick:(UIButton *)sender {
//    HLog(@"主页");
    
    if ([_delegate respondsToSelector:@selector(homeBtnDidClick)]) {
        [_delegate homeBtnDidClick];
    }
}

- (IBAction)pageBtnClick:(UIButton *)sender {
//    HLog(@"页面");
    self.pageBtn.enabled = NO;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        self.pageBtn.enabled = YES;
    });
    
    if ([_delegate respondsToSelector:@selector(pageBtnDidClick)]) {
        [_delegate pageBtnDidClick];
    }
}

@end
