单词列表跳转详情页增加卡片放大过渡动画
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,8 @@ final class WordCardCell: UITableViewCell {
|
||||
|
||||
var onSpeak: ((Word) -> Void)?
|
||||
|
||||
var zoomSourceView: UIView { cardView }
|
||||
|
||||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
backgroundColor = .clear
|
||||
|
||||
@@ -147,7 +147,15 @@ extension WordListViewController: UITableViewDataSource, UITableViewDelegate {
|
||||
|
||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
Haptics.selection()
|
||||
navigationController?.pushViewController(
|
||||
WordDetailViewController(word: category.words[indexPath.row], categoryName: category.name), animated: true)
|
||||
let detail = WordDetailViewController(word: category.words[indexPath.row], categoryName: category.name)
|
||||
detail.preferredTransition = .zoom(options: .init()) { [weak self] _ in
|
||||
guard let self else { return nil }
|
||||
if self.tableView.cellForRow(at: indexPath) == nil {
|
||||
self.tableView.scrollToRow(at: indexPath, at: .middle, animated: false)
|
||||
self.tableView.layoutIfNeeded()
|
||||
}
|
||||
return (self.tableView.cellForRow(at: indexPath) as? WordCardCell)?.zoomSourceView
|
||||
}
|
||||
navigationController?.pushViewController(detail, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user