feat: 添加情绪颜色选择功能及相关存储管理

主要变更:
1. 在 EPMomentPublishViewController 中添加情绪颜色选择按钮,用户可通过色轮选择情绪颜色。
2. 新增 EPEmotionColorStorage 类,提供情绪颜色的保存、获取和删除功能,支持动态 ID 的关联。
3. 新增 EPEmotionColorPicker 视图,提供环形布局的颜色选择器,增强用户体验。
4. 更新 EPMomentCell 和 EPMomentListView,以支持情绪颜色的显示和处理,确保动态展示的情绪效果。

此更新旨在提升用户交互体验,丰富动态发布功能,确保情绪颜色的有效管理和展示。
This commit is contained in:
edwinQQQ
2025-10-14 18:26:16 +08:00
parent de8627a230
commit a8319c61d8
9 changed files with 561 additions and 5 deletions

View File

@@ -10,6 +10,7 @@
#import "EPMomentCell.h"
#import <MJRefresh/MJRefresh.h>
#import "YuMi-Swift.h"
#import "EPEmotionColorStorage.h"
@interface EPMomentListView () <UITableViewDelegate, UITableViewDataSource>
@@ -91,6 +92,9 @@
@kStrongify(self);
[self endLoading];
if (list.count > 0) {
//
[self processEmotionColors:list isFirstPage:(self.nextID.length == 0)];
self.nextID = nextMomentID;
[self.mutableRawList addObjectsFromArray:list];
[self.tableView reloadData];
@@ -120,6 +124,41 @@
[self.refreshControl endRefreshing];
}
/// UserDefaults +
- (void)processEmotionColors:(NSArray<MomentsInfoModel *> *)list isFirstPage:(BOOL)isFirstPage {
//
NSString *pendingColor = [[NSUserDefaults standardUserDefaults] stringForKey:@"EP_Pending_Emotion_Color"];
NSNumber *pendingTimestamp = [[NSUserDefaults standardUserDefaults] objectForKey:@"EP_Pending_Emotion_Timestamp"];
for (NSInteger i = 0; i < list.count; i++) {
MomentsInfoModel *model = list[i];
//
if (isFirstPage && i == 0 && pendingColor && pendingTimestamp) {
// 5
NSTimeInterval now = [[NSDate date] timeIntervalSince1970];
NSTimeInterval pending = pendingTimestamp.doubleValue;
if ((now - pending) < 5.0) {
model.emotionColor = pendingColor;
//
[EPEmotionColorStorage saveColor:pendingColor forDynamicId:model.dynamicId];
//
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"EP_Pending_Emotion_Color"];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"EP_Pending_Emotion_Timestamp"];
[[NSUserDefaults standardUserDefaults] synchronize];
continue;
}
}
//
NSString *savedColor = [EPEmotionColorStorage colorForDynamicId:model.dynamicId];
if (savedColor) {
model.emotionColor = savedColor;
}
// nilCell
}
}
#pragma mark - UITableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {