Skip to content

Commit 4d7fc93

Browse files
committed
[refactor] #211 ScrollView + LazyVStack -> List로 리팩토링
1 parent a720fca commit 4d7fc93

3 files changed

Lines changed: 72 additions & 54 deletions

File tree

Projects/Feature/FeaturePokit/Sources/PokitRootView.swift

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ public extension PokitRootView {
3232
WithPerceptionTracking {
3333
VStack(spacing: 0) {
3434
self.filterHeader
35+
.padding(.horizontal, 20)
36+
3537
self.cardScrollView
3638
}
37-
.padding(.horizontal, 20)
3839
.padding(.vertical, 16)
3940
.background(.pokit(.bg(.base)))
4041
.ignoresSafeArea(edges: .bottom)
@@ -122,6 +123,7 @@ private extension PokitRootView {
122123
if store.folderType == .folder(.포킷) {
123124
pokitView
124125
.padding(.top, 20)
126+
.padding(.horizontal, 20)
125127
} else {
126128
unclassifiedView
127129
}
@@ -184,36 +186,39 @@ private extension PokitRootView {
184186
} else {
185187
unclassifiedList
186188
.padding(.top, 20)
189+
.padding(.bottom, 74)
187190
}
188191
} else {
189192
PokitLoading()
190193
}
191194
}
192195

193196
var unclassifiedList: some View {
194-
ScrollView {
195-
LazyVStack(spacing: 0) {
196-
ForEach(
197-
Array(store.scope(state: \.contents, action: \.contents))
198-
) { store in
199-
let isFirst = store.state.id == self.store.contents.first?.id
200-
let isLast = store.state.id == self.store.contents.last?.id
201-
202-
ContentCardView(
203-
store: store,
204-
type: .linkList,
205-
isFirst: isFirst,
206-
isLast: isLast
207-
)
208-
}
197+
List {
198+
ForEach(
199+
Array(store.scope(state: \.contents, action: \.contents))
200+
) { store in
201+
let isFirst = store.state.id == self.store.contents.first?.id
202+
let isLast = store.state.id == self.store.contents.last?.id
203+
204+
ContentCardView(
205+
store: store,
206+
type: .linkList,
207+
isFirst: isFirst,
208+
isLast: isLast
209+
)
210+
}
209211

210-
if store.unclassifiedHasNext {
211-
PokitLoading()
212-
.onAppear(perform: { send(.페이지_로딩중일때) })
213-
}
212+
if store.unclassifiedHasNext {
213+
PokitLoading()
214+
.listRowBackground(Color.clear)
215+
.listRowInsets(EdgeInsets(.zero))
216+
.listRowSeparator(.hidden)
217+
.onAppear(perform: { send(.페이지_로딩중일때) })
214218
}
215-
.padding(.bottom, 150)
216219
}
220+
.listStyle(.plain)
221+
.listRowSpacing(0)
217222
}
218223
}
219224

Projects/Feature/FeatureRecommend/Sources/Recommend/RecommendView.swift

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,21 +177,33 @@ private extension RecommendView {
177177
func listContent(
178178
_ recommendedList: IdentifiedArrayOf<BaseContentItem>
179179
) -> some View {
180-
ScrollView {
181-
LazyVStack(spacing: 8) {
182-
ForEach(recommendedList) { content in
183-
recommendedCard(content)
184-
}
180+
List {
181+
ForEach(recommendedList) { content in
182+
let isFirst = recommendedList.first == content
183+
let isLast = recommendedList.last == content
185184

186-
if store.hasNext {
187-
PokitLoading()
188-
.task { await send(.pagination).finish() }
189-
}
185+
recommendedCard(content)
186+
.listRowBackground(Color.clear)
187+
.listRowInsets(EdgeInsets(
188+
top: isFirst ? 12 : 0,
189+
leading: 20,
190+
bottom: !store.hasNext && isLast ? 150 : 0,
191+
trailing: 20
192+
))
193+
.listRowSeparator(.hidden)
194+
.id(content.id)
195+
}
196+
197+
if store.hasNext {
198+
PokitLoading()
199+
.listRowBackground(Color.clear)
200+
.listRowInsets(EdgeInsets(.zero))
201+
.listRowSeparator(.hidden)
202+
.task { await send(.pagination).finish() }
190203
}
191-
.padding(.horizontal, 20)
192-
.padding(.bottom, 150)
193-
.padding(.top, 12)
194204
}
205+
.listStyle(.plain)
206+
.listRowSpacing(8)
195207
}
196208

197209
@ViewBuilder

Projects/Feature/FeatureSetting/Sources/Search/PokitSearchView.swift

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -289,30 +289,31 @@ private extension PokitSearchView {
289289
}
290290

291291
var resultListContent: some View {
292-
ScrollView {
293-
LazyVStack(spacing: 0) {
294-
ForEach(
295-
Array(store.scope(state: \.contents, action: \.contents))
296-
) { store in
297-
let isFirst = store.state.id == self.store.contents.first?.id
298-
let isLast = store.state.id == self.store.contents.last?.id
299-
300-
ContentCardView(
301-
store: store,
302-
type: .linkList,
303-
isFirst: isFirst,
304-
isLast: isLast
305-
)
306-
}
292+
List {
293+
ForEach(
294+
Array(store.scope(state: \.contents, action: \.contents))
295+
) { store in
296+
let isFirst = store.state.id == self.store.contents.first?.id
297+
let isLast = store.state.id == self.store.contents.last?.id
307298

308-
if store.hasNext {
309-
PokitLoading()
310-
.task { await send(.로딩중일때, animation: .pokitDissolve).finish() }
311-
}
299+
ContentCardView(
300+
store: store,
301+
type: .linkList,
302+
isFirst: isFirst,
303+
isLast: isLast
304+
)
305+
}
306+
307+
if store.hasNext {
308+
PokitLoading()
309+
.listRowBackground(Color.clear)
310+
.listRowInsets(EdgeInsets(.zero))
311+
.listRowSeparator(.hidden)
312+
.task { await send(.로딩중일때, animation: .pokitDissolve).finish() }
312313
}
313-
.padding(.horizontal, 20)
314-
.padding(.bottom, 36)
315314
}
315+
.listStyle(.plain)
316+
.listRowSpacing(0)
316317
}
317318

318319
var resultEmptyLabel: some View {

0 commit comments

Comments
 (0)