diff --git a/PrimePickApp.xcodeproj/project.pbxproj b/PrimePickApp.xcodeproj/project.pbxproj index c315d7c..ee4fbef 100644 --- a/PrimePickApp.xcodeproj/project.pbxproj +++ b/PrimePickApp.xcodeproj/project.pbxproj @@ -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 */; }; @@ -29,7 +31,9 @@ 4F0C82852BC8247600E1480E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 4F0C82872BC8247600E1480E /* PrimePickApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PrimePickApp.entitlements; sourceTree = ""; }; 4F0C82892BC8247600E1480E /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; - 4F2239212BFC9DEB004C71A6 /* QuizTimeLimitVIew.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizTimeLimitVIew.swift; sourceTree = ""; }; + 4F2239212BFC9DEB004C71A6 /* QuizTimeLimitView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizTimeLimitView.swift; sourceTree = ""; }; + 4F2239232BFCEEF0004C71A6 /* QuizButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizButtonView.swift; sourceTree = ""; }; + 4F2239252BFD0873004C71A6 /* QuizIndexView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizIndexView.swift; sourceTree = ""; }; 4F42C7A32BF76E7700F92FBB /* QuizNumberView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizNumberView.swift; sourceTree = ""; }; 4F42C7A52BF7756200F92FBB /* ColorAssets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = ColorAssets.xcassets; sourceTree = ""; }; 4F8BE16B2BF4FFB000D7CF0E /* PrimeData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimeData.swift; sourceTree = ""; }; @@ -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 */, @@ -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 */, diff --git a/PrimePickApp/ColorAssets.xcassets/appBlue.colorset/Contents.json b/PrimePickApp/ColorAssets.xcassets/appBlue.colorset/Contents.json new file mode 100644 index 0000000..a8c9df1 --- /dev/null +++ b/PrimePickApp/ColorAssets.xcassets/appBlue.colorset/Contents.json @@ -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 + } +} diff --git a/PrimePickApp/MainView.swift b/PrimePickApp/MainView.swift index 232f270..8a3547d 100644 --- a/PrimePickApp/MainView.swift +++ b/PrimePickApp/MainView.swift @@ -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() } } } diff --git a/PrimePickApp/QuizButtonView.swift b/PrimePickApp/QuizButtonView.swift new file mode 100644 index 0000000..c91ccee --- /dev/null +++ b/PrimePickApp/QuizButtonView.swift @@ -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() + } + } + } +} diff --git a/PrimePickApp/QuizIndexView.swift b/PrimePickApp/QuizIndexView.swift new file mode 100644 index 0000000..b3079fa --- /dev/null +++ b/PrimePickApp/QuizIndexView.swift @@ -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) + } + } +} diff --git a/PrimePickApp/QuizTimeLimitVIew.swift b/PrimePickApp/QuizTimeLimitView.swift similarity index 54% rename from PrimePickApp/QuizTimeLimitVIew.swift rename to PrimePickApp/QuizTimeLimitView.swift index d3bc03e..12d32ed 100644 --- a/PrimePickApp/QuizTimeLimitVIew.swift +++ b/PrimePickApp/QuizTimeLimitView.swift @@ -1,5 +1,5 @@ // -// QuizTimeLimitVIew.swift +// QuizTimeLimitView.swift // PrimePickApp // // Created by 村石 拓海 on 2024/05/21. @@ -7,7 +7,7 @@ import SwiftUI -struct QuizTimeLimitVIew: View { +struct QuizTimeLimitView: View { @State private var progress: Double = 0.01 var body: some View { @@ -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) @@ -40,5 +58,5 @@ struct QuizTimeLimitVIew: View { } #Preview { - QuizTimeLimitVIew() + QuizTimeLimitView() } diff --git a/PrimePickApp/QuizView.swift b/PrimePickApp/QuizView.swift index dcf4d89..e924d8b 100644 --- a/PrimePickApp/QuizView.swift +++ b/PrimePickApp/QuizView.swift @@ -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) } } }