Skip to content

Commit 94a367d

Browse files
committed
[fix] #196 즐겨찾기 상세 카운트 수정
- 즐겨찾기 해제 시 카운트 반영 - 모든 즐겨찾기 해제 시 Empty 화면 출력 - 즐겨찾기 개별 해제 시 목록에서 사라지게 수정
1 parent c8a0d5d commit 94a367d

File tree

2 files changed

+41
-26
lines changed

2 files changed

+41
-26
lines changed

Projects/Feature/FeatureCategoryDetail/Sources/CategoryDetailFeature.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public struct CategoryDetailFeature {
6565
domain.contentList.hasNext
6666
}
6767
var isLoading: Bool = true
68+
var isContentsNotEmpty: Bool {
69+
(isFavoriteCategory && contents.contains { $0.content.isFavorite == true }) || (!isFavoriteCategory && !contents.isEmpty)
70+
}
6871

6972
public init(category: BaseCategoryItem) {
7073
self.domain = .init(categpry: category)

Projects/Feature/FeatureCategoryDetail/Sources/CategoryDetailView.swift

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,24 @@ public extension CategoryDetailView {
6363
.padding(.horizontal, 20)
6464
.padding(.top, 12)
6565
.pokitNavigationBar { navigationBar }
66-
//TODO: overlay(condition) merge 시 수정
67-
.overlay(alignment: .bottomTrailing) {
68-
if !store.contents.isEmpty {
69-
Button(action: { send(.링크_추가_버튼_눌렀을때) }) {
70-
Image(.icon(.plus))
71-
.resizable()
72-
.frame(width: 36, height: 36)
73-
.padding(12)
74-
.foregroundStyle(.pokit(.icon(.inverseWh)))
75-
.background {
76-
RoundedRectangle(cornerRadius: 9999, style: .continuous)
77-
.fill(.pokit(.bg(.brand)))
78-
}
79-
.frame(width: 60, height: 60)
80-
}
81-
.padding(.trailing, 20)
82-
.padding(.bottom, 39)
66+
.overlay(
67+
if: store.isContentsNotEmpty,
68+
alignment: .bottomTrailing
69+
) {
70+
Button(action: { send(.링크_추가_버튼_눌렀을때) }) {
71+
Image(.icon(.plus))
72+
.resizable()
73+
.frame(width: 36, height: 36)
74+
.padding(12)
75+
.foregroundStyle(.pokit(.icon(.inverseWh)))
76+
.background {
77+
RoundedRectangle(cornerRadius: 9999, style: .continuous)
78+
.fill(.pokit(.bg(.brand)))
79+
}
80+
.frame(width: 60, height: 60)
8381
}
82+
.padding(.trailing, 20)
83+
.padding(.bottom, 39)
8484
}
8585
.ignoresSafeArea(edges: .bottom)
8686
.sheet(isPresented: $store.isCategorySheetPresented) {
@@ -213,14 +213,15 @@ private extension CategoryDetailView {
213213
@ViewBuilder
214214
var filterHeader: some View {
215215
let isFavoriteCategory = store.isFavoriteCategory
216-
if !store.contents.isEmpty {
216+
let favoriteContentsCount = store.contents.filter { $0.content.isFavorite ?? false }.count
217+
if store.isContentsNotEmpty {
217218
HStack(spacing: isFavoriteCategory ? 2 : 8) {
218219
if isFavoriteCategory {
219220
Image(.icon(.link))
220221
.resizable()
221222
.frame(width: 16, height: 16)
222223
.foregroundStyle(.pokit(.icon(.secondary)))
223-
Text("\(store.contents.count)")
224+
Text("\(favoriteContentsCount)")
224225
.foregroundStyle(.pokit(.text(.tertiary)))
225226
.pokitFont(.b2(.m))
226227
} else {
@@ -258,7 +259,7 @@ private extension CategoryDetailView {
258259
var contentScrollView: some View {
259260
Group {
260261
if !store.isLoading {
261-
if store.contents.isEmpty {
262+
if !store.isContentsNotEmpty {
262263
VStack {
263264
PokitCaution(
264265
type: .포킷상세_링크없음,
@@ -275,12 +276,23 @@ private extension CategoryDetailView {
275276
let isFirst = store.state.id == self.store.contents.first?.id
276277
let isLast = store.state.id == self.store.contents.last?.id
277278

278-
ContentCardView(
279-
store: store,
280-
type: .linkList,
281-
isFirst: isFirst,
282-
isLast: isLast
283-
)
279+
if !self.store.isFavoriteCategory {
280+
ContentCardView(
281+
store: store,
282+
type: .linkList,
283+
isFirst: isFirst,
284+
isLast: isLast
285+
)
286+
} else {
287+
if store.content.isFavorite == true {
288+
ContentCardView(
289+
store: store,
290+
type: .linkList,
291+
isFirst: isFirst,
292+
isLast: isLast
293+
)
294+
}
295+
}
284296
}
285297

286298
if store.hasNext {

0 commit comments

Comments
 (0)