69 lines
2.2 KiB
Objective-C
69 lines
2.2 KiB
Objective-C
//
|
|
// ShoppingMallViewController.m
|
|
// YuMi
|
|
//
|
|
// Created by P on 2024/11/13.
|
|
//
|
|
|
|
#import "ShoppingMallViewController.h"
|
|
|
|
#import "ShoppingMallDataPresent.h"
|
|
#import "ShoppingMallCategoryListView.h"
|
|
|
|
@interface ShoppingMallViewController ()
|
|
|
|
@end
|
|
|
|
@implementation ShoppingMallViewController
|
|
|
|
- (ShoppingMallDataPresent *)createPresenter {
|
|
return [[ShoppingMallDataPresent alloc] init];
|
|
}
|
|
|
|
- (BOOL)isHiddenNavBar {
|
|
return YES;
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
|
|
self.view.backgroundColor = UIColorFromRGB(0x02061D);
|
|
UIImageView *topBG = [[UIImageView alloc] initWithImage:kImage(@"mall_top_bg")];
|
|
[self.view addSubview:topBG];
|
|
[topBG mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.leading.trailing.mas_equalTo(self.view);
|
|
make.height.mas_equalTo(kGetScaleWidth(200));
|
|
}];
|
|
|
|
NSInteger top = kNavigationHeight + 56;
|
|
ShoppingMallCategoryListView *listView = [[ShoppingMallCategoryListView alloc] initWithFrame:CGRectMake(0, top, KScreenWidth, KScreenHeight - top)];
|
|
// 设置数据请求回调
|
|
@kWeakify(self);
|
|
listView.fetchDataForPage = ^(NSInteger pageIndex, FetchDataCompletion completion) {
|
|
// 模拟网络请求或 API 数据请求
|
|
@kStrongify(self);
|
|
[self fetchDataForPage:pageIndex completion:completion];
|
|
};
|
|
[self.view addSubview:listView];
|
|
|
|
listView.items = @[@{YMLocalizedString(@"XPMineDressUpViewController2") : @1}, // 座驾
|
|
@{YMLocalizedString(@"XPMineDressUpViewController1") : @0}, // 头饰
|
|
@{YMLocalizedString(@"XPMineDressUpViewController3") : @2}, // 铭牌
|
|
@{YMLocalizedString(@"XPMineDressUpViewController4") : @3}, // 资料卡
|
|
@{YMLocalizedString(@"XPMineDressUpViewController5") : @4} // 聊天气泡
|
|
];
|
|
}
|
|
|
|
- (void)fetchDataForPage:(NSInteger)pageIndex completion:(FetchDataCompletion)completion {
|
|
|
|
[self.presenter loadCategoryItems:pageIndex success:^(NSArray <DressUpShopModel *>* array) {
|
|
if (completion) {
|
|
completion(array);
|
|
}
|
|
} failure:^(NSError * _Nonnull error) {
|
|
// TODO: 增加错误处理
|
|
}];
|
|
}
|
|
|
|
@end
|