feat(home): 응원 크리에이터 섹션을 연결한다

This commit is contained in:
Yu Sung
2026-06-29 21:18:04 +09:00
parent 2727cdc7cb
commit 007d63c0cd
4 changed files with 92 additions and 5 deletions

View File

@@ -0,0 +1,61 @@
import SwiftUI
struct MainHomeCheerCreatorSection: View {
let items: [HomeCreatorItem]
let isFollowAllCompleted: Bool
let isFollowAllLoading: Bool
let onTapCreator: (Int) -> Void
let onTapFollowAll: () -> Void
init(
items: [HomeCreatorItem],
isFollowAllCompleted: Bool = false,
isFollowAllLoading: Bool = false,
onTapCreator: @escaping (Int) -> Void = { _ in },
onTapFollowAll: @escaping () -> Void = {}
) {
self.items = items
self.isFollowAllCompleted = isFollowAllCompleted
self.isFollowAllLoading = isFollowAllLoading
self.onTapCreator = onTapCreator
self.onTapFollowAll = onTapFollowAll
}
var body: some View {
if !items.isEmpty {
VStack(alignment: .leading, spacing: SodaSpacing.s14) {
SectionTitle(title: I18n.HomeRecommendation.cheerCreatorSectionTitle)
MainHomeCreatorGroupSection(
title: I18n.HomeRecommendation.cheerCreatorSectionTitle,
showTitle: false,
creators: items,
isFollowAllCompleted: isFollowAllCompleted,
isFollowAllLoading: isFollowAllLoading,
onTapCreator: onTapCreator,
onTapFollowAll: onTapFollowAll
)
.padding(.horizontal, SodaSpacing.s14)
}
}
}
}
struct MainHomeCheerCreatorSection_Previews: PreviewProvider {
private static let previewImageUrl = "https://picsum.photos/200/200"
static var previews: some View {
MainHomeCheerCreatorSection(
items: (1...8).map {
HomeCreatorItem(
creatorId: $0,
creatorNickname: "크리에이터이름",
creatorProfileImage: previewImageUrl
)
}
)
.padding(.vertical, SodaSpacing.s20)
.background(Color.black)
.previewLayout(.sizeThatFits)
}
}

View File

@@ -49,6 +49,7 @@ struct MainHomeGenreCreatorSection: View {
struct MainHomeCreatorGroupSection: View {
let title: String
let showTitle: Bool
let creators: [HomeCreatorItem]
let isFollowAllCompleted: Bool
let isFollowAllLoading: Bool
@@ -57,6 +58,7 @@ struct MainHomeCreatorGroupSection: View {
init(
title: String,
showTitle: Bool = true,
creators: [HomeCreatorItem],
isFollowAllCompleted: Bool = false,
isFollowAllLoading: Bool = false,
@@ -64,6 +66,7 @@ struct MainHomeCreatorGroupSection: View {
onTapFollowAll: @escaping () -> Void = {}
) {
self.title = title
self.showTitle = showTitle
self.creators = creators
self.isFollowAllCompleted = isFollowAllCompleted
self.isFollowAllLoading = isFollowAllLoading
@@ -73,11 +76,13 @@ struct MainHomeCreatorGroupSection: View {
var body: some View {
VStack(alignment: .leading, spacing: SodaSpacing.s14) {
Text(title)
.appFont(.heading3)
.foregroundColor(.white)
.lineLimit(1)
.truncationMode(.tail)
if showTitle {
Text(title)
.appFont(.heading3)
.foregroundColor(.white)
.lineLimit(1)
.truncationMode(.tail)
}
LazyVGrid(columns: columns, alignment: .center, spacing: SodaSpacing.s14) {
ForEach(creators.prefix(8), id: \.self) { creator in

View File

@@ -60,6 +60,21 @@ struct MainHomeRecommendationView: View {
}
}
)
MainHomeCheerCreatorSection(
items: viewModel.recommendations?.cheerCreators ?? [],
isFollowAllCompleted: viewModel.isFollowAllCompleted("cheer"),
isFollowAllLoading: viewModel.isFollowAllLoading("cheer"),
onTapCreator: onTapCreator,
onTapFollowAll: {
onTapFollowAll {
viewModel.followAll(
creatorIds: viewModel.recommendations?.cheerCreators.map(\.creatorId) ?? [],
completionKey: "cheer"
)
}
}
)
}
.padding(.vertical, SodaSpacing.s20)
}