Skip to content

Commit

Permalink
Merge pull request #94 from shilokuma-inc/release/1.1.2
Browse files Browse the repository at this point in the history
【Release】v1.1.1
  • Loading branch information
mrs1669 committed Jun 1, 2024
2 parents 4518d94 + 0f2aa82 commit 4eb1800
Show file tree
Hide file tree
Showing 11 changed files with 229 additions and 203 deletions.
32 changes: 22 additions & 10 deletions PrimePickApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
4F02A57D2BF62F61003DF310 /* PrimeQuizEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F02A57C2BF62F61003DF310 /* PrimeQuizEntity.swift */; };
4F02A57D2BF62F61003DF310 /* QuizEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F02A57C2BF62F61003DF310 /* QuizEntity.swift */; };
4F02A57F2BF63A43003DF310 /* QuizDataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F02A57E2BF63A43003DF310 /* QuizDataManager.swift */; };
4F0C82822BC8247500E1480E /* PrimePickApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F0C82812BC8247500E1480E /* PrimePickApp.swift */; };
4F0C82842BC8247500E1480E /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F0C82832BC8247500E1480E /* MainView.swift */; };
Expand All @@ -22,12 +22,13 @@
4F8BE16C2BF4FFB000D7CF0E /* PrimeData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8BE16B2BF4FFB000D7CF0E /* PrimeData.swift */; };
4F8BE16E2BF504BB00D7CF0E /* QuizView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8BE16D2BF504BB00D7CF0E /* QuizView.swift */; };
4F8DC1842C08D66200247F62 /* QuizResultView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8DC1832C08D66200247F62 /* QuizResultView.swift */; };
4F8DC1872C08F56000247F62 /* QuizContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8DC1862C08F56000247F62 /* QuizContentView.swift */; };
4FEC65B12C01164800A8B731 /* SelectDifficultyButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FEC65B02C01164800A8B731 /* SelectDifficultyButtonView.swift */; };
4FEC65B42C01184E00A8B731 /* Text+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FEC65B32C01184E00A8B731 /* Text+Extension.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
4F02A57C2BF62F61003DF310 /* PrimeQuizEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimeQuizEntity.swift; sourceTree = "<group>"; };
4F02A57C2BF62F61003DF310 /* QuizEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizEntity.swift; sourceTree = "<group>"; };
4F02A57E2BF63A43003DF310 /* QuizDataManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizDataManager.swift; sourceTree = "<group>"; };
4F0C827E2BC8247500E1480E /* PrimePickApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PrimePickApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
4F0C82812BC8247500E1480E /* PrimePickApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimePickApp.swift; sourceTree = "<group>"; };
Expand All @@ -44,6 +45,7 @@
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>"; };
4F8DC1832C08D66200247F62 /* QuizResultView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizResultView.swift; sourceTree = "<group>"; };
4F8DC1862C08F56000247F62 /* QuizContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuizContentView.swift; sourceTree = "<group>"; };
4FC177B82BEEAB2C00447A06 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
4FEC65B02C01164800A8B731 /* SelectDifficultyButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectDifficultyButtonView.swift; sourceTree = "<group>"; };
4FEC65B32C01184E00A8B731 /* Text+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Text+Extension.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -82,8 +84,8 @@
4F65A3972C0100FD00065A53 /* Enum */,
4FEC65B22C0117FC00A8B731 /* Extension */,
4FEC65B52C01234C00A8B731 /* View */,
4F0C82812BC8247500E1480E /* PrimePickApp.swift */,
4F8BE1682BF4FB8E00D7CF0E /* QuizData */,
4F0C82812BC8247500E1480E /* PrimePickApp.swift */,
4F0C82852BC8247600E1480E /* Assets.xcassets */,
4F42C7A52BF7756200F92FBB /* ColorAssets.xcassets */,
4FC177B82BEEAB2C00447A06 /* Info.plist */,
Expand Down Expand Up @@ -114,11 +116,22 @@
children = (
4F8BE16B2BF4FFB000D7CF0E /* PrimeData.swift */,
4F02A57E2BF63A43003DF310 /* QuizDataManager.swift */,
4F02A57C2BF62F61003DF310 /* PrimeQuizEntity.swift */,
4F02A57C2BF62F61003DF310 /* QuizEntity.swift */,
);
path = QuizData;
sourceTree = "<group>";
};
4F8DC1852C08F53D00247F62 /* QuizContent */ = {
isa = PBXGroup;
children = (
4F8DC1862C08F56000247F62 /* QuizContentView.swift */,
4F2239252BFD0873004C71A6 /* QuizIndexView.swift */,
4F42C7A32BF76E7700F92FBB /* QuizNumberView.swift */,
4F2239212BFC9DEB004C71A6 /* QuizTimeLimitView.swift */,
);
path = QuizContent;
sourceTree = "<group>";
};
4FEC65B22C0117FC00A8B731 /* Extension */ = {
isa = PBXGroup;
children = (
Expand All @@ -141,9 +154,7 @@
isa = PBXGroup;
children = (
4F8BE16D2BF504BB00D7CF0E /* QuizView.swift */,
4F2239252BFD0873004C71A6 /* QuizIndexView.swift */,
4F42C7A32BF76E7700F92FBB /* QuizNumberView.swift */,
4F2239212BFC9DEB004C71A6 /* QuizTimeLimitView.swift */,
4F8DC1852C08F53D00247F62 /* QuizContent */,
4F2239232BFCEEF0004C71A6 /* QuizButtonView.swift */,
4F8DC1832C08D66200247F62 /* QuizResultView.swift */,
);
Expand Down Expand Up @@ -225,11 +236,12 @@
4F2239242BFCEEF0004C71A6 /* QuizButtonView.swift in Sources */,
4F8DC1842C08D66200247F62 /* QuizResultView.swift in Sources */,
4F2239262BFD0873004C71A6 /* QuizIndexView.swift in Sources */,
4F02A57D2BF62F61003DF310 /* PrimeQuizEntity.swift in Sources */,
4F02A57D2BF62F61003DF310 /* QuizEntity.swift in Sources */,
4F65A3992C01019000065A53 /* Difficulty.swift in Sources */,
4F0C82842BC8247500E1480E /* MainView.swift in Sources */,
4FEC65B12C01164800A8B731 /* SelectDifficultyButtonView.swift in Sources */,
4F8BE16E2BF504BB00D7CF0E /* QuizView.swift in Sources */,
4F8DC1872C08F56000247F62 /* QuizContentView.swift in Sources */,
4F2239222BFC9DEB004C71A6 /* QuizTimeLimitView.swift in Sources */,
4F0C82822BC8247500E1480E /* PrimePickApp.swift in Sources */,
4F02A57F2BF63A43003DF310 /* QuizDataManager.swift in Sources */,
Expand Down Expand Up @@ -386,7 +398,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.2;
MARKETING_VERSION = 1.1.1;
MARKETING_VERSION = 1.1.2;
PRODUCT_BUNDLE_IDENTIFIER = ml.mrs1669.PrimePickApp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand Down Expand Up @@ -426,7 +438,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.2;
MARKETING_VERSION = 1.1.1;
MARKETING_VERSION = 1.1.2;
PRODUCT_BUNDLE_IDENTIFIER = ml.mrs1669.PrimePickApp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand Down
6 changes: 3 additions & 3 deletions PrimePickApp/QuizData/QuizDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import Foundation
import GameplayKit

class QuizDataManager {
func makeQuizData(difficulty: Difficulty) -> [PrimeQuizEntity] {
func makeQuizData(difficulty: Difficulty) -> [QuizEntity] {
let primeData = PrimeData()
var quizData: [PrimeQuizEntity] = []
var quizData: [QuizEntity] = []
let timestamp = UInt64(Date().timeIntervalSince1970 * 1000)
var generator = SeededGenerator(seed: timestamp)

Expand All @@ -34,7 +34,7 @@ class QuizDataManager {
let primeNumbers = primeData.generateThreeDigitPrimes()
isCorrect = primeNumbers.contains(randomInt)
}
let primeQuizEntity = PrimeQuizEntity(quizId: i, number: randomInt, isCorrect: isCorrect)
let primeQuizEntity = QuizEntity(quizId: i, number: randomInt, isCorrect: isCorrect)
quizData.append(primeQuizEntity)
}
return quizData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// PrimeQuizEntity.swift
// QuizEntity.swift
// PrimePickApp
//
// Created by 村石 拓海 on 2024/05/16.
//

import Foundation

struct PrimeQuizEntity {
struct QuizEntity {
var quizId: Int
var number: Int
var isCorrect: Bool
Expand Down
59 changes: 18 additions & 41 deletions PrimePickApp/View/Quiz/QuizButtonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,29 @@
import SwiftUI

struct QuizButtonView: View {
var quizData: [PrimeQuizEntity]
var quizData: [QuizEntity]
@Binding var correctQuizNumber: Int
@Binding var quizIndex: Int
@Binding var isPresentedResult: Bool
@State private var showAlert = false
@Environment(\.dismiss) private var dismiss

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

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

Text("")
.font(.custom("ArialRoundedMTBold", size: 80))
}
quizButton(option: "Incorrect")
.onTapGesture {
print("")
if !quizData[quizIndex].isCorrect {
print("正解")
correctQuizNumber += 1
} else {
print("不正解")
if !isPresentedResult {
if !quizData[quizIndex].isCorrect {
print("正解")
correctQuizNumber += 1
} else {
print("不正解")
}
}
if quizIndex < 9 {
if quizIndex < 9 {
quizIndex += 1
}
quizIndex += 1
} else {
// showAlert = true
isPresentedResult = true
}
}
Expand All @@ -52,34 +39,24 @@ struct QuizButtonView: View {

quizButton(option: "Correct")
.onTapGesture {
print("")
if quizData[quizIndex].isCorrect {
print("正解")
correctQuizNumber += 1
} else {
print("不正解")
if !isPresentedResult {
if quizData[quizIndex].isCorrect {
print("正解")
correctQuizNumber += 1
} else {
print("不正解")
}
}
if quizIndex < 9 {
if quizIndex < 9 {
quizIndex += 1
}
quizIndex += 1
} else {
// showAlert = true
isPresentedResult = true
}
}

Spacer()
}
}
.alert(isPresented: $showAlert) {
Alert(
title: Text("You Score is \(correctQuizNumber) points!"),
dismissButton: .default(Text("OK!")) {
dismiss()
}
)
}
}
}

Expand Down
62 changes: 62 additions & 0 deletions PrimePickApp/View/Quiz/QuizContent/QuizContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// QuizContentView.swift
// PrimePickApp
//
// Created by 村石 拓海 on 2024/05/31.
//

import SwiftUI

struct QuizContentView: View {
@Binding var quizNumber: Int
let difficulty: Difficulty
let quizData: [QuizEntity]

var body: some View {
GeometryReader { geometry in
ZStack(alignment: .leading) {
switch difficulty {
case .easy:
Color("appGreen")
.opacity(0.5)
.edgesIgnoringSafeArea(.all)
case .normal:
Color.blue
.opacity(0.5)
.edgesIgnoringSafeArea(.all)
case .hard:
Color.red
.opacity(0.5)
.edgesIgnoringSafeArea(.all)
}

VStack(spacing: .zero) {
QuizIndexView(difficulty: difficulty, quizNumber: $quizNumber)
.frame(height: geometry.size.height / 6)

QuizNumberView(
quizNumber: $quizNumber,
difficulty: difficulty,
quizData: quizData
)
.frame(height: geometry.size.height * 2 / 3)

QuizTimeLimitView(difficulty: difficulty)
.frame(height: geometry.size.height / 6)
}
}
}
}
}

struct QuizContentView_Previews: PreviewProvider {
@State static var quizNumber = 0

static var previews: some View {
QuizContentView(
quizNumber: $quizNumber,
difficulty: .easy,
quizData: [QuizEntity(quizId: 0, number: 3, isCorrect: true)]
)
}
}
21 changes: 21 additions & 0 deletions PrimePickApp/View/Quiz/QuizContent/QuizIndexView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// QuizIndexView.swift
// PrimePickApp
//
// Created by 村石 拓海 on 2024/05/22.
//

import SwiftUI

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

var body: some View {
Text("No.\(quizNumber + 1)")
.font(.custom("ArialRoundedMTBold", size: 45))
.foregroundStyle(Color.gray)
.padding(.horizontal, 16)
.frame(maxWidth: .infinity, alignment: .leading)
}
}
68 changes: 68 additions & 0 deletions PrimePickApp/View/Quiz/QuizContent/QuizNumberView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// QuizNumberView.swift
// PrimePickApp
//
// Created by 村石 拓海 on 2024/05/17.
//

import SwiftUI

struct QuizNumberView: View {
@Binding var quizNumber: Int
let difficulty: Difficulty
let quizData: [QuizEntity]

var body: some View {
ZStack {
quizNumberBackgroundView(difficulty: difficulty)

quizNumberText(
quizNumber: quizNumber,
difficulty: difficulty,
quizData: quizData
)
}
}
}

private func quizNumberBackgroundView(difficulty: Difficulty) -> some View {
let color = if difficulty == .easy {
Color.appGreen
} else if difficulty == .normal {
Color.blue
} else {
Color.red
}

return RoundedRectangle(cornerRadius: 25)
.stroke(color, lineWidth: 5)
.frame(width: 300, height: 200)
.shadow(radius: 10)
.background(
RoundedRectangle(cornerRadius: 25).fill(Color.white)
)
}

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

static var previews: some View {
QuizNumberView(
quizNumber: $quizNumber,
difficulty: .easy,
quizData: [QuizEntity(quizId: 0, number: 3, isCorrect: true)]
)
}
}
Loading

0 comments on commit 4eb1800

Please sign in to comment.