-
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
[Feat/#62] 퀴즈 풀기 화면 수정 #63
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
66d3a59
feat: 퀴즈 메인페이지 버튼 수정
mooyoung2309 fdb9db8
feat: progress 바 추가
mooyoung2309 c4b5606
feat: progress bar에 time 추가
mooyoung2309 6c2d838
feat: animation button 추가
mooyoung2309 4c3b3ed
feat: 퀴즈 풀이 뷰 수정
mooyoung2309 cd81174
feat: button animation 추가
mooyoung2309 4319494
feat: quiz client 분리
mooyoung2309 97c0f25
feat: quiz id 변경
mooyoung2309 130b0c9
feat: 버튼 수정
mooyoung2309 24cfb5b
feat: signing 파일 추가
mooyoung2309 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
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
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
20 changes: 20 additions & 0 deletions
20
Targets/D3N/Sources/Domain/Quiz/DTO/Request/SubmitQuizListRequest.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,20 @@ | ||
// | ||
// SubmitQuizListRequest.swift | ||
// D3N | ||
// | ||
// Created by 송영모 on 11/20/23. | ||
// Copyright © 2023 sju. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct SubmitQuizListRequestElement: Codable { | ||
let quizId, selectedAnswer: Int | ||
|
||
public init(quizId: Int, selectedAnswer: Int) { | ||
self.quizId = quizId | ||
self.selectedAnswer = selectedAnswer | ||
} | ||
} | ||
|
||
public typealias SubmitQuizListRequestDTO = [SubmitQuizListRequestElement] |
File renamed without changes.
15 changes: 15 additions & 0 deletions
15
Targets/D3N/Sources/Domain/Quiz/DTO/Response/SubmitQuizListResponse.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,15 @@ | ||
// | ||
// SubmitQuizListResponse.swift | ||
// D3N | ||
// | ||
// Created by 송영모 on 11/20/23. | ||
// Copyright © 2023 sju. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct SubmitQuizListResponseElement: Codable { | ||
let quizId: Int | ||
} | ||
|
||
public typealias SubmitQuizListResponseDTO = [SubmitQuizListResponseElement] |
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,9 @@ | ||
// | ||
// QuizModel.swift | ||
// D3N | ||
// | ||
// Created by 송영모 on 11/20/23. | ||
// Copyright © 2023 sju. All rights reserved. | ||
// | ||
|
||
import Foundation |
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,55 @@ | ||
// | ||
// QuizClient.swift | ||
// D3N | ||
// | ||
// Created by 송영모 on 11/20/23. | ||
// Copyright © 2023 sju. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
import ComposableArchitecture | ||
import Moya | ||
|
||
struct QuizClient { | ||
var fetch: (Int) async -> Result<[QuizEntity], D3NAPIError> | ||
var submit: ([QuizEntity]) async -> Result<[Int], D3NAPIError> | ||
} | ||
|
||
extension QuizClient: TestDependencyKey { | ||
static let previewValue = Self( | ||
fetch: { _ in .failure(.none) }, | ||
submit: { _ in .failure(.none) } | ||
) | ||
|
||
static let testValue = Self( | ||
fetch: unimplemented("\(Self.self).fetch"), | ||
submit: unimplemented("\(Self.self).submit") | ||
) | ||
} | ||
|
||
extension DependencyValues { | ||
var quizClient: QuizClient { | ||
get { self[QuizClient.self] } | ||
set { self[QuizClient.self] = newValue } | ||
} | ||
} | ||
|
||
extension QuizClient: DependencyKey { | ||
static let liveValue = QuizClient( | ||
fetch: { newsId in | ||
let target: TargetType = NewsService.fetchQuizList(newsId: newsId) | ||
let response: Result<FetchQuizListResponseDTO, D3NAPIError> = await D3NAPIkProvider.reqeust(target: target) | ||
|
||
return response.map { $0.map { $0.toEntity() } } | ||
}, | ||
submit: { quizs in | ||
let target: TargetType = QuizService.submit(quizs: quizs) | ||
let response: Result<SubmitQuizListResponseDTO, D3NAPIError> = await D3NAPIkProvider.reqeust(target: target) | ||
|
||
return response.map { | ||
$0.map { $0.quizId } | ||
} | ||
} | ||
) | ||
} |
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,52 @@ | ||
// | ||
// QuizService.swift | ||
// D3N | ||
// | ||
// Created by 송영모 on 11/20/23. | ||
// Copyright © 2023 sju. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
import Moya | ||
|
||
public enum QuizService { | ||
case fetch(newsId: Int) | ||
case submit(quizs: [QuizEntity]) | ||
} | ||
|
||
extension QuizService: TargetType { | ||
public var baseURL: URL { URL(string: Environment.baseURL)! } | ||
|
||
public var path: String { | ||
switch self { | ||
case .fetch: return "quiz/list" | ||
case .submit: return "quiz/list/submit" | ||
} | ||
} | ||
|
||
public var method: Moya.Method { | ||
switch self { | ||
case .fetch: return .get | ||
case .submit: return .post | ||
} | ||
} | ||
|
||
public var task: Task { | ||
switch self { | ||
case let .fetch(newsId: id): | ||
return .requestParameters(parameters: ["newsId": id], encoding: URLEncoding.queryString) | ||
case let .submit(quizs): | ||
let dto: SubmitQuizListRequestDTO = quizs.compactMap { | ||
if let userAnswer = $0.userAnswer { | ||
return .init(quizId: $0.id, selectedAnswer: userAnswer) | ||
} else { | ||
return nil | ||
} | ||
} | ||
return .requestJSONEncodable(dto) | ||
} | ||
} | ||
|
||
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
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
Oops, something went wrong.
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.
여기서 secondTime = 70이라는 변수의 의미가 무엇인가요?
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.
임시로 넣은 값입니다!