This commit is contained in:
2025-12-04 15:44:43 +08:00
parent ce4c4f0531
commit c9863cd353
3 changed files with 29 additions and 58 deletions

View File

@@ -32,6 +32,7 @@
#define KB_API_FILE_UPLOAD @"/file/upload" // 上传头像
#define KB_API_CHARACTER_DETAIL @"/character/detail" // 人设详情
#define KB_API_CHARACTER_LISTBYUSER @"/character/listByUser" // 用户人设列表
#define API_CHARACTER_UPDATE_USER_CHARTSORT @"/character/updateUserCharacterSort" // 更新用户人设排序

View File

@@ -72,14 +72,34 @@ static NSString * const kKBMyKeyboardCellId = @"kKBMyKeyboardCellId";
make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-12);
make.height.mas_equalTo(50);
}];
//
// [self buildDefaultData];
// 使
__weak typeof(self) weakSelf = self;
[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
/// 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
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return self.dataSourceArray.count; }

View File

@@ -23,6 +23,9 @@ typedef void(^KBUpdateUserInfoCompletion)(BOOL success, NSError * _Nullable erro
/// 用户人设列表(/character/listByUser
- (void)fetchCharacterListByUserWithCompletion:(KBCharacterListCompletion)completion;
/// 更新用户人设排序
/// 上传头像
- (void)upLoadAvatarWithData:(NSData *)avatarData completion:(KBUpLoadAvatarCompletion)completion;