163 lines
6.1 KiB
Mathematica
163 lines
6.1 KiB
Mathematica
|
|
//
|
||
|
|
// BottleBaseViewController.m
|
||
|
|
// TreeHole
|
||
|
|
//
|
||
|
|
// Created by 郑创权 on 2022/10/6.
|
||
|
|
//
|
||
|
|
|
||
|
|
#import "BottleBaseViewController.h"
|
||
|
|
#import "BottleNerbyViewController.h"
|
||
|
|
#import "BottleViewController.h"
|
||
|
|
#import "BottleService.h"
|
||
|
|
#import "SetLoginUserInfoViewController.h"
|
||
|
|
#import "WZLBadgeImport.h"
|
||
|
|
//#import "ProfileViewController.h"
|
||
|
|
@interface BottleBaseViewController ()<YNPageViewControllerDataSource, YNPageViewControllerDelegate>{
|
||
|
|
NSInteger _selectIndex;
|
||
|
|
}
|
||
|
|
@property (nonatomic, strong)UIButton* navBottleBtn;
|
||
|
|
@property (nonatomic, strong)UIButton* navRightBtn;
|
||
|
|
@property (nonatomic, strong)BottleViewController *bottleVC;
|
||
|
|
@property (nonatomic, strong)BottleNerbyViewController* nerbyVC;
|
||
|
|
@end
|
||
|
|
|
||
|
|
@implementation BottleBaseViewController
|
||
|
|
|
||
|
|
|
||
|
|
- (void)viewDidLoad {
|
||
|
|
[super viewDidLoad];
|
||
|
|
// [BottleReadView showDetailWithAttach];
|
||
|
|
_selectIndex = 0;
|
||
|
|
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:self.navBottleBtn];
|
||
|
|
|
||
|
|
[_navRightBtn setImage:ImageNamed(@"TH_bottle_refresh_icon") forState:UIControlStateNormal];
|
||
|
|
|
||
|
|
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:self.navRightBtn];
|
||
|
|
}
|
||
|
|
|
||
|
|
-(UIButton *)navBottleBtn{
|
||
|
|
if (!_navBottleBtn) {
|
||
|
|
_navBottleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
|
|
_navBottleBtn.frame = CGRectMake(0, 0, FIX_SIZE(24), FIX_SIZE(24));
|
||
|
|
[_navBottleBtn setImage:ImageNamed(@"TH_chat_bottle_icon") forState:UIControlStateNormal];
|
||
|
|
[_navBottleBtn addTarget:self action:@selector(bottleButtonOnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||
|
|
}
|
||
|
|
return _navBottleBtn;
|
||
|
|
}
|
||
|
|
|
||
|
|
-(UIButton *)navRightBtn{
|
||
|
|
if (!_navRightBtn) {
|
||
|
|
_navRightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
|
|
_navRightBtn.frame = CGRectMake(0, 0, FIX_SIZE(24), FIX_SIZE(24));
|
||
|
|
[_navRightBtn setImage:ImageNamed(@"TH_bottle_refresh_icon") forState:UIControlStateNormal];
|
||
|
|
[_navRightBtn addTarget:self action:@selector(rightButtonOnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||
|
|
|
||
|
|
}
|
||
|
|
return _navRightBtn;
|
||
|
|
}
|
||
|
|
|
||
|
|
+ (instancetype)navPageVC {
|
||
|
|
YNPageConfigration *configration = [YNPageConfigration defaultConfig];
|
||
|
|
configration.pageStyle = YNPageStyleNavigation;
|
||
|
|
configration.headerViewCouldScale = YES;
|
||
|
|
configration.headerViewScaleMode = YNPageHeaderViewScaleModeTop;
|
||
|
|
configration.showTabbar = NO;
|
||
|
|
configration.showNavigation = NO;
|
||
|
|
configration.scrollMenu = NO;
|
||
|
|
configration.aligmentModeCenter = NO;
|
||
|
|
// configration.pageScrollEnabled = NO;
|
||
|
|
configration.lineWidthEqualFontWidth = NO;
|
||
|
|
configration.showBottomLine = NO;
|
||
|
|
configration.scrollViewBackgroundColor = [UIColor clearColor];
|
||
|
|
configration.lineColor = COLOR_WITH_RGB(0xEFAD01);
|
||
|
|
configration.selectedItemFont = FONT_BOLD_SIZE(20);
|
||
|
|
configration.selectedItemColor = COLOR_WITH_RGB(0xFFFFFF);
|
||
|
|
configration.itemFont = MT_FONT_MEDIUM_SIZE(18);
|
||
|
|
configration.normalItemColor = COLOR_WITH_RGB_A(0xFFFFFF, 0.7);
|
||
|
|
/// 设置菜单栏宽度
|
||
|
|
configration.menuWidth = 150;
|
||
|
|
configration.lineLeftAndRightAddWidth = -30;
|
||
|
|
BottleBaseViewController *vc = [BottleBaseViewController pageViewControllerWithControllers:[self getArrayVCs]
|
||
|
|
titles:[self getArrayTitles]
|
||
|
|
config:configration];
|
||
|
|
vc.dataSource = vc;
|
||
|
|
vc.delegate = vc;
|
||
|
|
return vc;
|
||
|
|
}
|
||
|
|
|
||
|
|
+ (NSArray *)getArrayVCs {
|
||
|
|
BottleViewController* firstVC = [[BottleViewController alloc] init];
|
||
|
|
firstVC.title = @"酒馆";
|
||
|
|
|
||
|
|
BottleNerbyViewController *secondVC = [[BottleNerbyViewController alloc]init];
|
||
|
|
secondVC.title = @"附近";
|
||
|
|
|
||
|
|
return @[firstVC, secondVC];
|
||
|
|
}
|
||
|
|
|
||
|
|
+ (NSArray *)getArrayTitles {
|
||
|
|
return @[@"酒馆", @"附近"];
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
#pragma mark - 导航栏按钮事件
|
||
|
|
-(void)rightButtonOnClick:(UIButton*)sender{
|
||
|
|
if (_selectIndex == 0) {
|
||
|
|
[_bottleVC refreshHomeBottleData];
|
||
|
|
// SetLoginUserInfoViewController* vc = [[SetLoginUserInfoViewController alloc]init];
|
||
|
|
// vc.title = @"完善您的个人形象";
|
||
|
|
// [self.navigationController pushViewController:vc animated:YES];
|
||
|
|
}else{
|
||
|
|
[_nerbyVC shaiXuanClick];
|
||
|
|
}
|
||
|
|
NSLog(@"select:%ld",(long)_selectIndex);
|
||
|
|
}
|
||
|
|
-(void)bottleButtonOnClick:(UIButton*)sender{
|
||
|
|
[_bottleVC getBottle];
|
||
|
|
}
|
||
|
|
#pragma mark - YNPageViewControllerDataSource
|
||
|
|
- (UIScrollView *)pageViewController:(YNPageViewController *)pageViewController pageForIndex:(NSInteger)index {
|
||
|
|
if(index == 0){
|
||
|
|
_bottleVC = pageViewController.controllersM[index];
|
||
|
|
return [_bottleVC collectionView];
|
||
|
|
}else{
|
||
|
|
_nerbyVC = pageViewController.controllersM[index];
|
||
|
|
return [_nerbyVC contentTableView];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
- (CGFloat)pageViewController:(YNPageViewController *)pageViewController heightForScrollViewAtIndex:(NSInteger )index{
|
||
|
|
return (SCREEN_HEIGHT - NAVIGATION_BAR_HEIGHT - TAB_BAR_HEIGHT);
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)pageViewController:(YNPageViewController *)pageViewController
|
||
|
|
didScroll:(UIScrollView *)scrollView
|
||
|
|
progress:(CGFloat)progress
|
||
|
|
formIndex:(NSInteger)fromIndex
|
||
|
|
toIndex:(NSInteger)toIndex{
|
||
|
|
if (toIndex == 0) {
|
||
|
|
_selectIndex = 0;
|
||
|
|
[_navRightBtn setImage:ImageNamed(@"TH_bottle_refresh_icon") forState:UIControlStateNormal];
|
||
|
|
}else if (toIndex == 1){
|
||
|
|
_selectIndex = 1;
|
||
|
|
[_navRightBtn setImage:ImageNamed(@"TH_bottle_shaiXuan_icon") forState:UIControlStateNormal];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)pageViewController:(YNPageViewController *)pageViewController
|
||
|
|
didScrollMenuItem:(UIButton *)itemButton
|
||
|
|
index:(NSInteger)index{
|
||
|
|
NSLog(@"itemButton : %@",itemButton.titleLabel.text);
|
||
|
|
NSLog(@"indext : %ld",(long)index);
|
||
|
|
NSLog(@"_selectIndex : %ld",(long)_selectIndex);
|
||
|
|
NSLog(@"contentTableView.y : %ld",(long)_nerbyVC.contentTableView.contentOffset.y);
|
||
|
|
|
||
|
|
if (_selectIndex == 1 && index == 1 && _nerbyVC.contentTableView.contentOffset.y != 0) {
|
||
|
|
// _nerbyVC.contentTableView.contentSize = CGSizeMake(0, 0);
|
||
|
|
[_nerbyVC.contentTableView setContentOffset:CGPointMake(0, 0) animated:YES];
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
@end
|