2
This commit is contained in:
@@ -279,7 +279,7 @@ static const CGFloat JXheightForHeaderInSection = 50;
|
||||
[KBHUD show];
|
||||
}
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[self.shopVM fetchWalletBalanceWithCompletion:^(NSString * _Nullable balance, NSError * _Nullable error) {
|
||||
[self.shopVM fetchWalletBalanceWithCompletion:^(NSNumber * _Nullable balance, NSError * _Nullable error) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (showHUD) {
|
||||
[KBHUD dismiss];
|
||||
@@ -289,9 +289,9 @@ static const CGFloat JXheightForHeaderInSection = 50;
|
||||
[KBHUD showInfo:msg];
|
||||
return;
|
||||
}
|
||||
// double amountValue = balance.doubleValue;
|
||||
// NSString *amountString = [NSString stringWithFormat:@"%.2f", amountValue];
|
||||
[weakSelf.userHeaderView updatePoints:balance];
|
||||
double amountValue = balance.doubleValue;
|
||||
NSString *amountString = [NSString stringWithFormat:@"%.2f", amountValue];
|
||||
[weakSelf.userHeaderView updatePoints:amountString];
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#import "KBSkinSectionTitleCell.h"
|
||||
#import "KBSkinBottomActionView.h"
|
||||
#import "KBShopVM.h"
|
||||
#import "KBShopThemeTagModel.h"
|
||||
|
||||
static NSString * const kHeaderCellId = @"kHeaderCellId";
|
||||
static NSString * const kTagsContainerCellId = @"kTagsContainerCellId";
|
||||
@@ -32,6 +33,7 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
||||
@property (nonatomic, copy) NSArray<NSString *> *tags; // 标签数据
|
||||
@property (nonatomic, copy) NSArray<NSDictionary *> *gridData; // 底部网格数据
|
||||
@property (nonatomic, strong) KBShopVM *shopVM;
|
||||
@property (nonatomic, strong, nullable) KBShopThemeDetailModel *detailModel;
|
||||
@end
|
||||
|
||||
@implementation KBSkinDetailVC
|
||||
@@ -40,8 +42,7 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
||||
[super viewDidLoad];
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
// 简单数据(演示)
|
||||
self.tags = @[ @"Cute", @"Fresh", @"Cute", @"Fresh", @"Cute", @"Fresh" ];
|
||||
self.tags = @[];
|
||||
self.gridData = @[
|
||||
@{ @"title": @"Dopamine" }, @{ @"title": @"Dopamine" },
|
||||
@{ @"title": @"Dopamine" }, @{ @"title": @"Dopamine" },
|
||||
@@ -80,7 +81,7 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
||||
switch (section) {
|
||||
case KBSkinDetailSectionHeader: return 1; // 顶部大卡片
|
||||
case KBSkinDetailSectionTags: return 1; // 标签容器
|
||||
case KBSkinDetailSectionTags: return self.tags.count > 0 ? 1 : 0;
|
||||
case KBSkinDetailSectionTitle: return 1; // 标题
|
||||
case KBSkinDetailSectionGrid: return self.gridData.count; // 2 列网格
|
||||
}
|
||||
@@ -91,7 +92,10 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
||||
switch (indexPath.section) {
|
||||
case KBSkinDetailSectionHeader: {
|
||||
KBSkinDetailHeaderCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kHeaderCellId forIndexPath:indexPath];
|
||||
[cell configWithTitle:@"Dopamine" right:@"Download: 1 Million"];
|
||||
NSString *title = self.detailModel.themeName.length ? self.detailModel.themeName : @"Dopamine";
|
||||
NSString *download = self.detailModel.themeDownload.length ? self.detailModel.themeDownload : @"0";
|
||||
NSString *right = [NSString stringWithFormat:@"%@: %@", KBLocalized(@"Download"), download];
|
||||
[cell configWithTitle:title right:right];
|
||||
return cell;
|
||||
}
|
||||
case KBSkinDetailSectionTags: {
|
||||
@@ -128,7 +132,7 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
||||
}
|
||||
case KBSkinDetailSectionTags: {
|
||||
CGFloat h = [KBSkinTagsContainerCell heightForTags:self.tags width:W];
|
||||
return CGSizeMake(contentW, 25);
|
||||
return CGSizeMake(contentW, MAX(h, 0.1));
|
||||
}
|
||||
case KBSkinDetailSectionTitle: {
|
||||
return CGSizeMake(contentW, 44);
|
||||
@@ -216,14 +220,24 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
||||
return;
|
||||
}
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[self.shopVM fetchThemeDetailWithId:self.themeId completion:^(NSDictionary * _Nullable json, NSError * _Nullable error) {
|
||||
[self.shopVM fetchThemeDetailWithId:self.themeId completion:^(KBShopThemeDetailModel * _Nullable detail, NSError * _Nullable error) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (error) {
|
||||
NSLog(@"[KBSkinDetailVC] fetch detail failed: %@", error);
|
||||
return;
|
||||
}
|
||||
NSLog(@"[KBSkinDetailVC] theme detail json: %@", json);
|
||||
// TODO: parse json into models once the structure is finalized.
|
||||
if (!detail) {
|
||||
NSLog(@"[KBSkinDetailVC] theme detail is empty");
|
||||
return;
|
||||
}
|
||||
weakSelf.detailModel = detail;
|
||||
NSMutableArray<NSString *> *tagNames = [NSMutableArray array];
|
||||
for (KBShopThemeTagModel *tag in detail.themeTag) {
|
||||
if (tag.label.length) {
|
||||
[tagNames addObject:tag.label];
|
||||
}
|
||||
}
|
||||
weakSelf.tags = tagNames.copy;
|
||||
[weakSelf.collectionView reloadData];
|
||||
});
|
||||
}];
|
||||
|
||||
Reference in New Issue
Block a user