Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ extension HomeFeature {
switch action {
case let .homeResponse(result):
state.isLoading = false
state.hasLoadedHome = true
switch result {
case let .success(bundle):
state.hasLoadedHome = true
let home = bundle.replacingEmptySectionsWithMocks
state.newNotice = home.newNotice
state.heroes = home.heroes
Expand Down
19 changes: 14 additions & 5 deletions Projects/Presentation/Home/Sources/Main/View/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public struct HomeView: View {

if !store.hotBattles.isEmpty {
hotBattlesSection()
adSection()
}
// 광고가 없으면 AdFitNativeAdView 가 스스로 접혀 높이 0 이 된다 —
// 섹션 간 spacing 32 가 두 번 겹치지 않도록 여백은 따로 주지 않는다.
AdFitNativeAdView(unit: .wide)
.frame(maxWidth: .infinity)
if !store.bestBattles.isEmpty {
bestBattlesSection()
if store.hotBattles.isEmpty {
adSection()
}
}
if !store.quizzes.isEmpty || !store.votes.isEmpty {
todayPickeSection()
Expand Down Expand Up @@ -84,7 +84,9 @@ public struct HomeView: View {

extension HomeView {
private var shouldShowSkeleton: Bool {
store.isLoading &&
// hasLoadedHome 이 아직 false 인 첫 프레임(onAppear 도착 전)도 스켈레톤으로
// 덮는다 — isLoading 만 보면 빈 콘텐츠 위 광고 자리만 먼저 번쩍인다.
(store.isLoading || !store.hasLoadedHome) &&
store.heroes.isEmpty &&
store.hotBattles.isEmpty &&
store.bestBattles.isEmpty &&
Expand All @@ -93,6 +95,13 @@ extension HomeView {
store.newBattles.isEmpty
}

/// 배틀 섹션 아래 네이티브 광고 — AdFit 은 한 화면에 같은 단위 1개만 허용해 호출부에서 하나만 그린다.
@ViewBuilder
private func adSection() -> some View {
AdFitNativeAdView(unit: .wide)
.frame(maxWidth: .infinity)
}

@ViewBuilder
private func hotBattlesSection() -> some View {
VStack(alignment: .leading, spacing: 12) {
Expand Down
Loading