Skip to content

Commit

Permalink
[refactor] quizNumberTextの作成
Browse files Browse the repository at this point in the history
  • Loading branch information
mrs1669 committed May 31, 2024
1 parent c0a7a76 commit f01b669
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions PrimePickApp/View/Quiz/QuizContent/QuizNumberView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@ struct QuizNumberView: View {
ZStack {
quizNumberBackgroundView(difficulty: difficulty)

switch difficulty {
case .easy:
Text(quizData[quizNumber].number.description)
.font(.custom("ArialRoundedMTBold", size: 180))
.foregroundStyle(Color.gray)
case .normal, .hard:
Text(quizData[quizNumber].number.description)
.font(.custom("ArialRoundedMTBold", size: 120))
.foregroundStyle(Color.gray)
}
quizNumberText(
quizNumber: quizNumber,
difficulty: difficulty,
quizData: quizData
)
}
}
}
Expand All @@ -48,6 +43,18 @@ private func quizNumberBackgroundView(difficulty: Difficulty) -> some View {
)
}

private func quizNumberText(quizNumber: Int, difficulty: Difficulty, quizData: [QuizEntity]) -> some View {
let size: CGFloat = if difficulty == .easy {
180
} else {
120
}

return Text(quizData[quizNumber].number.description)
.font(.custom("ArialRoundedMTBold", size: size))
.foregroundStyle(Color.gray)
}

struct QuizNumberView_Previews: PreviewProvider {
@State static var quizNumber = 3

Expand Down

0 comments on commit f01b669

Please sign in to comment.