
主要变更: 1. 在 .gitignore 中添加了 Docs/ 文件夹,以忽略文档相关文件。 2. 删除了多个过时的文档,包括构建指南、编译修复指南和当前状态报告等。 此更新旨在清理项目文件,确保版本控制的整洁性。
214 lines
7.4 KiB
Objective-C
214 lines
7.4 KiB
Objective-C
//
|
|
// EPEmotionInfoView.m
|
|
// YuMi
|
|
//
|
|
// 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
|
|
|