import SwiftUI

struct QuizSetupView: View {
    let request: QuizSetupRequest

    var body: some View {
        List {
            NavigationLink(value: AppRoute.quiz(QuizConfig(mode: request.mode, words: request.words))) {
                VStack(alignment: .leading, spacing: 4) {
                    Text("全部测试")
                        .font(.headline)
                    Text("\(request.words.count) 题")
                        .font(.subheadline)
                        .foregroundStyle(.secondary)
                }
                .padding(.vertical, 4)
            }
            NavigationLink(value: AppRoute.quiz(QuizConfig(mode: request.mode, words: Array(request.words.shuffled().prefix(10))))) {
                VStack(alignment: .leading, spacing: 4) {
                    Text("随机十个")
                        .font(.headline)
                    Text("从词库中随机抽取 10 题")
                        .font(.subheadline)
                        .foregroundStyle(.secondary)
                }
                .padding(.vertical, 4)
            }
        }
        .navigationTitle(request.mode.rawValue)
    }
}

#Preview {
    NavigationStack {
        QuizSetupView(request: QuizSetupRequest(mode: .enToZh, words: [
            Word(word: "red", phonetic: "/red/", meaning: "红色", example: "The apple is red.", exampleMeaning: "苹果是红色的。")
        ]))
    }
}
