feat: 优化 AI 修图模板选择页面

This commit is contained in:
2026-08-13 15:16:03 +08:00
parent 109ec3dad0
commit 7b9e630838
6 changed files with 35 additions and 25 deletions
@@ -583,6 +583,7 @@ final class TravelAlbumAIRetouchTemplateCell: UICollectionViewCell {
previewImageView.contentMode = .scaleAspectFill
previewImageView.clipsToBounds = true
previewImageView.backgroundColor = UIColor(hex: 0xEDF2F8)
previewImageView.accessibilityIdentifier = "travelAlbum.aiRetouchTemplateImage"
nameLabel.font = .systemFont(ofSize: 13, weight: .semibold)
nameLabel.textColor = AIRetouchTemplateStyle.textPrimary
nameLabel.textAlignment = .center
@@ -595,12 +596,12 @@ final class TravelAlbumAIRetouchTemplateCell: UICollectionViewCell {
previewConfiguration.title = "预览"
previewConfiguration.baseForegroundColor = .white
previewConfiguration.baseBackgroundColor = UIColor.black.withAlphaComponent(0.58)
previewConfiguration.background.cornerRadius = 15
previewConfiguration.background.cornerRadius = 14
previewConfiguration.contentInsets = .zero
previewConfiguration.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer {
attributes in
var attributes = attributes
attributes.font = .systemFont(ofSize: 13, weight: .regular)
attributes.font = .systemFont(ofSize: 12, weight: .regular)
return attributes
}
previewButton.configuration = previewConfiguration
@@ -625,9 +626,9 @@ final class TravelAlbumAIRetouchTemplateCell: UICollectionViewCell {
make.size.equalTo(22)
}
previewButton.snp.makeConstraints { make in
make.trailing.bottom.equalTo(previewImageView).inset(7)
make.width.equalTo(54)
make.height.equalTo(30)
make.trailing.bottom.equalTo(previewImageView).inset(4)
make.width.equalTo(48)
make.height.equalTo(28)
}
}
@@ -646,19 +647,16 @@ final class TravelAlbumAIRetouchTemplateCell: UICollectionViewCell {
/// 更新模板内容与选中状态。
func apply(template: TravelAlbumAIRetouchTemplate, selected: Bool) {
nameLabel.text = template.name
let placeholder = UIImage(named: "ai_retouch_template_placeholder")
if let url = URL(string: template.previewURL), !template.previewURL.isEmpty {
previewImageView.contentMode = .scaleAspectFill
previewImageView.kf.setImage(
with: url,
placeholder: UIImage(systemName: "photo")?.withTintColor(
AIRetouchTemplateStyle.textSecondary,
renderingMode: .alwaysOriginal
)
placeholder: placeholder
)
} else {
previewImageView.image = UIImage(systemName: "photo")
previewImageView.tintColor = AIRetouchTemplateStyle.textSecondary
previewImageView.contentMode = .scaleAspectFit
previewImageView.image = placeholder
previewImageView.contentMode = .scaleAspectFill
}
contentView.layer.borderColor = (
selected ? AIRetouchTemplateStyle.primary : AIRetouchTemplateStyle.border
@@ -680,7 +678,7 @@ final class TravelAlbumAIRetouchTemplateCell: UICollectionViewCell {
/// 扩大模板预览按钮的触摸区域,同时保持截图中的胶囊尺寸。
private final class AIRetouchTemplatePreviewButton: UIButton {
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
bounds.insetBy(dx: -6, dy: -6).contains(point)
bounds.insetBy(dx: -8, dy: -8).contains(point)
}
}
@@ -1009,17 +1007,14 @@ final class TravelAlbumAIRetouchTemplatePreviewViewController: UIViewController
}
private func loadPreview() {
let placeholder = UIImage(named: "ai_retouch_template_placeholder")
guard let url = URL(string: template.previewURL), !template.previewURL.isEmpty else {
imageView.image = UIImage(systemName: "photo")
imageView.tintColor = UIColor.white.withAlphaComponent(0.45)
imageView.image = placeholder
return
}
imageView.kf.setImage(
with: url,
placeholder: UIImage(systemName: "photo")?.withTintColor(
UIColor.white.withAlphaComponent(0.45),
renderingMode: .alwaysOriginal
)
placeholder: placeholder
)
}