禁用 MiniRoom 悬浮球(v0.2 版本)

问题:
- MiniRoom 悬浮球在启动时就显示
- v0.2 版本不包含房间功能,不需要此组件

修复:
1. 注释 setupRoomMiniView 调用
2. 添加版本说明注释
3. 后续版本可通过 Build Configuration 控制

影响范围:
- 仅影响 EPTabBarController
- GlobalEventManager 保留完整代码
- 便于后续版本恢复

技术说明:
- v0.2: 无 MiniRoom(当前)
- v0.5+: 启用 MiniRoom(需要房间功能)
- 使用注释而非删除,便于版本管理
This commit is contained in:
edwinQQQ
2025-10-10 15:40:28 +08:00
parent 12a8ef9a62
commit 49ac7efa66
11 changed files with 466 additions and 47 deletions

View File

@@ -0,0 +1,20 @@
//
// EPMineViewController.h
// YuMi
//
// Created by AI on 2025-10-09.
// Copyright © 2025 YuMi. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 新的个人中心页面控制器
/// 采用纵向卡片式设计,完全不同于原 XPMineViewController
/// 注意:直接继承 UIViewController不继承 BaseViewController避免依赖链
@interface EPMineViewController : UIViewController
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,250 @@
//
// EPMineViewController.m
// YuMi
//
// Created by AI on 2025-10-09.
// Copyright © 2025 YuMi. All rights reserved.
//
#import "EPMineViewController.h"
#import "EPMineHeaderView.h"
#import "EPMomentCell.h"
#import <Masonry/Masonry.h>
#import "Api+Moments.h"
#import "AccountInfoStorage.h"
#import "UserInfoModel.h"
#import "MomentsInfoModel.h"
#import <MJExtension/MJExtension.h>
@interface EPMineViewController () <UITableViewDelegate, UITableViewDataSource>
// MARK: - UI Components
///
@property (nonatomic, strong) UITableView *tableView;
///
@property (nonatomic, strong) EPMineHeaderView *headerView;
// MARK: - Data
///
@property (nonatomic, strong) NSMutableArray<MomentsInfoModel *> *momentsData;
///
@property (nonatomic, assign) NSInteger currentPage;
///
@property (nonatomic, assign) BOOL isLoading;
///
@property (nonatomic, strong) UserInfoModel *userInfo;
@end
@implementation EPMineViewController
// MARK: - Lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
self.momentsData = [NSMutableArray array];
self.currentPage = 1;
self.isLoading = NO;
[self setupUI];
[self loadUserInfo];
[self loadUserMoments];
NSLog(@"[EPMineViewController] 个人主页加载完成");
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
//
[self refreshUserInfo];
}
// MARK: - Setup
- (void)setupGradientBackground {
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.frame = self.view.bounds;
gradientLayer.colors = @[
(id)[UIColor colorWithRed:0.3 green:0.2 blue:0.6 alpha:1.0].CGColor, // #4C3399
(id)[UIColor colorWithRed:0.2 green:0.3 blue:0.8 alpha:1.0].CGColor // #3366CC
];
gradientLayer.startPoint = CGPointMake(0, 0);
gradientLayer.endPoint = CGPointMake(1, 1);
[self.view.layer insertSublayer:gradientLayer atIndex:0];
}
- (void)setupUI {
UIImageView *bgImageView = [[UIImageView alloc] initWithImage:kImage(@"vc_bg")];
[self.view addSubview:bgImageView];
[bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
}];
[self setupHeaderView];
[self setupTableView];
NSLog(@"[EPMineViewController] UI 设置完成");
}
- (void)setupHeaderView {
self.headerView = [[EPMineHeaderView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 300)];
[self.view addSubview:self.headerView];
[self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop).offset(20);
make.left.right.equalTo(self.view);
make.height.equalTo(@300);
}];
}
- (void)setupTableView {
self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.showsVerticalScrollIndicator = NO;
// cell EPMomentCell
[self.tableView registerClass:[EPMomentCell class] forCellReuseIdentifier:@"EPMomentCell"];
[self.view addSubview:self.tableView];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.headerView.mas_bottom).offset(10);
make.left.right.equalTo(self.view);
make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
}];
//
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged];
self.tableView.refreshControl = refreshControl;
}
// MARK: - Data Loading
- (void)loadUserInfo {
NSString *uid = [[AccountInfoStorage instance] getUid];
if (!uid.length) {
NSLog(@"[EPMineViewController] 未登录,无法获取用户信息");
return;
}
// API
[Api getUserInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200 && data.data) {
self.userInfo = [UserInfoModel mj_objectWithKeyValues:data.data];
//
NSDictionary *userInfoDict = @{
@"nickname": self.userInfo.nick ?: @"未设置昵称",
@"avatar": self.userInfo.avatar ?: @"",
@"uid": self.userInfo.uid > 0 ? @(self.userInfo.uid).stringValue : @"",
@"followers": @(self.userInfo.fansNum),
@"following": @(self.userInfo.followNum),
};
[self.headerView updateWithUserInfo:userInfoDict];
NSLog(@"[EPMineViewController] 用户信息加载成功: %@", self.userInfo.nick);
} else {
NSLog(@"[EPMineViewController] 用户信息加载失败: %@", msg);
}
} uid:uid];
}
- (void)refreshUserInfo {
[self loadUserInfo];
}
- (void)loadUserMoments {
if (self.isLoading) return;
NSString *uid = [[AccountInfoStorage instance] getUid];
if (!uid.length) {
NSLog(@"[EPMineViewController] 未登录,无法获取用户动态");
return;
}
self.isLoading = YES;
NSString *page = [NSString stringWithFormat:@"%ld", (long)self.currentPage];
// API API
[Api momentsRecommendList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
self.isLoading = NO;
[self.refreshControl endRefreshing];
if (code == 200 && data.data) {
NSArray *list = [MomentsInfoModel mj_objectArrayWithKeyValuesArray:data.data];
if (list.count > 0) {
[self.momentsData addObjectsFromArray:list];
self.currentPage++;
[self.tableView reloadData];
NSLog(@"[EPMineViewController] 用户动态加载成功,新增 %lu 条", (unsigned long)list.count);
}
} else {
NSLog(@"[EPMineViewController] 用户动态加载失败: %@", msg);
}
} page:page pageSize:@"10" types:@"0,2"];
}
- (void)refreshData {
self.currentPage = 1;
[self.momentsData removeAllObjects];
[self loadUserMoments];
}
// MARK: - UITableView DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.momentsData.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
EPMomentCell *cell = [tableView dequeueReusableCellWithIdentifier:@"EPMomentCell" forIndexPath:indexPath];
cell.backgroundColor = [UIColor clearColor];
if (indexPath.row < self.momentsData.count) {
[cell configureWithModel:self.momentsData[indexPath.row]];
}
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 200; //
}
// MARK: - UITableView Delegate
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
//
if (indexPath.row == self.momentsData.count - 1 && !self.isLoading) {
[self loadUserMoments];
}
}
// MARK: - Lazy Loading
- (EPMineHeaderView *)headerView {
if (!_headerView) {
_headerView = [[EPMineHeaderView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 300)];
}
return _headerView;
}
- (UIRefreshControl *)refreshControl {
return self.tableView.refreshControl;
}
@end

View File

@@ -0,0 +1,23 @@
//
// EPMineHeaderView.h
// YuMi
//
// Created by AI on 2025-10-09.
// Copyright © 2025 YuMi. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// EP 系列个人主页头部视图
/// 大圆形头像 + 渐变背景 + 用户信息展示
@interface EPMineHeaderView : UIView
/// 更新用户信息
/// @param userInfoDict 用户信息字典
- (void)updateWithUserInfo:(NSDictionary *)userInfoDict;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,165 @@
//
// EPMineHeaderView.m
// YuMi
//
// Created by AI on 2025-10-09.
// Copyright © 2025 YuMi. All rights reserved.
//
#import "EPMineHeaderView.h"
#import <Masonry/Masonry.h>
#import <SDWebImage/SDWebImage.h>
@interface EPMineHeaderView ()
///
@property (nonatomic, strong) UIImageView *avatarImageView;
///
@property (nonatomic, strong) UILabel *nicknameLabel;
/// ID
@property (nonatomic, strong) UILabel *idLabel;
///
@property (nonatomic, strong) UIButton *settingsButton;
///
@property (nonatomic, strong) UIButton *followButton;
///
@property (nonatomic, strong) UIButton *fansButton;
@end
@implementation EPMineHeaderView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self setupUI];
}
return self;
}
- (void)setupUI {
//
self.avatarImageView = [[UIImageView alloc] init];
self.avatarImageView.layer.cornerRadius = 60;
self.avatarImageView.layer.masksToBounds = YES;
self.avatarImageView.layer.borderWidth = 3;
self.avatarImageView.layer.borderColor = [UIColor whiteColor].CGColor;
self.avatarImageView.backgroundColor = [UIColor whiteColor];
self.avatarImageView.contentMode = UIViewContentModeScaleAspectFill;
[self addSubview:self.avatarImageView];
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.top.equalTo(self).offset(60);
make.size.mas_equalTo(CGSizeMake(120, 120));
}];
//
self.nicknameLabel = [[UILabel alloc] init];
self.nicknameLabel.font = [UIFont boldSystemFontOfSize:24];
self.nicknameLabel.textColor = [UIColor whiteColor];
self.nicknameLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.nicknameLabel];
[self.nicknameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.top.equalTo(self.avatarImageView.mas_bottom).offset(16);
}];
// ID
self.idLabel = [[UILabel alloc] init];
self.idLabel.font = [UIFont systemFontOfSize:14];
self.idLabel.textColor = [UIColor whiteColor];
self.idLabel.alpha = 0.8;
self.idLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.idLabel];
[self.idLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.top.equalTo(self.nicknameLabel.mas_bottom).offset(8);
}];
//
self.settingsButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.settingsButton setImage:[UIImage systemImageNamed:@"gearshape"] forState:UIControlStateNormal];
self.settingsButton.tintColor = [UIColor whiteColor];
self.settingsButton.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.2];
self.settingsButton.layer.cornerRadius = 20;
[self.settingsButton addTarget:self action:@selector(settingsButtonTapped) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:self.settingsButton];
[self.settingsButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self).offset(50);
make.right.equalTo(self).offset(-20);
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
//
self.followButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.followButton setTitle:@"关注" forState:UIControlStateNormal];
[self.followButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
self.followButton.titleLabel.font = [UIFont systemFontOfSize:16];
self.followButton.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.2];
self.followButton.layer.cornerRadius = 20;
[self addSubview:self.followButton];
[self.followButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.idLabel.mas_bottom).offset(20);
make.centerX.equalTo(self).offset(-50);
make.size.mas_equalTo(CGSizeMake(80, 40));
}];
//
self.fansButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.fansButton setTitle:@"粉丝" forState:UIControlStateNormal];
[self.fansButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
self.fansButton.titleLabel.font = [UIFont systemFontOfSize:16];
self.fansButton.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.2];
self.fansButton.layer.cornerRadius = 20;
[self addSubview:self.fansButton];
[self.fansButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.idLabel.mas_bottom).offset(20);
make.centerX.equalTo(self).offset(50);
make.size.mas_equalTo(CGSizeMake(80, 40));
}];
}
- (void)updateWithUserInfo:(NSDictionary *)userInfoDict {
//
NSString *nickname = userInfoDict[@"nickname"] ?: @"未设置昵称";
self.nicknameLabel.text = nickname;
// ID
NSString *uid = userInfoDict[@"uid"] ?: @"";
self.idLabel.text = [NSString stringWithFormat:@"ID:%@", uid];
//
NSNumber *following = userInfoDict[@"following"] ?: @0;
[self.followButton setTitle:[NSString stringWithFormat:@"关注 %@", following] forState:UIControlStateNormal];
//
NSNumber *followers = userInfoDict[@"followers"] ?: @0;
[self.fansButton setTitle:[NSString stringWithFormat:@"粉丝 %@", followers] forState:UIControlStateNormal];
//
NSString *avatarURL = userInfoDict[@"avatar"];
if (avatarURL && avatarURL.length > 0) {
[self.avatarImageView sd_setImageWithURL:[NSURL URLWithString:avatarURL]
placeholderImage:[UIImage imageNamed:@"default_avatar"]];
} else {
// 使
self.avatarImageView.image = [UIImage imageNamed:@"default_avatar"];
}
}
- (void)settingsButtonTapped {
NSLog(@"[EPMineHeaderView] 设置按钮点击");
// TODO:
}
@end

View File

@@ -0,0 +1,20 @@
//
// EPMomentViewController.h
// YuMi
//
// Created by AI on 2025-10-09.
// Copyright © 2025 YuMi. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 新的动态页面控制器
/// 采用卡片式布局,完全不同于原 XPMomentsViewController
/// 注意:直接继承 UIViewController不继承 BaseViewController避免依赖链
@interface EPMomentViewController : UIViewController
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,255 @@
//
// EPMomentViewController.m
// YuMi
//
// Created by AI on 2025-10-09.
// Copyright © 2025 YuMi. All rights reserved.
//
#import "EPMomentViewController.h"
#import "EPMomentCell.h"
#import "Api+Moments.h"
#import "AccountInfoStorage.h"
#import "MomentsInfoModel.h"
@interface EPMomentViewController () <UITableViewDelegate, UITableViewDataSource>
// MARK: - UI Components
///
@property (nonatomic, strong) UITableView *tableView;
///
@property (nonatomic, strong) UIRefreshControl *refreshControl;
///
@property (nonatomic, strong) UIButton *publishButton;
// MARK: - Data
/// MomentsInfoModel
@property (nonatomic, strong) NSMutableArray<MomentsInfoModel *> *dataSource;
///
@property (nonatomic, assign) NSInteger currentPage;
///
@property (nonatomic, assign) BOOL isLoading;
@end
@implementation EPMomentViewController
// MARK: - Lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"动态";
[self setupUI];
[self loadData];
NSLog(@"[EPMomentViewController] 页面加载完成");
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
//
// [self.navigationController setNavigationBarHidden:YES animated:animated];
}
// MARK: - Setup UI
- (void)setupUI {
UIImageView *bgImageView = [[UIImageView alloc] initWithImage:kImage(@"vc_bg")];
[self.view addSubview:bgImageView];
[bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
}];
// TableView
[self.view addSubview:self.tableView];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
//
[self.view addSubview:self.publishButton];
[self.publishButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.view).offset(-20);
make.bottom.equalTo(self.view).offset(-100); // TabBar
make.size.mas_equalTo(CGSizeMake(56, 56));
}];
NSLog(@"[EPMomentViewController] UI 设置完成");
}
// MARK: - Data Loading
- (void)loadData {
if (self.isLoading) return;
self.isLoading = YES;
NSLog(@"[EPMomentViewController] 开始加载数据,页码: %ld", (long)self.currentPage);
// API
NSString *page = [NSString stringWithFormat:@"%ld", (long)self.currentPage];
NSString *pageSize = @"10";
NSString *types = @"0,2"; // 0=2=
[Api momentsRecommendList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
self.isLoading = NO;
[self.refreshControl endRefreshing];
if (code == 200 && data.data) {
//
NSArray *list = [MomentsInfoModel mj_objectArrayWithKeyValuesArray:data.data];
if (list.count > 0) {
[self.dataSource addObjectsFromArray:list];
self.currentPage++;
[self.tableView reloadData];
NSLog(@"[EPMomentViewController] 加载成功,新增 %lu 条动态", (unsigned long)list.count);
} else {
NSLog(@"[EPMomentViewController] 没有更多数据");
}
} else {
NSLog(@"[EPMomentViewController] 加载失败: code=%ld, msg=%@", (long)code, msg);
// API
if (self.dataSource.count == 0) {
//
[self showAlertWithMessage:msg ?: @"加载失败"];
}
}
} page:page pageSize:pageSize types:types];
}
- (void)onRefresh {
self.currentPage = 0;
[self.dataSource removeAllObjects];
[self loadData];
}
// MARK: - Actions
- (void)onPublishButtonTapped {
NSLog(@"[EPMomentViewController] 发布按钮点击");
// TODO:
[self showAlertWithMessage:@"发布功能开发中"];
}
- (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)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataSource.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
EPMomentCell *cell = [tableView dequeueReusableCellWithIdentifier:@"NewMomentCell" forIndexPath:indexPath];
if (indexPath.row < self.dataSource.count) {
MomentsInfoModel *model = self.dataSource[indexPath.row];
[cell configureWithModel:model];
}
return cell;
}
// MARK: - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSLog(@"[EPMomentViewController] 点击动态: %ld", (long)indexPath.row);
// TODO:
[self showAlertWithMessage:[NSString stringWithFormat:@"点击了第 %ld 条动态", (long)indexPath.row]];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewAutomaticDimension;
}
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 200;
}
//
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat offsetY = scrollView.contentOffset.y;
CGFloat contentHeight = scrollView.contentSize.height;
CGFloat screenHeight = scrollView.frame.size.height;
if (offsetY > contentHeight - screenHeight - 100 && !self.isLoading) {
[self loadData];
}
}
// MARK: - Lazy Loading
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = self.view.backgroundColor;
_tableView.estimatedRowHeight = 200;
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.contentInset = UIEdgeInsetsMake(10, 0, 10, 0);
// Cell
[_tableView registerClass:[EPMomentCell class] forCellReuseIdentifier:@"NewMomentCell"];
//
_tableView.refreshControl = self.refreshControl;
}
return _tableView;
}
- (UIRefreshControl *)refreshControl {
if (!_refreshControl) {
_refreshControl = [[UIRefreshControl alloc] init];
[_refreshControl addTarget:self action:@selector(onRefresh) forControlEvents:UIControlEventValueChanged];
}
return _refreshControl;
}
- (UIButton *)publishButton {
if (!_publishButton) {
_publishButton = [UIButton buttonWithType:UIButtonTypeCustom];
_publishButton.backgroundColor = [UIColor colorWithRed:0.2 green:0.6 blue:0.86 alpha:1.0]; //
_publishButton.layer.cornerRadius = 28;
_publishButton.layer.shadowColor = [UIColor blackColor].CGColor;
_publishButton.layer.shadowOffset = CGSizeMake(0, 2);
_publishButton.layer.shadowOpacity = 0.3;
_publishButton.layer.shadowRadius = 4;
// 使
[_publishButton setTitle:@"+" forState:UIControlStateNormal];
_publishButton.titleLabel.font = [UIFont systemFontOfSize:32 weight:UIFontWeightLight];
[_publishButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_publishButton addTarget:self action:@selector(onPublishButtonTapped) forControlEvents:UIControlEventTouchUpInside];
}
return _publishButton;
}
- (NSMutableArray *)dataSource {
if (!_dataSource) {
_dataSource = [NSMutableArray array];
}
return _dataSource;
}
@end

View File

@@ -0,0 +1,25 @@
//
// NewMomentCell.h
// YuMi
//
// Created by AI on 2025-10-09.
// Copyright © 2025 YuMi. All rights reserved.
//
#import <UIKit/UIKit.h>
@class MomentsInfoModel;
NS_ASSUME_NONNULL_BEGIN
/// 新的动态 Cell卡片式设计
/// 完全不同于原 XPMomentsCell 的列表式设计
@interface EPMomentCell : UITableViewCell
/// 配置 Cell 数据
/// @param model 动态数据模型
- (void)configureWithModel:(MomentsInfoModel *)model;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,330 @@
//
// NewMomentCell.m
// YuMi
//
// Created by AI on 2025-10-09.
// Copyright © 2025 YuMi. All rights reserved.
//
#import "EPMomentCell.h"
#import "MomentsInfoModel.h"
#import "AccountInfoStorage.h"
#import "Api+Moments.h"
#import <Masonry/Masonry.h>
@interface EPMomentCell ()
// MARK: - UI Components
///
@property (nonatomic, strong) UIView *cardView;
///
@property (nonatomic, strong) UIImageView *avatarImageView;
///
@property (nonatomic, strong) UILabel *nameLabel;
///
@property (nonatomic, strong) UILabel *timeLabel;
///
@property (nonatomic, strong) UILabel *contentLabel;
///
@property (nonatomic, strong) UIView *imagesContainer;
///
@property (nonatomic, strong) UIView *actionBar;
///
@property (nonatomic, strong) UIButton *likeButton;
///
@property (nonatomic, strong) UIButton *commentButton;
///
@property (nonatomic, strong) UIButton *shareButton;
///
@property (nonatomic, strong) MomentsInfoModel *currentModel;
@end
@implementation EPMomentCell
// MARK: - Lifecycle
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.backgroundColor = [UIColor clearColor];
[self setupUI];
}
return self;
}
// MARK: - Setup UI
- (void)setupUI {
// +
[self.contentView addSubview:self.cardView];
[self.cardView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(15);
make.right.equalTo(self.contentView).offset(-15);
make.top.equalTo(self.contentView).offset(8);
make.bottom.equalTo(self.contentView).offset(-8);
}];
//
[self.cardView addSubview:self.avatarImageView];
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.cardView).offset(15);
make.top.equalTo(self.cardView).offset(15);
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
//
[self.cardView addSubview:self.nameLabel];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.avatarImageView.mas_right).offset(10);
make.top.equalTo(self.avatarImageView);
make.right.equalTo(self.cardView).offset(-15);
}];
//
[self.cardView addSubview:self.timeLabel];
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.nameLabel);
make.bottom.equalTo(self.avatarImageView);
make.right.equalTo(self.cardView).offset(-15);
}];
//
[self.cardView addSubview:self.contentLabel];
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.cardView).offset(15);
make.right.equalTo(self.cardView).offset(-15);
make.top.equalTo(self.avatarImageView.mas_bottom).offset(12);
}];
//
[self.cardView addSubview:self.actionBar];
[self.actionBar mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.cardView);
make.top.equalTo(self.contentLabel.mas_bottom).offset(15);
make.height.mas_equalTo(50);
make.bottom.equalTo(self.cardView).offset(-8);
}];
//
[self.actionBar addSubview:self.likeButton];
[self.likeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.actionBar).offset(15);
make.centerY.equalTo(self.actionBar);
make.width.mas_greaterThanOrEqualTo(60);
}];
//
[self.actionBar addSubview:self.commentButton];
[self.commentButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.actionBar);
make.centerY.equalTo(self.actionBar);
make.width.mas_greaterThanOrEqualTo(60);
}];
//
[self.actionBar addSubview:self.shareButton];
[self.shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.actionBar).offset(-15);
make.centerY.equalTo(self.actionBar);
make.width.mas_greaterThanOrEqualTo(60);
}];
}
// MARK: - Public Methods
- (void)configureWithModel:(MomentsInfoModel *)model {
self.currentModel = model;
//
self.nameLabel.text = model.nick ?: @"匿名用户";
//
self.timeLabel.text = model.publishTime;
//
self.contentLabel.text = model.content ?: @"";
//
[self.likeButton setTitle:[NSString stringWithFormat:@"👍 %ld", (long)model.likeCount] forState:UIControlStateNormal];
//
[self.commentButton setTitle:[NSString stringWithFormat:@"💬 %ld", (long)model.commentCount] forState:UIControlStateNormal];
//
[self.shareButton setTitle:@"🔗 分享" forState:UIControlStateNormal];
// TODO:
// [self.avatarImageView sd_setImageWithURL:[NSURL URLWithString:model.avatar]];
}
///
- (NSString *)formatTimeInterval:(NSInteger)timestamp {
if (timestamp <= 0) return @"刚刚";
NSTimeInterval interval = [[NSDate date] timeIntervalSince1970] - timestamp / 1000.0;
if (interval < 60) {
return @"刚刚";
} else if (interval < 3600) {
return [NSString stringWithFormat:@"%.0f分钟前", interval / 60];
} else if (interval < 86400) {
return [NSString stringWithFormat:@"%.0f小时前", interval / 3600];
} else if (interval < 604800) {
return [NSString stringWithFormat:@"%.0f天前", interval / 86400];
} else {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyy-MM-dd";
return [formatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:timestamp / 1000.0]];
}
}
// MARK: - Actions
- (void)onLikeButtonTapped {
if (!self.currentModel) return;
NSLog(@"[NewMomentCell] 点赞动态: %@", self.currentModel.dynamicId);
NSString *uid = [[AccountInfoStorage instance] getUid];
NSString *dynamicId = self.currentModel.dynamicId;
NSString *status = self.currentModel.isLike ? @"0" : @"1"; // 0=1=
NSString *likedUid = self.currentModel.uid;
NSString *worldId = self.currentModel.worldId > 0 ? @(self.currentModel.worldId).stringValue : @"";
[Api momentsLike:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
//
self.currentModel.isLike = !self.currentModel.isLike;
NSInteger likeCount = [self.currentModel.likeCount integerValue];
likeCount += self.currentModel.isLike ? 1 : -1;
self.currentModel.likeCount = @(likeCount).stringValue;
// UI
[self.likeButton setTitle:[NSString stringWithFormat:@"👍 %ld", (long)self.currentModel.likeCount] forState:UIControlStateNormal];
NSLog(@"[NewMomentCell] 点赞成功");
} else {
NSLog(@"[NewMomentCell] 点赞失败: %@", msg);
}
} dynamicId:dynamicId uid:uid status:status likedUid:likedUid worldId:worldId];
}
- (void)onCommentButtonTapped {
NSLog(@"[NewMomentCell] 评论");
// TODO:
}
- (void)onShareButtonTapped {
NSLog(@"[NewMomentCell] 分享");
// TODO:
}
// MARK: - Lazy Loading
- (UIView *)cardView {
if (!_cardView) {
_cardView = [[UIView alloc] init];
_cardView.backgroundColor = [UIColor whiteColor];
_cardView.layer.cornerRadius = 12; //
_cardView.layer.shadowColor = [UIColor blackColor].CGColor;
_cardView.layer.shadowOffset = CGSizeMake(0, 2);
_cardView.layer.shadowOpacity = 0.1;
_cardView.layer.shadowRadius = 8;
_cardView.layer.masksToBounds = NO;
}
return _cardView;
}
- (UIImageView *)avatarImageView {
if (!_avatarImageView) {
_avatarImageView = [[UIImageView alloc] init];
_avatarImageView.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0];
_avatarImageView.layer.cornerRadius = 8; //
_avatarImageView.layer.masksToBounds = YES;
_avatarImageView.contentMode = UIViewContentModeScaleAspectFill;
}
return _avatarImageView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
_nameLabel.textColor = [UIColor colorWithWhite:0.2 alpha:1.0];
}
return _nameLabel;
}
- (UILabel *)timeLabel {
if (!_timeLabel) {
_timeLabel = [[UILabel alloc] init];
_timeLabel.font = [UIFont systemFontOfSize:12];
_timeLabel.textColor = [UIColor colorWithWhite:0.6 alpha:1.0];
}
return _timeLabel;
}
- (UILabel *)contentLabel {
if (!_contentLabel) {
_contentLabel = [[UILabel alloc] init];
_contentLabel.font = [UIFont systemFontOfSize:15];
_contentLabel.textColor = [UIColor colorWithWhite:0.3 alpha:1.0];
_contentLabel.numberOfLines = 0;
_contentLabel.lineBreakMode = NSLineBreakByWordWrapping;
}
return _contentLabel;
}
- (UIView *)actionBar {
if (!_actionBar) {
_actionBar = [[UIView alloc] init];
_actionBar.backgroundColor = [UIColor colorWithWhite:0.98 alpha:1.0];
}
return _actionBar;
}
- (UIButton *)likeButton {
if (!_likeButton) {
_likeButton = [self createActionButtonWithTitle:@"👍 0"];
[_likeButton addTarget:self action:@selector(onLikeButtonTapped) forControlEvents:UIControlEventTouchUpInside];
}
return _likeButton;
}
- (UIButton *)commentButton {
if (!_commentButton) {
_commentButton = [self createActionButtonWithTitle:@"💬 0"];
[_commentButton addTarget:self action:@selector(onCommentButtonTapped) forControlEvents:UIControlEventTouchUpInside];
}
return _commentButton;
}
- (UIButton *)shareButton {
if (!_shareButton) {
_shareButton = [self createActionButtonWithTitle:@"🔗 分享"];
[_shareButton addTarget:self action:@selector(onShareButtonTapped) forControlEvents:UIControlEventTouchUpInside];
}
return _shareButton;
}
- (UIButton *)createActionButtonWithTitle:(NSString *)title {
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
[button setTitle:title forState:UIControlStateNormal];
button.titleLabel.font = [UIFont systemFontOfSize:13];
[button setTitleColor:[UIColor colorWithWhite:0.5 alpha:1.0] forState:UIControlStateNormal];
return button;
}
@end

View File

@@ -0,0 +1,365 @@
//
// EPTabBarController.swift
// YuMi
//
// Created by AI on 2025-10-09.
// Copyright © 2025 YuMi. All rights reserved.
//
import UIKit
import SnapKit
/// EP TabBar
/// + Moment Mine Tab
@objc class EPTabBarController: UITabBarController {
// MARK: - Properties
///
private var globalEventManager: GlobalEventManager?
///
private var isLoggedIn: Bool = false
/// TabBar
private var customTabBarView: UIView!
///
private var tabBarBackgroundView: UIVisualEffectView!
/// Tab
private var tabButtons: [UIButton] = []
// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
//
#if DEBUG
APIConfig.testEncryption()
#endif
// TabBar
self.tabBar.isHidden = true
setupCustomFloatingTabBar()
setupGlobalManagers()
setupInitialViewControllers()
NSLog("[EPTabBarController] 悬浮 TabBar 初始化完成")
}
deinit {
globalEventManager?.removeAllDelegates()
NSLog("[EPTabBarController] 已释放")
}
// MARK: - Setup
/// TabBar
private func setupCustomFloatingTabBar() {
//
customTabBarView = UIView()
customTabBarView.translatesAutoresizingMaskIntoConstraints = false
customTabBarView.backgroundColor = .clear
view.addSubview(customTabBarView)
// /
let effect: UIVisualEffect
if #available(iOS 26.0, *) {
// iOS 26+ 使Material
effect = UIGlassEffect()
} else {
// iOS 13-17 使
effect = UIBlurEffect(style: .systemMaterial)
}
tabBarBackgroundView = UIVisualEffectView(effect: effect)
tabBarBackgroundView.translatesAutoresizingMaskIntoConstraints = false
tabBarBackgroundView.layer.cornerRadius = 28
tabBarBackgroundView.layer.masksToBounds = true
//
tabBarBackgroundView.layer.borderWidth = 0.5
tabBarBackgroundView.layer.borderColor = UIColor.white.withAlphaComponent(0.2).cgColor
customTabBarView.addSubview(tabBarBackgroundView)
// Masonry
customTabBarView.snp.makeConstraints { make in
make.leading.equalTo(view).offset(16)
make.trailing.equalTo(view).offset(-16)
make.bottom.equalTo(view.safeAreaLayoutGuide).offset(-12)
make.height.equalTo(64)
}
tabBarBackgroundView.snp.makeConstraints { make in
make.edges.equalTo(customTabBarView)
}
// Tab
setupTabButtons()
NSLog("[EPTabBarController] 悬浮 TabBar 设置完成")
}
/// Tab
private func setupTabButtons() {
let momentButton = createTabButton(
normalImage: "tab_moment_off",
selectedImage: "tab_moment_on",
tag: 0
)
momentButton.isSelected = true
let mineButton = createTabButton(
normalImage: "tab_mine_off",
selectedImage: "tab_mine_on",
tag: 1
)
mineButton.isSelected = true
tabButtons = [momentButton, mineButton]
let stackView = UIStackView(arrangedSubviews: tabButtons)
stackView.axis = .horizontal
stackView.distribution = .fillEqually
stackView.spacing = 20
stackView.translatesAutoresizingMaskIntoConstraints = false
tabBarBackgroundView.contentView.addSubview(stackView)
stackView.snp.makeConstraints { make in
make.top.equalTo(tabBarBackgroundView).offset(8)
make.leading.equalTo(tabBarBackgroundView).offset(20)
make.trailing.equalTo(tabBarBackgroundView).offset(-20)
make.bottom.equalTo(tabBarBackgroundView).offset(-8)
}
//
updateTabButtonStates(selectedIndex: 0)
}
/// Tab
private func createTabButton(normalImage: String, selectedImage: String, tag: Int) -> UIButton {
let button = UIButton(type: .custom)
button.tag = tag
// button便
button.accessibilityLabel = normalImage
button.accessibilityHint = selectedImage
// 使 SF Symbols
if let normalImg = UIImage(named: normalImage), let _ = UIImage(named: selectedImage) {
// 使 off
button.setImage(normalImg, for: .normal)
} else {
// 使 SF Symbols
let fallbackIcons = ["sparkles", "person.circle"]
let iconName = fallbackIcons[tag]
let imageConfig = UIImage.SymbolConfiguration(pointSize: 24, weight: .medium)
button.setImage(UIImage(systemName: iconName, withConfiguration: imageConfig), for: .normal)
button.tintColor = .white.withAlphaComponent(0.6)
}
//
button.imageView?.contentMode = .scaleAspectFit
// 使
button.setTitle(nil, for: .normal)
button.setTitle(nil, for: .selected)
//
button.imageView?.snp.makeConstraints { make in
make.size.equalTo(28) //
}
button.addTarget(self, action: #selector(tabButtonTapped(_:)), for: .touchUpInside)
return button
}
/// Tab
@objc private func tabButtonTapped(_ sender: UIButton) {
let newIndex = sender.tag
// tab
if newIndex == selectedIndex {
return
}
//
updateTabButtonStates(selectedIndex: newIndex)
// ViewController使
selectedIndex = newIndex
let tabNames = ["动态", "我的"]
NSLog("[EPTabBarController] 选中 Tab: \(tabNames[newIndex])")
}
/// Tab
private func updateTabButtonStates(selectedIndex: Int) {
//
tabButtons.forEach { $0.isUserInteractionEnabled = false }
for (index, button) in tabButtons.enumerated() {
let isSelected = (index == selectedIndex)
button.isSelected = isSelected
//
if let normalImageName = button.accessibilityLabel,
let selectedImageName = button.accessibilityHint {
// 使
let imageName = isSelected ? selectedImageName : normalImageName
if let image = UIImage(named: imageName) {
button.setImage(image, for: .normal)
} else {
// 使 SF Symbols
button.tintColor = isSelected ? .white : .white.withAlphaComponent(0.6)
}
} else {
// 使 SF Symbols
button.tintColor = isSelected ? .white : .white.withAlphaComponent(0.6)
}
//
UIView.animate(withDuration: 0.25, delay: 0, options: [.curveEaseInOut], animations: {
button.transform = isSelected ? CGAffineTransform(scaleX: 1.1, y: 1.1) : .identity
}, completion: nil)
}
//
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
self.tabButtons.forEach { $0.isUserInteractionEnabled = true }
}
}
///
private func setupGlobalManagers() {
globalEventManager = GlobalEventManager.shared()
globalEventManager?.setupSDKDelegates()
// TODO: v0.2
// Build Configuration
/*
if let containerView = view {
globalEventManager?.setupRoomMiniView(on: containerView)
}
*/
//
globalEventManager?.registerSocialShareCallback()
NSLog("[EPTabBarController] 全局管理器设置完成v0.2 - 无 MiniRoom")
}
/// ViewController
private func setupInitialViewControllers() {
// TODO: 使
let blankVC1 = UIViewController()
blankVC1.view.backgroundColor = .white
blankVC1.tabBarItem = createTabBarItem(
title: "动态",
normalImage: "tab_moment_normal",
selectedImage: "tab_moment_selected"
)
let blankVC2 = UIViewController()
blankVC2.view.backgroundColor = .white
blankVC2.tabBarItem = createTabBarItem(
title: "我的",
normalImage: "tab_mine_normal",
selectedImage: "tab_mine_selected"
)
viewControllers = [blankVC1, blankVC2]
selectedIndex = 0
NSLog("[EPTabBarController] 初始 ViewControllers 设置完成")
}
/// TabBarItem
/// - Parameters:
/// - title:
/// - normalImage:
/// - selectedImage:
/// - Returns: UITabBarItem
private func createTabBarItem(title: String, normalImage: String, selectedImage: String) -> UITabBarItem {
let item = UITabBarItem(
title: title,
image: UIImage(named: normalImage)?.withRenderingMode(.alwaysOriginal),
selectedImage: UIImage(named: selectedImage)?.withRenderingMode(.alwaysOriginal)
)
return item
}
// MARK: - Public Methods
/// TabBar
/// - Parameter isLogin:
func refreshTabBar(isLogin: Bool) {
isLoggedIn = isLogin
if isLogin {
setupLoggedInViewControllers()
} else {
setupInitialViewControllers()
}
NSLog("[EPTabBarController] TabBar 已刷新,登录状态: \(isLogin)")
}
/// ViewControllers
private func setupLoggedInViewControllers() {
// viewControllers
if viewControllers?.count != 2 ||
!(viewControllers?[0] is EPMomentViewController) ||
!(viewControllers?[1] is EPMineViewController) {
// ViewControllerOC
let momentVC = EPMomentViewController()
momentVC.tabBarItem = createTabBarItem(
title: "动态",
normalImage: "tab_moment_normal",
selectedImage: "tab_moment_selected"
)
let mineVC = EPMineViewController()
mineVC.tabBarItem = createTabBarItem(
title: "我的",
normalImage: "tab_mine_normal",
selectedImage: "tab_mine_selected"
)
viewControllers = [momentVC, mineVC]
NSLog("[EPTabBarController] 登录后 ViewControllers 创建完成 - Moment & Mine")
}
selectedIndex = 0
}
}
// MARK: - UITabBarControllerDelegate
extension EPTabBarController: UITabBarControllerDelegate {
override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
NSLog("[EPTabBarController] 选中 Tab: \(item.title ?? "Unknown")")
}
}
// MARK: - OC Compatibility
extension EPTabBarController {
/// OC
@objc static func create() -> EPTabBarController {
return EPTabBarController()
}
/// OC TabBar
@objc func refreshTabBarWithIsLogin(_ isLogin: Bool) {
refreshTabBar(isLogin: isLogin)
}
}