Skip to content

Commit

Permalink
Merge pull request #139 from JORDYMA-Link/BUG/#135
Browse files Browse the repository at this point in the history
[BUG] QA 반영
  • Loading branch information
kimkyuchul authored Nov 10, 2024
2 parents 0ce0e05 + 08ad772 commit 8872882
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 12 deletions.
20 changes: 17 additions & 3 deletions Projects/Feature/Scene/Setting/Notice/NoticeFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public struct NoticeFeature {
var noticeList: [NoticeModel] = []
var nextPage: Int = 0
var size: Int = 10
var existNotFetchedNotice: Bool = true
}

public enum Action {
Expand All @@ -28,6 +29,9 @@ public struct NoticeFeature {
case setNoticeData(_ noticeData: [NoticeModel])
case expanding(target: UUID?)

//MARK: Business Logic
case isExistNextPage(Int)

//MARK: User Action
case tappedNaviBackButton
}
Expand All @@ -44,14 +48,24 @@ public struct NoticeFeature {
return .run { _ in await self.dismiss() }

case .fetchNotice:
guard state.existNotFetchedNotice else { return .none }

return .run { [page = state.nextPage, size = state.size] send in
let response = try await noticeClient.getNotice(page, size)
return await send(.setNoticeData(response))
await send(.setNoticeData(response))
await send(.isExistNextPage(response.count))
}

case let .setNoticeData(noticeData):
state.noticeList.append(contentsOf: noticeData)
state.nextPage += 1
if !noticeData.isEmpty {
state.noticeList.append(contentsOf: noticeData)
state.nextPage += 1
}
return .none

case let .isExistNextPage(fetchedNoticeCount):
let isExistNextPage = (fetchedNoticeCount >= state.size)
state.existNotFetchedNotice = isExistNextPage
return .none

case let .expanding(target):
Expand Down
37 changes: 30 additions & 7 deletions Projects/Feature/Scene/Setting/Notice/NoticeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,32 @@ import ComposableArchitecture


public struct NoticeView: View {
@Environment(\.dismiss) private var dismiss

public let store: StoreOf<NoticeFeature>
@Perception.Bindable public var store: StoreOf<NoticeFeature>

public var body: some View {
WithPerceptionTracking {
makeBKNavigationView(
leadingType: .dismiss("공지사항", { store.send(.tappedNaviBackButton) }),
trailingType: .none
)

.padding(.leading, 16)
.navigationBarBackButtonHidden(true)

if store.existNotFetchedNotice || !store.noticeList.isEmpty {
NoticeContentView(store: store)
} else {
NoticeEmptyView()
}
//
}
}// body
}

fileprivate struct NoticeContentView: View {
@Perception.Bindable fileprivate var store: StoreOf<NoticeFeature>

var body: some View {
WithPerceptionTracking {
ScrollView(.vertical) {
LazyVStack {
ForEach(store.noticeList) { notice in
Expand Down Expand Up @@ -78,10 +93,18 @@ public struct NoticeView: View {
.onAppear(perform: {
store.send(.fetchNotice)
}) //onAppear

.navigationBarBackButtonHidden(true)
}
}// body
}//Body
}

fileprivate struct NoticeEmptyView: View {

var body: some View {
VStack{
EmptyView()
}
.frame(maxHeight: .infinity)
}
}


Expand Down
2 changes: 0 additions & 2 deletions Projects/Feature/Scene/Setting/View/SettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import Common
import ComposableArchitecture

public struct SettingView: View {
@Environment(\.dismiss) private var dismiss

@Perception.Bindable var store: StoreOf<SettingFeature>

public var body: some View {
Expand Down

0 comments on commit 8872882

Please sign in to comment.