添加个人主页

This commit is contained in:
2026-01-29 16:03:21 +08:00
parent 766c62f3c0
commit 26096abbcc
6 changed files with 155 additions and 27 deletions

View File

@@ -6,7 +6,9 @@
//
#import "AIPersonInfoVC.h"
#import "AIReportVC.h"
//#import "AIReportVC.h"
#import "AiVM.h"
#import "KBAICompanionDetailModel.h"
#import <SDWebImage/SDWebImage.h>
@interface AIPersonInfoVC ()
@@ -29,6 +31,10 @@
@property (nonatomic, strong) UILabel *introLabel;
/// Go Chatting
@property (nonatomic, strong) UIButton *goChatButton;
/// AiVM
@property (nonatomic, strong) AiVM *aiVM;
///
@property (nonatomic, strong) KBAICompanionDetailModel *detailModel;
@end
@@ -41,12 +47,13 @@
self.kb_navView.hidden = YES;
self.view.backgroundColor = [UIColor blackColor];
self.aiVM = [[AiVM alloc] init];
/// 1
[self setupUI];
/// 2
[self bindActions];
/// 3
/// 3
[self loadData];
}
@@ -133,20 +140,55 @@
[self.view addGestureRecognizer:tap];
}
#pragma mark - 3
#pragma mark - 3
- (void)loadData {
//
if (self.backgroundImageURL.length > 0) {
[self.backgroundImageView sd_setImageWithURL:[NSURL URLWithString:self.backgroundImageURL]
if (self.companionId <= 0) {
NSLog(@"[AIPersonInfoVC] companionId 无效");
return;
}
[KBHUD show];
__weak typeof(self) weakSelf = self;
[self.aiVM fetchCompanionDetailWithCompanionId:self.companionId
completion:^(KBAICompanionDetailModel * _Nullable detail, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
[KBHUD dismiss];
if (error) {
NSLog(@"[AIPersonInfoVC] 获取详情失败: %@", error.localizedDescription);
[KBHUD showError:error.localizedDescription];
return;
}
if (!detail) {
NSLog(@"[AIPersonInfoVC] 详情数据为空");
return;
}
weakSelf.detailModel = detail;
[weakSelf updateUI];
});
}];
}
#pragma mark - 4 UI
- (void)updateUI {
// 使 coverImageUrl avatarUrl
NSString *imageUrl = self.detailModel.coverImageUrl.length > 0 ? self.detailModel.coverImageUrl : self.detailModel.avatarUrl;
if (imageUrl.length > 0) {
[self.backgroundImageView sd_setImageWithURL:[NSURL URLWithString:imageUrl]
placeholderImage:KBPlaceholderImage];
}
//
self.nameLabel.text = self.personaName ?: @"";
self.nameLabel.text = self.detailModel.name ?: @"";
//
self.introLabel.text = self.personaIntroduction ?: @"";
// 使 introText shortDesc
NSString *intro = self.detailModel.introText.length > 0 ? self.detailModel.introText : self.detailModel.shortDesc;
self.introLabel.text = intro ?: @"";
}
#pragma mark - Actions
@@ -162,9 +204,9 @@
- (void)reportButtonTapped {
self.reportPopView.hidden = YES;
AIReportVC *vc = [[AIReportVC alloc] init];
vc.personaId = self.personaId;
[self.navigationController pushViewController:vc animated:YES];
// AIReportVC *vc = [[AIReportVC alloc] init];
// vc.personaId = self.companionId;
// [self.navigationController pushViewController:vc animated:YES];
}
- (void)goChatButtonTapped {
@@ -228,9 +270,11 @@
- (UIButton *)moreButton {
if (!_moreButton) {
_moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
// 使
[_moreButton setImage:[UIImage imageNamed:@"ai_more_icon"] forState:UIControlStateNormal];
if (![UIImage imageNamed:@"ai_more_icon"]) {
// 使
UIImage *moreImage = [UIImage imageNamed:@"ai_more_icon"];
if (moreImage) {
[_moreButton setImage:moreImage forState:UIControlStateNormal];
} else {
// 使
[_moreButton setTitle:@"•••" forState:UIControlStateNormal];
[_moreButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
@@ -250,13 +294,16 @@
//
UIButton *reportBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[reportBtn setImage:[UIImage imageNamed:@"ai_report_icon"] forState:UIControlStateNormal];
UIImage *reportIcon = [UIImage imageNamed:@"ai_report_icon"];
if (reportIcon) {
[reportBtn setImage:reportIcon forState:UIControlStateNormal];
reportBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0);
reportBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 16, 0, 0);
}
[reportBtn setTitle:KBLocalized(@"Report") forState:UIControlStateNormal];
[reportBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
reportBtn.titleLabel.font = [UIFont systemFontOfSize:14];
reportBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
reportBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0);
reportBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 16, 0, 0);
[reportBtn addTarget:self action:@selector(reportButtonTapped) forControlEvents:UIControlEventTouchUpInside];
[_reportPopView addSubview:reportBtn];