feat(home): 팔로잉 크리에이터 섹션을 추가한다
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import SwiftUI
|
||||
|
||||
struct MainHomeFollowingCreatorSection: View {
|
||||
let followingCreators: [FollowingCreatorResponse]
|
||||
let onTapCreator: (Int) -> Void
|
||||
let onTapAll: () -> Void
|
||||
|
||||
init(
|
||||
followingCreators: [FollowingCreatorResponse],
|
||||
onTapCreator: @escaping (Int) -> Void = { _ in },
|
||||
onTapAll: @escaping () -> Void = {}
|
||||
) {
|
||||
self.followingCreators = followingCreators
|
||||
self.onTapCreator = onTapCreator
|
||||
self.onTapAll = onTapAll
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
LazyHStack(alignment: .top, spacing: SodaSpacing.s12) {
|
||||
ForEach(followingCreators) { creator in
|
||||
CreatorProfileItem(
|
||||
imageUrl: creator.creatorProfileImageUrl,
|
||||
name: creator.creatorNickname,
|
||||
imageSize: CGSize(width: 72, height: 72),
|
||||
spacing: SodaSpacing.s8
|
||||
) {
|
||||
onTapCreator(creator.creatorId)
|
||||
}
|
||||
.frame(width: 72)
|
||||
}
|
||||
|
||||
Button(action: onTapAll) {
|
||||
Text(I18n.HomeFollowing.allButtonTitle)
|
||||
.appFont(.body4)
|
||||
.foregroundColor(Color.soda400)
|
||||
.padding(.horizontal, 16)
|
||||
.frame(height: allButtonHeight)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
.padding(.horizontal, SodaSpacing.s20)
|
||||
}
|
||||
}
|
||||
|
||||
private var allButtonHeight: CGFloat { 72 + SodaSpacing.s8 + 20 }
|
||||
}
|
||||
|
||||
struct MainHomeFollowingCreatorSection_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack(spacing: SodaSpacing.s20) {
|
||||
MainHomeFollowingCreatorSection(
|
||||
followingCreators: [
|
||||
FollowingCreatorResponse(
|
||||
creatorId: 1,
|
||||
creatorNickname: "크리에이터",
|
||||
creatorProfileImageUrl: "https://picsum.photos/200/200"
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
MainHomeFollowingCreatorSection(followingCreators: [])
|
||||
}
|
||||
.padding(.vertical, SodaSpacing.s20)
|
||||
.background(Color.black)
|
||||
.previewLayout(.sizeThatFits)
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,21 @@
|
||||
import SwiftUI
|
||||
|
||||
struct MainHomeFollowingView: View {
|
||||
let onTapFollowingAll: () -> Void
|
||||
|
||||
init(onTapFollowingAll: @escaping () -> Void = {}) {
|
||||
self.onTapFollowingAll = onTapFollowingAll
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
MainPlaceholderTabView(title: "팔로잉")
|
||||
VStack(spacing: 0) {
|
||||
MainHomeFollowingCreatorSection(
|
||||
followingCreators: [],
|
||||
onTapAll: onTapFollowingAll
|
||||
)
|
||||
|
||||
MainPlaceholderTabView(title: "팔로잉")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ struct MainHomeView: View {
|
||||
let onTapBanner: (RecommendationBannerResponse) -> Void
|
||||
let onTapFollowAll: (@escaping () -> Void) -> Void
|
||||
let onSelectFollowingTab: () -> Bool
|
||||
let onTapFollowingAll: () -> Void
|
||||
|
||||
@State private var selectedTab: MainHomeTab = .recommendation
|
||||
|
||||
@@ -71,7 +72,7 @@ struct MainHomeView: View {
|
||||
case .ranking:
|
||||
MainHomeRankingView(onTapCreator: onTapCreator)
|
||||
case .following:
|
||||
MainHomeFollowingView()
|
||||
MainHomeFollowingView(onTapFollowingAll: onTapFollowingAll)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,7 +107,8 @@ struct MainHomeView_Previews: PreviewProvider {
|
||||
onTapCommunity: { _ in },
|
||||
onTapBanner: { _ in },
|
||||
onTapFollowAll: { action in action() },
|
||||
onSelectFollowingTab: { true }
|
||||
onSelectFollowingTab: { true },
|
||||
onTapFollowingAll: {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user