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

#import "XVNaviViewController.h"

@interface XVNaviViewController ()

@end

@implementation XVNaviViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.interactivePopGestureRecognizer.delegate=(id)self;
}

- (void)back {
    // 判断两种情况: push 和 present
    if ((self.presentedViewController || self.presentingViewController) && self.childViewControllers.count == 1) {
        [self dismissViewControllerAnimated:YES completion:nil];
    }else{
        [self popViewControllerAnimated:YES];
    }
    
}


#pragma mark - 非根控制器隐藏底部tabbar
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(back) image:IMG(@"fanhui")];
        
    }
    [super pushViewController:viewController animated:animated];
    
    //解决iPhone X Push 过程中 TabBar 位置上移
    CGRect frame = self.tabBarController.tabBar.frame;
    frame.origin.y = [UIScreen mainScreen].bounds.size.height - frame.size.height;
    self.tabBarController.tabBar.frame = frame;
}

@end
