拼写改为确认按钮手动提交,点击已填字母可删除重输
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -89,7 +89,7 @@ final class QuizViewController: UIViewController {
|
||||
var nextConfig = UIButton.Configuration.borderedProminent()
|
||||
nextConfig.contentInsets = .init(top: 12, leading: 16, bottom: 12, trailing: 16)
|
||||
nextButton.configuration = nextConfig
|
||||
nextButton.addAction(UIAction { [weak self] _ in self?.next() }, for: .touchUpInside)
|
||||
nextButton.addAction(UIAction { [weak self] _ in self?.primaryButtonTapped() }, for: .touchUpInside)
|
||||
|
||||
let headerStack = UIStackView(arrangedSubviews: [progressView, countLabel])
|
||||
headerStack.axis = .vertical
|
||||
@@ -136,7 +136,6 @@ final class QuizViewController: UIViewController {
|
||||
|
||||
resultLabel.isHidden = true
|
||||
resultPhoneticLabel.isHidden = true
|
||||
nextButton.isHidden = true
|
||||
|
||||
let isSpelling = config.mode == .spelling
|
||||
optionsStack.isHidden = isSpelling
|
||||
@@ -146,11 +145,16 @@ final class QuizViewController: UIViewController {
|
||||
if isSpelling {
|
||||
spellingHintLabel.text = "\(question.word.word.count) 个字母,补全空缺部分"
|
||||
spellingView.configure(blankedWord: question.blankedWord, blankPositions: question.blankPositions)
|
||||
spellingView.onComplete = { [weak self] typed in
|
||||
self?.submitSpelling(typed, for: question)
|
||||
spellingView.onChange = { [weak self] in
|
||||
guard let self else { return }
|
||||
nextButton.isEnabled = spellingView.isComplete
|
||||
}
|
||||
nextButton.configuration?.title = "确认"
|
||||
nextButton.isEnabled = false
|
||||
nextButton.isHidden = false
|
||||
spellingView.activate()
|
||||
} else {
|
||||
nextButton.isHidden = true
|
||||
buildOptionButtons(for: question)
|
||||
}
|
||||
}
|
||||
@@ -221,9 +225,19 @@ final class QuizViewController: UIViewController {
|
||||
resultLabel.isHidden = false
|
||||
|
||||
nextButton.configuration?.title = currentIndex + 1 < questions.count ? "下一题" : "查看成绩"
|
||||
nextButton.isEnabled = true
|
||||
nextButton.isHidden = false
|
||||
}
|
||||
|
||||
private func primaryButtonTapped() {
|
||||
if config.mode == .spelling, selectedOption == nil {
|
||||
guard let question = current, spellingView.isComplete else { return }
|
||||
submitSpelling(spellingView.typedWord(), for: question)
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}
|
||||
|
||||
private func next() {
|
||||
if currentIndex + 1 < questions.count {
|
||||
currentIndex += 1
|
||||
|
||||
Reference in New Issue
Block a user