From 09800c5b17e4b330955132c240ae96ec55401dc4 Mon Sep 17 00:00:00 2001 From: fish Date: Mon, 20 Jul 2026 08:31:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E8=AF=8D=E5=88=97=E8=A1=A8=E5=8D=A1?= =?UTF-8?q?=E7=89=87=E5=A2=9E=E5=8A=A0=E5=AD=A6=E4=B9=A0=E6=8C=89=E9=92=AE?= =?UTF-8?q?=EF=BC=8C=E7=82=B9=E5=87=BB=E8=B7=B3=E8=BD=AC=E6=8B=BC=E5=86=99?= =?UTF-8?q?=E7=BB=83=E4=B9=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- .../LearnEnglish/Views/WordCardCell.swift | 15 ++++++++++++++- .../Views/WordListViewController.swift | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/LearnEnglish/LearnEnglish/Views/WordCardCell.swift b/LearnEnglish/LearnEnglish/Views/WordCardCell.swift index 96db8c2..fd0fb92 100644 --- a/LearnEnglish/LearnEnglish/Views/WordCardCell.swift +++ b/LearnEnglish/LearnEnglish/Views/WordCardCell.swift @@ -5,10 +5,12 @@ final class WordCardCell: UITableViewCell { private let wordLabel = UILabel() private let phoneticLabel = UILabel() private let meaningLabel = UILabel() + private let learnButton = UIButton(type: .system) private let speakerButton = UIButton(type: .system) private var word: Word? var onSpeak: ((Word) -> Void)? + var onLearn: ((Word) -> Void)? var zoomSourceView: UIView { cardView } @@ -39,6 +41,15 @@ final class WordCardCell: UITableViewCell { textStack.axis = .vertical textStack.spacing = 8 + learnButton.setImage(UIImage(systemName: "book", + withConfiguration: UIImage.SymbolConfiguration(pointSize: 15, weight: .medium)), + for: .normal) + learnButton.tintColor = Theme.Color.accent + learnButton.addAction(UIAction { [weak self] _ in + guard let self, let word else { return } + onLearn?(word) + }, for: .touchUpInside) + speakerButton.tintColor = Theme.Color.accent speakerButton.addAction(UIAction { [weak self] _ in guard let self, let word else { return } @@ -46,7 +57,7 @@ final class WordCardCell: UITableViewCell { }, for: .touchUpInside) speakerButton.setContentHuggingPriority(.required, for: .horizontal) - let row = UIStackView(arrangedSubviews: [textStack, speakerButton]) + let row = UIStackView(arrangedSubviews: [textStack, learnButton, speakerButton]) row.axis = .horizontal row.alignment = .center row.spacing = 8 @@ -57,6 +68,8 @@ final class WordCardCell: UITableViewCell { row.leadingAnchor.constraint(equalTo: cardView.leadingAnchor, constant: 14), row.trailingAnchor.constraint(equalTo: cardView.trailingAnchor, constant: -8), row.bottomAnchor.constraint(equalTo: cardView.bottomAnchor, constant: -10), + learnButton.widthAnchor.constraint(equalToConstant: 44), + learnButton.heightAnchor.constraint(equalToConstant: 44), speakerButton.widthAnchor.constraint(equalToConstant: 44), speakerButton.heightAnchor.constraint(equalToConstant: 44) ]) diff --git a/LearnEnglish/LearnEnglish/Views/WordListViewController.swift b/LearnEnglish/LearnEnglish/Views/WordListViewController.swift index 81616c6..8fa03ca 100644 --- a/LearnEnglish/LearnEnglish/Views/WordListViewController.swift +++ b/LearnEnglish/LearnEnglish/Views/WordListViewController.swift @@ -148,6 +148,11 @@ extension WordListViewController: UITableViewDataSource, UITableViewDelegate { cell.onSpeak = { word in SpeechService.shared.speak(word.word) } + cell.onLearn = { [weak self] word in + guard let self else { return } + let config = QuizConfig(mode: .spelling, words: [word], isStudyMode: true) + navigationController?.pushViewController(QuizViewController(config: config), animated: true) + } return cell }