完善素材管理 UI 交互并修复列表解析与时间选择。
MaterialItem 兼容 Android 缺失字段默认值,优化素材详情/列表/标签布局与上下架开关交互,修复个人空间时间选择器初始值。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -229,7 +229,7 @@ final class MaterialListViewController: BaseViewController {
|
||||
|
||||
@MainActor
|
||||
private func applyViewModel() {
|
||||
filterTitleLabel.text = "筛选"
|
||||
filterTitleLabel.text = viewModel.filterStatus.title
|
||||
filterOptionButtons.forEach { status, button in
|
||||
let selected = status == viewModel.filterStatus
|
||||
button.setTitleColor(selected ? AppColor.primary : AppColor.textPrimary, for: .normal)
|
||||
@ -436,6 +436,7 @@ private final class MaterialListCell: UITableViewCell {
|
||||
private let cardView = UIView()
|
||||
private let coverImageView = UIImageView()
|
||||
private let placeholderLabel = UILabel()
|
||||
private let detailContentView = UIView()
|
||||
private let titleLabel = UILabel()
|
||||
private let timeLabel = UILabel()
|
||||
private let statusBadge = MaterialStatusBadgeView()
|
||||
@ -445,6 +446,7 @@ private final class MaterialListCell: UITableViewCell {
|
||||
private let likeStatView = MaterialStatView(iconName: "sample_ic_like_count")
|
||||
private let collectStatView = MaterialStatView(iconName: "sample_ic_collect_count")
|
||||
private var isApplying = false
|
||||
private var confirmedListingState = false
|
||||
|
||||
var onToggle: ((Bool) -> Void)?
|
||||
|
||||
@ -460,10 +462,11 @@ private final class MaterialListCell: UITableViewCell {
|
||||
|
||||
func apply(item: MaterialItem) {
|
||||
isApplying = true
|
||||
confirmedListingState = item.listingStatus == 1
|
||||
titleLabel.text = item.name
|
||||
timeLabel.text = item.createdAt
|
||||
statusBadge.apply(status: item.status)
|
||||
listingSwitch.setOn(item.listingStatus == 1, animated: false)
|
||||
listingSwitch.setOn(confirmedListingState, animated: false)
|
||||
downloadStatView.setCount(item.downloadCount)
|
||||
likeStatView.setCount(item.likesCount)
|
||||
collectStatView.setCount(item.collectCount)
|
||||
@ -515,11 +518,12 @@ private final class MaterialListCell: UITableViewCell {
|
||||
contentView.addSubview(cardView)
|
||||
cardView.addSubview(coverImageView)
|
||||
coverImageView.addSubview(placeholderLabel)
|
||||
cardView.addSubview(titleLabel)
|
||||
cardView.addSubview(timeLabel)
|
||||
cardView.addSubview(statusBadge)
|
||||
cardView.addSubview(listingSwitch)
|
||||
cardView.addSubview(statsStack)
|
||||
cardView.addSubview(detailContentView)
|
||||
detailContentView.addSubview(titleLabel)
|
||||
detailContentView.addSubview(timeLabel)
|
||||
detailContentView.addSubview(statusBadge)
|
||||
detailContentView.addSubview(listingSwitch)
|
||||
detailContentView.addSubview(statsStack)
|
||||
[downloadStatView, likeStatView, collectStatView].forEach(statsStack.addArrangedSubview)
|
||||
|
||||
cardView.snp.makeConstraints { make in
|
||||
@ -535,13 +539,18 @@ private final class MaterialListCell: UITableViewCell {
|
||||
make.center.equalToSuperview()
|
||||
make.leading.trailing.equalToSuperview().inset(8)
|
||||
}
|
||||
titleLabel.snp.makeConstraints { make in
|
||||
make.top.equalToSuperview().offset(16)
|
||||
detailContentView.snp.makeConstraints { make in
|
||||
make.leading.equalTo(coverImageView.snp.trailing).offset(12)
|
||||
make.trailing.equalToSuperview().inset(12)
|
||||
make.centerY.equalTo(coverImageView)
|
||||
make.top.greaterThanOrEqualToSuperview().inset(12)
|
||||
make.bottom.lessThanOrEqualToSuperview().inset(12)
|
||||
}
|
||||
titleLabel.snp.makeConstraints { make in
|
||||
make.top.leading.trailing.equalToSuperview()
|
||||
}
|
||||
timeLabel.snp.makeConstraints { make in
|
||||
make.top.equalTo(titleLabel.snp.bottom).offset(4)
|
||||
make.top.equalTo(titleLabel.snp.bottom).offset(2)
|
||||
make.leading.trailing.equalTo(titleLabel)
|
||||
}
|
||||
statusBadge.snp.makeConstraints { make in
|
||||
@ -551,20 +560,22 @@ private final class MaterialListCell: UITableViewCell {
|
||||
}
|
||||
listingSwitch.snp.makeConstraints { make in
|
||||
make.centerY.equalTo(statusBadge)
|
||||
make.trailing.equalToSuperview().inset(12)
|
||||
make.trailing.equalToSuperview()
|
||||
make.leading.greaterThanOrEqualTo(statusBadge.snp.trailing).offset(8)
|
||||
}
|
||||
statsStack.snp.makeConstraints { make in
|
||||
make.top.equalTo(statusBadge.snp.bottom).offset(8)
|
||||
make.leading.equalTo(titleLabel)
|
||||
make.trailing.lessThanOrEqualToSuperview().inset(12)
|
||||
make.bottom.lessThanOrEqualToSuperview().inset(12)
|
||||
make.leading.equalToSuperview()
|
||||
make.trailing.lessThanOrEqualToSuperview()
|
||||
make.bottom.equalToSuperview()
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func switchChanged() {
|
||||
guard !isApplying else { return }
|
||||
onToggle?(listingSwitch.isOn)
|
||||
let requestedState = listingSwitch.isOn
|
||||
listingSwitch.setOn(confirmedListingState, animated: true)
|
||||
onToggle?(requestedState)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user