Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Qapple/Qapple/SourceCode/Entity/AcademyEventFor4th.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ enum AcademyEventFor4th: CaseIterable {
let (startDate, endDate) = period
return daysBetween(startDate, endDate) + 1
}

/// 현재 이벤트의 남은 일수를 반환합니다.
var leftDays: Int {
daysBetween(.now, self.period.1) + 1
}
}

// MARK: - Helper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ extension MainFlowFeature {
case bulletinBoard(BulletinBoardFeature)
case bulletinBoardSearch(BulletinBoardSearchFeature)
case bulletinBoardPost(BulletinBoardPostFeature)
case comment(CommentFeature)
case comment(BoardCommentFeature)
case profileEdit(ProfileEditFeature)
case myAnswerList(MyAnswerListFeature)
case peopleWhoMadeQapple
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct MainFlowView: View {
case let .bulletinBoard(store): BulletinBoardView(store: store)
case let .bulletinBoardSearch(store): BulletinBoardSearchView(store: store)
case let .bulletinBoardPost(store): BulletinBoardPostView(store: store)
case let .comment(store): CommentView(store: store)
case let .comment(store): BoardCommentView(store: store)
case let .profileEdit(store): ProfileEditView(store: store)
case let .myAnswerList(store): MyAnswerListView(store: store)
case .peopleWhoMadeQapple: PeopleWhoMadeQappleView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct TodayQuestionFeature {
enum Action {
case onAppear
case onDisappear
case active
case refresh
case mainQuestionResponse(Question)
case answerListResponse([Answer])
Expand Down Expand Up @@ -58,7 +59,7 @@ struct TodayQuestionFeature {
var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .onAppear, .refresh:
case .onAppear, .active, .refresh:
return .run { [isFirstLaunch = state.isFirstLaunch] send in
if isFirstLaunch { await send(.toggleLoading(true), animation: .bouncy) }
do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import SwiftUI

struct TodayQuestionView: View {

@Environment(\.scenePhase) private var scenePhase

@Bindable var store: StoreOf<TodayQuestionFeature>

var body: some View {
Expand All @@ -26,6 +28,11 @@ struct TodayQuestionView: View {
}
.background(.second)
.scrollIndicators(.hidden)
.onChange(of: scenePhase) { _, newPhase in
if newPhase == .active {
store.send(.active)
}
}
.onAppear {
store.send(.onAppear)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,51 +85,63 @@ private struct CommentListView: View {

var body: some View {
ZStack {
ScrollView {
LazyVStack(spacing: 0) {
seperator
// TODO: 4/14 데이터 연결 필요
// ForEach(Array(self.store.commentList.enumerated()), id: \.offset) { index, comment in
// AnswerCommentCell(
// comment: comment,
// like: {
// store.send(.likeCommentButtonTapped(comment))
// },
// delete: {
// store.send(.deleteCommentButtonTapped(comment))
// },
// report: {
// store.send(.reportButtonTapped(comment))
// }
// )
// .configurePagination(
// store.commentList,
// currentIndex: index,
// hasNext: store.paginationInfo.hasNext,
// pagination: {
// store.send(.pagination)
// }
// )
// .disabled(store.isLoading)
//
// seperator
// }

ForEach(AnswerCommentFeature.sampleComment) { comment in
AnswerCommentCell(
comment: comment,
like: {
store.send(.likeCommentButtonTapped(comment))
},
delete: {
store.send(.deleteCommentButtonTapped(comment))
},
report: {
store.send(.reportButtonTapped(comment))
}
)
VStack {
seperator

HStack {
Text("댓글")
.pretendard(.medium, 14)
.foregroundStyle(.sub3)
Spacer()
}
.padding(.top, 12)
.padding(.horizontal, 20)

ScrollView {
LazyVStack(spacing: 0) {
// TODO: 4/14 데이터 연결 필요
// ForEach(Array(self.store.commentList.enumerated()), id: \.offset) { index, comment in
// AnswerCommentCell(
// comment: comment,
// like: {
// store.send(.likeCommentButtonTapped(comment))
// },
// delete: {
// store.send(.deleteCommentButtonTapped(comment))
// },
// report: {
// store.send(.reportButtonTapped(comment))
// }
// )
// .configurePagination(
// store.commentList,
// currentIndex: index,
// hasNext: store.paginationInfo.hasNext,
// pagination: {
// store.send(.pagination)
// }
// )
// .disabled(store.isLoading)
//
// seperator
// }

seperator
ForEach(AnswerCommentFeature.sampleComment) { comment in
AnswerCommentCell(
comment: comment,
like: {
store.send(.likeCommentButtonTapped(comment))
},
delete: {
store.send(.deleteCommentButtonTapped(comment))
},
report: {
store.send(.reportButtonTapped(comment))
}
)

seperator
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ private struct NormalBoardCell: View {
board: board,
like: like
)
.padding(.top, 16)
.padding(.horizontal, 16)

Divider()
.padding(.top, 16)
.padding(.top, 24)
}
.background(Background.first)
}
Expand Down Expand Up @@ -158,7 +159,7 @@ private struct ContentView: View {
board: board,
like: like
)
.padding(.top, 12)
.padding(.top, 16)
.disabled(board.isReported)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ struct BulletinBoardFeature {
@Presents var alert: AlertState<Action.Alert>?
var bulletinBoardList: [BulletinBoard] = []
var todayQuestion: Question = .initialState
var event: AcademyEventFor4th = .fourthStart
var paginationInfo = QappleAPI.PaginationInfo(threshold: "", hasNext: false)
var isLoading: Bool = false
var isFirstLaunch = true
}

enum Action {
case onAppear
case active
case refresh
case pagination
case bulletinBoardListResponse(Question, [BulletinBoard], QappleAPI.PaginationInfo)
Expand Down Expand Up @@ -61,9 +63,12 @@ struct BulletinBoardFeature {
@Dependency(\.bulletinBoardRepository) var bulletinBoardRepository

var body: some ReducerOf<Self> {
Reduce { state,action in
Reduce { state, action in
switch action {
case .onAppear, .refresh:
case .onAppear, .active, .refresh:
if let currentEvent = AcademyEventFor4th.currentEvent {
state.event = currentEvent
}
return .run { [isFirstLaunch = state.isFirstLaunch] send in
if isFirstLaunch { await send(.toggleLoading(true), animation: .bouncy) }
do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import ComposableArchitecture

struct BulletinBoardView: View {

@Environment(\.scenePhase) private var scenePhase

@Bindable var store: StoreOf<BulletinBoardFeature>

var body: some View {
Expand All @@ -22,7 +24,11 @@ struct BulletinBoardView: View {
.padding(.bottom, 20)
}
.background(.first)

.onChange(of: scenePhase) { _, newPhase in
if newPhase == .active {
store.send(.active)
}
}
Comment on lines +27 to +31
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ScenePhase 환경 변수를 이용해 앱에 재진입 시 자연스럽게 리프레쉬 할 수 있도록 구현했습니다. 오늘의 질문 쪽도 똑같아요!

.onAppear{
store.send(.onAppear)
}
Expand Down Expand Up @@ -67,7 +73,7 @@ private struct BulletinBoardContentView: View {
Button {
store.send(.academyDayCounterTapped)
} label: {
QPAcademyDayCounter()
QPAcademyDayCounter(event: store.event)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아카데미 일정 카운터 컴포넌트에 event 속성을 주입받을 수 있도록 업데이트했습니다.

onAppear, refresh, active 등에 대응하기 위해선 Reducer가 이벤트 속성을 가지고 있어야 하기 때문에 수정해주었습니다!

.padding(.top, 8)
.padding(.horizontal, 16)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// CommentCell.swift
// BoardCommentCell.swift
// Qapple
//
// Created by 문인범 on 1/21/25.
//

import SwiftUI

struct CommentCell: View {
struct BoardCommentCell: View {
let comment: BoardComment
let like: () -> Void
let delete: () -> Void
Expand Down Expand Up @@ -272,7 +272,7 @@ private struct CommentReportButton: View {
anonymityId: 2
)

CommentCell(
BoardCommentCell(
comment: comment,
like: {},
delete: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// CommentFeature.swift
// BoardCommentFeature.swift
// Qapple
//
// Created by 문인범 on 1/21/25.
Expand All @@ -9,7 +9,7 @@ import Foundation
import ComposableArchitecture

@Reducer
struct CommentFeature {
struct BoardCommentFeature {
@ObservableState
struct State: Equatable {
var board: BulletinBoard
Expand Down Expand Up @@ -273,7 +273,7 @@ struct CommentFeature {

// MARK: - BulletinBoardSheet

extension CommentFeature {
extension BoardCommentFeature {
@Reducer(state: .equatable)
enum Sheet {
case seeMore(SeeMoreSheetFeature)
Expand All @@ -282,7 +282,7 @@ extension CommentFeature {

// MARK: - CommentAlert

extension AlertState where Action == CommentFeature.Action.Alert {
extension AlertState where Action == BoardCommentFeature.Action.Alert {
static func confirmDeletion(_ boardCommentId: Int) -> Self {
return Self {
TextState("정말로 댓글을 삭제하시겠습니까?")
Expand All @@ -305,7 +305,7 @@ extension AlertState where Action == CommentFeature.Action.Alert {
}
}

extension CommentFeature {
extension BoardCommentFeature {
// 이름을 익명화 해주는 method
private func anonymizeCommentList(_ BoardWriterId: Int, _ commentList: [BoardComment]) -> [BoardComment] {
var anonymousArray: [Int: Int] = [:]
Expand Down
Loading