完善账号切换展示、首页菜单图标与有线传输设置 chip。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-15 14:59:31 +08:00
parent 5eef31b8da
commit ce6de76055
18 changed files with 321 additions and 130 deletions

View File

@ -55,7 +55,6 @@ final class TravelAlbumEntryViewController: BaseViewController {
cell.apply(album: album)
cell.onShootUpload = { [weak self] in self?.pushWiredTransfer(album: album) }
cell.onAlbumCode = { [weak self] in self?.loadAlbumCode(album) }
cell.onShare = { [weak self] in self?.showShareSheet() }
return cell
}
@ -162,18 +161,6 @@ final class TravelAlbumEntryViewController: BaseViewController {
present(controller, animated: true)
}
private func showShareSheet() {
let sheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
sheet.addAction(UIAlertAction(title: "微信好友", style: .default) { [weak self] _ in
self?.showToast("已选择微信好友")
})
sheet.addAction(UIAlertAction(title: "QQ好友", style: .default) { [weak self] _ in
self?.showToast("已选择QQ好友")
})
sheet.addAction(UIAlertAction(title: "取消", style: .cancel))
present(sheet, animated: true)
}
private func pushWiredTransfer(album: TravelAlbum) {
let controller = WiredCameraTransferViewController(
viewModel: WiredCameraTransferViewModel(
@ -272,7 +259,6 @@ private final class TravelAlbumTaskCell: UITableViewCell {
var onShootUpload: (() -> Void)?
var onAlbumCode: (() -> Void)?
var onShare: (() -> Void)?
private let cardView = UIView()
private let coverView = UIImageView()
@ -280,7 +266,6 @@ private final class TravelAlbumTaskCell: UITableViewCell {
private let nameLabel = UILabel()
private let timeLabel = UILabel()
private let phoneLabel = UILabel()
private let shareButton = UIButton(type: .system)
private let codeButton = UIButton(type: .system)
private let uploadButton = UIButton(type: .system)
@ -314,8 +299,6 @@ private final class TravelAlbumTaskCell: UITableViewCell {
phoneLabel.numberOfLines = 1
phoneLabel.setContentCompressionResistancePriority(.required, for: .vertical)
shareButton.setImage(UIImage(systemName: "square.and.arrow.up"), for: .normal)
shareButton.tintColor = AppColor.primary
codeButton.setImage(UIImage(systemName: "qrcode"), for: .normal)
codeButton.tintColor = .black
uploadButton.setImage(UIImage(systemName: "camera.fill"), for: .normal)
@ -332,7 +315,6 @@ private final class TravelAlbumTaskCell: UITableViewCell {
cardView.addSubview(nameLabel)
cardView.addSubview(timeLabel)
cardView.addSubview(phoneLabel)
cardView.addSubview(shareButton)
cardView.addSubview(codeButton)
cardView.addSubview(uploadButton)
@ -347,20 +329,15 @@ private final class TravelAlbumTaskCell: UITableViewCell {
make.center.equalToSuperview()
make.size.equalTo(42)
}
shareButton.snp.makeConstraints { make in
make.top.equalToSuperview().offset(12)
make.trailing.equalTo(codeButton.snp.leading).offset(-8)
make.size.equalTo(26)
}
codeButton.snp.makeConstraints { make in
make.top.equalTo(shareButton)
make.top.equalToSuperview().offset(12)
make.trailing.equalToSuperview().offset(-10)
make.size.equalTo(26)
}
nameLabel.snp.makeConstraints { make in
make.top.equalToSuperview().offset(14)
make.leading.equalTo(coverView.snp.trailing).offset(12)
make.trailing.equalTo(shareButton.snp.leading).offset(-8)
make.trailing.equalTo(codeButton.snp.leading).offset(-8)
}
timeLabel.snp.makeConstraints { make in
make.top.equalTo(nameLabel.snp.bottom).offset(7)
@ -381,7 +358,6 @@ private final class TravelAlbumTaskCell: UITableViewCell {
}
uploadButton.addTarget(self, action: #selector(uploadTapped), for: .touchUpInside)
shareButton.addTarget(self, action: #selector(shareTapped), for: .touchUpInside)
codeButton.addTarget(self, action: #selector(codeTapped), for: .touchUpInside)
}
@ -404,7 +380,6 @@ private final class TravelAlbumTaskCell: UITableViewCell {
}
@objc private func uploadTapped() { onShootUpload?() }
@objc private func shareTapped() { onShare?() }
@objc private func codeTapped() { onAlbumCode?() }
}

View File

@ -40,10 +40,9 @@ final class WiredCameraTransferViewController: BaseViewController {
private let refreshButton = UIButton(type: .system)
private let helpLabel = UILabel()
private let chipsStack = UIStackView()
private let retouchButton = UIButton(type: .system)
private let formatButton = UIButton(type: .system)
private let modeButton = UIButton(type: .system)
private let modeChevronView = UIImageView()
private let retouchButton = WiredTransferSettingChipButton()
private let formatButton = WiredTransferSettingChipButton()
private let modeButton = WiredTransferSettingChipButton(showsChevron: true)
private let settingsStatsDivider = UIView()
private let statsCard = UIStackView()
private let firstStatsDivider = UIView()
@ -160,19 +159,10 @@ final class WiredCameraTransferViewController: BaseViewController {
chipsStack.spacing = 6
chipsStack.distribution = .fillEqually
[retouchButton, formatButton, modeButton].forEach {
configureChipButton($0)
chipsStack.addArrangedSubview($0)
}
retouchButton.isUserInteractionEnabled = false
formatButton.isUserInteractionEnabled = false
modeButton.setConfigurationContentInsets(
NSDirectionalEdgeInsets(top: 6, leading: 10, bottom: 6, trailing: 32)
)
modeChevronView.image = UIImage(systemName: "chevron.down")?
.withConfiguration(UIImage.SymbolConfiguration(pointSize: 13, weight: .semibold))
modeChevronView.tintColor = AppColor.textTertiary
modeChevronView.contentMode = .scaleAspectFit
modeChevronView.isUserInteractionEnabled = false
settingsStatsDivider.backgroundColor = AppColor.border
statsCard.axis = .horizontal
@ -269,7 +259,6 @@ final class WiredCameraTransferViewController: BaseViewController {
view.addSubview(emptyLabel)
view.addSubview(bottomBar)
bottomBar.addSubview(bottomButtonsStack)
modeButton.addSubview(modeChevronView)
bottomButtonsStack.addArrangedSubview(batchButton)
bottomButtonsStack.addArrangedSubview(specifyButton)
bottomButtonsStack.addArrangedSubview(albumImportButton)
@ -318,11 +307,6 @@ final class WiredCameraTransferViewController: BaseViewController {
make.leading.trailing.equalToSuperview().inset(14)
make.height.equalTo(34)
}
modeChevronView.snp.makeConstraints { make in
make.trailing.equalToSuperview().offset(-10)
make.centerY.equalToSuperview()
make.size.equalTo(16)
}
settingsStatsDivider.snp.makeConstraints { make in
make.top.equalTo(chipsStack.snp.bottom).offset(12)
make.leading.trailing.equalToSuperview()
@ -431,9 +415,9 @@ final class WiredCameraTransferViewController: BaseViewController {
statusLabel.backgroundColor = (isFailed ? AppColor.danger : AppColor.primary).withAlphaComponent(0.10)
refreshButton.setTitle(viewModel.actionButtonText, for: .normal)
retouchButton.setTitle(viewModel.retouchOption, for: .normal)
formatButton.setTitle("JPG", for: .normal)
modeButton.setTitle(viewModel.transferModeOption, for: .normal)
retouchButton.apply(title: viewModel.retouchOption)
formatButton.apply(title: "JPG")
modeButton.apply(title: viewModel.transferModeOption)
helpLabel.attributedText = helpText(viewModel.sonyMTPHint)
rebuildStats()
@ -642,19 +626,6 @@ final class WiredCameraTransferViewController: BaseViewController {
statsCard.bringSubviewToFront(secondStatsDivider)
}
private func configureChipButton(_ button: UIButton) {
button.titleLabel?.font = .systemFont(ofSize: 11)
button.setTitleColor(AppColor.textTertiary, for: .normal)
button.backgroundColor = AppColor.pageBackground
button.layer.cornerRadius = 8
button.layer.borderWidth = 1
button.layer.borderColor = AppColor.border.cgColor
button.contentHorizontalAlignment = .leading
button.setConfigurationContentInsets(
NSDirectionalEdgeInsets(top: 6, leading: 10, bottom: 6, trailing: 10)
)
}
private func makeStatButton(title: String, count: Int, selected: Bool, danger: Bool) -> UIButton {
var config = UIButton.Configuration.plain()
config.title = "\(count)"

View File

@ -0,0 +1,88 @@
//
// WiredTransferSettingChipButton.swift
// suixinkan
//
import SnapKit
import UIKit
/// 线 chip `UIButton` title
final class WiredTransferSettingChipButton: UIButton {
private let titleLabelView = UILabel()
private let chevronView = UIImageView()
private var titleTrailingToSuperviewConstraint: Constraint?
private var titleTrailingToChevronConstraint: Constraint?
///
var showsChevron: Bool {
didSet { updateChevronLayout() }
}
///
private(set) var titleText: String = ""
/// chip
/// - Parameter showsChevron:
init(showsChevron: Bool = false) {
self.showsChevron = showsChevron
super.init(frame: .zero)
setupUI()
updateChevronLayout()
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
/// chip
func apply(title: String) {
titleText = title
titleLabelView.text = title
accessibilityLabel = title
}
private func setupUI() {
backgroundColor = AppColor.pageBackground
layer.cornerRadius = 8
layer.borderWidth = 1
layer.borderColor = AppColor.border.cgColor
titleLabelView.font = .systemFont(ofSize: 11)
titleLabelView.textColor = AppColor.textTertiary
titleLabelView.lineBreakMode = .byTruncatingTail
titleLabelView.isUserInteractionEnabled = false
chevronView.image = UIImage(systemName: "chevron.down")?
.withConfiguration(UIImage.SymbolConfiguration(pointSize: 13, weight: .semibold))
chevronView.tintColor = AppColor.textTertiary
chevronView.contentMode = .scaleAspectFit
chevronView.isUserInteractionEnabled = false
addSubview(titleLabelView)
addSubview(chevronView)
titleLabelView.snp.makeConstraints { make in
make.leading.equalToSuperview().offset(10)
make.centerY.equalToSuperview()
titleTrailingToSuperviewConstraint = make.trailing.lessThanOrEqualToSuperview().offset(-10).constraint
titleTrailingToChevronConstraint = make.trailing.lessThanOrEqualTo(chevronView.snp.leading).offset(-4).constraint
}
chevronView.snp.makeConstraints { make in
make.trailing.equalToSuperview().offset(-10)
make.centerY.equalToSuperview()
make.size.equalTo(16)
}
}
private func updateChevronLayout() {
chevronView.isHidden = !showsChevron
if showsChevron {
titleTrailingToSuperviewConstraint?.deactivate()
titleTrailingToChevronConstraint?.activate()
} else {
titleTrailingToChevronConstraint?.deactivate()
titleTrailingToSuperviewConstraint?.activate()
}
}
}