fix: 优化AI修图标签显示
This commit is contained in:
@@ -285,7 +285,7 @@ final class TravelAlbumAIRetouchTemplateViewController: BaseViewController {
|
||||
title: category.title,
|
||||
badge: category == .cover
|
||||
? .gift
|
||||
: (self.viewModel.isOptional(category) ? .optional : .required)
|
||||
: (self.viewModel.isOptional(category) ? .optional : nil)
|
||||
)
|
||||
case .mode:
|
||||
return nil
|
||||
@@ -840,7 +840,6 @@ final class TravelAlbumAIRetouchModeCell: UICollectionViewCell {
|
||||
|
||||
/// 模板分组标题右侧的业务标记。
|
||||
fileprivate enum AIRetouchTemplateSectionBadge {
|
||||
case required
|
||||
case optional
|
||||
case gift
|
||||
}
|
||||
@@ -850,30 +849,36 @@ final class TravelAlbumAIRetouchSectionHeader: UICollectionReusableView {
|
||||
static let reuseIdentifier = "TravelAlbumAIRetouchSectionHeader"
|
||||
|
||||
private let titleLabel = UILabel()
|
||||
private let optionalLabel = UILabel()
|
||||
private let badgeContainer = UIView()
|
||||
private let badgeLabel = UILabel()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
titleLabel.font = .systemFont(ofSize: 17, weight: .semibold)
|
||||
titleLabel.textColor = AIRetouchTemplateStyle.textPrimary
|
||||
optionalLabel.font = .systemFont(ofSize: 11, weight: .medium)
|
||||
optionalLabel.textAlignment = .center
|
||||
optionalLabel.layer.cornerRadius = 10
|
||||
optionalLabel.clipsToBounds = true
|
||||
badgeContainer.layer.cornerRadius = 10
|
||||
badgeContainer.clipsToBounds = true
|
||||
badgeLabel.font = .systemFont(ofSize: 11, weight: .medium)
|
||||
badgeLabel.textAlignment = .center
|
||||
badgeLabel.numberOfLines = 1
|
||||
|
||||
addSubview(titleLabel)
|
||||
addSubview(optionalLabel)
|
||||
addSubview(badgeContainer)
|
||||
badgeContainer.addSubview(badgeLabel)
|
||||
titleLabel.snp.makeConstraints { make in
|
||||
make.leading.equalToSuperview().offset(18)
|
||||
make.centerY.equalToSuperview()
|
||||
}
|
||||
optionalLabel.snp.makeConstraints { make in
|
||||
badgeContainer.snp.makeConstraints { make in
|
||||
make.leading.equalTo(titleLabel.snp.trailing).offset(8)
|
||||
make.centerY.equalTo(titleLabel)
|
||||
make.width.greaterThanOrEqualTo(38)
|
||||
make.height.equalTo(20)
|
||||
make.trailing.lessThanOrEqualToSuperview().offset(-18)
|
||||
}
|
||||
badgeLabel.snp.makeConstraints { make in
|
||||
make.leading.trailing.equalToSuperview().inset(9)
|
||||
make.centerY.equalToSuperview()
|
||||
}
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
@@ -884,24 +889,20 @@ final class TravelAlbumAIRetouchSectionHeader: UICollectionReusableView {
|
||||
/// 更新分组标题与业务标记。
|
||||
fileprivate func apply(title: String, badge: AIRetouchTemplateSectionBadge?) {
|
||||
titleLabel.text = title
|
||||
optionalLabel.isHidden = badge == nil
|
||||
badgeContainer.isHidden = badge == nil
|
||||
switch badge {
|
||||
case .required:
|
||||
optionalLabel.text = " 必选 "
|
||||
optionalLabel.textColor = AIRetouchTemplateStyle.primary
|
||||
optionalLabel.backgroundColor = AIRetouchTemplateStyle.primary.withAlphaComponent(0.1)
|
||||
case .optional:
|
||||
optionalLabel.text = " 选填 "
|
||||
optionalLabel.textColor = AIRetouchTemplateStyle.primary
|
||||
optionalLabel.backgroundColor = AIRetouchTemplateStyle.primary.withAlphaComponent(0.1)
|
||||
badgeLabel.text = "选填"
|
||||
badgeLabel.textColor = AIRetouchTemplateStyle.primary
|
||||
badgeContainer.backgroundColor = AIRetouchTemplateStyle.primary.withAlphaComponent(0.1)
|
||||
case .gift:
|
||||
optionalLabel.text = " 赠送 · 不占额度 "
|
||||
optionalLabel.textColor = AIRetouchTemplateStyle.gift
|
||||
optionalLabel.backgroundColor = AIRetouchTemplateStyle.giftBackground
|
||||
badgeLabel.text = "赠送 · 不占额度"
|
||||
badgeLabel.textColor = AIRetouchTemplateStyle.gift
|
||||
badgeContainer.backgroundColor = AIRetouchTemplateStyle.giftBackground
|
||||
case nil:
|
||||
optionalLabel.text = nil
|
||||
badgeLabel.text = nil
|
||||
}
|
||||
let badgeText = optionalLabel.text?.trimmingCharacters(in: .whitespaces)
|
||||
let badgeText = badgeLabel.text
|
||||
accessibilityLabel = badgeText.map { "\(title),\($0)" } ?? title
|
||||
accessibilityTraits = .header
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user