Skip to content

Commit 1413f4c

Browse files
committed
[#358] TodayQuestionView 첫 진입, N번째 진입 로직 구현
1 parent 4fa4d09 commit 1413f4c

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

Qapple/Qapple/Resource/Constant/Constant.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ enum Constant {
1717

1818
extension Constant {
1919
static let isSignIn = "isSignIn"
20+
static let recentQuestionID = "recentQuestionID"
2021
static let userRandomID = "userRandomID"
2122
}

Qapple/Qapple/SourceCode/Feature/2.QuestionTab/2-2.TodayQuestion/TodayQuestionFeature.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ struct TodayQuestionFeature {
1919
var timeRemainingForQuestion: TimeInterval = 0
2020
var isLoading = true
2121
var isFirstLaunch = true
22+
var isNewQuestion = false
2223
@Presents var sheet: Sheet.State?
2324
@Presents var alert: AlertState<Action.Alert>?
25+
@Shared(.appStorage(Constant.recentQuestionID)) var recentQuestionID = 0
2426
}
2527

2628
enum Action {
@@ -79,6 +81,14 @@ struct TodayQuestionFeature {
7981
case let .mainQuestionResponse(mainQuestion):
8082
state.isFirstLaunch = false
8183
state.todayQuestion = mainQuestion
84+
85+
if mainQuestion.id != state.recentQuestionID {
86+
state.isNewQuestion = true
87+
state.$recentQuestionID.withLock { $0 = mainQuestion.id }
88+
} else {
89+
state.isNewQuestion = false
90+
}
91+
8292
if isQuestionLiveTime {
8393
state.questionState = mainQuestion.isAnswered ? .complete : .ready
8494
return .none

Qapple/Qapple/SourceCode/Feature/2.QuestionTab/2-2.TodayQuestion/TodayQuestionView.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ struct TodayQuestionView: View {
1515
var body: some View {
1616
ScrollView {
1717
VStack(spacing: 0) {
18-
LargeHeaderView(store: store)
19-
LargeQuestionButton(store: store)
20-
// SmallHeaderView(store: store)
18+
if store.isNewQuestion {
19+
LargeHeaderView(store: store)
20+
LargeQuestionButton(store: store)
21+
} else {
22+
SmallHeaderView(store: store)
23+
}
2124
AnswerPreviewList(store: store)
2225
}
23-
2426
}
2527
.background(.second)
2628
.scrollIndicators(.hidden)

0 commit comments

Comments
 (0)