单词列表跳转详情页增加卡片放大过渡动画
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 onSpeak: ((Word) -> Void)?
|
||||||
|
|
||||||
|
var zoomSourceView: UIView { cardView }
|
||||||
|
|
||||||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
|
|||||||
@@ -147,7 +147,15 @@ extension WordListViewController: UITableViewDataSource, UITableViewDelegate {
|
|||||||
|
|
||||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||||
Haptics.selection()
|
Haptics.selection()
|
||||||
navigationController?.pushViewController(
|
let detail = WordDetailViewController(word: category.words[indexPath.row], categoryName: category.name)
|
||||||
WordDetailViewController(word: category.words[indexPath.row], categoryName: category.name), animated: true)
|
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