//
//  WorkFlowSearchVC.m
//  smartRhino
//
//  Created by tederen on 2019/11/5.
//  Copyright © 2019 tederen. All rights reserved.
//

#import "WorkFlowSearchVC.h"
#import "InfoSearchView.h"
#import "WorkFlowSearchView.h"
#import "WorkFlowSearchDetailVC.h"
@interface WorkFlowSearchVC ()<InfoSearchViewDelegate,WorkFlowSearchViewDelegate>
@property (nonatomic, strong) InfoSearchView *topNavSearch;
@property (nonatomic, strong) WorkFlowSearchView *workFlowSearchView;
@property (nonatomic, strong) UIView *myBackImageView;
@end

@implementation WorkFlowSearchVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.fd_prefersNavigationBarHidden = YES;
    [self.view addSubview:self.myBackImageView];
    self.view.backgroundColor = UIColorHex(EEEEEE);
    [self.view addSubview:self.topNavSearch];
    self.topNavSearch.searchPlaceholder = @" 搜索标题、编号、正文内容";
    [self.topNavSearch.searchBar becomeFirstResponder];
    [self.view addSubview:self.workFlowSearchView];
}
#pragma mark - InfoSearchViewDelegate
- (void)searchButtonAction:(UISearchBar *)searchBar {
    [self goDetailController:searchBar.text];
//    [self gotoDetailSearchList];
}
#pragma mark - setter
- (InfoSearchView *)topNavSearch {
    if (!_topNavSearch) {
        _topNavSearch = [[InfoSearchView alloc] initWithFrame:CGRectMake(0, (IS_IPHONEX?40:20), kGXScreenWidth, 45) type:InfoSearchViewTypeDefault];
        _topNavSearch.delegate = self;
        WEAKSELF
        _topNavSearch.backBlock = ^{
            STRONGSELF
            [strongSelf.navigationController popViewControllerAnimated:YES];
        };
//        [_topNavSearch showLineView];
    }
    return _topNavSearch;
}
- (WorkFlowSearchView *)workFlowSearchView{
    if (!_workFlowSearchView) {
        _workFlowSearchView = [[WorkFlowSearchView alloc] initWithFrame:CGRectMake(15,  (IS_IPHONEX?40:20) + 45 + 35, kGXScreenWidth -30,130.f)];
        _workFlowSearchView.delegate = self;
    }
    return _workFlowSearchView;
}
- (UIView *)myBackImageView{
    if (!_myBackImageView) {
        _myBackImageView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kGXScreenHeigh, kNavigationHeight-1)];
        _myBackImageView.backgroundColor = [UIColor whiteColor];
    }
    return _myBackImageView;
}
- (void)didSelectWorkFlowSearchViewAction:(TDButton *)sender{
    [self goDetailController:@""];
}


- (void)goDetailController:(NSString *)searchString{
    WorkFlowSearchDetailVC *workFlowSearchDetailVC = [[WorkFlowSearchDetailVC alloc ]init];
    workFlowSearchDetailVC.typeString = self.typeString;
    workFlowSearchDetailVC.apprvovalType = self.apprvovalType;
    workFlowSearchDetailVC.pageType = self.pageType;
    [workFlowSearchDetailVC goDetailController:searchString];
    [self.navigationController pushViewController:workFlowSearchDetailVC animated:YES];
}
@end