-
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
26 changed files
with
510 additions
and
381 deletions.
There are no files selected for viewing
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 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 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
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) | ||
} | ||
|
||
} |
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.