Files
real-e-party-iOS/YuMi/E-P/Moments/Controllers/EPMomentViewController.m
edwinQQQ f84044425f feat: 添加优化版本的 Localizable.strings 清理工具
主要变更:
1. 新增 clean_localizable_optimized.py 脚本,用于清理 Localizable.strings 文件,只保留使用的 key,并移除多余空行。
2. 优化了清理逻辑,支持多语言版本的处理,提升了文件的整洁性和可维护性。
3. 生成清理报告,显示保留和删除的 key 数量及删除率。

此更新旨在提高本地化文件的管理效率,减少冗余内容。
2025-10-17 15:38:34 +08:00

181 lines
5.9 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

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.

// Created by AI on 2025-10-09.
// Copyright © 2025 YuMi. All rights reserved.
#import "EPMomentViewController.h"
#import <UIKit/UIKit.h>
#import <Masonry/Masonry.h>
#import "EPMomentCell.h"
#import "EPMomentListView.h"
#import "EPMomentPublishViewController.h"
#import "YUMIMacroUitls.h"
@interface EPMomentViewController ()
// MARK: - UI Components
@property (nonatomic, strong) EPMomentListView *listView;
@property (nonatomic, strong) UIImageView *topIconImageView;
@property (nonatomic, strong) UILabel *topTipLabel;
@end
@implementation EPMomentViewController
// MARK: - Lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Enjoy your Life Time";
[self.navigationController.navigationBar setTitleTextAttributes:@{
NSForegroundColorAttributeName: [UIColor whiteColor]
}];
[self setupUI];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onMomentPublishSuccess:)
name:EPMomentPublishSuccessNotification
object:nil];
NSLog(@"[EPMomentViewController] 页面加载完成UI 已设置");
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSLog(@"[EPMomentViewController] 首次 viewDidAppear延迟 0.3s 后开始加载数据");
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSLog(@"[EPMomentViewController] 触发首次数据加载");
[self.listView reloadFirstPage];
});
});
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
// MARK: - Setup UI
- (void)setupUI {
UIImageView *bgImageView = [[UIImageView alloc] initWithImage:kImage(@"vc_bg")];
bgImageView.contentMode = UIViewContentModeScaleAspectFill;
bgImageView.clipsToBounds = YES;
[self.view addSubview:bgImageView];
[bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
}];
[self.view addSubview:self.topIconImageView];
[self.topIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop).offset(14);
make.size.mas_equalTo(CGSizeMake(56, 41));
}];
[self.view addSubview:self.topTipLabel];
[self.topTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.topIconImageView.mas_bottom).offset(14);
make.leading.trailing.equalTo(self.view).inset(20);
}];
[self.view addSubview:self.listView];
[self.listView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.bottom.equalTo(self.view);
make.top.equalTo(self.topTipLabel.mas_bottom).offset(8);
}];
UIImage *addIcon = [UIImage imageNamed:@"icon_moment_add"];
UIButton *publishButton = [UIButton buttonWithType:UIButtonTypeCustom];
publishButton.contentMode = UIViewContentModeScaleAspectFit;
[publishButton setImage:addIcon forState:UIControlStateNormal];
publishButton.frame = CGRectMake(0, 0, 40, 40);
[publishButton addTarget:self action:@selector(onPublishButtonTapped) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *publishItem = [[UIBarButtonItem alloc] initWithCustomView:publishButton];
self.navigationItem.rightBarButtonItem = publishItem;
NSLog(@"[EPMomentViewController] UI 设置完成");
}
// MARK: - Actions
- (void)onPublishButtonTapped {
NSLog(@"[EPMomentViewController] 发布按钮点击");
EPMomentPublishViewController *vc = [[EPMomentPublishViewController alloc] init];
vc.modalPresentationStyle = UIModalPresentationFullScreen;
[self.navigationController presentViewController:vc animated:YES completion:nil];
}
- (void)showAlertWithMessage:(NSString *)message {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:YMLocalizedString(@"common.tips")
message:message
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:YMLocalizedString(@"common.confirm") style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alert animated:YES completion:nil];
}
- (void)onMomentPublishSuccess:(NSNotification *)notification {
NSLog(@"[EPMomentViewController] 收到发布成功通知,刷新列表");
[self.listView reloadFirstPage];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
// MARK: - Lazy Loading
- (EPMomentListView *)listView {
if (!_listView) {
_listView = [[EPMomentListView alloc] initWithFrame:CGRectZero];
_listView.onSelectMoment = ^(NSInteger index) {
};
}
return _listView;
}
- (UIImageView *)topIconImageView {
if (!_topIconImageView) {
_topIconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_moment_Volume"]];
_topIconImageView.contentMode = UIViewContentModeScaleAspectFit;
}
return _topIconImageView;
}
- (UILabel *)topTipLabel {
if (!_topTipLabel) {
_topTipLabel = [UILabel new];
_topTipLabel.numberOfLines = 0;
_topTipLabel.textColor = [UIColor whiteColor];
_topTipLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightRegular];
_topTipLabel.text = @"In the quiet gallery of the heart, we learn to see the colors of emotion. And in the shared silence between souls, we begin to find the sound of resonance. This is more than an app—it's a space where your inner world is both a masterpiece and a melody.";
}
return _topTipLabel;
}
@end