feat: 更新 EPLoginTypesViewController 和 EPLoginInputView 以增强布局和用户体验

主要变更:
1. 在 EPLoginTypesViewController 中添加了对多个 UI 组件的约束设置,确保布局更加灵活。
2. 更新了标题标签的文本内容,使用本地化字符串替代硬编码文本,提升国际化支持。
3. 在 EPLoginInputView 中为多个组件添加了自动布局支持,确保在不同屏幕尺寸下的适配性。

此更新旨在提升用户界面的可用性和美观性,确保更好的用户体验。
This commit is contained in:
edwinQQQ
2025-10-14 17:46:37 +08:00
parent 9466b65b40
commit de8627a230
8 changed files with 89 additions and 28 deletions

View File

@@ -71,6 +71,7 @@ class EPLoginTypesViewController: BaseViewController {
private func setupBackground() { private func setupBackground() {
view.addSubview(backgroundImageView) view.addSubview(backgroundImageView)
backgroundImageView.translatesAutoresizingMaskIntoConstraints = false
backgroundImageView.image = kImage(EPLoginConfig.Images.background) backgroundImageView.image = kImage(EPLoginConfig.Images.background)
backgroundImageView.contentMode = .scaleAspectFill backgroundImageView.contentMode = .scaleAspectFill
@@ -81,6 +82,7 @@ class EPLoginTypesViewController: BaseViewController {
private func setupNavigationBar() { private func setupNavigationBar() {
view.addSubview(backButton) view.addSubview(backButton)
backButton.translatesAutoresizingMaskIntoConstraints = false
backButton.setImage(UIImage(systemName: EPLoginConfig.Images.iconBack), for: .normal) backButton.setImage(UIImage(systemName: EPLoginConfig.Images.iconBack), for: .normal)
backButton.tintColor = EPLoginConfig.Colors.textLight backButton.tintColor = EPLoginConfig.Colors.textLight
backButton.addTarget(self, action: #selector(handleBack), for: .touchUpInside) backButton.addTarget(self, action: #selector(handleBack), for: .touchUpInside)
@@ -94,16 +96,20 @@ class EPLoginTypesViewController: BaseViewController {
private func setupTitle() { private func setupTitle() {
view.addSubview(titleLabel) view.addSubview(titleLabel)
titleLabel.translatesAutoresizingMaskIntoConstraints = false
titleLabel.font = .systemFont(ofSize: EPLoginConfig.Layout.titleFontSize, weight: .bold) titleLabel.font = .systemFont(ofSize: EPLoginConfig.Layout.titleFontSize, weight: .bold)
titleLabel.textColor = EPLoginConfig.Colors.textLight titleLabel.textColor = EPLoginConfig.Colors.textLight
titleLabel.snp.makeConstraints { make in titleLabel.snp.makeConstraints { make in
make.centerX.equalToSuperview() make.centerX.equalToSuperview()
make.top.equalTo(view.safeAreaLayoutGuide).offset(100) make.centerY.equalTo(backButton) //
} }
} }
private func setupInputViews() { private func setupInputViews() {
firstInputView.translatesAutoresizingMaskIntoConstraints = false
secondInputView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(firstInputView) view.addSubview(firstInputView)
view.addSubview(secondInputView) view.addSubview(secondInputView)
@@ -123,6 +129,7 @@ class EPLoginTypesViewController: BaseViewController {
private func setupActionButton() { private func setupActionButton() {
view.addSubview(actionButton) view.addSubview(actionButton)
actionButton.translatesAutoresizingMaskIntoConstraints = false
actionButton.setTitle("Login", for: .normal) actionButton.setTitle("Login", for: .normal)
actionButton.setTitleColor(EPLoginConfig.Colors.textLight, for: .normal) actionButton.setTitleColor(EPLoginConfig.Colors.textLight, for: .normal)
actionButton.layer.cornerRadius = EPLoginConfig.Layout.uniformCornerRadius actionButton.layer.cornerRadius = EPLoginConfig.Layout.uniformCornerRadius
@@ -232,7 +239,7 @@ class EPLoginTypesViewController: BaseViewController {
actionButton.setTitle("Login", for: .normal) actionButton.setTitle("Login", for: .normal)
case .emailReset: case .emailReset:
titleLabel.text = "Recover Password" titleLabel.text = YMLocalizedString("20.20.51_text_20")
firstInputView.configure(with: EPLoginInputConfig( firstInputView.configure(with: EPLoginInputConfig(
showAreaCode: false, showAreaCode: false,
showCodeButton: false, showCodeButton: false,
@@ -263,7 +270,7 @@ class EPLoginTypesViewController: BaseViewController {
actionButton.setTitle("Confirm", for: .normal) actionButton.setTitle("Confirm", for: .normal)
case .phoneReset: case .phoneReset:
titleLabel.text = "Recover Password" titleLabel.text = YMLocalizedString("20.20.51_text_20")
firstInputView.configure(with: EPLoginInputConfig( firstInputView.configure(with: EPLoginInputConfig(
showAreaCode: false, showAreaCode: false,
showCodeButton: false, showCodeButton: false,
@@ -297,6 +304,7 @@ class EPLoginTypesViewController: BaseViewController {
private func setupForgotPasswordButton() { private func setupForgotPasswordButton() {
let button = UIButton(type: .system) let button = UIButton(type: .system)
button.translatesAutoresizingMaskIntoConstraints = false
button.setTitle("Forgot Password?", for: .normal) button.setTitle("Forgot Password?", for: .normal)
button.setTitleColor(EPLoginConfig.Colors.textLight, for: .normal) button.setTitleColor(EPLoginConfig.Colors.textLight, for: .normal)
button.titleLabel?.font = .systemFont(ofSize: EPLoginConfig.Layout.smallFontSize) button.titleLabel?.font = .systemFont(ofSize: EPLoginConfig.Layout.smallFontSize)
@@ -314,6 +322,7 @@ class EPLoginTypesViewController: BaseViewController {
private func setupThirdInputView() { private func setupThirdInputView() {
let inputView = EPLoginInputView() let inputView = EPLoginInputView()
inputView.translatesAutoresizingMaskIntoConstraints = false
inputView.configure(with: EPLoginInputConfig( inputView.configure(with: EPLoginInputConfig(
showAreaCode: false, showAreaCode: false,
showCodeButton: false, showCodeButton: false,

View File

@@ -94,6 +94,7 @@ class EPLoginInputView: UIView {
stackView.alignment = .center stackView.alignment = .center
stackView.distribution = .fill stackView.distribution = .fill
stackView.spacing = 8 stackView.spacing = 8
stackView.translatesAutoresizingMaskIntoConstraints = false
addSubview(stackView) addSubview(stackView)
setupAreaCodeView() setupAreaCodeView()
@@ -120,19 +121,23 @@ class EPLoginInputView: UIView {
areaStackView.alignment = .center areaStackView.alignment = .center
areaStackView.distribution = .fill areaStackView.distribution = .fill
areaStackView.spacing = 8 areaStackView.spacing = 8
areaStackView.translatesAutoresizingMaskIntoConstraints = false
// //
areaCodeButton.setTitle("+86", for: .normal) areaCodeButton.setTitle("+86", for: .normal)
areaCodeButton.setTitleColor(EPLoginConfig.Colors.inputText, for: .normal) areaCodeButton.setTitleColor(EPLoginConfig.Colors.inputText, for: .normal)
areaCodeButton.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium) areaCodeButton.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
areaCodeButton.isUserInteractionEnabled = false areaCodeButton.isUserInteractionEnabled = false
areaCodeButton.translatesAutoresizingMaskIntoConstraints = false
// //
areaArrowImageView.image = kImage("login_area_arrow") areaArrowImageView.image = kImage("login_area_arrow")
areaArrowImageView.contentMode = .scaleAspectFit areaArrowImageView.contentMode = .scaleAspectFit
areaArrowImageView.isUserInteractionEnabled = false areaArrowImageView.isUserInteractionEnabled = false
areaArrowImageView.translatesAutoresizingMaskIntoConstraints = false
// //
areaTapButton.translatesAutoresizingMaskIntoConstraints = false
areaTapButton.addTarget(self, action: #selector(handleAreaTap), for: .touchUpInside) areaTapButton.addTarget(self, action: #selector(handleAreaTap), for: .touchUpInside)
areaStackView.addSubview(areaTapButton) areaStackView.addSubview(areaTapButton)
@@ -147,7 +152,6 @@ class EPLoginInputView: UIView {
areaCodeButton.snp.makeConstraints { make in areaCodeButton.snp.makeConstraints { make in
make.width.lessThanOrEqualTo(60) make.width.lessThanOrEqualTo(60)
make.height.equalTo(stackView)
} }
areaArrowImageView.snp.makeConstraints { make in areaArrowImageView.snp.makeConstraints { make in
@@ -160,6 +164,7 @@ class EPLoginInputView: UIView {
// Icon () // Icon ()
iconImageView.contentMode = .scaleAspectFit iconImageView.contentMode = .scaleAspectFit
iconImageView.tintColor = EPLoginConfig.Colors.icon iconImageView.tintColor = EPLoginConfig.Colors.icon
iconImageView.translatesAutoresizingMaskIntoConstraints = false
stackView.addArrangedSubview(iconImageView) stackView.addArrangedSubview(iconImageView)
iconImageView.snp.makeConstraints { make in iconImageView.snp.makeConstraints { make in
@@ -170,12 +175,9 @@ class EPLoginInputView: UIView {
inputTextField.textColor = EPLoginConfig.Colors.textLight inputTextField.textColor = EPLoginConfig.Colors.textLight
inputTextField.font = .systemFont(ofSize: 14) inputTextField.font = .systemFont(ofSize: 14)
inputTextField.tintColor = EPLoginConfig.Colors.textLight inputTextField.tintColor = EPLoginConfig.Colors.textLight
inputTextField.translatesAutoresizingMaskIntoConstraints = false
inputTextField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged) inputTextField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
stackView.addArrangedSubview(inputTextField) stackView.addArrangedSubview(inputTextField)
inputTextField.snp.makeConstraints { make in
make.height.equalTo(stackView)
}
} }
@objc private func textFieldDidChange() { @objc private func textFieldDidChange() {
@@ -183,6 +185,7 @@ class EPLoginInputView: UIView {
} }
private func setupEyeButton() { private func setupEyeButton() {
eyeButton.translatesAutoresizingMaskIntoConstraints = false
eyeButton.setImage(kImage(EPLoginConfig.Images.iconPasswordUnsee), for: .normal) eyeButton.setImage(kImage(EPLoginConfig.Images.iconPasswordUnsee), for: .normal)
eyeButton.setImage(kImage(EPLoginConfig.Images.iconPasswordSee), for: .selected) eyeButton.setImage(kImage(EPLoginConfig.Images.iconPasswordSee), for: .selected)
eyeButton.addTarget(self, action: #selector(handleEyeTap), for: .touchUpInside) eyeButton.addTarget(self, action: #selector(handleEyeTap), for: .touchUpInside)
@@ -194,6 +197,7 @@ class EPLoginInputView: UIView {
} }
private func setupCodeButton() { private func setupCodeButton() {
codeButton.translatesAutoresizingMaskIntoConstraints = false
codeButton.setTitle(YMLocalizedString("XPLoginInputView0"), for: .normal) codeButton.setTitle(YMLocalizedString("XPLoginInputView0"), for: .normal)
codeButton.setTitleColor(.white, for: .normal) codeButton.setTitleColor(.white, for: .normal)
codeButton.titleLabel?.font = .systemFont(ofSize: 12, weight: .medium) codeButton.titleLabel?.font = .systemFont(ofSize: 12, weight: .medium)

View File

@@ -11,7 +11,7 @@ import SnapKit
/// ///
/// 退 /// 退
class EPEditSettingViewController: UIViewController { class EPEditSettingViewController: BaseViewController {
// MARK: - UI Components // MARK: - UI Components
private lazy var profileImageView: UIImageView = { private lazy var profileImageView: UIImageView = {
@@ -317,19 +317,33 @@ class EPEditSettingViewController: UIViewController {
} }
private func updateNickname(_ newNickname: String) { private func updateNickname(_ newNickname: String) {
// UserInfoModel //
let userInfo = UserInfoModel() showLoading()
userInfo.nick = newNickname
// Presenter (OC) // API
let presenter = XPMineUserInfoEditPresenter() apiHelper.updateNickname(withNick: newNickname,
presenter.getUserInfoEditDataSource(withUserInfo: userInfo) completion: { [weak self] in
self?.hideHUD()
//
self.userInfo?.nick = newNickname //
tableView.reloadData() self?.userInfo?.nick = newNickname
self?.tableView.reloadData()
print("[EPEditSetting] 昵称更新为: \(newNickname)")
//
self?.showSuccessToast(YMLocalizedString("XPMineUserInfoEditViewController13"))
print("[EPEditSetting] 昵称更新成功: \(newNickname)")
},
failure: { [weak self] (code: Int, msg: String?) in
self?.hideHUD()
//
let errorMsg = msg ?? "昵称更新失败,请稍后重试"
self?.showErrorToast(errorMsg)
print("[EPEditSetting] 昵称更新失败: \(code) - \(errorMsg)")
}
)
} }
private func showLogoutConfirm() { private func showLogoutConfirm() {

View File

@@ -79,7 +79,7 @@
make.top.mas_equalTo(self.view); make.top.mas_equalTo(self.view);
make.leading.mas_equalTo(self.view); make.leading.mas_equalTo(self.view);
make.trailing.mas_equalTo(self.view); make.trailing.mas_equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(320)); make.height.mas_equalTo(kGetScaleWidth(260));
}]; }];
// //
@@ -100,7 +100,6 @@
self.momentListView = [[EPMomentListView alloc] initWithFrame:CGRectZero]; self.momentListView = [[EPMomentListView alloc] initWithFrame:CGRectZero];
[self.view addSubview:self.momentListView]; [self.view addSubview:self.momentListView];
// 使 Masonry
[self.momentListView mas_makeConstraints:^(MASConstraintMaker *make) { [self.momentListView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.headerView.mas_bottom); make.top.mas_equalTo(self.headerView.mas_bottom);
make.bottom.mas_equalTo(self.view); make.bottom.mas_equalTo(self.view);
@@ -118,10 +117,10 @@
return; return;
} }
__weak typeof(self) weakSelf = self; @kWeakify(self);
[self.apiHelper getUserDetailInfoWithUid:uid [self.apiHelper getUserDetailInfoWithUid:uid
completion:^(UserInfoModel * _Nullable userInfo) { completion:^(UserInfoModel * _Nullable userInfo) {
__strong typeof(weakSelf) self = weakSelf; @kStrongify(self);
if (!userInfo) { if (!userInfo) {
NSLog(@"[EPMineViewController] 加载用户信息失败"); NSLog(@"[EPMineViewController] 加载用户信息失败");
return; return;

View File

@@ -29,6 +29,11 @@ NS_ASSUME_NONNULL_BEGIN
completion:(void (^)(void))completion completion:(void (^)(void))completion
failure:(void (^)(NSInteger code, NSString * _Nullable msg))failure; failure:(void (^)(NSInteger code, NSString * _Nullable msg))failure;
/// 更新用户昵称
- (void)updateNicknameWithNick:(NSString *)nickname
completion:(void (^)(void))completion
failure:(void (^)(NSInteger code, NSString * _Nullable msg))failure;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -9,6 +9,7 @@
#import "Api+Mine.h" #import "Api+Mine.h"
#import "UserInfoModel.h" #import "UserInfoModel.h"
#import "BaseModel.h" #import "BaseModel.h"
#import "AccountInfoStorage.h"
@implementation EPMineAPIHelper @implementation EPMineAPIHelper
@@ -50,5 +51,27 @@
} avatarUrl:avatarUrl needPay:@NO]; } avatarUrl:avatarUrl needPay:@NO];
} }
- (void)updateNicknameWithNick:(NSString *)nickname
completion:(void (^)(void))completion
failure:(void (^)(NSInteger code, NSString * _Nullable msg))failure {
NSString *uid = [[AccountInfoStorage instance] getUid];
NSString *ticket = [[AccountInfoStorage instance] getTicket];
NSMutableDictionary *params = [NSMutableDictionary dictionary];
if (nickname.length > 0) {
[params setValue:nickname forKey:@"nick"];
}
[params setObject:uid forKey:@"uid"];
[params setObject:ticket forKey:@"ticket"];
[Api completeUserInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
if (completion) completion();
} else {
if (failure) failure(code, msg);
}
} userInfo:params];
}
@end @end

View File

@@ -90,10 +90,16 @@ NSString *const EPMomentPublishSuccessNotification = @"EPMomentPublishSuccessNot
make.leading.trailing.equalTo(self.textView); make.leading.trailing.equalTo(self.textView);
make.height.mas_equalTo(1); make.height.mas_equalTo(1);
}]; }];
// 3
// itemW = ( - 30 - 20) / 3
// = 3itemW + 2(10*2)
CGFloat itemW = (KScreenWidth - 15*2 - 10*2)/3.0;
CGFloat collectionHeight = itemW * 3 + 10 * 2;
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) { [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.equalTo(self.contentView).inset(15); make.leading.trailing.equalTo(self.contentView).inset(15);
make.top.equalTo(self.lineView.mas_bottom).offset(10); make.top.equalTo(self.lineView.mas_bottom).offset(10);
make.height.mas_equalTo(110); make.height.mas_equalTo(collectionHeight);
}]; }];
// //

View File

@@ -120,7 +120,8 @@
make.leading.trailing.equalTo(self.cardView); make.leading.trailing.equalTo(self.cardView);
make.top.equalTo(self.imagesContainer.mas_bottom).offset(12); make.top.equalTo(self.imagesContainer.mas_bottom).offset(12);
make.height.mas_equalTo(50); make.height.mas_equalTo(50);
make.bottom.equalTo(self.cardView).offset(-8); //
make.bottom.equalTo(self.cardView).offset(-8).priority(UILayoutPriorityDefaultHigh);
}]; }];
// //