1
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
|
||||
|
||||
#import "KBWebViewViewController.h"
|
||||
#import "KBShopVM.h"
|
||||
#import "KBHUD.h"
|
||||
|
||||
static const CGFloat JXTableHeaderViewHeight = (323);
|
||||
static const CGFloat JXheightForHeaderInSection = 50;
|
||||
@@ -33,11 +35,13 @@ static const CGFloat JXheightForHeaderInSection = 50;
|
||||
|
||||
@property (nonatomic, strong) JXCategoryTitleView *categoryView;
|
||||
@property (nonatomic, strong) NSArray <NSString *> *titles;
|
||||
@property (nonatomic, copy) NSArray<KBShopStyleModel *> *styles;
|
||||
@property (nonatomic, strong) UIImageView *bgImageView; // 全屏背景图
|
||||
@property (nonatomic, strong) UIButton *searchBtn;
|
||||
@property (nonatomic, strong) UIButton *skinBtn;
|
||||
// 记录当前分类条是否为白底,避免重复设置
|
||||
@property (nonatomic, assign) BOOL categoryIsWhite;
|
||||
@property (nonatomic, strong) KBShopVM *shopVM;
|
||||
|
||||
@end
|
||||
|
||||
@@ -65,6 +69,7 @@ static const CGFloat JXheightForHeaderInSection = 50;
|
||||
make.width.height.mas_equalTo(25);
|
||||
}];
|
||||
|
||||
[self fetchShopStylesWithHUD:YES];
|
||||
}
|
||||
|
||||
// 系统导航栏显隐由 Base 统一管理(全局隐藏),该 VC 不再手动切换,避免闪烁。
|
||||
@@ -76,10 +81,8 @@ static const CGFloat JXheightForHeaderInSection = 50;
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
self.navigationController.navigationBar.translucent = false;
|
||||
self.edgesForExtendedLayout = UIRectEdgeNone;
|
||||
_titles = @[KBLocalized(@"能力"), KBLocalized(@"爱好"), KBLocalized(@"队友"),
|
||||
KBLocalized(@"能力2"), KBLocalized(@"爱好2"), KBLocalized(@"队友2"),
|
||||
KBLocalized(@"能力"), KBLocalized(@"爱好"), KBLocalized(@"队友"),
|
||||
KBLocalized(@"能力2"), KBLocalized(@"爱好2"), KBLocalized(@"队友2")];
|
||||
self.styles = @[];
|
||||
_titles = @[];
|
||||
|
||||
_userHeaderView = [[KBShopHeadView alloc] init];
|
||||
_categoryView = (JXCategoryTitleView *)[[KBCategoryTitleView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, JXheightForHeaderInSection)];
|
||||
@@ -133,13 +136,7 @@ static const CGFloat JXheightForHeaderInSection = 50;
|
||||
|
||||
__weak typeof(self)weakSelf = self;
|
||||
self.pagerView.mainTableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
self.categoryView.titles = @[KBLocalized(@"高级能力"), KBLocalized(@"高级爱好"), KBLocalized(@"高级队友")];
|
||||
self.categoryView.defaultSelectedIndex = 0;
|
||||
[self.categoryView reloadData];
|
||||
[self.pagerView reloadData];
|
||||
[weakSelf.pagerView.mainTableView.mj_header endRefreshing];
|
||||
});
|
||||
[weakSelf fetchShopStylesWithHUD:NO];
|
||||
}];
|
||||
|
||||
self.pagerView.pinSectionHeaderVerticalOffset = KB_NAV_TOTAL_HEIGHT;
|
||||
@@ -194,19 +191,9 @@ static const CGFloat JXheightForHeaderInSection = 50;
|
||||
list.title = self.titles[index];
|
||||
list.isNeedHeader = self.isNeedHeader;
|
||||
list.isNeedFooter = self.isNeedFooter;
|
||||
if (index == 0) {
|
||||
list.dataSource = @[KBLocalized(@"橡胶火箭"), KBLocalized(@"橡胶火箭炮"), KBLocalized(@"橡胶机关枪"), KBLocalized(@"橡胶子弹"),
|
||||
KBLocalized(@"橡胶攻城炮"), KBLocalized(@"橡胶象枪"), KBLocalized(@"橡胶象枪乱打"), KBLocalized(@"橡胶灰熊铳"),
|
||||
KBLocalized(@"橡胶雷神象枪"), KBLocalized(@"橡胶猿王枪"), KBLocalized(@"橡胶犀·榴弹炮"), KBLocalized(@"橡胶大蛇炮"),
|
||||
KBLocalized(@"橡胶火箭"), KBLocalized(@"橡胶火箭炮"), KBLocalized(@"橡胶机关枪"), KBLocalized(@"橡胶子弹"),
|
||||
KBLocalized(@"橡胶攻城炮"), KBLocalized(@"橡胶象枪"), KBLocalized(@"橡胶象枪乱打"), KBLocalized(@"橡胶灰熊铳"),
|
||||
KBLocalized(@"橡胶雷神象枪"), KBLocalized(@"橡胶猿王枪"), KBLocalized(@"橡胶犀·榴弹炮"), KBLocalized(@"橡胶大蛇炮")].mutableCopy;
|
||||
}else if (index == 1) {
|
||||
list.dataSource = @[KBLocalized(@"吃烤肉"), KBLocalized(@"吃鸡腿肉"), KBLocalized(@"吃牛肉"), KBLocalized(@"各种肉")].mutableCopy;
|
||||
}else {
|
||||
list.dataSource = @[KBLocalized(@"【剑士】罗罗诺亚·索隆"), KBLocalized(@"【航海士】娜美"), KBLocalized(@"【狙击手】乌索普"),
|
||||
KBLocalized(@"【厨师】香吉士"), KBLocalized(@"【船医】托尼托尼·乔巴"), KBLocalized(@"【船匠】 弗兰奇"),
|
||||
KBLocalized(@"【音乐家】布鲁克"), KBLocalized(@"【考古学家】妮可·罗宾")].mutableCopy;
|
||||
list.shopViewModel = self.shopVM;
|
||||
if (index < self.styles.count) {
|
||||
list.style = self.styles[index];
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -277,4 +264,46 @@ static const CGFloat JXheightForHeaderInSection = 50;
|
||||
}
|
||||
return _skinBtn;
|
||||
}
|
||||
|
||||
- (KBShopVM *)shopVM {
|
||||
if (!_shopVM) {
|
||||
_shopVM = [[KBShopVM alloc] init];
|
||||
}
|
||||
return _shopVM;
|
||||
}
|
||||
|
||||
- (void)fetchShopStylesWithHUD:(BOOL)showHUD {
|
||||
if (showHUD) {
|
||||
[KBHUD show];
|
||||
}
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[self.shopVM fetchAllStylesWithCompletion:^(NSArray<KBShopStyleModel *> * _Nullable styles, NSError * _Nullable error) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (showHUD) {
|
||||
[KBHUD dismiss];
|
||||
}
|
||||
[weakSelf.pagerView.mainTableView.mj_header endRefreshing];
|
||||
if (error) {
|
||||
NSString *msg = error.localizedDescription ?: KBLocalized(@"Network error");
|
||||
[KBHUD showInfo:msg];
|
||||
return;
|
||||
}
|
||||
[weakSelf applyStyles:styles];
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)applyStyles:(NSArray<KBShopStyleModel *> *)styles {
|
||||
self.styles = styles ?: @[];
|
||||
NSMutableArray *names = [NSMutableArray array];
|
||||
for (KBShopStyleModel *style in self.styles) {
|
||||
NSString *name = style.styleName.length ? style.styleName : KBLocalized(@"Themes");
|
||||
[names addObject:name];
|
||||
}
|
||||
self.titles = names.copy;
|
||||
self.categoryView.titles = self.titles;
|
||||
self.categoryView.defaultSelectedIndex = 0;
|
||||
[self.categoryView reloadData];
|
||||
[self.pagerView reloadData];
|
||||
}
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user