feat: 新商城框架
This commit is contained in:
70
YuMi/Modules/ShoppingMall/ShoppingMallViewController.m
Normal file
70
YuMi/Modules/ShoppingMall/ShoppingMallViewController.m
Normal file
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// 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 {
|
||||
// 模拟异步数据请求,并在获取到数据后调用 completion
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
NSMutableArray *data = [NSMutableArray array];
|
||||
for (int i = 0; i < 20; i++) {
|
||||
[data addObject:@(i + arc4random()%100 * 20)];
|
||||
}
|
||||
if (completion) {
|
||||
completion(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
Reference in New Issue
Block a user