-
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.
Merge pull request #85 from Nexters/refactor/network-manager
๋คํธ์ํฌ ๋งค๋์ ๋ฆฌํฉํ ๋ง
- Loading branch information
Showing
44 changed files
with
989 additions
and
615 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,61 @@ | ||
// | ||
// KeymeTestHomeFeature.swift | ||
// Features | ||
// | ||
// Created by ์ด์๋น on 2023/08/30. | ||
// Copyright ยฉ 2023 team.humanwave. All rights reserved. | ||
// | ||
|
||
import ComposableArchitecture | ||
import Domain | ||
import Network | ||
|
||
struct KeymeTestsHomeFeature: Reducer { | ||
@Dependency(\.keymeAPIManager) private var network | ||
|
||
// ํ ์คํธ๋ฅผ ์์ง ํ์ง ์์๊ฑฐ๋, ํ์๊ฑฐ๋ 2๊ฐ์ง ์ผ์ด์ค๋ง ์กด์ฌ | ||
struct State: Equatable { | ||
@PresentationState var testStartViewState: KeymeTestsStartFeature.State? | ||
var view: View | ||
|
||
struct View: Equatable { | ||
let nickname: String | ||
var dailyTestId: Int? | ||
} | ||
|
||
init(nickname: String) { | ||
self.view = View(nickname: nickname) | ||
} | ||
} | ||
|
||
enum Action { | ||
case fetchDailyTests | ||
case showTestStartView(testData: KeymeTestsModel) | ||
case startTest(PresentationAction<KeymeTestsStartFeature.Action>) | ||
|
||
enum View {} | ||
} | ||
|
||
var body: some ReducerOf<Self> { | ||
Reduce { state, action in | ||
switch action { | ||
case .fetchDailyTests: | ||
return .run { send in | ||
let fetchedTest = try await network.request(.test(.daily), object: KeymeTestsDTO.self) | ||
let testData = fetchedTest.toKeymeTestsModel() | ||
|
||
await send(.showTestStartView(testData: testData)) | ||
} | ||
|
||
case .showTestStartView(let testData): | ||
state.view.dailyTestId = testData.testId | ||
state.testStartViewState = .init(nickname: state.view.nickname, testData: testData) | ||
|
||
default: | ||
break | ||
} | ||
|
||
return .none | ||
} | ||
} | ||
} |
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,71 @@ | ||
// | ||
// KeymeTestHomeView.swift | ||
// Features | ||
// | ||
// Created by ์ด์๋น on 2023/08/30. | ||
// Copyright ยฉ 2023 team.humanwave. All rights reserved. | ||
// | ||
|
||
import ComposableArchitecture | ||
import DSKit | ||
import SwiftUI | ||
|
||
struct KeymeTestsHomeView: View { | ||
var store: StoreOf<KeymeTestsHomeFeature> | ||
|
||
init(store: StoreOf<KeymeTestsHomeFeature>) { | ||
self.store = store | ||
store.send(.fetchDailyTests) | ||
} | ||
|
||
var body: some View { | ||
WithViewStore(store, observe: { $0.view }) { viewStore in | ||
ZStack(alignment: .center) { | ||
DSKitAsset.Color.keymeBlack.swiftUIColor.ignoresSafeArea() | ||
|
||
VStack(alignment: .leading) { | ||
// Filler | ||
Spacer().frame(height: 75) | ||
|
||
welcomeText(nickname: viewStore.nickname) | ||
.foregroundColor(DSKitAsset.Color.keymeWhite.swiftUIColor) | ||
|
||
Spacer() | ||
} | ||
.fullFrame() | ||
.padding(.horizontal, 16) | ||
|
||
// ํ ์คํธ ๋ทฐ | ||
testView | ||
|
||
// ๊ฒฐ๊ณผ ํ๋ฉด ํ์๋ ์๊ฐ | ||
|
||
} | ||
} | ||
} | ||
} | ||
|
||
extension KeymeTestsHomeView { | ||
var testView: some View { | ||
let startTestStore = store.scope( | ||
state: \.$testStartViewState, | ||
action: KeymeTestsHomeFeature.Action.startTest) | ||
|
||
return IfLetStore(startTestStore) { store in | ||
KeymeTestsStartView(store: store) | ||
} else: { | ||
Circle() | ||
.strokeBorder(.white.opacity(0.3), lineWidth: 1) | ||
.background(Circle().foregroundColor(.white.opacity(0.3))) | ||
.frame(width: 280, height: 280) | ||
} | ||
} | ||
|
||
func welcomeText(nickname: String) -> some View { | ||
Text.keyme( | ||
"ํ์ํด์ \(nickname)๋!", | ||
// "ํ์ํด์ \(viewStore.nickname)๋!\n์ด์ ๋ฌธ์ ๋ฅผ ํ์ด๋ณผ๊น์?", | ||
font: .heading1) | ||
} | ||
|
||
} |
Oops, something went wrong.