引入设计系统,统一 UI 风格,增加拼写/默写结果状态反馈

This commit is contained in:
2026-07-18 23:55:00 +08:00
parent 1c3d62d46c
commit c3a4990984
15 changed files with 981 additions and 205 deletions
@@ -76,6 +76,26 @@ final class SpellingInputView: UIView, UITextFieldDelegate {
refreshBoxes()
}
func showResultState(correct: Bool) {
let color = correct ? Theme.Color.correct : Theme.Color.wrong
for position in blankPositions {
boxViews[position].layer.borderColor = color.cgColor
}
}
private func popBox(atBlank blankIndex: Int) {
guard blankPositions.indices.contains(blankIndex) else { return }
let box = boxViews[blankPositions[blankIndex]]
UIView.animate(withDuration: 0.25, delay: 0, usingSpringWithDamping: 0.5,
initialSpringVelocity: 0, options: .allowUserInteraction) {
box.transform = CGAffineTransform(scaleX: 1.12, y: 1.12)
} completion: { _ in
UIView.animate(withDuration: 0.2) {
box.transform = .identity
}
}
}
@objc private func reactivate() {
activate()
}
@@ -95,6 +115,7 @@ final class SpellingInputView: UIView, UITextFieldDelegate {
filledBlanks[cursorIndex] = String(char).lowercased()
cursorIndex += 1
refreshBoxes()
popBox(atBlank: cursorIndex - 1)
onChange?()
}
textField.text = nil