Files
real-e-party-iOS/YuMi/Modules/NewMine/Controllers/NewMineViewController.m
edwinQQQ 98fb194718 Phase 1 Day 2-3: 创建 Moment 和 Mine 模块
- 创建 NewMomentViewController(OC)
  * 列表式布局 + 下拉刷新 + 滚动加载
  * 发布按钮(右下角悬浮)
  * 使用模拟数据

- 创建 NewMomentCell(OC)
  * 卡片式设计(白色卡片 + 阴影)
  * 圆角矩形头像(不是圆形!)
  * 底部操作栏(点赞/评论/分享)

- 创建 NewMineViewController(OC)
  * TableView 布局 + 8 个菜单项
  * 设置按钮(右上角)

- 创建 NewMineHeaderView(OC)
  * 渐变背景(蓝色系)
  * 圆角矩形头像 + 白色边框
  * 昵称、等级、经验进度条
  * 关注/粉丝统计
  * 纵向卡片式设计

- 集成到 NewTabBarController
  * 使用真实的 ViewController 替换占位
  * 支持登录前/后状态切换

- 更新 Bridging Header
  * 添加新模块的 OC 类引用

- 创建测试指南文档
  * 如何运行新 TabBar
  * 测试清单
  * 常见问题解答

新增文件:
- NewMomentViewController.h/m
- NewMomentCell.h/m
- NewMineViewController.h/m
- NewMineHeaderView.h/m
- white-label-test-guide.md

代码量:约 1500 行
2025-10-09 17:54:32 +08:00

236 lines
7.6 KiB
Objective-C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// NewMineViewController.m
// YuMi
//
// Created by AI on 2025-10-09.
// Copyright © 2025 YuMi. All rights reserved.
//
#import "NewMineViewController.h"
#import "NewMineHeaderView.h"
#import <Masonry/Masonry.h>
@interface NewMineViewController () <UITableViewDelegate, UITableViewDataSource>
// MARK: - UI Components
/// 主列表
@property (nonatomic, strong) UITableView *tableView;
/// 顶部个人信息卡片
@property (nonatomic, strong) NewMineHeaderView *headerView;
/// 设置按钮
@property (nonatomic, strong) UIButton *settingsButton;
// MARK: - Data
/// 菜单项数据源
@property (nonatomic, strong) NSArray<NSDictionary *> *menuItems;
@end
@implementation NewMineViewController
// MARK: - Lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"我的";
self.view.backgroundColor = [UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1.0]; // 浅灰背景
[self setupNavigationBar];
[self setupUI];
[self loadData];
NSLog(@"[NewMineViewController] 页面加载完成");
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// 刷新用户信息
[self refreshUserInfo];
}
// MARK: - Setup
- (void)setupNavigationBar {
// 设置按钮(右上角)
self.settingsButton = [UIButton buttonWithType:UIButtonTypeSystem];
[self.settingsButton setTitle:@"⚙️" forState:UIControlStateNormal];
self.settingsButton.titleLabel.font = [UIFont systemFontOfSize:24];
[self.settingsButton addTarget:self action:@selector(onSettingsButtonTapped) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *settingsBarButton = [[UIBarButtonItem alloc] initWithCustomView:self.settingsButton];
self.navigationItem.rightBarButtonItem = settingsBarButton;
}
- (void)setupUI {
// TableView
[self.view addSubview:self.tableView];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
// 设置头部视图
self.tableView.tableHeaderView = self.headerView;
NSLog(@"[NewMineViewController] UI 设置完成");
}
// MARK: - Data Loading
- (void)loadData {
// 菜单项配置(完全不同的顺序和图标)
self.menuItems = @[
@{@"title": @"💎 我的钱包", @"type": @"wallet"},
@{@"title": @"📊 数据统计", @"type": @"stats"},
@{@"title": @"⭐️ 我的收藏", @"type": @"favorites"},
@{@"title": @"📝 编辑资料", @"type": @"profile"},
@{@"title": @"🔔 消息通知", @"type": @"notifications"},
@{@"title": @"🎨 主题设置", @"type": @"theme"},
@{@"title": @"🌐 语言切换", @"type": @"language"},
@{@"title": @" 关于我们", @"type": @"about"},
];
[self.tableView reloadData];
}
- (void)refreshUserInfo {
// TODO: 从接口获取用户信息
// 暂时使用模拟数据
NSDictionary *mockUserInfo = @{
@"nickname": @"测试用户",
@"avatar": @"",
@"level": @(12),
@"exp": @(3580),
@"nextLevelExp": @(5000),
@"followers": @(128),
@"following": @(256),
};
[self.headerView configureWithUserInfo:mockUserInfo];
NSLog(@"[NewMineViewController] 用户信息已刷新");
}
// MARK: - Actions
- (void)onSettingsButtonTapped {
NSLog(@"[NewMineViewController] 设置按钮点击");
// TODO: 跳转到设置页面
[self showAlertWithMessage:@"设置功能开发中"];
}
- (void)onMenuItemTapped:(NSDictionary *)item {
NSString *type = item[@"type"];
NSString *title = item[@"title"];
NSLog(@"[NewMineViewController] 菜单项点击: %@", type);
if ([type isEqualToString:@"wallet"]) {
// TODO: 跳转到钱包页面
[self showAlertWithMessage:@"钱包功能开发中"];
} else if ([type isEqualToString:@"stats"]) {
// TODO: 跳转到数据统计页面
[self showAlertWithMessage:@"数据统计功能开发中"];
} else if ([type isEqualToString:@"favorites"]) {
// TODO: 跳转到收藏页面
[self showAlertWithMessage:@"收藏功能开发中"];
} else if ([type isEqualToString:@"profile"]) {
// TODO: 跳转到编辑资料页面
[self showAlertWithMessage:@"编辑资料功能开发中"];
} else {
[self showAlertWithMessage:[NSString stringWithFormat:@"%@ 功能开发中", title]];
}
}
- (void)showAlertWithMessage:(NSString *)message {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示"
message:message
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alert animated:YES completion:nil];
}
// MARK: - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.menuItems.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identifier = @"MenuCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
cell.backgroundColor = [UIColor whiteColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.font = [UIFont systemFontOfSize:15];
cell.textLabel.textColor = [UIColor colorWithWhite:0.2 alpha:1.0];
}
if (indexPath.row < self.menuItems.count) {
NSDictionary *item = self.menuItems[indexPath.row];
cell.textLabel.text = item[@"title"];
}
return cell;
}
// MARK: - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (indexPath.row < self.menuItems.count) {
NSDictionary *item = self.menuItems[indexPath.row];
[self onMenuItemTapped:item];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 56; // 卡片式高度
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 15; // 上间距
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *header = [[UIView alloc] init];
header.backgroundColor = [UIColor clearColor];
return header;
}
// MARK: - Lazy Loading
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
_tableView.separatorInset = UIEdgeInsetsMake(0, 15, 0, 15);
_tableView.backgroundColor = self.view.backgroundColor;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
return _tableView;
}
- (NewMineHeaderView *)headerView {
if (!_headerView) {
_headerView = [[NewMineHeaderView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 280)];
}
return _headerView;
}
@end