From 2d824776161baed349c3f06df3eb29c00aa94752 Mon Sep 17 00:00:00 2001 From: gaeng2y Date: Tue, 17 Oct 2023 22:29:10 +0900 Subject: [PATCH] =?UTF-8?q?#62=20=EA=B2=B0=EA=B3=BC=20=ED=99=94=EB=A9=B4?= =?UTF-8?q?=20=EB=93=B1=EA=B8=89=20Text=EB=B3=B4=EC=9D=B4=EB=8A=94=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Level1Kuiz/Model/ResultModel.swift | 8 +++--- Level1Kuiz/View/Quiz/QuizView.swift | 29 +++++++++++----------- Level1Kuiz/View/Quiz/ReachEffectView.swift | 8 +++--- Level1Kuiz/View/Result/ResultView.swift | 25 ++++++------------- Level1Kuiz/View/Result/ShareView.swift | 8 +++--- 5 files changed, 33 insertions(+), 45 deletions(-) diff --git a/Level1Kuiz/Model/ResultModel.swift b/Level1Kuiz/Model/ResultModel.swift index b846424..8f16fa7 100644 --- a/Level1Kuiz/Model/ResultModel.swift +++ b/Level1Kuiz/Model/ResultModel.swift @@ -7,13 +7,13 @@ import Foundation -//enum Rank: String { +// enum Rank: String { // case newbie = "맞춤법 더듬이" // case normal = "일반인" // case pro = "맞춤법 변태" // case master = "맞춤법 달인" // case expert = "국립국어원 직원" -//} +// } enum Rank { case newbie @@ -51,7 +51,7 @@ enum Rank { return "국립국어원 직원" } } - + func getRemainScore(score: Int) -> Int { switch self { case .newbie: @@ -66,7 +66,7 @@ enum Rank { return 40 } } - + func getRankByScore(with score: Int) -> Rank { if score >= 40 { return Rank.expert diff --git a/Level1Kuiz/View/Quiz/QuizView.swift b/Level1Kuiz/View/Quiz/QuizView.swift index 2bd6f99..18e9129 100644 --- a/Level1Kuiz/View/Quiz/QuizView.swift +++ b/Level1Kuiz/View/Quiz/QuizView.swift @@ -10,10 +10,10 @@ import SwiftUIMargin import ConfettiSwiftUI struct QuizView: View { - + @Environment(\.presentationMode) var mode: Binding @GestureState private var dragOffSet = CGSize.zero - + @State var quizzes: [Quiz] = [] @State var score: Int = 0 @State var answer: String = "" @@ -22,7 +22,7 @@ struct QuizView: View { @State var isQuizEnded: Bool = false @State var scoreCounter: Int = 0 @State var isEvent: Bool = false - + var body: some View { GeometryReader { geometry in ZStack { @@ -39,8 +39,8 @@ struct QuizView: View { screenChangeScore(with: score) .edgesIgnoringSafeArea(.all) .animation(.default, value: score) - - VStack{ + + VStack { Text("당신은 \(Rank(score: score).rawValue)!") .font(Font.system(size: 20, weight: .semibold)) Spacer() @@ -50,7 +50,7 @@ struct QuizView: View { .fontWeight(.bold) .fullScreenCover(isPresented: $isEvent, content: { ReachEffectView(nowScore: $score, isEvent: $isEvent) - } ) + }) VStack(alignment: .center, spacing: 12) { if quizzes.isEmpty { ProgressView() @@ -76,22 +76,21 @@ struct QuizView: View { .preferredColorScheme(.light) .navigationBarBackButtonHidden() } - private func screenChangeScore(with score : Int)-> Color{ - if score <= 9{ + private func screenChangeScore(with score: Int) -> Color { + if score <= 9 { return Color.yellow - }else if score <= 19{ + } else if score <= 19 { return Color.blue - }else if score <= 29{ + } else if score <= 29 { return Color.green - }else if score <= 39{ + } else if score <= 39 { return Color.orange - }else if score <= 49{ + } else if score <= 49 { return Color.cyan } return Color.yellow } - func generateAnswerText(index: Int, geometry: GeometryProxy) -> some View { Text(quizzes[score].answers[index].text) .fontWeight(.black) @@ -103,7 +102,7 @@ struct QuizView: View { .onTapGesture { if quizzes[score].answers[index].isCorrect { score += 1 - if score % 10 == 0{ + if score % 10 == 0 { isEvent = true } } else { @@ -119,7 +118,7 @@ struct QuizView: View { randomBool = Bool.random() } } - + private func getRankByScore(with score: Int) -> Rank { if score >= 40 { return Rank.expert diff --git a/Level1Kuiz/View/Quiz/ReachEffectView.swift b/Level1Kuiz/View/Quiz/ReachEffectView.swift index 45e88bb..aabab86 100644 --- a/Level1Kuiz/View/Quiz/ReachEffectView.swift +++ b/Level1Kuiz/View/Quiz/ReachEffectView.swift @@ -11,12 +11,12 @@ import ConfettiSwiftUI struct ReachEffectView: View { @Binding var nowScore: Int @Binding var isEvent: Bool - + @State var scoreCounter: Int = 10 var body: some View { - ZStack{ + ZStack { Color.black.ignoresSafeArea() - VStack(alignment: .center){ + VStack(alignment: .center) { Spacer() Text("🎉축하합니다🎉") .font(.system(size: 40)) @@ -31,7 +31,7 @@ struct ReachEffectView: View { scoreCounter += 10 }) Spacer() - Button{ + Button { isEvent = false }label: { Text("확인") diff --git a/Level1Kuiz/View/Result/ResultView.swift b/Level1Kuiz/View/Result/ResultView.swift index 6174568..c22a9d9 100644 --- a/Level1Kuiz/View/Result/ResultView.swift +++ b/Level1Kuiz/View/Result/ResultView.swift @@ -13,9 +13,9 @@ struct ResultView: View { var score: Int var answer: String var description: String - var scoreColor : Color + var scoreColor: Color var maxScore: Int = 40 - + static let TRANSITION_TIME_INTERVAL: TimeInterval = 0.1 @State private var isNavigationLinkActive = false @@ -24,7 +24,6 @@ struct ResultView: View { @State private var showShareSheet = false @State private var imageToShare: UIImage? - var body: some View { VStack { GeometryReader { geometry in @@ -51,7 +50,7 @@ struct ResultView: View { .padding(EdgeInsets(top: 0, leading: 40, bottom: 0, trailing: 40)) .frame(width: geometry.size.width, height: geometry.size.height) } - + GeometryReader { geometry in VStack { VStack(spacing: 24) { @@ -80,15 +79,8 @@ struct ResultView: View { Text("\(Rank(score: score + 10).rawValue) 등급까지 \(Rank(score: score).getRemainScore(score: score))문제 남았어요.") .font(.system(size: 18, weight: .semibold)) Text("더 높은 등급에 도전해 보세요!") - Text("\(Rank(score: score + 10).rawValue)") - .font(.system(size: 20)) - .fontWeight(.black) - .padding(EdgeInsets(top: 20, leading: 40, bottom: 20, trailing: 40)) - .foregroundColor(Color.white) - .background(Color.black) - .cornerRadius(80) } - + NavigationLink(destination: QuizView(), isActive: $isNavigationLinkActive) { Button { isNavigationLinkActive = true @@ -103,15 +95,13 @@ struct ResultView: View { } } .navigationBarBackButtonHidden(true) - - - + Button { let message = "\(Rank(score: score + 10).rawValue) 등급까지 \(Rank(score: score).getRemainScore(score: score))문제 남았어요." let renderer = ImageRenderer(content: ShareView(score: dynamicScore.description, rank: Rank(score: score).rawValue, message: message).frame(width: 400, height: 400)) - + if let uiImage = renderer.uiImage { imageToShare = uiImage if let _ = imageToShare { @@ -121,7 +111,6 @@ struct ResultView: View { } } - } label: { Text("공유하기") .font(.system(size: 20)) @@ -159,7 +148,7 @@ struct ResultView: View { dynamicScore += 1 } - + } } diff --git a/Level1Kuiz/View/Result/ShareView.swift b/Level1Kuiz/View/Result/ShareView.swift index 75d4bb7..3940c91 100644 --- a/Level1Kuiz/View/Result/ShareView.swift +++ b/Level1Kuiz/View/Result/ShareView.swift @@ -8,11 +8,11 @@ import SwiftUI struct ShareView: View { - + let score: String let rank: String let message: String - + var body: some View { ZStack { Color.yellow.ignoresSafeArea() @@ -29,7 +29,7 @@ struct ShareView: View { Text("\(message)") .font(.title3) .fontWeight(.heavy) - + } .margin(top: 40) .padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20)) @@ -53,6 +53,6 @@ struct ShareSheet: UIViewControllerRepresentable { } func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) { - + } }