修复测验页空白问题,测验入口改为文字按钮
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -6,13 +6,18 @@ struct QuizView: View {
|
|||||||
@Environment(SpeechService.self) private var speech
|
@Environment(SpeechService.self) private var speech
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
|
|
||||||
@State private var questions: [QuizQuestion] = []
|
@State private var questions: [QuizQuestion]
|
||||||
@State private var currentIndex = 0
|
@State private var currentIndex = 0
|
||||||
@State private var selectedOption: String?
|
@State private var selectedOption: String?
|
||||||
@State private var wrongWords: [Word] = []
|
@State private var wrongWords: [Word] = []
|
||||||
@State private var finished = false
|
@State private var finished = false
|
||||||
@State private var startDate = Date.now
|
@State private var startDate = Date.now
|
||||||
|
|
||||||
|
init(config: QuizConfig) {
|
||||||
|
self.config = config
|
||||||
|
_questions = State(initialValue: QuizGenerator.makeQuestions(mode: config.mode, words: config.words))
|
||||||
|
}
|
||||||
|
|
||||||
private var current: QuizQuestion? {
|
private var current: QuizQuestion? {
|
||||||
questions.indices.contains(currentIndex) ? questions[currentIndex] : nil
|
questions.indices.contains(currentIndex) ? questions[currentIndex] : nil
|
||||||
}
|
}
|
||||||
@@ -33,9 +38,6 @@ struct QuizView: View {
|
|||||||
}
|
}
|
||||||
.navigationTitle(config.mode.rawValue)
|
.navigationTitle(config.mode.rawValue)
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.onAppear {
|
|
||||||
if questions.isEmpty { restart() }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func questionView(_ question: QuizQuestion) -> some View {
|
private func questionView(_ question: QuizQuestion) -> some View {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ struct WordListView: View {
|
|||||||
Button("英选汉") { startQuiz(.enToZh) }
|
Button("英选汉") { startQuiz(.enToZh) }
|
||||||
Button("汉选英") { startQuiz(.zhToEn) }
|
Button("汉选英") { startQuiz(.zhToEn) }
|
||||||
} label: {
|
} label: {
|
||||||
Label("测验", systemImage: "questionmark.circle")
|
Text("测验")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user