Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【REFACTOR】ファイル構成と共通化 #77

Merged
merged 9 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 39 additions & 7 deletions PrimePickApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
4F65A3992C01019000065A53 /* Difficulty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F65A3982C01019000065A53 /* Difficulty.swift */; };
4F8BE16C2BF4FFB000D7CF0E /* PrimeData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8BE16B2BF4FFB000D7CF0E /* PrimeData.swift */; };
4F8BE16E2BF504BB00D7CF0E /* QuizView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8BE16D2BF504BB00D7CF0E /* QuizView.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 */
Expand All @@ -41,6 +43,8 @@
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>"; };
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>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -74,17 +78,13 @@
isa = PBXGroup;
children = (
4F65A3972C0100FD00065A53 /* Enum */,
4FC177B82BEEAB2C00447A06 /* Info.plist */,
4FEC65B22C0117FC00A8B731 /* Extension */,
4FEC65B52C01234C00A8B731 /* View */,
4F0C82812BC8247500E1480E /* PrimePickApp.swift */,
4F0C82832BC8247500E1480E /* MainView.swift */,
4F8BE16D2BF504BB00D7CF0E /* QuizView.swift */,
4F2239212BFC9DEB004C71A6 /* QuizTimeLimitView.swift */,
4F2239252BFD0873004C71A6 /* QuizIndexView.swift */,
4F42C7A32BF76E7700F92FBB /* QuizNumberView.swift */,
4F2239232BFCEEF0004C71A6 /* QuizButtonView.swift */,
4F8BE1682BF4FB8E00D7CF0E /* QuizData */,
4F0C82852BC8247600E1480E /* Assets.xcassets */,
4F42C7A52BF7756200F92FBB /* ColorAssets.xcassets */,
4FC177B82BEEAB2C00447A06 /* Info.plist */,
4F0C82872BC8247600E1480E /* PrimePickApp.entitlements */,
4F0C82882BC8247600E1480E /* Preview Content */,
);
Expand Down Expand Up @@ -117,6 +117,36 @@
path = QuizData;
sourceTree = "<group>";
};
4FEC65B22C0117FC00A8B731 /* Extension */ = {
isa = PBXGroup;
children = (
4FEC65B32C01184E00A8B731 /* Text+Extension.swift */,
);
path = Extension;
sourceTree = "<group>";
};
4FEC65B52C01234C00A8B731 /* View */ = {
isa = PBXGroup;
children = (
4F0C82832BC8247500E1480E /* MainView.swift */,
4FEC65B02C01164800A8B731 /* SelectDifficultyButtonView.swift */,
4FEC65B62C01252800A8B731 /* Quiz */,
);
path = View;
sourceTree = "<group>";
};
4FEC65B62C01252800A8B731 /* Quiz */ = {
isa = PBXGroup;
children = (
4F8BE16D2BF504BB00D7CF0E /* QuizView.swift */,
4F2239252BFD0873004C71A6 /* QuizIndexView.swift */,
4F42C7A32BF76E7700F92FBB /* QuizNumberView.swift */,
4F2239212BFC9DEB004C71A6 /* QuizTimeLimitView.swift */,
4F2239232BFCEEF0004C71A6 /* QuizButtonView.swift */,
);
path = Quiz;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -194,11 +224,13 @@
4F02A57D2BF62F61003DF310 /* PrimeQuizEntity.swift in Sources */,
4F65A3992C01019000065A53 /* Difficulty.swift in Sources */,
4F0C82842BC8247500E1480E /* MainView.swift in Sources */,
4FEC65B12C01164800A8B731 /* SelectDifficultyButtonView.swift in Sources */,
4F8BE16E2BF504BB00D7CF0E /* QuizView.swift in Sources */,
4F2239222BFC9DEB004C71A6 /* QuizTimeLimitView.swift in Sources */,
4F0C82822BC8247500E1480E /* PrimePickApp.swift in Sources */,
4F02A57F2BF63A43003DF310 /* QuizDataManager.swift in Sources */,
4F8BE16C2BF4FFB000D7CF0E /* PrimeData.swift in Sources */,
4FEC65B42C01184E00A8B731 /* Text+Extension.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
45 changes: 45 additions & 0 deletions PrimePickApp/Extension/Text+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Text+Extension.swift
// PrimePickApp
//
// Created by 村石 拓海 on 2024/05/25.
//

import SwiftUI

public extension View {
func gamingText() -> some View {
self.modifier(GamingText())
}
}

struct GamingText: ViewModifier {
@State private var hue: Double = 0

func body(content: Content) -> some View {
content
.foregroundColor(Color.white)
.overlay(
LinearGradient(
gradient: Gradient(colors: [
Color.red, Color.orange, Color.yellow, Color.green,
Color.blue, Color.purple, Color.red
]),
startPoint: .leading,
endPoint: .trailing
)
.mask(content)
.hueRotation(Angle(degrees: hue))
)
.onAppear {
withAnimation(Animation.linear(duration: 1).repeatForever(autoreverses: false)) {
hue = 360
}
}
}
}

#Preview {
Text("Gaming ON!")
.gamingText()
}
151 changes: 0 additions & 151 deletions PrimePickApp/MainView.swift

This file was deleted.

66 changes: 66 additions & 0 deletions PrimePickApp/View/MainView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// ContentView.swift
// PrimePickApp
//
// Created by 村石 拓海 on 2024/04/11.
//

import SwiftUI

struct MainView: View {
@State private var hue: Double = 0

var body: some View {
NavigationStack {
ZStack {
Color("appBlue")
.ignoresSafeArea()

VStack {
Spacer()

Text("Prime Pick")
.gamingText()
.font(.custom("Helvetica Neue", size: 60))
.fontWeight(.bold)


Spacer()

SelectDifficultyButtonView()

Spacer()
}
}
}
}
}

extension Difficulty {
public var gradientColors: [Color] {
switch self {
case .easy:
return [Color.green, Color.yellow]
case .normal:
return [Color.purple, Color.blue]
case .hard:
return [Color.red, Color.purple]
}
}
}

struct LazyView<Content: View>: View {
let content: () -> Content

init(_ content: @autoclosure @escaping () -> Content) {
self.content = content
}

var body: Content {
content()
}
}

#Preview {
MainView()
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ struct QuizNumberView_Previews: PreviewProvider {
@State static var quizNumber = 3

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