feat: 更新登录模块以支持验证码和渐变背景
主要变更: 1. 在 EPLoginTypesViewController 中添加了渐变背景到 actionButton,提升视觉效果。 2. 实现了输入框状态检查功能,确保在输入有效信息时启用登录按钮。 3. 更新了输入框配置,支持不同类型的键盘输入(如数字键盘和邮箱键盘)。 4. 在 EPLoginService 中添加了对手机号和邮箱的 DES 加密,增强安全性。 5. 更新了 EPLoginConfig,统一输入框和按钮的样式设置。 此更新旨在提升用户体验,确保登录过程的安全性和流畅性。
This commit is contained in:
@@ -16,6 +16,7 @@ struct EPLoginInputConfig {
|
||||
var isSecure: Bool = false
|
||||
var icon: String?
|
||||
var placeholder: String
|
||||
var keyboardType: UIKeyboardType = .default
|
||||
}
|
||||
|
||||
/// 输入框代理
|
||||
@@ -31,6 +32,9 @@ class EPLoginInputView: UIView {
|
||||
|
||||
weak var delegate: EPLoginInputViewDelegate?
|
||||
|
||||
/// 输入内容变化回调
|
||||
var onTextChanged: ((String) -> Void)?
|
||||
|
||||
private let stackView = UIStackView()
|
||||
|
||||
// 区号区域
|
||||
@@ -82,6 +86,8 @@ class EPLoginInputView: UIView {
|
||||
private func setupUI() {
|
||||
backgroundColor = EPLoginConfig.Colors.inputBackground
|
||||
layer.cornerRadius = EPLoginConfig.Layout.inputCornerRadius
|
||||
layer.borderWidth = EPLoginConfig.Layout.inputBorderWidth
|
||||
layer.borderColor = EPLoginConfig.Colors.inputBorder.cgColor
|
||||
|
||||
// Main StackView
|
||||
stackView.axis = .horizontal
|
||||
@@ -161,9 +167,10 @@ class EPLoginInputView: UIView {
|
||||
}
|
||||
|
||||
// TextField
|
||||
inputTextField.textColor = EPLoginConfig.Colors.inputText
|
||||
inputTextField.textColor = EPLoginConfig.Colors.textLight
|
||||
inputTextField.font = .systemFont(ofSize: 14)
|
||||
inputTextField.tintColor = EPLoginConfig.Colors.primary
|
||||
inputTextField.tintColor = EPLoginConfig.Colors.textLight
|
||||
inputTextField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
|
||||
stackView.addArrangedSubview(inputTextField)
|
||||
|
||||
inputTextField.snp.makeConstraints { make in
|
||||
@@ -171,15 +178,18 @@ class EPLoginInputView: UIView {
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func textFieldDidChange() {
|
||||
onTextChanged?(inputTextField.text ?? "")
|
||||
}
|
||||
|
||||
private func setupEyeButton() {
|
||||
eyeButton.setImage(UIImage(systemName: "eye.slash"), for: .normal)
|
||||
eyeButton.setImage(UIImage(systemName: "eye"), for: .selected)
|
||||
eyeButton.tintColor = EPLoginConfig.Colors.icon
|
||||
eyeButton.setImage(kImage(EPLoginConfig.Images.iconPasswordUnsee), for: .normal)
|
||||
eyeButton.setImage(kImage(EPLoginConfig.Images.iconPasswordSee), for: .selected)
|
||||
eyeButton.addTarget(self, action: #selector(handleEyeTap), for: .touchUpInside)
|
||||
stackView.addArrangedSubview(eyeButton)
|
||||
|
||||
eyeButton.snp.makeConstraints { make in
|
||||
make.width.equalTo(30)
|
||||
make.size.equalTo(24)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,16 +219,17 @@ class EPLoginInputView: UIView {
|
||||
// 区号
|
||||
areaStackView.isHidden = !config.showAreaCode
|
||||
|
||||
// Icon
|
||||
if let iconName = config.icon {
|
||||
iconImageView.image = UIImage(systemName: iconName)
|
||||
iconImageView.isHidden = false
|
||||
} else {
|
||||
iconImageView.isHidden = true
|
||||
}
|
||||
// Icon - 默认隐藏,不再使用
|
||||
iconImageView.isHidden = true
|
||||
|
||||
// Placeholder
|
||||
inputTextField.placeholder = config.placeholder
|
||||
// Placeholder(60% 白色)
|
||||
inputTextField.attributedPlaceholder = NSAttributedString(
|
||||
string: config.placeholder,
|
||||
attributes: [NSAttributedString.Key.foregroundColor: UIColor.white.withAlphaComponent(0.6)]
|
||||
)
|
||||
|
||||
// 键盘类型
|
||||
inputTextField.keyboardType = config.keyboardType
|
||||
|
||||
// 密码模式
|
||||
inputTextField.isSecureTextEntry = config.isSecure
|
||||
|
Reference in New Issue
Block a user