feat: 添加设置编辑页面及相关功能

主要变更:
1. 新增 EPEditSettingViewController,提供用户头像更新、昵称修改和退出登录功能。
2. 在 Bridging Header 中引入 UserInfoModel、XPMineUserInfoEditPresenter 等新模块,以支持设置页面的功能。
3. 更新多语言文件,添加设置页面相关的本地化字符串。

此更新旨在提升用户体验,简化用户信息管理流程。
This commit is contained in:
edwinQQQ
2025-10-13 19:20:11 +08:00
parent 02a8335d70
commit e4f4557369
13 changed files with 771 additions and 60 deletions

View File

@@ -12,6 +12,8 @@
#import "EPMineAPIHelper.h"
#import "AccountInfoStorage.h"
#import "UserInfoModel.h"
#import <Masonry/Masonry.h>
#import "YuMi-Swift.h" // Swift
@interface EPMineViewController ()
@@ -42,7 +44,7 @@
[self setupUI];
NSLog(@"[EPMineViewController] 个人主页加载完成");
NSLog(@"[EPMineViewController] viewDidLoad 完成");
}
- (void)viewWillAppear:(BOOL)animated {
@@ -56,17 +58,10 @@
}
// MARK: - Setup
- (void)setupUI {
//
self.view.backgroundColor = [UIColor clearColor];
UIImageView *bgImageView = [[UIImageView alloc] initWithImage:kImage(@"vc_bg")];
bgImageView.contentMode = UIViewContentModeScaleAspectFill;
bgImageView.clipsToBounds = YES;
[self.view addSubview:bgImageView];
[bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
}];
//
self.view.backgroundColor = [UIColor colorWithRed:0.047 green:0.020 blue:0.153 alpha:1.0]; // #0C0527
[self setupHeaderView];
[self setupMomentListView];
@@ -75,76 +70,88 @@
}
- (void)setupHeaderView {
self.headerView = [[EPMineHeaderView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 300)];
self.headerView = [[EPMineHeaderView alloc] initWithFrame:CGRectZero];
[self.view addSubview:self.headerView];
[self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.view).offset(20);
make.leading.trailing.equalTo(self.view);
make.height.equalTo(@300);
}];
// 使
self.headerView.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[self.headerView.topAnchor constraintEqualToAnchor:self.view.topAnchor],
[self.headerView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
[self.headerView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
[self.headerView.heightAnchor constraintEqualToConstant:320]
]];
//
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(openSettings)
name:@"EPMineHeaderSettingsButtonTapped"
object:nil];
}
- (void)setupMomentListView {
self.momentListView = [[EPMomentListView alloc] initWithFrame:CGRectZero];
[self.view addSubview:self.momentListView];
[self.momentListView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.headerView.mas_bottom).offset(10);
make.leading.trailing.bottom.equalTo(self.view);
}];
// 使
self.momentListView.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[self.momentListView.topAnchor constraintEqualToAnchor:self.headerView.bottomAnchor],
[self.momentListView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
[self.momentListView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
[self.momentListView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor]
]];
}
// MARK: - Data Loading
- (void)loadUserDetailInfo {
NSString *uid = [[AccountInfoStorage instance] getUid];
if (!uid.length) {
NSLog(@"[EPMineViewController] 未登录,无法获取用户信息");
if (!uid || uid.length == 0) {
NSLog(@"[EPMineViewController] 用户未登录");
return;
}
__weak typeof(self) weakSelf = self;
[self.apiHelper getUserDetailInfoWithUid:uid completion:^(UserInfoModel * _Nullable userInfo) {
[self.apiHelper getUserDetailInfoWithUid:uid
completion:^(UserInfoModel * _Nullable userInfo) {
__strong typeof(weakSelf) self = weakSelf;
if (!userInfo) {
NSLog(@"[EPMineViewController] 加载用户信息失败");
return;
}
self.userInfo = userInfo;
[self updateHeaderWithUserInfo:userInfo];
//
NSDictionary *userInfoDict = @{
@"nickname": userInfo.nick ?: @"未设置昵称",
@"avatar": userInfo.avatar ?: @"",
@"uid": userInfo.uid > 0 ? @(userInfo.uid).stringValue : @"",
@"followers": @(userInfo.fansNum),
@"following": @(userInfo.followNum),
};
[self.headerView updateWithUserInfo:userInfoDict];
// 使
[self.momentListView loadWithDynamicInfo:userInfo.dynamicInfo refreshCallback:^{
[self loadUserDetailInfo];
}];
NSLog(@"[EPMineViewController] 用户详情加载成功: %@ (动态数: %lu)",
userInfo.nick, (unsigned long)userInfo.dynamicInfo.count);
// 使
if (userInfo.dynamicInfo && userInfo.dynamicInfo.count > 0) {
[self.momentListView loadWithDynamicInfo:userInfo.dynamicInfo refreshCallback:^{
[self loadUserDetailInfo]; //
}];
}
} failure:^(NSInteger code, NSString * _Nullable msg) {
NSLog(@"[EPMineViewController] 用户详情加载失败: code=%ld, msg=%@", (long)code, msg);
NSLog(@"[EPMineViewController] 加载用户信息失败: %@", msg);
}];
}
- (void)updateHeaderWithUserInfo:(UserInfoModel *)userInfo {
NSDictionary *userInfoDict = @{
@"nickname": userInfo.nick ?: @"未设置昵称",
@"uid": [NSString stringWithFormat:@"%ld", (long)userInfo.uid],
@"avatar": userInfo.avatar ?: @"",
@"following": @(userInfo.followNum),
@"followers": @(userInfo.fansNum)
};
[self.headerView updateWithUserInfo:userInfoDict];
}
// MARK: - Lazy Loading
- (EPMineHeaderView *)headerView {
if (!_headerView) {
_headerView = [[EPMineHeaderView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 300)];
}
return _headerView;
}
- (EPMomentListView *)momentListView {
if (!_momentListView) {
_momentListView = [[EPMomentListView alloc] initWithFrame:CGRectZero];
_momentListView = [[EPMomentListView alloc] init];
__weak typeof(self) weakSelf = self;
_momentListView.onSelectMoment = ^(NSInteger index) {
__strong typeof(weakSelf) self = weakSelf;
@@ -162,4 +169,16 @@
return _apiHelper;
}
// MARK: - Actions
- (void)openSettings {
EPEditSettingViewController *settingsVC = [[EPEditSettingViewController alloc] init];
[self.navigationController pushViewController:settingsVC animated:YES];
NSLog(@"[EPMineViewController] 打开设置页面");
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end