Skip to content

Commit

Permalink
#62 결과 화면 등급 Text보이는 부분 수정
Browse files Browse the repository at this point in the history
개요
* 결과화면에 하단에 다음 등급?에 대한 Text가 있어서 제거
작업사항
* ResultView 수정
* 나머지는 자동 수정된 부분입니다
변경로직
* Text 제거
  • Loading branch information
gaeng2y authored Oct 20, 2023
2 parents 672ff95 + 2d82477 commit 3885630
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 45 deletions.
8 changes: 4 additions & 4 deletions Level1Kuiz/Model/ResultModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -51,7 +51,7 @@ enum Rank {
return "국립국어원 직원"
}
}

func getRemainScore(score: Int) -> Int {
switch self {
case .newbie:
Expand All @@ -66,7 +66,7 @@ enum Rank {
return 40
}
}

func getRankByScore(with score: Int) -> Rank {
if score >= 40 {
return Rank.expert
Expand Down
29 changes: 14 additions & 15 deletions Level1Kuiz/View/Quiz/QuizView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import SwiftUIMargin
import ConfettiSwiftUI

struct QuizView: View {

@Environment(\.presentationMode) var mode: Binding<PresentationMode>
@GestureState private var dragOffSet = CGSize.zero

@State var quizzes: [Quiz] = []
@State var score: Int = 0
@State var answer: String = ""
Expand All @@ -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 {
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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)
Expand All @@ -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 {
Expand All @@ -119,7 +118,7 @@ struct QuizView: View {
randomBool = Bool.random()
}
}

private func getRankByScore(with score: Int) -> Rank {
if score >= 40 {
return Rank.expert
Expand Down
8 changes: 4 additions & 4 deletions Level1Kuiz/View/Quiz/ReachEffectView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -31,7 +31,7 @@ struct ReachEffectView: View {
scoreCounter += 10
})
Spacer()
Button{
Button {
isEvent = false
}label: {
Text("확인")
Expand Down
25 changes: 7 additions & 18 deletions Level1Kuiz/View/Result/ResultView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -121,7 +111,6 @@ struct ResultView: View {
}
}


} label: {
Text("공유하기")
.font(.system(size: 20))
Expand Down Expand Up @@ -159,7 +148,7 @@ struct ResultView: View {

dynamicScore += 1
}

}
}

Expand Down
8 changes: 4 additions & 4 deletions Level1Kuiz/View/Result/ShareView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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))
Expand All @@ -53,6 +53,6 @@ struct ShareSheet: UIViewControllerRepresentable {
}

func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {

}
}

0 comments on commit 3885630

Please sign in to comment.