Skip to content

Commit 5f1b88b

Browse files
committed
[fix] #203 empty 화면에 링크 추가 버튼 제거, empty 노출 시 즐겨찾기/안읽음 버튼 노출 필요
1 parent a73d572 commit 5f1b88b

File tree

2 files changed

+60
-67
lines changed

2 files changed

+60
-67
lines changed

Projects/Feature/FeatureCategoryDetail/Sources/CategoryDetailFeature.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ 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-
}
7168

7269
public init(category: BaseCategoryItem) {
7370
self.domain = .init(categpry: category)

Projects/Feature/FeatureCategoryDetail/Sources/CategoryDetailView.swift

Lines changed: 60 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public extension CategoryDetailView {
6565
.padding(.top, 12)
6666
.pokitNavigationBar { navigationBar }
6767
.overlay(
68-
if: store.isContentsNotEmpty,
68+
if: !store.isFavoriteCategory,
6969
alignment: .bottomTrailing
7070
) {
7171
Button(action: { send(.링크_추가_버튼_눌렀을때) }) {
@@ -215,30 +215,32 @@ private extension CategoryDetailView {
215215
var filterHeader: some View {
216216
let isFavoriteCategory = store.isFavoriteCategory
217217
let favoriteContentsCount = store.contents.filter { $0.content.isFavorite ?? false }.count
218-
if store.isContentsNotEmpty {
219-
HStack(spacing: isFavoriteCategory ? 2 : 8) {
220-
if isFavoriteCategory {
221-
Image(.icon(.link))
222-
.resizable()
223-
.frame(width: 16, height: 16)
224-
.foregroundStyle(.pokit(.icon(.secondary)))
225-
Text("\(favoriteContentsCount)")
226-
.foregroundStyle(.pokit(.text(.tertiary)))
227-
.pokitFont(.b2(.m))
228-
} else {
229-
favoriteButton
230-
231-
unreadButton
232-
}
218+
219+
HStack(spacing: isFavoriteCategory ? 2 : 8) {
220+
if isFavoriteCategory {
221+
Image(.icon(.link))
222+
.resizable()
223+
.frame(width: 16, height: 16)
224+
.foregroundStyle(.pokit(.icon(.secondary)))
233225

234-
Spacer()
235-
PokitIconLTextLink(
236-
store.sortType.title,
237-
icon: .icon(.align),
238-
action: { send(.정렬_버튼_눌렀을때) }
239-
)
240-
.contentTransition(.numericText())
226+
Text("\(favoriteContentsCount)")
227+
.foregroundStyle(.pokit(.text(.tertiary)))
228+
.pokitFont(.b2(.m))
229+
230+
} else {
231+
favoriteButton
232+
233+
unreadButton
241234
}
235+
236+
Spacer()
237+
238+
PokitIconLTextLink(
239+
store.sortType.title,
240+
icon: .icon(.align),
241+
action: { send(.정렬_버튼_눌렀을때) }
242+
)
243+
.contentTransition(.numericText())
242244
}
243245
}
244246

@@ -286,53 +288,47 @@ private extension CategoryDetailView {
286288
}
287289
}
288290

291+
@ViewBuilder
289292
var contentScrollView: some View {
290-
Group {
291-
if !store.isLoading {
292-
if store.contents.isEmpty {
293-
PokitCaution(
294-
type: .포킷상세_링크없음,
295-
action: { send(.링크_추가_버튼_눌렀을때) }
296-
)
297-
} else {
298-
LazyVStack(spacing: 0) {
299-
ForEach(
300-
Array(store.scope(state: \.contents, action: \.contents))
301-
) { store in
302-
let isFirst = store.state.id == self.store.contents.first?.id
303-
let isLast = store.state.id == self.store.contents.last?.id
304-
305-
if !self.store.isFavoriteCategory {
306-
ContentCardView(
307-
store: store,
308-
type: .linkList,
309-
isFirst: isFirst,
310-
isLast: isLast
311-
)
312-
} else {
313-
if store.content.isFavorite == true {
314-
ContentCardView(
315-
store: store,
316-
type: .linkList,
317-
isFirst: isFirst,
318-
isLast: isLast
319-
)
320-
}
321-
}
322-
}
293+
if !store.isLoading {
294+
if store.contents.isEmpty {
295+
PokitCaution(type: .포킷상세_링크없음)
296+
} else {
297+
LazyVStack(spacing: 0) {
298+
ForEach(
299+
Array(store.scope(state: \.contents, action: \.contents))
300+
) { store in
301+
let isFirst = store.state.id == self.store.contents.first?.id
302+
let isLast = store.state.id == self.store.contents.last?.id
323303

324-
if store.hasNext {
325-
PokitLoading()
326-
.task { await send(.pagenation).finish() }
304+
if !self.store.isFavoriteCategory {
305+
ContentCardView(
306+
store: store,
307+
type: .linkList,
308+
isFirst: isFirst,
309+
isLast: isLast
310+
)
311+
} else if store.content.isFavorite == true {
312+
ContentCardView(
313+
store: store,
314+
type: .linkList,
315+
isFirst: isFirst,
316+
isLast: isLast
317+
)
327318
}
328-
329-
Spacer()
330319
}
331-
.padding(.bottom, 36)
320+
321+
if store.hasNext {
322+
PokitLoading()
323+
.task { await send(.pagenation).finish() }
324+
}
325+
326+
Spacer()
332327
}
333-
} else {
334-
PokitLoading()
328+
.padding(.bottom, 36)
335329
}
330+
} else {
331+
PokitLoading()
336332
}
337333
}
338334

0 commit comments

Comments
 (0)