Skip to content

Commit

Permalink
Merge pull request #51 from shilokuma-inc/feat/quizNumberView
Browse files Browse the repository at this point in the history
【FEAT】問題の数字を上部に固定で表示
  • Loading branch information
mrs1669 committed May 17, 2024
2 parents fcc11a6 + f3b1d55 commit d46fee5
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 13 deletions.
8 changes: 8 additions & 0 deletions PrimePickApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
4F0C82842BC8247500E1480E /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F0C82832BC8247500E1480E /* MainView.swift */; };
4F0C82862BC8247600E1480E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4F0C82852BC8247600E1480E /* Assets.xcassets */; };
4F0C828A2BC8247600E1480E /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4F0C82892BC8247600E1480E /* Preview Assets.xcassets */; };
4F42C7A42BF76E7700F92FBB /* QuizNumberView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F42C7A32BF76E7700F92FBB /* QuizNumberView.swift */; };
4F42C7A62BF7756200F92FBB /* ColorAssets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4F42C7A52BF7756200F92FBB /* ColorAssets.xcassets */; };
4F8BE16C2BF4FFB000D7CF0E /* PrimeData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8BE16B2BF4FFB000D7CF0E /* PrimeData.swift */; };
4F8BE16E2BF504BB00D7CF0E /* QuizView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8BE16D2BF504BB00D7CF0E /* QuizView.swift */; };
/* End PBXBuildFile section */
Expand All @@ -26,6 +28,8 @@
4F0C82852BC8247600E1480E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4F0C82872BC8247600E1480E /* PrimePickApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PrimePickApp.entitlements; sourceTree = "<group>"; };
4F0C82892BC8247600E1480E /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
4F42C7A32BF76E7700F92FBB /* QuizNumberView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizNumberView.swift; sourceTree = "<group>"; };
4F42C7A52BF7756200F92FBB /* ColorAssets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = ColorAssets.xcassets; sourceTree = "<group>"; };
4F8BE16B2BF4FFB000D7CF0E /* PrimeData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimeData.swift; sourceTree = "<group>"; };
4F8BE16D2BF504BB00D7CF0E /* QuizView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizView.swift; sourceTree = "<group>"; };
4FC177B82BEEAB2C00447A06 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -65,8 +69,10 @@
4F0C82812BC8247500E1480E /* PrimePickApp.swift */,
4F0C82832BC8247500E1480E /* MainView.swift */,
4F8BE16D2BF504BB00D7CF0E /* QuizView.swift */,
4F42C7A32BF76E7700F92FBB /* QuizNumberView.swift */,
4F8BE1682BF4FB8E00D7CF0E /* QuizData */,
4F0C82852BC8247600E1480E /* Assets.xcassets */,
4F42C7A52BF7756200F92FBB /* ColorAssets.xcassets */,
4F0C82872BC8247600E1480E /* PrimePickApp.entitlements */,
4F0C82882BC8247600E1480E /* Preview Content */,
);
Expand Down Expand Up @@ -150,6 +156,7 @@
buildActionMask = 2147483647;
files = (
4F0C828A2BC8247600E1480E /* Preview Assets.xcassets in Resources */,
4F42C7A62BF7756200F92FBB /* ColorAssets.xcassets in Resources */,
4F0C82862BC8247600E1480E /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -161,6 +168,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4F42C7A42BF76E7700F92FBB /* QuizNumberView.swift in Sources */,
4F02A57D2BF62F61003DF310 /* PrimeQuizEntity.swift in Sources */,
4F0C82842BC8247500E1480E /* MainView.swift in Sources */,
4F8BE16E2BF504BB00D7CF0E /* QuizView.swift in Sources */,
Expand Down
6 changes: 6 additions & 0 deletions PrimePickApp/ColorAssets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
20 changes: 20 additions & 0 deletions PrimePickApp/ColorAssets.xcassets/appGreen.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x77",
"green" : "0xDD",
"red" : "0x77"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
39 changes: 39 additions & 0 deletions PrimePickApp/QuizNumberView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// QuizNumberView.swift
// PrimePickApp
//
// Created by 村石 拓海 on 2024/05/17.
//

import SwiftUI

struct QuizNumberView: View {
@Binding var quizNumber: Int
let quizData: [PrimeQuizEntity]

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) // シャドウを追加して立体感を出す

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

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

static var previews: some View {
QuizNumberView(quizNumber: $quizNumber, quizData: [PrimeQuizEntity(quizId: 0, number: 3, isCorrect: true)])
}
}
21 changes: 8 additions & 13 deletions PrimePickApp/QuizView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,26 @@ import SwiftUI

struct QuizView: View {
@Environment(\.dismiss) private var dismiss
@State private var quizNumber: Int = 0

let primeData = PrimeData()
var primes: [Int]
let difficulty: String
let manager = QuizDataManager()
let quizData: [PrimeQuizEntity]

@State private var quizNumber: Int = 0

init(difficulty: String) {
self.difficulty = difficulty
if self.difficulty == "Easy" {
primes = primeData.generateOneOrTwoDigitPrimes()
} else if self.difficulty == "Normal" {
primes = primeData.generateThreeDigitPrimes()
} else if self.difficulty == "Hard" {
primes = primeData.generateFourDigitPrimes()
} else {
primes = []
}
quizData = manager.makeQuizData()
}

var body: some View {
VStack {
Text(quizData[quizNumber].number.description)
QuizNumberView(
quizNumber: $quizNumber,
quizData: quizData
)
.frame(height: UIScreen.main.bounds.height / 3)

HStack {
if quizNumber < 9 {
Button {
Expand Down Expand Up @@ -62,6 +56,7 @@ struct QuizView: View {
Text("終わり")
}
}
Spacer()
}
.onAppear {
print(quizData)
Expand Down

0 comments on commit d46fee5

Please sign in to comment.