-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[ํ] ๋ฐ์ผ๋ฆฌ ๋ฌธ์ ๋ฆฌ์คํธ ํ๋ฉด ๊ตฌํ
- Loading branch information
Showing
29 changed files
with
716 additions
and
198 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
Projects/DSKit/Resources/Image.xcassets/person.imageset/Contents.json
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,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "profile.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+254 Bytes
Projects/DSKit/Resources/Image.xcassets/person.imageset/profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+416 Bytes
Projects/DSKit/Resources/Image.xcassets/person.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+578 Bytes
Projects/DSKit/Resources/Image.xcassets/person.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
Projects/DSKit/Resources/Image.xcassets/speech-bubble.imageset/Contents.json
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,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Group 1000012460.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "Group [email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "Group [email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+636 Bytes
...ects/DSKit/Resources/Image.xcassets/speech-bubble.imageset/Group 1000012460.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.18 KB
...s/DSKit/Resources/Image.xcassets/speech-bubble.imageset/Group [email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.84 KB
...s/DSKit/Resources/Image.xcassets/speech-bubble.imageset/Group [email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,43 @@ | ||
// | ||
// DailyStatisticsModel.swift | ||
// Domain | ||
// | ||
// Created by ๊น์์ธ on 2023/09/06. | ||
// Copyright ยฉ 2023 team.humanwave. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
import Network | ||
|
||
public struct DailyStatisticsModel: Equatable { | ||
public let solvedCount: Int | ||
public let testsStatistics: [TestsStatisticsModel] | ||
} | ||
|
||
public struct TestsStatisticsModel: Hashable, Equatable { | ||
public let keymeTests: KeymeTestsInfoModel | ||
public let avarageScore: Double? | ||
} | ||
|
||
public extension StatisticsDTO { | ||
func toDailyStatisticsModel() -> DailyStatisticsModel { | ||
let testsStatistics = data.questionsStatistics.map { | ||
TestsStatisticsModel( | ||
keymeTests: KeymeTestsInfoModel( | ||
keyword: $0.keyword, | ||
icon: IconModel( | ||
imageURL: $0.category.iconUrl, | ||
color: Color.hex($0.category.color) | ||
) | ||
), | ||
avarageScore: $0.avgScore | ||
) | ||
} | ||
|
||
return DailyStatisticsModel( | ||
solvedCount: data.solvedCount, | ||
testsStatistics: testsStatistics | ||
) | ||
} | ||
} |
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,16 @@ | ||
// | ||
// EmptyModel.swift | ||
// Domain | ||
// | ||
// Created by ๊น์์ธ on 2023/09/06. | ||
// Copyright ยฉ 2023 team.humanwave. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public extension DailyStatisticsModel { | ||
static var EMPTY: Self = .init( | ||
solvedCount: 0, | ||
testsStatistics: [] | ||
) | ||
} |
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
66 changes: 66 additions & 0 deletions
66
Projects/Features/Sources/Home/DailyTestList/DailyTestListFeature.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,66 @@ | ||
// | ||
// DailyTestFeature.swift | ||
// Features | ||
// | ||
// Created by ๊น์์ธ on 2023/09/06. | ||
// Copyright ยฉ 2023 team.humanwave. All rights reserved. | ||
// | ||
|
||
import ComposableArchitecture | ||
|
||
import Domain | ||
import Network | ||
|
||
public struct DailyTestListFeature: Reducer { | ||
@Dependency(\.keymeAPIManager) private var network | ||
|
||
public struct State: Equatable { | ||
let testData: KeymeTestsModel | ||
var dailyStatistics: DailyStatisticsModel = .EMPTY | ||
|
||
init(testData: KeymeTestsModel) { | ||
self.testData = testData | ||
} | ||
} | ||
|
||
public enum Action { | ||
case onAppear | ||
case onDisappear | ||
case fetchDailyStatistics | ||
case saveDailyStatistics(DailyStatisticsModel) | ||
case shareButtonDidTap | ||
} | ||
|
||
enum CancelID { | ||
case dailyTestList | ||
} | ||
|
||
public var body: some Reducer<State, Action> { | ||
Reduce { state, action in | ||
switch action { | ||
case .onAppear: | ||
return .send(.fetchDailyStatistics) | ||
|
||
case .onDisappear: | ||
return .cancel(id: CancelID.dailyTestList) | ||
|
||
case .fetchDailyStatistics: | ||
return .run { [testId = state.testData.testId] send in | ||
let dailyStatisticsData = try await network.request(.test(.statistics(testId)), object: StatisticsDTO.self) | ||
// let dailyStatisticsData = try await network.requestWithSampleData(.test(.statistics(testId)), object: StatisticsDTO.self) | ||
let dailyStatistics = dailyStatisticsData.toDailyStatisticsModel() | ||
await send(.saveDailyStatistics(dailyStatistics)) | ||
} | ||
.cancellable(id: CancelID.dailyTestList) | ||
|
||
case let .saveDailyStatistics(dailyStatistics): | ||
state.dailyStatistics = dailyStatistics | ||
|
||
default: | ||
return .none | ||
} | ||
|
||
return .none | ||
} | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
Projects/Features/Sources/Home/DailyTestList/DailyTestListView.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,116 @@ | ||
// | ||
// DailyTestListView.swift | ||
// Features | ||
// | ||
// Created by ๊น์์ธ on 2023/09/06. | ||
// Copyright ยฉ 2023 team.humanwave. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
import ComposableArchitecture | ||
|
||
import Core | ||
import DSKit | ||
import Util | ||
|
||
struct DailyTestListView: View { | ||
var store: StoreOf<DailyTestListFeature> | ||
typealias DailyTestStore = ViewStore<DailyTestListFeature.State, | ||
DailyTestListFeature.Action> | ||
|
||
init(store: StoreOf<DailyTestListFeature>) { | ||
self.store = store | ||
} | ||
|
||
var body: some View { | ||
WithViewStore(store, observe: { $0 }) { viewStore in | ||
VStack(alignment: .leading) { | ||
Spacer() | ||
.frame(height: 75) | ||
|
||
welcomeText(nickname: viewStore.testData.nickname) | ||
|
||
Spacer() | ||
|
||
HStack(spacing: 4) { | ||
Image(uiImage: DSKitAsset.Image.person.image) | ||
.resizable() | ||
.frame(width: 16, height: 16) | ||
|
||
Text.keyme( | ||
"\(viewStore.dailyStatistics.solvedCount)๋ช ์ ์น๊ตฌ๊ฐ ๋ฌธ์ ๋ฅผ ํ์์ด์", | ||
font: .body4 | ||
) | ||
.foregroundColor(.white) | ||
} | ||
|
||
dailyTestList(viewStore) | ||
|
||
Spacer() | ||
} | ||
.onAppear { | ||
viewStore.send(.onAppear) | ||
} | ||
.onDisappear { | ||
viewStore.send(.onDisappear) | ||
} | ||
.fullFrame() | ||
.padding([.leading, .trailing], 16) | ||
} | ||
} | ||
} | ||
|
||
extension DailyTestListView { | ||
func welcomeText(nickname: String) -> some View { | ||
Text.keyme( | ||
"\(nickname)๋ ์น๊ตฌ๋ค์\n๋ต๋ณ์ด ์์ด๊ณ ์์ด์!", | ||
font: .heading1) | ||
.foregroundColor(DSKitAsset.Color.keymeWhite.swiftUIColor) | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
} | ||
|
||
func dailyTestList(_ viewStore: DailyTestStore) -> some View { | ||
LazyVStack(spacing: 12) { | ||
ForEach(viewStore.dailyStatistics.testsStatistics, id: \.self) { testStatistics in | ||
ZStack(alignment: .leading) { | ||
Rectangle() | ||
.foregroundColor(.white.opacity(0.05)) | ||
.frame(height: 86) | ||
.cornerRadius(14) | ||
|
||
HStack(spacing: 12) { | ||
Spacer() | ||
.frame(width: 14) | ||
|
||
ZStack { | ||
Circle() | ||
.foregroundColor(testStatistics.keymeTests.icon.color) | ||
|
||
KFImageManager.shared.toImage(url: testStatistics.keymeTests.icon.imageURL) | ||
.scaledToFit() | ||
.frame(width: 20) | ||
} | ||
.frame(width: 40, height: 40) | ||
|
||
VStack(alignment: .leading, spacing: 7) { | ||
Text.keyme("\(viewStore.testData.nickname)๋์ \(testStatistics.keymeTests.keyword)์ ๋๋?", | ||
font: .body3Semibold) | ||
.foregroundColor(.white) | ||
|
||
statisticsScoreText(score: testStatistics.avarageScore) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
extension DailyTestListView { | ||
func statisticsScoreText(score: Double?) -> some View { | ||
Text.keyme(score != nil ? "ํ๊ท ์ ์ | \(String(describing: score))์ " : "์์ง ์๋ฌด๋ ํ์ง ์์์ด์", | ||
font: .body4) | ||
.foregroundColor(.white.opacity(0.5)) | ||
} | ||
} |
Oops, something went wrong.