feat: 更新 EPEditSettingViewController 以增强用户信息管理功能

主要变更:
1. 在 EPEditSettingViewController 中添加了用户头像和相机图标的布局,提升用户界面友好性。
2. 引入 EPMineAPIHelper 以支持头像更新功能,简化 API 调用。
3. 优化了导航栏的显示和隐藏逻辑,确保用户体验流畅。
4. 更新了 UITableView 的数据源和布局,确保信息展示清晰。

此更新旨在提升用户体验,简化用户信息的管理和更新流程。
This commit is contained in:
edwinQQQ
2025-10-14 14:46:08 +08:00
parent e4f4557369
commit 955cc3622f
13 changed files with 392 additions and 279 deletions

View File

@@ -41,7 +41,6 @@
- (void)viewDidLoad {
[super viewDidLoad];
[self setupUI];
NSLog(@"[EPMineViewController] viewDidLoad 完成");
@@ -49,10 +48,7 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
//
[self.navigationController setNavigationBarHidden:YES animated:animated];
//
[self loadUserDetailInfo];
}
@@ -60,8 +56,13 @@
// MARK: - Setup
- (void)setupUI {
//
self.view.backgroundColor = [UIColor colorWithRed:0.047 green:0.020 blue:0.153 alpha:1.0]; // #0C0527
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 setupHeaderView];
[self setupMomentListView];
@@ -73,19 +74,25 @@
self.headerView = [[EPMineHeaderView alloc] initWithFrame:CGRectZero];
[self.view addSubview:self.headerView];
// 使
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]
]];
// 使 Masonry
[self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view);
make.leading.mas_equalTo(self.view);
make.trailing.mas_equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(320));
}];
//
//
__weak typeof(self) weakSelf = self;
self.headerView.onSettingsButtonTapped = ^{
__strong typeof(weakSelf) self = weakSelf;
[self openSettings];
};
//
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(openSettings)
name:@"EPMineHeaderSettingsButtonTapped"
selector:@selector(onAvatarUpdated:)
name:@"EPEditSettingAvatarUpdated"
object:nil];
}
@@ -93,14 +100,13 @@
self.momentListView = [[EPMomentListView alloc] initWithFrame:CGRectZero];
[self.view addSubview:self.momentListView];
// 使
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]
]];
// 使 Masonry
[self.momentListView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.headerView.mas_bottom);
make.bottom.mas_equalTo(self.view);
make.leading.mas_equalTo(self.view);
make.trailing.mas_equalTo(self.view);
}];
}
// MARK: - Data Loading
@@ -172,13 +178,37 @@
// MARK: - Actions
- (void)openSettings {
//
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@""
style:UIBarButtonItemStylePlain
target:nil
action:nil];
EPEditSettingViewController *settingsVC = [[EPEditSettingViewController alloc] init];
//
if (self.userInfo) {
[settingsVC updateWithUserInfo:self.userInfo];
}
[self.navigationController pushViewController:settingsVC animated:YES];
NSLog(@"[EPMineViewController] 打开设置页面");
NSLog(@"[EPMineViewController] 打开设置页面,已传递用户信息");
}
- (void)onAvatarUpdated:(NSNotification *)notification {
NSString *avatarUrl = notification.userInfo[@"avatarUrl"];
if (avatarUrl && self.userInfo) {
//
self.userInfo.avatar = avatarUrl;
// UI
[self updateHeaderWithUserInfo:self.userInfo];
NSLog(@"[EPMineViewController] 头像已更新: %@", avatarUrl);
}
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
// 使 block
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"EPEditSettingAvatarUpdated" object:nil];
}
@end