Skip to content

Commit b82d7ba

Browse files
authored
Merge pull request #365 from Team-Capple/feat/#364-ui-update
[Feat] UI 업데이트 내용 반영
2 parents bd367be + a813847 commit b82d7ba

File tree

13 files changed

+154
-195
lines changed

13 files changed

+154
-195
lines changed

Qapple/Qapple/SourceCode/Entity/AcademyEventFor4th.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ enum AcademyEventFor4th: CaseIterable {
9999
let (startDate, endDate) = period
100100
return daysBetween(startDate, endDate) + 1
101101
}
102+
103+
/// 현재 이벤트의 남은 일수를 반환합니다.
104+
var leftDays: Int {
105+
daysBetween(.now, self.period.1) + 1
106+
}
102107
}
103108

104109
// MARK: - Helper

Qapple/Qapple/SourceCode/Feature/1.MainFlow/MainFlowFeature.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ extension MainFlowFeature {
238238
case bulletinBoard(BulletinBoardFeature)
239239
case bulletinBoardSearch(BulletinBoardSearchFeature)
240240
case bulletinBoardPost(BulletinBoardPostFeature)
241-
case comment(CommentFeature)
241+
case comment(BoardCommentFeature)
242242
case profileEdit(ProfileEditFeature)
243243
case myAnswerList(MyAnswerListFeature)
244244
case peopleWhoMadeQapple

Qapple/Qapple/SourceCode/Feature/1.MainFlow/MainFlowView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct MainFlowView: View {
5252
case let .bulletinBoard(store): BulletinBoardView(store: store)
5353
case let .bulletinBoardSearch(store): BulletinBoardSearchView(store: store)
5454
case let .bulletinBoardPost(store): BulletinBoardPostView(store: store)
55-
case let .comment(store): CommentView(store: store)
55+
case let .comment(store): BoardCommentView(store: store)
5656
case let .profileEdit(store): ProfileEditView(store: store)
5757
case let .myAnswerList(store): MyAnswerListView(store: store)
5858
case .peopleWhoMadeQapple: PeopleWhoMadeQappleView()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct TodayQuestionFeature {
2828
enum Action {
2929
case onAppear
3030
case onDisappear
31+
case active
3132
case refresh
3233
case mainQuestionResponse(Question)
3334
case answerListResponse([Answer])
@@ -58,7 +59,7 @@ struct TodayQuestionFeature {
5859
var body: some ReducerOf<Self> {
5960
Reduce { state, action in
6061
switch action {
61-
case .onAppear, .refresh:
62+
case .onAppear, .active, .refresh:
6263
return .run { [isFirstLaunch = state.isFirstLaunch] send in
6364
if isFirstLaunch { await send(.toggleLoading(true), animation: .bouncy) }
6465
do {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import SwiftUI
1010

1111
struct TodayQuestionView: View {
1212

13+
@Environment(\.scenePhase) private var scenePhase
14+
1315
@Bindable var store: StoreOf<TodayQuestionFeature>
1416

1517
var body: some View {
@@ -26,6 +28,11 @@ struct TodayQuestionView: View {
2628
}
2729
.background(.second)
2830
.scrollIndicators(.hidden)
31+
.onChange(of: scenePhase) { _, newPhase in
32+
if newPhase == .active {
33+
store.send(.active)
34+
}
35+
}
2936
.onAppear {
3037
store.send(.onAppear)
3138
}

Qapple/Qapple/SourceCode/Feature/2.QuestionTab/2-7.AnswerCommentList/AnswerCommentView.swift

Lines changed: 56 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -85,51 +85,63 @@ private struct CommentListView: View {
8585

8686
var body: some View {
8787
ZStack {
88-
ScrollView {
89-
LazyVStack(spacing: 0) {
90-
seperator
91-
// TODO: 4/14 데이터 연결 필요
92-
// ForEach(Array(self.store.commentList.enumerated()), id: \.offset) { index, comment in
93-
// AnswerCommentCell(
94-
// comment: comment,
95-
// like: {
96-
// store.send(.likeCommentButtonTapped(comment))
97-
// },
98-
// delete: {
99-
// store.send(.deleteCommentButtonTapped(comment))
100-
// },
101-
// report: {
102-
// store.send(.reportButtonTapped(comment))
103-
// }
104-
// )
105-
// .configurePagination(
106-
// store.commentList,
107-
// currentIndex: index,
108-
// hasNext: store.paginationInfo.hasNext,
109-
// pagination: {
110-
// store.send(.pagination)
111-
// }
112-
// )
113-
// .disabled(store.isLoading)
114-
//
115-
// seperator
116-
// }
117-
118-
ForEach(AnswerCommentFeature.sampleComment) { comment in
119-
AnswerCommentCell(
120-
comment: comment,
121-
like: {
122-
store.send(.likeCommentButtonTapped(comment))
123-
},
124-
delete: {
125-
store.send(.deleteCommentButtonTapped(comment))
126-
},
127-
report: {
128-
store.send(.reportButtonTapped(comment))
129-
}
130-
)
88+
VStack {
89+
seperator
90+
91+
HStack {
92+
Text("댓글")
93+
.pretendard(.medium, 14)
94+
.foregroundStyle(.sub3)
95+
Spacer()
96+
}
97+
.padding(.top, 12)
98+
.padding(.horizontal, 20)
99+
100+
ScrollView {
101+
LazyVStack(spacing: 0) {
102+
// TODO: 4/14 데이터 연결 필요
103+
// ForEach(Array(self.store.commentList.enumerated()), id: \.offset) { index, comment in
104+
// AnswerCommentCell(
105+
// comment: comment,
106+
// like: {
107+
// store.send(.likeCommentButtonTapped(comment))
108+
// },
109+
// delete: {
110+
// store.send(.deleteCommentButtonTapped(comment))
111+
// },
112+
// report: {
113+
// store.send(.reportButtonTapped(comment))
114+
// }
115+
// )
116+
// .configurePagination(
117+
// store.commentList,
118+
// currentIndex: index,
119+
// hasNext: store.paginationInfo.hasNext,
120+
// pagination: {
121+
// store.send(.pagination)
122+
// }
123+
// )
124+
// .disabled(store.isLoading)
125+
//
126+
// seperator
127+
// }
131128

132-
seperator
129+
ForEach(AnswerCommentFeature.sampleComment) { comment in
130+
AnswerCommentCell(
131+
comment: comment,
132+
like: {
133+
store.send(.likeCommentButtonTapped(comment))
134+
},
135+
delete: {
136+
store.send(.deleteCommentButtonTapped(comment))
137+
},
138+
report: {
139+
store.send(.reportButtonTapped(comment))
140+
}
141+
)
142+
143+
seperator
144+
}
133145
}
134146
}
135147
}

Qapple/Qapple/SourceCode/Feature/3.BulletinBoard/3-1.BulletinBoard/BulletinBoardCell.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ private struct NormalBoardCell: View {
6060
board: board,
6161
like: like
6262
)
63+
.padding(.top, 16)
6364
.padding(.horizontal, 16)
6465

6566
Divider()
66-
.padding(.top, 16)
67+
.padding(.top, 24)
6768
}
6869
.background(Background.first)
6970
}
@@ -158,7 +159,7 @@ private struct ContentView: View {
158159
board: board,
159160
like: like
160161
)
161-
.padding(.top, 12)
162+
.padding(.top, 16)
162163
.disabled(board.isReported)
163164
}
164165
}

Qapple/Qapple/SourceCode/Feature/3.BulletinBoard/3-1.BulletinBoard/BulletinBoardFeature.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ struct BulletinBoardFeature {
1616
@Presents var alert: AlertState<Action.Alert>?
1717
var bulletinBoardList: [BulletinBoard] = []
1818
var todayQuestion: Question = .initialState
19+
var event: AcademyEventFor4th = .fourthStart
1920
var paginationInfo = QappleAPI.PaginationInfo(threshold: "", hasNext: false)
2021
var isLoading: Bool = false
2122
var isFirstLaunch = true
2223
}
2324

2425
enum Action {
2526
case onAppear
27+
case active
2628
case refresh
2729
case pagination
2830
case bulletinBoardListResponse(Question, [BulletinBoard], QappleAPI.PaginationInfo)
@@ -61,9 +63,12 @@ struct BulletinBoardFeature {
6163
@Dependency(\.bulletinBoardRepository) var bulletinBoardRepository
6264

6365
var body: some ReducerOf<Self> {
64-
Reduce { state,action in
66+
Reduce { state, action in
6567
switch action {
66-
case .onAppear, .refresh:
68+
case .onAppear, .active, .refresh:
69+
if let currentEvent = AcademyEventFor4th.currentEvent {
70+
state.event = currentEvent
71+
}
6772
return .run { [isFirstLaunch = state.isFirstLaunch] send in
6873
if isFirstLaunch { await send(.toggleLoading(true), animation: .bouncy) }
6974
do {

Qapple/Qapple/SourceCode/Feature/3.BulletinBoard/3-1.BulletinBoard/BulletinBoardView.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import ComposableArchitecture
1212

1313
struct BulletinBoardView: View {
1414

15+
@Environment(\.scenePhase) private var scenePhase
16+
1517
@Bindable var store: StoreOf<BulletinBoardFeature>
1618

1719
var body: some View {
@@ -22,7 +24,11 @@ struct BulletinBoardView: View {
2224
.padding(.bottom, 20)
2325
}
2426
.background(.first)
25-
27+
.onChange(of: scenePhase) { _, newPhase in
28+
if newPhase == .active {
29+
store.send(.active)
30+
}
31+
}
2632
.onAppear{
2733
store.send(.onAppear)
2834
}
@@ -67,7 +73,7 @@ private struct BulletinBoardContentView: View {
6773
Button {
6874
store.send(.academyDayCounterTapped)
6975
} label: {
70-
QPAcademyDayCounter()
76+
QPAcademyDayCounter(event: store.event)
7177
.padding(.top, 8)
7278
.padding(.horizontal, 16)
7379
}

Qapple/Qapple/SourceCode/Feature/4.Comment/CommentCell.swift renamed to Qapple/Qapple/SourceCode/Feature/3.BulletinBoard/3-4.BoardComment/BoardCommentCell.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//
2-
// CommentCell.swift
2+
// BoardCommentCell.swift
33
// Qapple
44
//
55
// Created by 문인범 on 1/21/25.
66
//
77

88
import SwiftUI
99

10-
struct CommentCell: View {
10+
struct BoardCommentCell: View {
1111
let comment: BoardComment
1212
let like: () -> Void
1313
let delete: () -> Void
@@ -272,7 +272,7 @@ private struct CommentReportButton: View {
272272
anonymityId: 2
273273
)
274274

275-
CommentCell(
275+
BoardCommentCell(
276276
comment: comment,
277277
like: {},
278278
delete: {},

0 commit comments

Comments
 (0)