Skip to content

Commit

Permalink
Merge pull request #67 from shilokuma-inc/feat/backgroungColor
Browse files Browse the repository at this point in the history
【FEAT】難易度ごとに背景色を変える
  • Loading branch information
mrs1669 committed May 22, 2024
2 parents a6c3674 + c868550 commit e061c43
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 19 deletions.
17 changes: 14 additions & 3 deletions PrimePickApp/QuizIndexView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@
import SwiftUI

struct QuizIndexView: View {
let difficulty: String
@Binding var quizNumber: Int

var body: some View {
ZStack(alignment: .leading) {
Color("appGreen")
.opacity(0.5)
.edgesIgnoringSafeArea(.all)
if difficulty == "Easy" {
Color("appGreen")
.opacity(0.5)
.edgesIgnoringSafeArea(.all)
} else if difficulty == "Normal" {
Color.blue
.opacity(0.5)
.edgesIgnoringSafeArea(.all)
} else if difficulty == "Hard" {
Color.red
.opacity(0.5)
.edgesIgnoringSafeArea(.all)
}

Text("No.\(quizNumber + 1)")
.font(.custom("ArialRoundedMTBold", size: 45))
Expand Down
40 changes: 31 additions & 9 deletions PrimePickApp/QuizNumberView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,37 @@ struct QuizNumberView: View {

var body: some View {
ZStack {
Color("appGreen")
.opacity(0.5)
.edgesIgnoringSafeArea(.all)

RoundedRectangle(cornerRadius: 25)
.stroke(Color.green, lineWidth: 5) // 緑色の枠線と角丸
.background(RoundedRectangle(cornerRadius: 25).fill(Color.white)) // 背景を白にする
.frame(width: 300, height: 200) // フレームサイズを指定
.shadow(radius: 10) // シャドウを追加して立体感を出す
if difficulty == "Easy" {
Color("appGreen")
.opacity(0.5)
.edgesIgnoringSafeArea(.all)

RoundedRectangle(cornerRadius: 25)
.stroke(Color.green, lineWidth: 5) // 緑色の枠線と角丸
.background(RoundedRectangle(cornerRadius: 25).fill(Color.white)) // 背景を白にする
.frame(width: 300, height: 200) // フレームサイズを指定
.shadow(radius: 10) // シャドウを追加して立体感を出す
} else if difficulty == "Normal" {
Color.blue
.opacity(0.5)
.edgesIgnoringSafeArea(.all)

RoundedRectangle(cornerRadius: 25)
.stroke(Color.blue, lineWidth: 5) // 緑色の枠線と角丸
.background(RoundedRectangle(cornerRadius: 25).fill(Color.white)) // 背景を白にする
.frame(width: 300, height: 200) // フレームサイズを指定
.shadow(radius: 10) // シャドウを追加して立体感を出す
} else if difficulty == "Hard" {
Color.red
.opacity(0.5)
.edgesIgnoringSafeArea(.all)

RoundedRectangle(cornerRadius: 25)
.stroke(Color.red, lineWidth: 5) // 緑色の枠線と角丸
.background(RoundedRectangle(cornerRadius: 25).fill(Color.white)) // 背景を白にする
.frame(width: 300, height: 200) // フレームサイズを指定
.shadow(radius: 10) // シャドウを追加して立体感を出す
}

if difficulty == "Easy" {
Text(quizData[quizNumber].number.description)
Expand Down
31 changes: 27 additions & 4 deletions PrimePickApp/QuizTimeLimitView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,35 @@
import SwiftUI

struct QuizTimeLimitView: View {
let difficulty: String
var borderColor: Color {
switch difficulty {
case "Easy":
return Color.green // Color.appGreen の代わりに Color.green を使っています
case "Normal":
return Color.blue
default:
return Color.red
}
}

@State private var progress: Double = 0.01

var body: some View {
ZStack {
Color.appGreen
.opacity(0.5)
.edgesIgnoringSafeArea(.all)
if difficulty == "Easy" {
Color.appGreen
.opacity(0.5)
.edgesIgnoringSafeArea(.all)
} else if difficulty == "Normal" {
Color.blue
.opacity(0.5)
.edgesIgnoringSafeArea(.all)
} else if difficulty == "Hard" {
Color.red
.opacity(0.5)
.edgesIgnoringSafeArea(.all)
}

ProgressView(value: progress)
.progressViewStyle(LinearProgressViewStyle(tint: .gray))
Expand Down Expand Up @@ -54,9 +76,10 @@ struct QuizTimeLimitView: View {
.padding()

}
.border(borderColor, width: 5.0)
}
}

#Preview {
QuizTimeLimitView()
QuizTimeLimitView(difficulty: "Easy")
}
5 changes: 2 additions & 3 deletions PrimePickApp/QuizView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct QuizView: View {
.ignoresSafeArea()

VStack(spacing: .zero) {
QuizIndexView(quizNumber: $quizNumber)
QuizIndexView(difficulty: difficulty, quizNumber: $quizNumber)
.frame(height: UIScreen.main.bounds.height / 12)

QuizNumberView(
Expand All @@ -37,9 +37,8 @@ struct QuizView: View {
)
.frame(height: UIScreen.main.bounds.height / 3)

QuizTimeLimitView()
QuizTimeLimitView(difficulty: difficulty)
.frame(height: UIScreen.main.bounds.height / 12)
.border(Color.appGreen, width: 5.0)

Spacer()

Expand Down

0 comments on commit e061c43

Please sign in to comment.