// // TFComicBrowseMenuView.m // TFReader // // Created by 谢腾飞 on 2020/12/16. // Copyright © 2020 xtfei_2011@126.com. All rights reserved. // #import "TFComicBrowseMenuView.h" #import "TFComicBrowseTopBar.h" #import "TFComicBrowseBottomBar.h" @interface TFComicBrowseMenuView () { TFComicBrowseTopBar *topBar; TFComicBrowseBottomBar *bottomBar; } @end @implementation TFComicBrowseMenuView implementation_singleton(TFComicBrowseMenuView) - (instancetype)init { if (self = [super init]) { [self initialize]; [self createSubViews]; } return self; } - (void)initialize { self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); self.backgroundColor = [UIColor clearColor]; self.userInteractionEnabled = YES; self.isShowing = NO; } - (void)createSubViews { topBar = [[TFComicBrowseTopBar alloc] init]; [self addSubview:topBar]; bottomBar = [[TFComicBrowseBottomBar alloc] init]; [self addSubview:bottomBar]; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self hiddenMenuView]; } - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { UIView *touchView = [super hitTest:point withEvent:event]; if (CGRectContainsPoint(topBar.bounds, point)) { if ([touchView isKindOfClass:[UIButton class]]) { return touchView; } return nil; } if ([touchView isDescendantOfView:bottomBar]) { return touchView; } return nil; } - (void)autoShowOrHiddenMenuView { if (!self.isShowing) { [self showMenuView]; } else { [self hiddenMenuView]; } } - (void)showMenuView { [bottomBar reloadCollectionState]; if (self.isShowing) { return; } self.isShowing = YES; [topBar showMenuTopBar]; [bottomBar showMenuBottomBar]; [TFViewHelper setStateBarDefaultStyle]; [UIApplication sharedApplication].statusBarHidden = NO; } - (void)hiddenMenuView { if (!self.isShowing) { return; } self.isShowing = NO; [topBar hiddenMenuTopBar]; [bottomBar hiddenMenuBottomBar]; [UIApplication sharedApplication].statusBarHidden = YES; } - (void)startLoadingData { [bottomBar startLoadingData]; } - (void)stopLoadingData { [bottomBar stopLoadingData]; } - (void)setComicChapterModel:(TFProductionChapterModel *)comicChapterModel { _comicChapterModel = comicChapterModel; if (comicChapterModel) { [topBar setNavTitle:comicChapterModel.chapter_title?:self.productionModel.name]; bottomBar.comicChapterModel = comicChapterModel; } else { [topBar setNavTitle:@""]; bottomBar.comicChapterModel = comicChapterModel; } } - (void)setProductionModel:(TFProductionModel *)productionModel { if (_productionModel != productionModel) { _productionModel = productionModel; bottomBar.productionModel = productionModel; } } @end