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

[Feat/#69] 코드 정리 #70

Merged
merged 3 commits into from
Dec 3, 2023
Merged
Changes from 1 commit
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
Next Next commit
feat: quiz result 기능 제거
  • Loading branch information
mooyoung2309 committed Dec 3, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 0b69ff0e30b883dad326c1f8dc970d090e455702
Original file line number Diff line number Diff line change
@@ -34,23 +34,18 @@ public struct AllNewsNavigationStackStore: Reducer {
public struct Path: Reducer {
public enum State: Equatable {
case quizMain(QuizMainStore.State)
case quizResult(QuizResultStore.State)
case allNews(AllNewsStore.State)
}

public enum Action: Equatable {
case quizMain(QuizMainStore.Action)
case quizResult(QuizResultStore.Action)
case allNews(AllNewsStore.Action)
}

public var body: some Reducer<State, Action> {
Scope(state: /State.quizMain, action: /Action.quizMain) {
QuizMainStore()
}
Scope(state: /State.quizResult, action: /Action.quizResult) {
QuizResultStore()
}
Scope(state: /State.allNews, action: /Action.allNews) {
AllNewsStore()
}
@@ -72,19 +67,6 @@ public struct AllNewsNavigationStackStore: Reducer {
return .none
}

case let .path(.element(id: _, action: .quizMain(.delegate(action)))):
switch action {
case let .solved(quizEntityList):
state.path.append(.quizResult(.init(quizEntityList: quizEntityList)))
return .none
}

case let .path(.element(id: _, action: .quizResult(.delegate(action)))):
switch action {
case .backToRoot:
return .send(.popToRoot)
}

case let .path(.element(id: _, action: .allNews(.delegate(action)))):
switch action {
case let .select(newsEntity):
Original file line number Diff line number Diff line change
@@ -37,13 +37,6 @@ public struct AllNewsNavigationStackView: View {
then: QuizMainView.init(store:)
)

case .quizResult:
CaseLet(
/AllNewsNavigationStackStore.Path.State.quizResult,
action: AllNewsNavigationStackStore.Path.Action.quizResult,
then: QuizResultView.init(store:)
)

case .allNews:
CaseLet(
/AllNewsNavigationStackStore.Path.State.allNews,
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
////
//// QuizResultItemCellStore.swift
//// D3N
////
//// Created by 송영모 on 10/15/23.
//// Copyright © 2023 sju. All rights reserved.
////
//
// QuizResultItemCellStore.swift
// D3N
//
// Created by 송영모 on 10/15/23.
// Copyright © 2023 sju. All rights reserved.
//import Foundation
//


import Foundation

import ComposableArchitecture

public struct QuizResultItemCellStore: Reducer {
public struct State: Equatable, Identifiable {
public var id: UUID
public var quizEntity: QuizEntity

public init(
id: UUID = .init(),
quizEntity: QuizEntity
) {
self.id = id
self.quizEntity = quizEntity
}
}

public enum Action: Equatable {
case onAppear

case tapped

case delegate(Delegate)

public enum Delegate: Equatable {
case tapped
}
}

public var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .onAppear:
return .none

case .tapped:
return .send(.delegate(.tapped))

default:
return .none
}
}
}
}
//import ComposableArchitecture
//
//public struct QuizResultItemCellStore: Reducer {
// public struct State: Equatable, Identifiable {
// public var id: UUID
// public var quizEntity: QuizEntity
//
// public init(
// id: UUID = .init(),
// quizEntity: QuizEntity
// ) {
// self.id = id
// self.quizEntity = quizEntity
// }
// }
//
// public enum Action: Equatable {
// case onAppear
//
// case tapped
//
// case delegate(Delegate)
//
// public enum Delegate: Equatable {
// case tapped
// }
// }
//
// public var body: some ReducerOf<Self> {
// Reduce { state, action in
// switch action {
// case .onAppear:
// return .none
//
// case .tapped:
// return .send(.delegate(.tapped))
//
// default:
// return .none
// }
// }
// }
//}
Original file line number Diff line number Diff line change
@@ -1,93 +1,93 @@
////
//// QuizResultItemCellView.swift
//// D3N
////
//// Created by 송영모 on 10/15/23.
//// Copyright © 2023 sju. All rights reserved.
////
//
// QuizResultItemCellView.swift
// D3N
//import Foundation
//import SwiftUI
//
// Created by 송영모 on 10/15/23.
// Copyright © 2023 sju. All rights reserved.
//import ComposableArchitecture
//

import Foundation
import SwiftUI

import ComposableArchitecture

public struct QuizResultItemCellView: View {
let store: StoreOf<QuizResultItemCellStore>

public var body: some View {
WithViewStore(self.store, observe: { $0 }) { viewStore in
VStack {
VStack {
titleView(viewStore: viewStore)

quizResultListView(viewStore: viewStore)
}
.minimalBackgroundStyle()

reasoneView(viewStore: viewStore)
.minimalBackgroundStyle()
}
.padding(.horizontal)
}
}
private func titleView(viewStore: ViewStoreOf<QuizResultItemCellStore>) -> some View {
HStack {
Text(viewStore.state.quizEntity.question)
.font(.title3)
.fontWeight(.semibold)
.lineLimit(nil)
.fixedSize(horizontal: false, vertical: true)

Spacer()
}
}

private func quizResultListView(viewStore: ViewStoreOf<QuizResultItemCellStore>) -> some View {
VStack(alignment: .leading) {
HStack {
Spacer()
}
ForEach(Array(viewStore.state.quizEntity.choiceList.enumerated()), id: \.offset) { index, choice in
Label(title: {
Text(choice)
}, icon: {
quizResultItemImage(
current: index,
answer: viewStore.state.quizEntity.answer,
userAnswer: viewStore.state.quizEntity.selectedAnswer ?? 0
)
})
.font(.subheadline)
}
}
}

private func reasoneView(viewStore: ViewStoreOf<QuizResultItemCellStore>) -> some View {
HStack {
Text(viewStore.state.quizEntity.reason)
.font(.subheadline)
.lineLimit(nil)
.fixedSize(horizontal: false, vertical: true)

Spacer()
}
}

private func quizResultItemImage(current: Int, answer: Int, userAnswer: Int) -> some View {
VStack {
if current == answer && current == userAnswer {
return Image(systemName: "checkmark.circle.fill")
.foregroundStyle(.mint)
} else if current == answer {
return Image(systemName: "checkmark.circle.fill")
.foregroundStyle(.pink)
} else if current == userAnswer {
return Image(systemName: "circle.fill")
.foregroundStyle(.foreground)
} else {
return Image(systemName: "circle")
.foregroundStyle(.foreground)
}
}
}
}
//public struct QuizResultItemCellView: View {
// let store: StoreOf<QuizResultItemCellStore>
//
// public var body: some View {
// WithViewStore(self.store, observe: { $0 }) { viewStore in
// VStack {
// VStack {
// titleView(viewStore: viewStore)
//
// quizResultListView(viewStore: viewStore)
// }
// .minimalBackgroundStyle()
//
// reasoneView(viewStore: viewStore)
// .minimalBackgroundStyle()
// }
// .padding(.horizontal)
// }
// }
// private func titleView(viewStore: ViewStoreOf<QuizResultItemCellStore>) -> some View {
// HStack {
// Text(viewStore.state.quizEntity.question)
// .font(.title3)
// .fontWeight(.semibold)
// .lineLimit(nil)
// .fixedSize(horizontal: false, vertical: true)
//
// Spacer()
// }
// }
//
// private func quizResultListView(viewStore: ViewStoreOf<QuizResultItemCellStore>) -> some View {
// VStack(alignment: .leading) {
// HStack {
// Spacer()
// }
// ForEach(Array(viewStore.state.quizEntity.choiceList.enumerated()), id: \.offset) { index, choice in
// Label(title: {
// Text(choice)
// }, icon: {
// quizResultItemImage(
// current: index,
// answer: viewStore.state.quizEntity.answer,
// userAnswer: viewStore.state.quizEntity.selectedAnswer ?? 0
// )
// })
// .font(.subheadline)
// }
// }
// }
//
// private func reasoneView(viewStore: ViewStoreOf<QuizResultItemCellStore>) -> some View {
// HStack {
// Text(viewStore.state.quizEntity.reason)
// .font(.subheadline)
// .lineLimit(nil)
// .fixedSize(horizontal: false, vertical: true)
//
// Spacer()
// }
// }
//
// private func quizResultItemImage(current: Int, answer: Int, userAnswer: Int) -> some View {
// VStack {
// if current == answer && current == userAnswer {
// return Image(systemName: "checkmark.circle.fill")
// .foregroundStyle(.mint)
// } else if current == answer {
// return Image(systemName: "checkmark.circle.fill")
// .foregroundStyle(.pink)
// } else if current == userAnswer {
// return Image(systemName: "circle.fill")
// .foregroundStyle(.foreground)
// } else {
// return Image(systemName: "circle")
// .foregroundStyle(.foreground)
// }
// }
// }
//}
Loading