Skip to content

Commit

Permalink
Merge pull request #60 from shilokuma-inc/feat/quizAnswer
Browse files Browse the repository at this point in the history
【FEAT】正当数を10問目の回答後に表示
  • Loading branch information
mrs1669 committed May 22, 2024
2 parents 6da8a2c + 22c9772 commit bcd626d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions PrimePickApp/QuizButtonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import SwiftUI

struct QuizButtonView: View {
var quizData: [PrimeQuizEntity]
@State private var correctQuizNumber: Int = 0
@Binding var quizNumber: Int
@State private var showAlert = false
@Environment(\.dismiss) private var dismiss

var body: some View {
ZStack {
Expand All @@ -30,13 +33,16 @@ struct QuizButtonView: View {
print("")
if !quizData[quizNumber].isCorrect {
print("正解")
correctQuizNumber += 1
} else {
print("不正解")
}
if quizNumber < 9 {
if quizNumber < 9 {
quizNumber += 1
}
} else {
showAlert = true
}
}

Expand All @@ -56,18 +62,29 @@ struct QuizButtonView: View {
print("")
if quizData[quizNumber].isCorrect {
print("正解")
correctQuizNumber += 1
} else {
print("不正解")
}
if quizNumber < 9 {
if quizNumber < 9 {
quizNumber += 1
}
} else {
showAlert = true
}
}

Spacer()
}
}
.alert(isPresented: $showAlert) {
Alert(
title: Text("You Score is \(correctQuizNumber) points!"),
dismissButton: .default(Text("OK!")) {
dismiss()
}
)
}
}
}

0 comments on commit bcd626d

Please sign in to comment.