Skip to content

Commit

Permalink
Merge pull request #57 from shilokuma-inc/feat/quizButton
Browse files Browse the repository at this point in the history
【FEAT】正解 & 失敗ボタンの作成
  • Loading branch information
mrs1669 committed May 22, 2024
2 parents 9b1ad2f + 1c3fcde commit 6da8a2c
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 90 deletions.
16 changes: 12 additions & 4 deletions PrimePickApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
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 */; };
4F2239222BFC9DEB004C71A6 /* QuizTimeLimitVIew.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F2239212BFC9DEB004C71A6 /* QuizTimeLimitVIew.swift */; };
4F2239222BFC9DEB004C71A6 /* QuizTimeLimitView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F2239212BFC9DEB004C71A6 /* QuizTimeLimitView.swift */; };
4F2239242BFCEEF0004C71A6 /* QuizButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F2239232BFCEEF0004C71A6 /* QuizButtonView.swift */; };
4F2239262BFD0873004C71A6 /* QuizIndexView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F2239252BFD0873004C71A6 /* QuizIndexView.swift */; };
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 */; };
Expand All @@ -29,7 +31,9 @@
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>"; };
4F2239212BFC9DEB004C71A6 /* QuizTimeLimitVIew.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizTimeLimitVIew.swift; sourceTree = "<group>"; };
4F2239212BFC9DEB004C71A6 /* QuizTimeLimitView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizTimeLimitView.swift; sourceTree = "<group>"; };
4F2239232BFCEEF0004C71A6 /* QuizButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizButtonView.swift; sourceTree = "<group>"; };
4F2239252BFD0873004C71A6 /* QuizIndexView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizIndexView.swift; 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>"; };
Expand Down Expand Up @@ -71,8 +75,10 @@
4F0C82812BC8247500E1480E /* PrimePickApp.swift */,
4F0C82832BC8247500E1480E /* MainView.swift */,
4F8BE16D2BF504BB00D7CF0E /* QuizView.swift */,
4F2239212BFC9DEB004C71A6 /* QuizTimeLimitVIew.swift */,
4F2239212BFC9DEB004C71A6 /* QuizTimeLimitView.swift */,
4F2239252BFD0873004C71A6 /* QuizIndexView.swift */,
4F42C7A32BF76E7700F92FBB /* QuizNumberView.swift */,
4F2239232BFCEEF0004C71A6 /* QuizButtonView.swift */,
4F8BE1682BF4FB8E00D7CF0E /* QuizData */,
4F0C82852BC8247600E1480E /* Assets.xcassets */,
4F42C7A52BF7756200F92FBB /* ColorAssets.xcassets */,
Expand Down Expand Up @@ -172,10 +178,12 @@
buildActionMask = 2147483647;
files = (
4F42C7A42BF76E7700F92FBB /* QuizNumberView.swift in Sources */,
4F2239242BFCEEF0004C71A6 /* QuizButtonView.swift in Sources */,
4F2239262BFD0873004C71A6 /* QuizIndexView.swift in Sources */,
4F02A57D2BF62F61003DF310 /* PrimeQuizEntity.swift in Sources */,
4F0C82842BC8247500E1480E /* MainView.swift in Sources */,
4F8BE16E2BF504BB00D7CF0E /* QuizView.swift in Sources */,
4F2239222BFC9DEB004C71A6 /* QuizTimeLimitVIew.swift in Sources */,
4F2239222BFC9DEB004C71A6 /* QuizTimeLimitView.swift in Sources */,
4F0C82822BC8247500E1480E /* PrimePickApp.swift in Sources */,
4F02A57F2BF63A43003DF310 /* QuizDataManager.swift in Sources */,
4F8BE16C2BF4FFB000D7CF0E /* PrimeData.swift in Sources */,
Expand Down
20 changes: 20 additions & 0 deletions PrimePickApp/ColorAssets.xcassets/appBlue.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" : "1.000",
"green" : "1.000",
"red" : "0.900"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
91 changes: 48 additions & 43 deletions PrimePickApp/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,57 @@ import SwiftUI
struct MainView: View {
var body: some View {
NavigationStack {
VStack {
Text("PrimePick")
.font(.custom("Helvetica Neue", size: 40))
.fontWeight(.bold)
.padding(.top, 100)
.padding(.bottom, 30)
ZStack {
Color("appBlue")
.ignoresSafeArea()

Spacer()

Text("Select Difficulty")
.font(.headline)
.padding()

NavigationLink(destination: QuizView(difficulty: "Hard")) {
Text("Hard")
.padding()
.frame(maxWidth: .infinity)
.background(Color.red)
.foregroundColor(.white)
.cornerRadius(20)
}
.padding(.horizontal, 50)
.padding(.bottom, 10)

NavigationLink(destination: QuizView(difficulty: "Normal")) {
Text("Normal")
VStack {
Text("PrimePick")
.font(.custom("Helvetica Neue", size: 40))
.fontWeight(.bold)
.padding(.top, 100)
.padding(.bottom, 30)

Spacer()

Text("Select Difficulty")
.font(.headline)
.padding()
.frame(maxWidth: .infinity)
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(20)

NavigationLink(destination: QuizView(difficulty: "Hard")) {
Text("Hard")
.padding()
.frame(maxWidth: .infinity)
.background(Color.red)
.foregroundColor(.white)
.cornerRadius(20)
}
.padding(.horizontal, 50)
.padding(.bottom, 10)

NavigationLink(destination: QuizView(difficulty: "Normal")) {
Text("Normal")
.padding()
.frame(maxWidth: .infinity)
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(20)
}
.padding(.horizontal, 50)
.padding(.bottom, 10)

NavigationLink(destination: QuizView(difficulty: "Easy")) {
Text("Easy")
.padding()
.frame(maxWidth: .infinity)
.background(Color.green)
.foregroundColor(.white)
.cornerRadius(20)
}
.padding(.horizontal, 50)

Spacer()
}
.padding(.horizontal, 50)
.padding(.bottom, 10)

NavigationLink(destination: QuizView(difficulty: "Easy")) {
Text("Easy")
.padding()
.frame(maxWidth: .infinity)
.background(Color.green)
.foregroundColor(.white)
.cornerRadius(20)
}
.padding(.horizontal, 50)

Spacer()
}
}
}
Expand Down
73 changes: 73 additions & 0 deletions PrimePickApp/QuizButtonView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// QuizButtonView.swift
// PrimePickApp
//
// Created by 村石 拓海 on 2024/05/22.
//

import SwiftUI

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

var body: some View {
ZStack {
HStack {
Spacer()

ZStack {
RoundedRectangle(cornerRadius: 25)
.stroke(Color.pink, lineWidth: 5)
.background(RoundedRectangle(cornerRadius: 25).fill(Color.white))
.frame(width: UIScreen.main.bounds.width * 2 / 5, height: UIScreen.main.bounds.height / 4)
.shadow(radius: 10)

Text("")
.font(.custom("ArialRoundedMTBold", size: 80))
}
.onTapGesture {
print("")
if !quizData[quizNumber].isCorrect {
print("正解")
} else {
print("不正解")
}
if quizNumber < 9 {
if quizNumber < 9 {
quizNumber += 1
}
}
}

Spacer()

ZStack {
RoundedRectangle(cornerRadius: 25)
.stroke(Color.cyan, lineWidth: 5)
.background(RoundedRectangle(cornerRadius: 25).fill(Color.white))
.frame(width: UIScreen.main.bounds.width * 2 / 5, height: UIScreen.main.bounds.height / 4)
.shadow(radius: 10)

Text("")
.font(.custom("ArialRoundedMTBold", size: 80))
}
.onTapGesture {
print("")
if quizData[quizNumber].isCorrect {
print("正解")
} else {
print("不正解")
}
if quizNumber < 9 {
if quizNumber < 9 {
quizNumber += 1
}
}
}

Spacer()
}
}
}
}
25 changes: 25 additions & 0 deletions PrimePickApp/QuizIndexView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// QuizIndexView.swift
// PrimePickApp
//
// Created by 村石 拓海 on 2024/05/22.
//

import SwiftUI

struct QuizIndexView: View {
@Binding var quizNumber: Int

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

Text("No.\(quizNumber + 1)")
.font(.custom("ArialRoundedMTBold", size: 45))
.foregroundStyle(Color.gray)
.padding(.horizontal, 16)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// QuizTimeLimitVIew.swift
// QuizTimeLimitView.swift
// PrimePickApp
//
// Created by 村石 拓海 on 2024/05/21.
//

import SwiftUI

struct QuizTimeLimitVIew: View {
struct QuizTimeLimitView: View {
@State private var progress: Double = 0.01

var body: some View {
Expand All @@ -26,7 +26,25 @@ struct QuizTimeLimitVIew: View {
.font(.largeTitle)
.fontWeight(.heavy)
.foregroundColor(.black)
.offset(x: 2, y: 2)
.offset(x: 1, y: 1)

Text("No Timelimit!")
.font(.largeTitle)
.fontWeight(.heavy)
.foregroundColor(.black)
.offset(x: 1, y: -1)

Text("No Timelimit!")
.font(.largeTitle)
.fontWeight(.heavy)
.foregroundColor(.black)
.offset(x: -1, y: 1)

Text("No Timelimit!")
.font(.largeTitle)
.fontWeight(.heavy)
.foregroundColor(.black)
.offset(x: -1, y: -1)

Text("No Timelimit!")
.font(.largeTitle)
Expand All @@ -40,5 +58,5 @@ struct QuizTimeLimitVIew: View {
}

#Preview {
QuizTimeLimitVIew()
QuizTimeLimitView()
}
65 changes: 26 additions & 39 deletions PrimePickApp/QuizView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,34 @@ struct QuizView: View {
}

var body: some View {
VStack(spacing: .zero) {
QuizNumberView(
quizNumber: $quizNumber,
quizData: quizData
)
.frame(height: UIScreen.main.bounds.height / 3)
ZStack {
Color("appBlue")
.ignoresSafeArea()

QuizTimeLimitVIew()
.frame(height: UIScreen.main.bounds.height / 12)

HStack {
if quizNumber < 9 {
Button {
print("正解")
if quizNumber < 9 {
quizNumber += 1
} else {
// dismiss()
}
} label: {
Text("正解")
}

Button {
print("不正解")
if quizNumber < 9 {
quizNumber += 1
} else {
// dismiss()
}
} label: {
Text("不正解")
}
} else {
Text("終わり")
}
VStack(spacing: .zero) {
QuizIndexView(quizNumber: $quizNumber)
.frame(height: UIScreen.main.bounds.height / 12)

QuizNumberView(
quizNumber: $quizNumber,
quizData: quizData
)
.frame(height: UIScreen.main.bounds.height / 3)

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

Spacer()

QuizButtonView(quizData: quizData, quizNumber: $quizNumber)
.frame(height: UIScreen.main.bounds.height / 3)

Spacer()
}
.onAppear {
print(quizData)
}
Spacer()
}
.onAppear {
print(quizData)
}
}
}
Expand Down

0 comments on commit 6da8a2c

Please sign in to comment.