-
Notifications
You must be signed in to change notification settings - Fork 0
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
FIXME: 코드 1차 수정 #77
Closed
Closed
FIXME: 코드 1차 수정 #77
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fixme: 코드 1차 수정
- Loading branch information
commit 371cab73fb0197e329bd2d4298fb6dbfd39bbecb
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Targets/D3N/Sources/Domain/Quiz/DTO/Response/FetchSolvedQuizListResponseDTO.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// SolvedQuizClient.swift | ||
// D3N | ||
// | ||
// Created by Younghoon Ahn on 11/29/23. | ||
// Copyright © 2023 sju. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
import ComposableArchitecture | ||
import Moya | ||
|
||
struct SolvedQuizClient { | ||
var fetch: (Int) async -> Result<[SolvedQuizEntity], D3NAPIError> | ||
} | ||
|
||
extension SolvedQuizClient: TestDependencyKey { | ||
static let previewValue = Self( | ||
fetch: { _ in .failure(.none) } | ||
) | ||
|
||
static let testValue = Self( | ||
fetch: unimplemented("\(Self.self).fetch") | ||
) | ||
} | ||
|
||
extension DependencyValues { | ||
var solvedQuizClient: SolvedQuizClient { | ||
get { self[SolvedQuizClient.self] } | ||
} | ||
} | ||
|
||
extension SolvedQuizClient: DependencyKey { | ||
static let liveValue = SolvedQuizClient( | ||
fetch: { _ in | ||
let target: TargetType = SolvedQuizService.fetch | ||
let response: Result<FetchSolvedQuizListResponseDTO, D3NAPIError> = await D3NAPIkProvider.reqeust(target: target) | ||
|
||
return response.map { $0.map { $0.toEntity() } } | ||
} | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// SolvedQuizService.swift | ||
// D3N | ||
// | ||
// Created by Younghoon Ahn on 11/29/23. | ||
// Copyright © 2023 sju. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
import Moya | ||
|
||
public enum SolvedQuizService { | ||
case fetch | ||
} | ||
|
||
extension SolvedQuizService: TargetType { | ||
public var baseURL: URL { URL(string: Environment.baseURL)! } | ||
|
||
public var path: String { | ||
switch self { | ||
case .fetch: return "quiz/list/solved" | ||
} | ||
} | ||
|
||
public var method: Moya.Method { | ||
switch self { | ||
case .fetch: return .get | ||
} | ||
} | ||
|
||
Comment on lines
+13
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 비슷한 피드백으로 QuizService에 들어가야할 내용이라고 생각합니다. 그리고 이미 들어가있는것으로 알고있습니다! |
||
public var task: Task { | ||
switch self { | ||
case .fetch: | ||
return .requestPlain | ||
} | ||
} | ||
|
||
public var headers: [String: String]? { nil } | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
Targets/D3N/Sources/Feature/Quiz/List/Cell/SolvedQuizListItemCellStore.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// SolvedQuizListItemCellStore.swift | ||
// D3N | ||
// | ||
// Created by Younghoon Ahn on 12/1/23. | ||
// Copyright © 2023 sju. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
import ComposableArchitecture | ||
|
||
public struct SolvedQuizListItemCellStore: Reducer { | ||
public struct State: Equatable, Identifiable { | ||
public var id: Int | ||
|
||
var question: String | ||
var choices: [String] | ||
var answer: Int | ||
var reason: String | ||
var userAnswer: Int | ||
var news: NewsEntity | ||
|
||
init( | ||
id: Int = .init(), | ||
question: String, | ||
choices: [String], | ||
answer: Int, | ||
reason: String, | ||
userAnswer: Int, | ||
news: NewsEntity | ||
) { | ||
self.id = id | ||
self.question = question | ||
self.choices = choices | ||
self.answer = answer | ||
self.reason = reason | ||
self.userAnswer = userAnswer | ||
self.news = news | ||
} | ||
} | ||
|
||
public enum Action: Equatable { | ||
case onAppear | ||
|
||
case delegate(Delegate) | ||
|
||
public enum Delegate: Equatable { | ||
case submit(Int) | ||
} | ||
} | ||
|
||
public var body: some ReducerOf<Self> { | ||
Reduce { state, action in | ||
switch action { | ||
case .onAppear: | ||
return .none | ||
|
||
default: | ||
return .none | ||
} | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Targets/D3N/Sources/Feature/Quiz/List/Cell/SolvedQuizListItemCellView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// SolvedQuizListItemCellView.swift | ||
// D3N | ||
// | ||
// Created by Younghoon Ahn on 12/1/23. | ||
// Copyright © 2023 sju. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
import ComposableArchitecture | ||
|
||
public struct SolvedQuizListItemCellView: View { | ||
let store: StoreOf<SolvedQuizListItemCellStore> | ||
|
||
public init(store: StoreOf<SolvedQuizListItemCellStore>) { | ||
self.store = store | ||
} | ||
|
||
public var body: some View { | ||
WithViewStore(self.store, observe: { $0 }) { viewStore in | ||
VStack { | ||
Text(viewStore.state.question) | ||
.padding(.top, 40) | ||
|
||
Spacer() | ||
|
||
ForEach(Array(viewStore.choices.enumerated()), id: \.offset) { index, choice in | ||
VStack{ | ||
Text("Hello123") | ||
} | ||
} | ||
.padding() | ||
} | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
client를 또 추가할 필요가 없는 이유는 Quiz라는 도메인으로 묶어서 생각할 수 있기 때문이라고 생각합니다. 기존에 있는 QuizClient에 fetchSolved를 하는 방식이 응집도가 높아서 더 좋아보입니다.