Files
real-e-party-iOS/YuMi/E-P/NewMoments/Views/EPEmotionInfoView.m
edwinQQQ c8173bf034 refactor: 移除 Core Data 相关代码并添加新的消息列表视图控制器
主要变更:
1. 从 AppDelegate 中移除 Core Data 相关的属性和方法,简化应用结构。
2. 新增 EPBaseListViewController 作为消息列表的基础类,提供通用的表视图功能。
3. 添加 EPMessageListVC、EPFriendListVC、EPFollowingListVC 和 EPFansListVC,分别用于展示消息、朋友、关注和粉丝列表。
4. 引入 EPMessageSegmentView 以支持消息主界面的分段控制。

此更新旨在提升代码的可维护性,简化数据管理,并增强用户界面的功能性和交互性。
2025-10-20 11:25:33 +08:00

211 lines
7.2 KiB
Objective-C

// Created by AI on 2025-10-16.
#import "EPEmotionInfoView.h"
#import <Masonry/Masonry.h>
@interface EPEmotionInfoView ()
@property (nonatomic, strong) UIView *backgroundMask;
@property (nonatomic, strong) UIView *contentContainer;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) UILabel *contentLabel;
@property (nonatomic, strong) UIButton *closeButton;
@end
@implementation EPEmotionInfoView
#pragma mark - Lifecycle
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self setupUI];
}
return self;
}
- (void)setupUI {
self.backgroundColor = [UIColor clearColor];
[self addSubview:self.backgroundMask];
[self.backgroundMask mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
[self addSubview:self.contentContainer];
[self.contentContainer mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self);
make.leading.trailing.equalTo(self).inset(30);
make.height.mas_lessThanOrEqualTo(500);
}];
[self.contentContainer addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentContainer).offset(24);
make.leading.trailing.equalTo(self.contentContainer).inset(20);
}];
[self.contentContainer addSubview:self.scrollView];
[self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.titleLabel.mas_bottom).offset(16);
make.leading.trailing.equalTo(self.contentContainer).inset(20);
make.height.mas_lessThanOrEqualTo(320);
}];
[self.scrollView addSubview:self.contentLabel];
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.scrollView);
make.width.equalTo(self.scrollView);
}];
[self.contentContainer addSubview:self.closeButton];
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.scrollView.mas_bottom).offset(20);
make.centerX.equalTo(self.contentContainer);
make.leading.trailing.equalTo(self.contentContainer).inset(20);
make.height.mas_equalTo(50);
make.bottom.equalTo(self.contentContainer).offset(-24);
}];
}
#pragma mark - Actions
- (void)onBackgroundTapped {
[self dismiss];
}
- (void)onCloseButtonTapped {
[self dismiss];
}
#pragma mark - Public Methods
- (void)showInView:(UIView *)parentView {
[parentView addSubview:self];
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(parentView);
}];
self.backgroundMask.alpha = 0;
self.contentContainer.alpha = 0;
self.contentContainer.transform = CGAffineTransformMakeScale(0.9, 0.9);
[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.backgroundMask.alpha = 1;
self.contentContainer.alpha = 1;
self.contentContainer.transform = CGAffineTransformIdentity;
} completion:nil];
}
- (void)dismiss {
[UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
self.backgroundMask.alpha = 0;
self.contentContainer.alpha = 0;
self.contentContainer.transform = CGAffineTransformMakeScale(0.95, 0.95);
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
#pragma mark - Lazy Loading
- (UIView *)backgroundMask {
if (!_backgroundMask) {
_backgroundMask = [[UIView alloc] init];
_backgroundMask.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onBackgroundTapped)];
[_backgroundMask addGestureRecognizer:tap];
}
return _backgroundMask;
}
- (UIView *)contentContainer {
if (!_contentContainer) {
_contentContainer = [[UIView alloc] init];
_contentContainer.backgroundColor = [UIColor colorWithRed:0x1a/255.0 green:0x1a/255.0 blue:0x2e/255.0 alpha:1.0];
_contentContainer.layer.cornerRadius = 16;
_contentContainer.layer.masksToBounds = YES;
}
return _contentContainer;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.text = @"About Emotion Colors";
_titleLabel.textColor = [UIColor whiteColor];
_titleLabel.font = [UIFont systemFontOfSize:20 weight:UIFontWeightBold];
_titleLabel.textAlignment = NSTextAlignmentCenter;
}
return _titleLabel;
}
- (UIScrollView *)scrollView {
if (!_scrollView) {
_scrollView = [[UIScrollView alloc] init];
_scrollView.showsVerticalScrollIndicator = YES;
_scrollView.alwaysBounceVertical = YES;
}
return _scrollView;
}
- (UILabel *)contentLabel {
if (!_contentLabel) {
_contentLabel = [[UILabel alloc] init];
_contentLabel.numberOfLines = 0;
_contentLabel.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.9];
_contentLabel.font = [UIFont systemFontOfSize:15];
NSString *content = @"Based on Plutchik's Wheel of Emotions, we use 8 core colors to represent fundamental human emotions:\n\n"
"🟡 Joy (Gold)\n"
"Represents happiness, delight, and cheerfulness. Like sunshine warming your heart.\n\n"
"🔵 Sadness (Sky Blue)\n"
"Reflects sorrow, melancholy, and contemplation. The quiet depth of blue skies.\n\n"
"🔴 Anger (Coral Red)\n"
"Expresses frustration, rage, and intensity. The fire of passionate emotions.\n\n"
"🟣 Fear (Violet)\n"
"Embodies anxiety, worry, and apprehension. The uncertainty of purple twilight.\n\n"
"🟠 Surprise (Amber)\n"
"Captures amazement, shock, and wonder. The spark of unexpected moments.\n\n"
"🟢 Disgust (Emerald)\n"
"Conveys aversion, distaste, and rejection. The instinctive green of caution.\n\n"
"🔵 Trust (Bright Blue)\n"
"Symbolizes confidence, faith, and security. The clarity of open skies.\n\n"
"🟡 Anticipation (Amber)\n"
"Represents expectation, hope, and eagerness. The warmth of looking forward.\n\n"
"Each color helps you express your current emotional state in moments you share.";
_contentLabel.text = content;
}
return _contentLabel;
}
- (UIButton *)closeButton {
if (!_closeButton) {
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_closeButton setTitle:@"Got it" forState:UIControlStateNormal];
[_closeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_closeButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
_closeButton.backgroundColor = [UIColor colorWithRed:0x9B/255.0 green:0x59/255.0 blue:0xB6/255.0 alpha:1.0];
_closeButton.layer.cornerRadius = 25;
_closeButton.layer.masksToBounds = YES;
[_closeButton addTarget:self action:@selector(onCloseButtonTapped) forControlEvents:UIControlEventTouchUpInside];
}
return _closeButton;
}
@end