-
Notifications
You must be signed in to change notification settings - Fork 1
오늘의 질문 UI 업데이트 #359
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
Merged
Merged
오늘의 질문 UI 업데이트 #359
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6b6207d
[#358] TodayQuestionViwe UI 업데이트
thinkySide 188636c
[#358] QPAnswerCell 업데이트
thinkySide 4fa4d09
[#358] LargeHeader, SmallHeader 각각 구현
thinkySide 1413f4c
[#358] TodayQuestionView 첫 진입, N번째 진입 로직 구현
thinkySide cb0c0bd
[#358] QuestionButton Title 업데이트
thinkySide 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -19,8 +19,10 @@ struct TodayQuestionFeature { | |
| var timeRemainingForQuestion: TimeInterval = 0 | ||
| var isLoading = true | ||
| var isFirstLaunch = true | ||
| var isNewQuestion = false | ||
| @Presents var sheet: Sheet.State? | ||
| @Presents var alert: AlertState<Action.Alert>? | ||
| @Shared(.appStorage(Constant.recentQuestionID)) var recentQuestionID = 0 | ||
| } | ||
|
|
||
| enum Action { | ||
|
|
@@ -79,6 +81,14 @@ struct TodayQuestionFeature { | |
| case let .mainQuestionResponse(mainQuestion): | ||
| state.isFirstLaunch = false | ||
| state.todayQuestion = mainQuestion | ||
|
|
||
| if mainQuestion.id != state.recentQuestionID { | ||
| state.isNewQuestion = true | ||
| state.$recentQuestionID.withLock { $0 = mainQuestion.id } | ||
| } else { | ||
| state.isNewQuestion = false | ||
| } | ||
|
Comment on lines
+85
to
+90
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 메인 질문을 받아올 때 저장되어있던 Question ID값과 비교 후 새롭게 등록된 질문인지 판단 + 업데이트합니다. |
||
|
|
||
| if isQuestionLiveTime { | ||
| state.questionState = mainQuestion.isAnswered ? .complete : .ready | ||
| return .none | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -13,18 +13,19 @@ struct TodayQuestionView: View { | |
| @Bindable var store: StoreOf<TodayQuestionFeature> | ||
|
|
||
| var body: some View { | ||
| ZStack { | ||
| Color.second.ignoresSafeArea() | ||
|
|
||
| ScrollView { | ||
| VStack(spacing: 0) { | ||
| HeaderView(store: store) | ||
| QuestionButton(store: store) | ||
| AnswerPreviewList(store: store) | ||
| ScrollView { | ||
| VStack(spacing: 0) { | ||
| if store.isNewQuestion { | ||
| LargeHeaderView(store: store) | ||
| LargeQuestionButton(store: store) | ||
| } else { | ||
| SmallHeaderView(store: store) | ||
| } | ||
| AnswerPreviewList(store: store) | ||
| } | ||
|
Comment on lines
+16
to
25
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 새롭게 등록됐으면 LargeHeader, 이미 봤던 질문이라면 SmallHeader |
||
| .scrollIndicators(.hidden) | ||
| } | ||
| .background(.second) | ||
| .scrollIndicators(.hidden) | ||
| .onAppear { | ||
| store.send(.onAppear) | ||
| } | ||
|
|
@@ -36,20 +37,98 @@ struct TodayQuestionView: View { | |
| } | ||
| .loadingIndicator(isLoading: store.isLoading) | ||
| .alert($store.scope(state: \.alert, action: \.alert)) | ||
| .sheet(item: $store.scope( | ||
| state: \.sheet, | ||
| action: \.sheet) | ||
| ) { store in | ||
| .sheet(item: $store.scope(state: \.sheet, action: \.sheet)) { store in | ||
| switch store.case { | ||
| case let .seeMore(store): SeeMoreSheet(store: store) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // MARK: - HeaderView | ||
| // MARK: - SmallHeaderView | ||
|
|
||
| private struct SmallHeaderView: View { | ||
|
|
||
| let store: StoreOf<TodayQuestionFeature> | ||
|
|
||
| var body: some View { | ||
| ZStack { | ||
| Color.first.ignoresSafeArea() | ||
|
|
||
| HStack(spacing: 8) { | ||
| Image(store.questionState.graphicImage) | ||
| .resizable() | ||
| .scaledToFill() | ||
| .frame(width: 40, height: 40) | ||
|
|
||
| Text(store.questionState.mainTitle) | ||
| .font(.pretendard(.semiBold, size: 18)) | ||
| .foregroundStyle(.wh) | ||
| .tracking(-1) | ||
|
|
||
| Spacer() | ||
|
|
||
| if store.questionState == .creating { | ||
| QuestionTimer() | ||
| } else { | ||
| AnsweringButton() | ||
| } | ||
| } | ||
| .padding(.horizontal, 24) | ||
| .frame(maxWidth: .infinity) | ||
| .frame(height: 90) | ||
| .background(.second) | ||
| .cornerRadius(32, corners: [.bottomLeft, .bottomRight]) | ||
| } | ||
| } | ||
|
|
||
| /// 질문 타이머 | ||
| private func QuestionTimer() -> some View { | ||
| Text(store.timeRemainingForQuestion.timerFormat) | ||
| .font(.pretendard(.bold, size: 22)) | ||
| .foregroundStyle(LinearGradient.timer) | ||
| .monospacedDigit() | ||
| .kerning(-2) | ||
| } | ||
|
|
||
| /// 답변하기 버튼 | ||
| private func AnsweringButton() -> some View { | ||
| Button { | ||
| store.send(.questionButtonTapped(store.todayQuestion)) | ||
| } label: { | ||
| Text(title) | ||
| .font(.pretendard(.semiBold, size: 15)) | ||
| .frame(width: 84) | ||
| .padding(.vertical, 10) | ||
| .foregroundStyle(.main) | ||
| .background(backgroundColor) | ||
| .clipShape(RoundedRectangle(cornerRadius: 20)) | ||
| } | ||
| .opacity(store.isLoading ? 0 : 1) | ||
| .buttonStyle(ScalableButtonStyle()) | ||
| } | ||
|
|
||
| /// 버튼 제목 | ||
| private var title: String { | ||
| store.questionState.buttonTitle( | ||
| isAnswerd: store.todayQuestion.isAnswered | ||
| ) | ||
| } | ||
|
|
||
| /// 버튼 배경 색상 | ||
| private var backgroundColor: Color { | ||
| switch store.questionState { | ||
| case .creating: | ||
| store.todayQuestion.isAnswered ? .secondaryButton : .button | ||
| case .ready: .button | ||
| case .complete: .secondaryButton | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // MARK: - LargeHeaderView | ||
|
|
||
| private struct HeaderView: View { | ||
| private struct LargeHeaderView: View { | ||
|
|
||
| @State private var offsetY: CGFloat = 0 | ||
|
|
||
|
|
@@ -93,9 +172,9 @@ private struct HeaderView: View { | |
| } | ||
| } | ||
|
|
||
| // MARK: - QuestionButton | ||
| // MARK: - LargeQuestionButton | ||
|
|
||
| private struct QuestionButton: View { | ||
| private struct LargeQuestionButton: View { | ||
|
|
||
| let store: StoreOf<TodayQuestionFeature> | ||
|
|
||
|
|
@@ -141,7 +220,6 @@ private struct QuestionButton: View { | |
| } | ||
| } | ||
| } | ||
|
|
||
| // MARK: - AnswerPreviewList | ||
|
|
||
| private struct AnswerPreviewList: View { | ||
|
|
@@ -165,7 +243,7 @@ private struct AnswerPreviewList: View { | |
| if store.answerPreviewList.isEmpty { | ||
| Spacer() | ||
|
|
||
| Text("아직 답변이 달리지않았어요\n첫 답변을 달아보세요!") | ||
| Text("첫 답변을 달아보세요!") | ||
| .font(.pretendard(.semiBold, size: 14)) | ||
| .foregroundStyle(.sub4) | ||
| .multilineTextAlignment(.center) | ||
|
|
@@ -221,6 +299,12 @@ private struct AnswerPreviewList: View { | |
| state: .normal, | ||
| seeMoreAction: { | ||
| store.send(.seeMoreAnswerButtonTapped(answer)) | ||
| }, | ||
| likeAction: { | ||
|
|
||
| }, | ||
| commentAction: { | ||
|
|
||
| } | ||
| ) | ||
| } | ||
|
|
||
This file contains hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.
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.
isNewQuestion: 새로운 질문이 등록되었는지 여부를 확인recentQuestionID: 가장 최근에 등록됐었던 질문의 IDrecentQuestionID의 경우 AppStorge에 저장함으로써 N번째 진입 시 SmallHeaderView를 보여줄 수 있도록 구현했습니다.