11
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
#define KB_API_FILE_UPLOAD @"/file/upload" // 上传头像
|
#define KB_API_FILE_UPLOAD @"/file/upload" // 上传头像
|
||||||
#define KB_API_CHARACTER_DETAIL @"/character/detail" // 人设详情
|
#define KB_API_CHARACTER_DETAIL @"/character/detail" // 人设详情
|
||||||
#define KB_API_CHARACTER_LISTBYUSER @"/character/listByUser" // 用户人设列表
|
#define KB_API_CHARACTER_LISTBYUSER @"/character/listByUser" // 用户人设列表
|
||||||
|
#define API_CHARACTER_UPDATE_USER_CHARTSORT @"/character/updateUserCharacterSort" // 更新用户人设排序
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -72,14 +72,34 @@ static NSString * const kKBMyKeyboardCellId = @"kKBMyKeyboardCellId";
|
|||||||
make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-12);
|
make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-12);
|
||||||
make.height.mas_equalTo(50);
|
make.height.mas_equalTo(50);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
// 初始数据
|
// 使用后端真实数据初始化列表
|
||||||
// [self buildDefaultData];
|
|
||||||
__weak typeof(self) weakSelf = self;
|
__weak typeof(self) weakSelf = self;
|
||||||
[self.viewModel fetchCharacterListByUserWithCompletion:^(NSArray<KBCharacter *> * _Nonnull characterArray, NSError * _Nullable error) {
|
[self.viewModel fetchCharacterListByUserWithCompletion:^(NSArray<KBCharacter *> * _Nonnull characterArray, NSError * _Nullable error) {
|
||||||
if (characterArray.count > 0) {
|
// 请求失败或无数据时,不再使用本地测试数据,直接清空展示
|
||||||
|
if (error || characterArray.count == 0) {
|
||||||
|
weakSelf.dataSourceArray = [NSMutableArray array];
|
||||||
|
[weakSelf.collectionView reloadData];
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 将 KBCharacter 模型转换为当前列表使用的 {emoji, title} 结构
|
||||||
|
NSMutableArray<NSDictionary *> *section = [NSMutableArray arrayWithCapacity:characterArray.count];
|
||||||
|
for (KBCharacter *c in characterArray) {
|
||||||
|
NSString *emoji = c.emoji ?: @"";
|
||||||
|
NSString *title = c.characterName ?: @"";
|
||||||
|
// 如果某条数据既没有 emoji 也没有标题,则忽略
|
||||||
|
if (emoji.length == 0 && title.length == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
[section addObject:@{@"emoji": emoji, @"title": title}];
|
||||||
|
}
|
||||||
|
|
||||||
|
weakSelf.dataSourceArray = [NSMutableArray array];
|
||||||
|
if (section.count > 0) {
|
||||||
|
[weakSelf.dataSourceArray addObject:section];
|
||||||
|
}
|
||||||
|
[weakSelf.collectionView reloadData];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,59 +120,6 @@ static NSString * const kKBMyKeyboardCellId = @"kKBMyKeyboardCellId";
|
|||||||
|
|
||||||
#pragma mark - Data
|
#pragma mark - Data
|
||||||
|
|
||||||
/// 构造示例数据(二维数组,仅 1 个 section)
|
|
||||||
- (void)buildDefaultData {
|
|
||||||
NSArray *arr = @[
|
|
||||||
@{@"emoji":@"😊", @"title":@"Humor"},
|
|
||||||
@{@"emoji":@"😄", @"title":@"Jokes"},
|
|
||||||
@{@"emoji":@"🥰", @"title":@"Love"},
|
|
||||||
@{@"emoji":@"🤔", @"title":@"Thinking"},
|
|
||||||
@{@"emoji":@"🔥", @"title":@"Hot"},
|
|
||||||
@{@"emoji":@"🎉", @"title":@"Celebrate"},
|
|
||||||
@{@"emoji":@"🧠", @"title":@"Brainstorm"},
|
|
||||||
@{@"emoji":@"🐱", @"title":@"Cats"},
|
|
||||||
@{@"emoji":@"😂", @"title":@"LOL"},
|
|
||||||
@{@"emoji":@"📸", @"title":@"Photography"},
|
|
||||||
@{@"emoji":@"🌟", @"title":@"Star"},
|
|
||||||
@{@"emoji":@"🍀", @"title":@"Lucky"},
|
|
||||||
@{@"emoji":@"📚", @"title":@"Knowledge"},
|
|
||||||
@{@"emoji":@"🎵", @"title":@"Music"},
|
|
||||||
@{@"emoji":@"🚀", @"title":@"Launch"},
|
|
||||||
@{@"emoji":@"😊", @"title":@"Humor"},
|
|
||||||
@{@"emoji":@"😄", @"title":@"Jokes"},
|
|
||||||
@{@"emoji":@"🥰", @"title":@"Love"},
|
|
||||||
@{@"emoji":@"🤔", @"title":@"Thinking"},
|
|
||||||
@{@"emoji":@"🔥", @"title":@"Hot"},
|
|
||||||
@{@"emoji":@"🎉", @"title":@"Celebrate"},
|
|
||||||
@{@"emoji":@"🧠", @"title":@"Brainstorm"},
|
|
||||||
@{@"emoji":@"🐱", @"title":@"Cats"},
|
|
||||||
@{@"emoji":@"😂", @"title":@"LOL"},
|
|
||||||
@{@"emoji":@"📸", @"title":@"Photography"},
|
|
||||||
@{@"emoji":@"🌟", @"title":@"Star"},
|
|
||||||
@{@"emoji":@"🍀", @"title":@"Lucky"},
|
|
||||||
@{@"emoji":@"📚", @"title":@"Knowledge"},
|
|
||||||
@{@"emoji":@"🎵", @"title":@"Music"},
|
|
||||||
@{@"emoji":@"🚀", @"title":@"Launch"},
|
|
||||||
@{@"emoji":@"😊", @"title":@"Humor"},
|
|
||||||
@{@"emoji":@"😄", @"title":@"Jokes"},
|
|
||||||
@{@"emoji":@"🥰", @"title":@"Love"},
|
|
||||||
@{@"emoji":@"🤔", @"title":@"Thinking"},
|
|
||||||
@{@"emoji":@"🔥", @"title":@"Hot"},
|
|
||||||
@{@"emoji":@"🎉", @"title":@"Celebrate"},
|
|
||||||
@{@"emoji":@"🧠", @"title":@"Brainstorm"},
|
|
||||||
@{@"emoji":@"🐱", @"title":@"Cats"},
|
|
||||||
@{@"emoji":@"😂", @"title":@"LOL"},
|
|
||||||
@{@"emoji":@"📸", @"title":@"Photography"},
|
|
||||||
@{@"emoji":@"🌟", @"title":@"Star"},
|
|
||||||
@{@"emoji":@"🍀", @"title":@"Lucky"},
|
|
||||||
@{@"emoji":@"📚", @"title":@"Knowledge"},
|
|
||||||
@{@"emoji":@"🎵", @"title":@"Music"},
|
|
||||||
@{@"emoji":@"🚀", @"title":@"Launch"},
|
|
||||||
];
|
|
||||||
self.dataSourceArray = [@[[arr mutableCopy]] mutableCopy];
|
|
||||||
[self.collectionView reloadData];
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - BMLongPressDragCellCollectionViewDataSource
|
#pragma mark - BMLongPressDragCellCollectionViewDataSource
|
||||||
|
|
||||||
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return self.dataSourceArray.count; }
|
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return self.dataSourceArray.count; }
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ typedef void(^KBUpdateUserInfoCompletion)(BOOL success, NSError * _Nullable erro
|
|||||||
|
|
||||||
/// 用户人设列表(/character/listByUser)
|
/// 用户人设列表(/character/listByUser)
|
||||||
- (void)fetchCharacterListByUserWithCompletion:(KBCharacterListCompletion)completion;
|
- (void)fetchCharacterListByUserWithCompletion:(KBCharacterListCompletion)completion;
|
||||||
|
/// 更新用户人设排序
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// 上传头像
|
/// 上传头像
|
||||||
- (void)upLoadAvatarWithData:(NSData *)avatarData completion:(KBUpLoadAvatarCompletion)completion;
|
- (void)upLoadAvatarWithData:(NSData *)avatarData completion:(KBUpLoadAvatarCompletion)completion;
|
||||||
|
|||||||
Reference in New Issue
Block a user